From 0b6c70014406b141b13337eba6b5e43394de4aee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20O=2E=20Cordero=20P=C3=A9rez?= Date: Wed, 17 Apr 2024 12:47:17 -0400 Subject: [PATCH] Fix builds would compile parts for both Qt 5 and 6 CMAKE_PREFIX_PATHs that contained both Qt 5 and 6 would trigger lines specific to both versions of the framework instead of only running lines specific to the version being used for compilation Solves #997 --- plugins/CMakeLists.txt | 4 ++-- plugins/network/CMakeLists.txt | 2 +- plugins/openglsupport/CMakeLists.txt | 2 +- plugins/statemachineviewer/CMakeLists.txt | 4 ++-- tests/CMakeLists.txt | 6 +++--- tests/manual/CMakeLists.txt | 7 +++++-- 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index ae5cef6692..77f267905a 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -7,7 +7,7 @@ # Contact KDAB at for commercial licensing options. # -if(TARGET Qt5::Core) +if(QT_VERSION_MAJOR EQUAL 5 AND TARGET Qt5::Core) add_subdirectory(codecbrowser) endif() if((QT_VERSION_MAJOR EQUAL 5) OR (QT_VERSION_MAJOR EQUAL 6 AND TARGET Qt6::StateMachine)) @@ -35,7 +35,7 @@ if(TARGET Qt::Gui) add_subdirectory(guisupport) add_subdirectory(textdocumentinspector) endif() -if(TARGET Qt5::Gui OR TARGET Qt6::OpenGL) +if((QT_VERSION_MAJOR EQUAL 5 AND TARGET Qt5::Gui) OR (QT_VERSION_MAJOR EQUAL 6 AND TARGET Qt6::OpenGL)) add_subdirectory(openglsupport) endif() diff --git a/plugins/network/CMakeLists.txt b/plugins/network/CMakeLists.txt index 2e0e7690c4..1735ab7151 100644 --- a/plugins/network/CMakeLists.txt +++ b/plugins/network/CMakeLists.txt @@ -23,7 +23,7 @@ if(NOT GAMMARAY_CLIENT_ONLY_BUILD) networksupportinterface.cpp networksupportinterface.h ) - if(TARGET Qt5::Network) + if(${QT_VERSION_MAJOR} EQUAL 5 AND TARGET Qt5::Network) list(APPEND gammaray_network_srcs networkconfigurationmodel.cpp networkconfigurationmodel.h) endif() gammaray_add_plugin( diff --git a/plugins/openglsupport/CMakeLists.txt b/plugins/openglsupport/CMakeLists.txt index 51225a41d1..969fbb36f6 100644 --- a/plugins/openglsupport/CMakeLists.txt +++ b/plugins/openglsupport/CMakeLists.txt @@ -18,7 +18,7 @@ if(NOT GAMMARAY_CLIENT_ONLY_BUILD) openglsupport.h ) target_link_libraries(gammaray_openglsupport gammaray_core Qt::Gui Qt::CorePrivate) - if(TARGET Qt6::OpenGL) + if(QT_VERSION_MAJOR EQUAL 6 AND TARGET Qt6::OpenGL) target_link_libraries(gammaray_openglsupport Qt6::OpenGL) endif() endif() diff --git a/plugins/statemachineviewer/CMakeLists.txt b/plugins/statemachineviewer/CMakeLists.txt index 10d13596ac..80f9a45f4e 100644 --- a/plugins/statemachineviewer/CMakeLists.txt +++ b/plugins/statemachineviewer/CMakeLists.txt @@ -49,7 +49,7 @@ if(NOT GAMMARAY_CLIENT_ONLY_BUILD) if(TARGET Qt::Scxml) target_link_libraries(gammaray_statemachineviewer_plugin Qt::Scxml Qt::ScxmlPrivate) endif() - if(TARGET Qt6::StateMachine) + if(QT_VERSION_MAJOR EQUAL 6 AND TARGET Qt6::StateMachine) target_link_libraries(gammaray_statemachineviewer_plugin Qt6::StateMachine Qt6::StateMachinePrivate) endif() endif() @@ -83,7 +83,7 @@ if(GAMMARAY_BUILD_UI AND GAMMARAY_WITH_KDSME) gammaray_ui ) - if(TARGET Qt6::StateMachine) + if(QT_VERSION_MAJOR EQUAL 6 AND TARGET Qt6::StateMachine) target_link_libraries(gammaray_statemachineviewer_ui_plugin Qt6::StateMachine) endif() endif() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 69f2ee9e3f..0f465c0171 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -445,7 +445,7 @@ target_link_libraries( fontdatabasemodeltest Qt::Gui ) -if(TARGET Qt5::Core) +if(QT_VERSION_MAJOR EQUAL 5 AND TARGET Qt5::Core) gammaray_add_test( codecmodeltest codecmodeltest.cpp ${CMAKE_SOURCE_DIR}/plugins/codecbrowser/codecmodel.cpp $ @@ -518,7 +518,7 @@ if(NOT GAMMARAY_CLIENT_ONLY_BUILD) ) # only opengl rhi backend is supported atm - if(TARGET Qt6::Quick) + if(QT_VERSION_MAJOR EQUAL 6 AND TARGET Qt6::Quick) set_tests_properties( quickinspectortest PROPERTIES ENVIRONMENT "QT_QUICK_BACKEND=rhi;QSG_RHI_BACKEND=opengl" ) @@ -528,7 +528,7 @@ if(NOT GAMMARAY_CLIENT_ONLY_BUILD) quickinspectortest2 quickinspectortest2.cpp quickinspectortest.qrc $ ) target_link_libraries(quickinspectortest2 gammaray_core gammaray_quickinspector_shared Qt::Quick) - if(TARGET Qt6::Quick) + if(QT_VERSION_MAJOR EQUAL 6 AND TARGET Qt6::Quick) set_tests_properties( quickinspectortest2 PROPERTIES ENVIRONMENT "QT_QUICK_BACKEND=rhi;QSG_RHI_BACKEND=opengl" ) diff --git a/tests/manual/CMakeLists.txt b/tests/manual/CMakeLists.txt index d4ddbafd67..acc234a46d 100644 --- a/tests/manual/CMakeLists.txt +++ b/tests/manual/CMakeLists.txt @@ -46,7 +46,7 @@ if(TARGET Qt::Widgets) add_dependencies(translator_test translator_test_qm) endif() -if(Qt5Webkit_FOUND) +if(QT_VERSION_MAJOR EQUAL 5 AND Qt5Webkit_FOUND) add_executable(wk1application wk1application.cpp) target_link_libraries( wk1application @@ -58,7 +58,10 @@ if(Qt5Webkit_FOUND) ) endif() -if(Qt5WebKit_FOUND AND TARGET Qt::Quick) +if(QT_VERSION_MAJOR EQUAL 5 + AND Qt5WebKit_FOUND + AND TARGET Qt::Quick +) set(wk2application_srcs wk2application.cpp wk2application.qrc) add_executable(wk2application ${wk2application_srcs}) target_link_libraries(wk2application Qt::Quick)