diff options
author | Louie S <louie@example.com> | 2024-02-19 13:45:23 -0500 |
---|---|---|
committer | Louie S <louie@example.com> | 2024-02-19 13:45:23 -0500 |
commit | d54b1cc6ec723c01c1e3313fd41345e3833f5594 (patch) | |
tree | 53e6748bf424a0b4f848dbf89248dafd1c028440 /CMakeLists.txt | |
parent | 7bbc2a93b6f123dfe8d2b97df8a4239032a6397b (diff) |
Modularize CMakeLists.txt for Qt version
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index b07fb66..8874654 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,28 +1,47 @@ -cmake_minimum_required(VERSION 3.1.0) +cmake_minimum_required(VERSION 3.5) project(assignment-list VERSION 0.0.1 LANGUAGES CXX) -set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) -if(CMAKE_VERSION VERSION_LESS "3.7.0") - set(CMAKE_INCLUDE_CURRENT_DIR ON) +option(USE_QT5 "Use Qt5, instead of Qt6" no) +option(USE_QT6 "Use Qt6, instead of Qt5" no) + +set(qt_components "Core" "Gui" "UiTools" "Widgets") +set(qt_names "Qt6" "Qt5") +if(USE_QT5) + set(qt_names "Qt5") +elseif(USE_QT6) + set(qt_names "Qt6") endif() -find_package(Qt5 COMPONENTS Core Gui UiTools Widgets REQUIRED) +find_package(QT NAMES ${qt_names} REQUIRED COMPONENTS ${qt_components}) +find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS ${qt_components}) + +message("Using Qt${QT_VERSION_MAJOR}") + +set(qt_libraries "") +foreach(X ${qt_components}) + list(APPEND qt_libraries "Qt${QT_VERSION_MAJOR}::${X}") +endforeach() + +set(project_sources + "src/add_entry_form.ui" + "src/add_group_form.ui" + "src/assignmentList.cpp" + "src/assignmentList.h" + "src/main.cpp" + "src/main.ui" + "src/preferences_dialog.ui" +) add_executable(assignment-list - "${CMAKE_CURRENT_SOURCE_DIR}/src/add_entry_form.ui" - "${CMAKE_CURRENT_SOURCE_DIR}/src/add_group_form.ui" - "${CMAKE_CURRENT_SOURCE_DIR}/src/assignmentList.cpp" - "${CMAKE_CURRENT_SOURCE_DIR}/src/assignmentList.h" - "${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp" - "${CMAKE_CURRENT_SOURCE_DIR}/src/main.ui" - "${CMAKE_CURRENT_SOURCE_DIR}/src/preferences_dialog.ui" + ${project_sources} ) -target_link_libraries(assignment-list Qt5::Core Qt5::Gui Qt5::UiTools Qt5::Widgets) +target_link_libraries(assignment-list ${qt_libraries}) |