Mercurial > public > ostc_companion
comparison CmakeLists.txt @ 1:0b3630a29ad8
Initial version based on previous repository.
Project was ported to QT6 and in now cmake based.
| author | Ideenmodellierer <tiefenrauscher@web.de> |
|---|---|
| date | Thu, 27 Nov 2025 18:40:28 +0100 |
| parents | |
| children | e30f00f760d3 |
comparison
equal
deleted
inserted
replaced
| 0:76ccd6ce50c0 | 1:0b3630a29ad8 |
|---|---|
| 1 cmake_minimum_required(VERSION 3.21) | |
| 2 | |
| 3 project(OSTCCompanion VERSION 1.0 LANGUAGES CXX) | |
| 4 | |
| 5 project(OSTCCompanion LANGUAGES CXX) | |
| 6 | |
| 7 # ---------------------------------------- | |
| 8 # C++ Standard | |
| 9 # ---------------------------------------- | |
| 10 set(CMAKE_CXX_STANDARD 17) | |
| 11 set(CMAKE_CXX_STANDARD_REQUIRED ON) | |
| 12 set(CMAKE_AUTOMOC ON) | |
| 13 set(CMAKE_AUTORCC ON) | |
| 14 set(CMAKE_AUTOUIC ON) | |
| 15 | |
| 16 # ---------------------------------------- | |
| 17 # Qt6 Modules | |
| 18 # ---------------------------------------- | |
| 19 find_package(Qt6 REQUIRED COMPONENTS | |
| 20 Core | |
| 21 Gui | |
| 22 Widgets | |
| 23 Network | |
| 24 Svg | |
| 25 Xml | |
| 26 SerialPort | |
| 27 LinguistTools | |
| 28 ) | |
| 29 | |
| 30 | |
| 31 # ---------------------------------------- | |
| 32 # Sources, Header, UI and Ressources | |
| 33 # ---------------------------------------- | |
| 34 set(SOURCES | |
| 35 main.cpp | |
| 36 AES/rijndael.cpp | |
| 37 editlogdialog.cpp | |
| 38 Utils/Exception.cpp | |
| 39 Utils/Log.cpp | |
| 40 Utils/LogAppender.cpp | |
| 41 Utils/LogConsole.cpp | |
| 42 Utils/LogFile.cpp | |
| 43 Utils/ProgressEvent.cpp | |
| 44 MainWindow.cpp | |
| 45 Serial.cpp | |
| 46 HexFile.cpp | |
| 47 SettingsDialog.cpp | |
| 48 HardwareOperations.cpp | |
| 49 OSTCFrogOperations.cpp | |
| 50 OSTCSportOperations.cpp | |
| 51 OSTC2cOperations.cpp | |
| 52 OSTC2Operations.cpp | |
| 53 OSTC3Operations.cpp | |
| 54 OSTC3pOperations.cpp | |
| 55 OSTC4Operations.cpp | |
| 56 OSTC_CR_Operations.cpp | |
| 57 ) | |
| 58 | |
| 59 set(HEADERS | |
| 60 AES/rijndael.h | |
| 61 AES/Adler16.h | |
| 62 Utils/Exception.h | |
| 63 Utils/Log.h | |
| 64 Utils/LogAppender.h | |
| 65 Utils/LogConsole.h | |
| 66 Utils/LogFile.h | |
| 67 Utils/ProgressEvent.h | |
| 68 MainWindow.h | |
| 69 Serial.h | |
| 70 HexFile.h | |
| 71 SettingsDialog.h | |
| 72 HardwareOperations.h | |
| 73 OSTCFrogOperations.h | |
| 74 OSTCSportOperations.h | |
| 75 OSTC2cOperations.h | |
| 76 OSTC2Operations.h | |
| 77 OSTC3Operations.h | |
| 78 OSTC3pOperations.h | |
| 79 OSTC4Operations.h | |
| 80 OSTC_CR_Operations.h | |
| 81 editlogdialog.h | |
| 82 ui_LogEditor.h | |
| 83 ) | |
| 84 | |
| 85 set(UIS | |
| 86 LogEditor.ui | |
| 87 MainWindow.ui | |
| 88 Settings.ui | |
| 89 ) | |
| 90 | |
| 91 set(RESOURCES | |
| 92 Resources.qrc | |
| 93 icon.rc | |
| 94 ) | |
| 95 | |
| 96 set(TRANSLATIONS | |
| 97 Translations/companion_DE.ts | |
| 98 Translations/companion_FR.ts | |
| 99 Translations/companion_ES.ts | |
| 100 Translations/companion_IT.ts | |
| 101 Translations/companion_RU.ts | |
| 102 ) | |
| 103 | |
| 104 set(app_icon_resource_windows "${CMAKE_CURRENT_SOURCE_DIR}/icon.rc") | |
| 105 | |
| 106 # ---------------------------------------- | |
| 107 # Executable erstellen | |
| 108 # ---------------------------------------- | |
| 109 qt_add_executable(${PROJECT_NAME} | |
| 110 ${SOURCES} | |
| 111 ${HEADERS} | |
| 112 ${UIS} | |
| 113 ${RESOURCES} | |
| 114 Utils/Export.h | |
| 115 ${app_icon_resource_windows} | |
| 116 ) | |
| 117 | |
| 118 target_include_directories(${PROJECT_NAME} PRIVATE | |
| 119 ${CMAKE_CURRENT_SOURCE_DIR} # Root | |
| 120 ${CMAKE_CURRENT_SOURCE_DIR}/Utils | |
| 121 ${CMAKE_CURRENT_SOURCE_DIR}/AES | |
| 122 ) | |
| 123 | |
| 124 # ---------------------------------------- | |
| 125 # Qt Libraries verlinken | |
| 126 # ---------------------------------------- | |
| 127 target_link_libraries(${PROJECT_NAME} | |
| 128 PRIVATE Qt6::Core Qt6::Gui Qt6::Widgets Qt6::Network Qt6::Svg Qt6::Xml Qt6::SerialPort | |
| 129 ) | |
| 130 | |
| 131 # ---------------------------------------- | |
| 132 # Plattform-spezifische Anpassungen | |
| 133 # ---------------------------------------- | |
| 134 if(WIN32) | |
| 135 target_compile_definitions(${PROJECT_NAME} PRIVATE _CRT_SECURE_NO_WARNINGS=1 BUILDING_OSTC_COMPANION) | |
| 136 elseif(APPLE) | |
| 137 target_compile_options(${PROJECT_NAME} PRIVATE -std=c++11 -Wno-inconsistent-missing-override) | |
| 138 elseif(UNIX) | |
| 139 target_compile_options(${PROJECT_NAME} PRIVATE -std=c++11) | |
| 140 set_target_properties(${PROJECT_NAME} PROPERTIES | |
| 141 BUILD_RPATH "\$ORIGIN/lib" | |
| 142 ) | |
| 143 endif() | |
| 144 | |
| 145 # ---------------------------------------- | |
| 146 # Debug/Release-Builds | |
| 147 # ---------------------------------------- | |
| 148 if(CMAKE_BUILD_TYPE MATCHES Debug) | |
| 149 target_compile_definitions(${PROJECT_NAME} PRIVATE DEBUG=1) | |
| 150 endif() | |
| 151 | |
| 152 # ---------------------------------------- | |
| 153 # Version aus Datei einlesen (optional) | |
| 154 # ---------------------------------------- | |
| 155 file(STRINGS "${CMAKE_SOURCE_DIR}/VERSION.txt" VERSION_CONTENT) | |
| 156 string(REGEX MATCH "MAJOR=([0-9]+)" _ ${VERSION_CONTENT}) | |
| 157 set(MAJOR_VERSION ${CMAKE_MATCH_1}) | |
| 158 string(REGEX MATCH "MINOR=([0-9]+)" _ ${VERSION_CONTENT}) | |
| 159 set(MINOR_VERSION ${CMAKE_MATCH_1}) | |
| 160 string(REGEX MATCH "PATCH=([0-9]+)" _ ${VERSION_CONTENT}) | |
| 161 set(PATCH_VERSION ${CMAKE_MATCH_1}) | |
| 162 string(REGEX MATCH "BETA=([0-9]+)" _ ${VERSION_CONTENT}) | |
| 163 set(BETA_VERSION ${CMAKE_MATCH_1}) | |
| 164 | |
| 165 | |
| 166 message("MAJOR_VERSION = '${MAJOR_VERSION}'") | |
| 167 | |
| 168 target_compile_definitions(${PROJECT_NAME} PRIVATE | |
| 169 MAJOR_VERSION=${MAJOR_VERSION} | |
| 170 MINOR_VERSION=${MINOR_VERSION} | |
| 171 PATCH_VERSION=${PATCH_VERSION} | |
| 172 BETA_VERSION=${BETA_VERSION} | |
| 173 ) | |
| 174 | |
| 175 # Show folder in Qt Creator | |
| 176 file(GLOB ICON_FILES "${CMAKE_SOURCE_DIR}/Images/*") | |
| 177 add_custom_target(Resources ALL SOURCES ${ICON_FILES}) | |
| 178 | |
| 179 | |
| 180 qt6_add_translation(QM_FILES ${TRANSLATIONS}) | |
| 181 | |
| 182 if(CMAKE_BUILD_TYPE MATCHES Release) | |
| 183 target_compile_definitions(${PROJECT_NAME} PRIVATE DEBUG=1) | |
| 184 | |
| 185 message("Build release and installer") | |
| 186 | |
| 187 set(CPACK_IFW_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/Images/inst_OSTC_Companion.ico") | |
| 188 | |
| 189 install(FILES ${CMAKE_SOURCE_DIR}/Images/app_OSTC_Companion.ico | |
| 190 DESTINATION . # relativ zum Package root | |
| 191 COMPONENT Core) | |
| 192 | |
| 193 install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin COMPONENT Core) | |
| 194 | |
| 195 qt_generate_deploy_app_script( | |
| 196 TARGET ${PROJECT_NAME} | |
| 197 OUTPUT_SCRIPT deploy_script | |
| 198 NO_UNSUPPORTED_PLATFORM_ERROR | |
| 199 ) | |
| 200 | |
| 201 install(SCRIPT ${deploy_script} | |
| 202 COMPONENT Core) | |
| 203 | |
| 204 # CPack IFW Konfiguration | |
| 205 set(CPACK_GENERATOR "IFW") | |
| 206 set(CPACK_IFW_ROOT "D:/Programme/QT/Tools/QtInstallerFramework/4.10") | |
| 207 set(CPACK_PACKAGE_VERSION_MAJOR "3") | |
| 208 set(CPACK_PACKAGE_VERSION_MINOR "3") | |
| 209 set(CPACK_PACKAGE_NAME "${PROJECT_NAME}") | |
| 210 set(CPACK_PACKAGE_VENDOR "Heinrichs Weikamp") | |
| 211 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "OSTC Companion Application") | |
| 212 set (CPACK_IFW_PACKAGE_NAME "${PROJECT_NAME} 3.3.1") | |
| 213 set (CPACK_IFW_PACKAGE_TITLE "${PROJECT_NAME} Installer") | |
| 214 set (CPACK_IFW_PACKAGE_PUBLISHER "Heinrichs Weikamp") | |
| 215 set (CPACK_IFW_PACKAGE_WIZARD_STYLE "Modern") | |
| 216 set (CPACK_IFW_PACKAGE_WIZARD_SHOW_PAGE_LIST OFF) | |
| 217 | |
| 218 set (CPACK_IFW_PACKAGE_START_MENU_DIRECTORY "OSTC-Tools") | |
| 219 | |
| 220 include(CPack) | |
| 221 include(CPackIFW) | |
| 222 | |
| 223 # Hauptkomponente | |
| 224 cpack_add_component(Core | |
| 225 DISPLAY_NAME "OSTC Companion" | |
| 226 DESCRIPTION "OSTC maintenance application" | |
| 227 REQUIRED | |
| 228 ) | |
| 229 | |
| 230 cpack_ifw_configure_component(Core ESSENTIAL FORCED_INSTALLATION) | |
| 231 endif() | |
| 232 | |
| 233 | |
| 234 |
