if(enable-qt5)
	include(../cmake-qt5.txt)

	find_qt5_libs(OFF ON Network)
	if(TARGET Qt5::Network)
		set(MGL_QT5_LIBS ${MGL_QT5_LIBS} Qt5::Network)
		find_qt5_libs(OFF OFF WebKitWidgets WebEngineWidgets)
		if(enable-json-sample-we)
			if(TARGET Qt5::WebEngineWidgets)
				set(MGL_QT5_LIBS ${MGL_QT5_LIBS} Qt5::WebEngineWidgets)
				set(mgl_qt_def MGL_USE_QT5_WE)
			else(TARGET Qt5::WebEngineWidgets)
				message(STATUS "Couldn't find Qt5 WebEngineWidgets library. Trying WebKit.")
				set(enable-json-sample-we OFF)
			endif(TARGET Qt5::WebEngineWidgets)
		endif(enable-json-sample-we)
		if(TARGET Qt5::WebKitWidgets)
			set(MGL_QT5_LIBS ${MGL_QT5_LIBS} Qt5::WebKitWidgets)
		else(TARGET Qt5::WebKitWidgets)
			message(STATUS "Couldn't find Qt5 WebKitWidgets library. JSON sample disabled.")
			set(enable-json-sample OFF)
		endif(TARGET Qt5::WebKitWidgets)
	else(TARGET Qt5::Network)
		message(STATUS "Couldn't find Qt5 Network library. JSON sample disabled.")
		set(enable-json-sample OFF)
	endif(TARGET Qt5::Network)
else(enable-qt5)
	include(../cmake-qt4.txt)

	foreach(mgl_qt4_lib ${MGL_QT4_LIBS_FIND_JSON})
		if(TARGET Qt4::${mgl_qt4_lib})
			set(MGL_QT4_LIBS ${MGL_QT4_LIBS} Qt4::${mgl_qt4_lib})
		else(TARGET Qt4::${mgl_qt4_lib})
			message(STATUS "Couldn't find Qt4 ${mgl_qt4_lib} library. JSON sample disabled.")
			set(enable-json-sample OFF)
		endif(TARGET Qt4::${mgl_qt4_lib})
	endforeach(mgl_qt4_lib)
endif(enable-qt5)

if(enable-json-sample)

set(json_src Backend.cpp MainWindow.cpp MainWindow.ui)
set(json_moc_hdr Backend.hpp MainWindow.hpp)

include_directories(${MathGL2_BINARY_DIR}/json)
add_executable(MglForJsTestBench ${json_src} ${json_moc_hdr})
if(enable-qt5)
	target_compile_definitions(MglForJsTestBench PUBLIC MGL_USE_QT5 ${mgl_qt_def})
	target_link_libraries(MglForJsTestBench mgl-qt5 ${MGL_QT5_LIBS})
else(enable-qt5)
	target_link_libraries(MglForJsTestBench mgl-qt4 ${MGL_QT4_LIBS})
endif(enable-qt5)

endif(enable-json-sample)
