Skip to content

Commit

Permalink
Fix builds would compile parts for both Qt 5 and 6
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Cuperino committed Apr 17, 2024
1 parent 25ca491 commit 5ac3617
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Contact KDAB at <[email protected]> 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))
Expand Down Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion plugins/network/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion plugins/openglsupport/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
4 changes: 2 additions & 2 deletions plugins/statemachineviewer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
6 changes: 3 additions & 3 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
$<TARGET_OBJECTS:modeltestobj>
Expand Down Expand Up @@ -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"
)
Expand All @@ -528,7 +528,7 @@ if(NOT GAMMARAY_CLIENT_ONLY_BUILD)
quickinspectortest2 quickinspectortest2.cpp quickinspectortest.qrc $<TARGET_OBJECTS:modeltestobj>
)
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"
)
Expand Down

0 comments on commit 5ac3617

Please sign in to comment.