mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Prepare CMake to support both Qt5 andf Qt6
CEE_USE_QT6 controls if Qt6 is used. Improved install and package for Qt6, target version Qt 6.5.3 Added Qt6 to github action for AppFwkUnitTest
This commit is contained in:
@@ -2,12 +2,22 @@ cmake_minimum_required(VERSION 3.15)
|
||||
|
||||
project(cafUserInterface_UnitTests)
|
||||
|
||||
find_package(
|
||||
Qt5
|
||||
COMPONENTS
|
||||
REQUIRED Core Gui Widgets
|
||||
)
|
||||
set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Widgets Qt5::OpenGL)
|
||||
# Qt
|
||||
if(CEE_USE_QT6)
|
||||
find_package(
|
||||
Qt6
|
||||
COMPONENTS
|
||||
REQUIRED Core Gui Widgets Svg
|
||||
)
|
||||
qt_standard_project_setup()
|
||||
else()
|
||||
find_package(
|
||||
Qt5
|
||||
COMPONENTS
|
||||
REQUIRED Core Gui Widgets OpenGL
|
||||
)
|
||||
set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::OpenGL)
|
||||
endif()
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR} # required for gtest-all.cpp
|
||||
)
|
||||
@@ -16,13 +26,16 @@ set(PROJECT_FILES cafUserInterface_UnitTests.cpp cafPdmUiTreeViewModelTest.cpp
|
||||
cafPdmUiTreeSelectionQModelTest.cpp gtest/gtest-all.cpp
|
||||
)
|
||||
|
||||
# add the executable
|
||||
add_executable(${PROJECT_NAME} ${PROJECT_FILES})
|
||||
if(CEE_USE_QT6)
|
||||
qt_add_executable(${PROJECT_NAME} ${PROJECT_FILES})
|
||||
else()
|
||||
add_executable(${PROJECT_NAME} ${PROJECT_FILES})
|
||||
endif(CEE_USE_QT6)
|
||||
|
||||
source_group("" FILES ${PROJECT_FILES})
|
||||
|
||||
target_link_libraries(
|
||||
${PROJECT_NAME} cafUserInterface ${QT_LIBRARIES} ${THREAD_LIBRARY}
|
||||
${PROJECT_NAME} PRIVATE cafUserInterface ${QT_LIBRARIES} ${THREAD_LIBRARY}
|
||||
)
|
||||
|
||||
# Copy Qt Dlls
|
||||
@@ -34,3 +47,18 @@ foreach(qtlib ${QT_LIBRARIES})
|
||||
$<TARGET_FILE_DIR:${PROJECT_NAME}>
|
||||
)
|
||||
endforeach(qtlib)
|
||||
|
||||
# Install
|
||||
install(
|
||||
TARGETS ${PROJECT_NAME}
|
||||
BUNDLE DESTINATION .
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
if(CEE_USE_QT6)
|
||||
qt_generate_deploy_app_script(
|
||||
TARGET ${PROJECT_NAME} OUTPUT_SCRIPT deploy_script
|
||||
NO_UNSUPPORTED_PLATFORM_ERROR NO_TRANSLATIONS
|
||||
)
|
||||
install(SCRIPT ${deploy_script})
|
||||
endif(CEE_USE_QT6)
|
||||
|
||||
Reference in New Issue
Block a user