|
| 1 | +cmake_minimum_required(VERSION 3.16) |
| 2 | +project(ScopeOne VERSION 1.3.30 LANGUAGES CXX) |
| 3 | + |
| 4 | +set(CMAKE_CXX_STANDARD 20) |
| 5 | +set(CMAKE_AUTOMOC ON) |
| 6 | +set(CMAKE_AUTORCC ON) |
| 7 | +set(CMAKE_AUTOUIC ON) |
| 8 | + |
| 9 | +include(GNUInstallDirs) |
| 10 | + |
| 11 | +set(ScopeOneCore_DIR "${CMAKE_SOURCE_DIR}/ScopeOneCore/install/lib/cmake/ScopeOneCore") |
| 12 | + |
| 13 | +set(CMAKE_PREFIX_PATH "C:/Qt/6.9.1/msvc2022_64") |
| 14 | + |
| 15 | +file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/include") |
| 16 | +configure_file( |
| 17 | + "${CMAKE_SOURCE_DIR}/src/AppVersion.h.in" |
| 18 | + "${CMAKE_BINARY_DIR}/include/AppVersion.h" |
| 19 | + @ONLY |
| 20 | +) |
| 21 | + |
| 22 | +file(GLOB_RECURSE _ui_layer_files LIST_DIRECTORIES false |
| 23 | + "${CMAKE_SOURCE_DIR}/src/*.h" |
| 24 | + "${CMAKE_SOURCE_DIR}/src/*.cpp" |
| 25 | +) |
| 26 | +foreach (_file IN LISTS _ui_layer_files) |
| 27 | + file(STRINGS "${_file}" _internal_core_include_hits REGEX |
| 28 | + "^[ \t]*#[ \t]*include[ \t]*[\"<]core/internal/") |
| 29 | + if (_internal_core_include_hits) |
| 30 | + message(FATAL_ERROR "Layering violation: UI file '${_file}' includes internal core headers.") |
| 31 | + endif () |
| 32 | +endforeach () |
| 33 | + |
| 34 | +find_package(Qt6 COMPONENTS |
| 35 | + Core |
| 36 | + Gui |
| 37 | + Widgets |
| 38 | + OpenGL |
| 39 | + OpenGLWidgets |
| 40 | + Network |
| 41 | + Concurrent |
| 42 | + REQUIRED |
| 43 | +) |
| 44 | + |
| 45 | +find_package(ScopeOneCore CONFIG REQUIRED) |
| 46 | + |
| 47 | +if (WIN32 AND TARGET Qt6::qmake) |
| 48 | + get_target_property(qmake_executable Qt6::qmake IMPORTED_LOCATION) |
| 49 | + if (qmake_executable) |
| 50 | + get_filename_component(qt_bin_dir "${qmake_executable}" DIRECTORY) |
| 51 | + set(SCOPEONE_QT_BIN_DIR "${qt_bin_dir}") |
| 52 | + find_program(WINDEPLOYQT_EXECUTABLE |
| 53 | + NAMES windeployqt |
| 54 | + HINTS "${qt_bin_dir}" |
| 55 | + ) |
| 56 | + endif () |
| 57 | +endif () |
| 58 | + |
| 59 | +set(SCOPEONE_UI_SOURCES |
| 60 | + src/main.cpp |
| 61 | + src/InspectWidget.cpp |
| 62 | + src/MainWindow.cpp |
| 63 | + src/ImageProcessingWidget.cpp |
| 64 | + src/PreviewWidget.cpp |
| 65 | + src/ConsoleWidget.cpp |
| 66 | + src/AboutDialog.cpp |
| 67 | + src/SettingsDialog.cpp |
| 68 | + src/DeviceControlWidget.cpp |
| 69 | + src/RecordingWidget.cpp |
| 70 | + src/ImageSessionDialog.cpp |
| 71 | + src/DevicePropertyWidget.cpp |
| 72 | + ${CMAKE_SOURCE_DIR}/resources/resources.qrc |
| 73 | +) |
| 74 | + |
| 75 | +set(SCOPEONE_UI_HEADERS |
| 76 | + src/InspectWidget.h |
| 77 | + src/MainWindow.h |
| 78 | + src/ImageProcessingWidget.h |
| 79 | + src/PreviewWidget.h |
| 80 | + src/ConsoleWidget.h |
| 81 | + src/AboutDialog.h |
| 82 | + src/SettingsDialog.h |
| 83 | + src/DeviceControlWidget.h |
| 84 | + src/RecordingWidget.h |
| 85 | + src/ImageSessionDialog.h |
| 86 | + src/DevicePropertyWidget.h |
| 87 | +) |
| 88 | + |
| 89 | +if (WIN32) |
| 90 | + list(APPEND SCOPEONE_UI_SOURCES ${CMAKE_SOURCE_DIR}/resources/app_icon.rc) |
| 91 | +endif () |
| 92 | + |
| 93 | +add_executable(ScopeOne ${SCOPEONE_UI_SOURCES} ${SCOPEONE_UI_HEADERS}) |
| 94 | +target_link_libraries(ScopeOne PRIVATE |
| 95 | + scopeone::ScopeOneCore |
| 96 | + Qt::Widgets |
| 97 | + Qt::OpenGL |
| 98 | + Qt::OpenGLWidgets |
| 99 | + Qt::Concurrent |
| 100 | +) |
| 101 | +target_include_directories(ScopeOne PRIVATE |
| 102 | + ${CMAKE_SOURCE_DIR}/src |
| 103 | + ${CMAKE_BINARY_DIR}/include |
| 104 | +) |
| 105 | + |
| 106 | +install(TARGETS ScopeOne |
| 107 | + RUNTIME DESTINATION . |
| 108 | +) |
| 109 | + |
| 110 | +add_custom_command(TARGET ScopeOne POST_BUILD |
| 111 | + COMMAND ${CMAKE_COMMAND} -E copy_directory |
| 112 | + "$<TARGET_FILE_DIR:scopeone::ScopeOneCore>" |
| 113 | + "$<TARGET_FILE_DIR:ScopeOne>" |
| 114 | +) |
| 115 | + |
| 116 | +if (WIN32) |
| 117 | + if (WINDEPLOYQT_EXECUTABLE) |
| 118 | + add_custom_command(TARGET ScopeOne POST_BUILD |
| 119 | + COMMAND "${WINDEPLOYQT_EXECUTABLE}" |
| 120 | + --no-translations |
| 121 | + --no-compiler-runtime |
| 122 | + --release |
| 123 | + "$<TARGET_FILE:ScopeOne>" |
| 124 | + WORKING_DIRECTORY "${SCOPEONE_QT_BIN_DIR}" |
| 125 | + VERBATIM |
| 126 | + ) |
| 127 | + else () |
| 128 | + message(WARNING "windeployqt was not found; ScopeOne may not start outside Qt Creator.") |
| 129 | + endif () |
| 130 | +endif () |
| 131 | + |
| 132 | +if (MSVC) |
| 133 | + target_compile_options(ScopeOne PRIVATE |
| 134 | + $<$<CONFIG:Release>:/O2 /GL /fp:fast /arch:AVX2> |
| 135 | + ) |
| 136 | + target_compile_definitions(ScopeOne PRIVATE |
| 137 | + $<$<CONFIG:Release>:NDEBUG> |
| 138 | + ) |
| 139 | + target_link_options(ScopeOne PRIVATE |
| 140 | + $<$<CONFIG:Release>:/LTCG> |
| 141 | + ) |
| 142 | +endif () |
| 143 | + |
| 144 | +install(FILES |
| 145 | + "${CMAKE_SOURCE_DIR}/LICENSE.txt" |
| 146 | + "${CMAKE_SOURCE_DIR}/README.md" |
| 147 | + DESTINATION . |
| 148 | +) |
| 149 | + |
| 150 | +if (WIN32) |
| 151 | + install(CODE " |
| 152 | + file(GLOB _core_runtime_files |
| 153 | + \"$<TARGET_FILE_DIR:scopeone::ScopeOneCore>/*.dll\" |
| 154 | + \"$<TARGET_FILE_DIR:scopeone::ScopeOneCore>/ScopeOne_Agent.exe\" |
| 155 | + ) |
| 156 | + if (_core_runtime_files) |
| 157 | + file(INSTALL |
| 158 | + DESTINATION \"\${CMAKE_INSTALL_PREFIX}\" |
| 159 | + TYPE FILE |
| 160 | + FILES \${_core_runtime_files} |
| 161 | + ) |
| 162 | + endif() |
| 163 | + ") |
| 164 | + |
| 165 | + install(CODE " |
| 166 | + set(_runtime_dir \"${CMAKE_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}\") |
| 167 | + if (NOT EXISTS \"\${_runtime_dir}/$<TARGET_FILE_NAME:ScopeOne>\") |
| 168 | + return() |
| 169 | + endif() |
| 170 | +
|
| 171 | + foreach(_pattern IN ITEMS |
| 172 | + Qt6*.dll |
| 173 | + opengl32sw.dll |
| 174 | + D3Dcompiler_47.dll |
| 175 | + dxcompiler.dll |
| 176 | + dxil.dll |
| 177 | + ) |
| 178 | + file(GLOB _qt_files \"\${_runtime_dir}/\${_pattern}\") |
| 179 | + if (_qt_files) |
| 180 | + file(INSTALL |
| 181 | + DESTINATION \"\${CMAKE_INSTALL_PREFIX}\" |
| 182 | + TYPE FILE |
| 183 | + FILES \${_qt_files} |
| 184 | + ) |
| 185 | + endif() |
| 186 | + endforeach() |
| 187 | +
|
| 188 | + foreach(_subdir IN ITEMS |
| 189 | + platforms |
| 190 | + imageformats |
| 191 | + iconengines |
| 192 | + networkinformation |
| 193 | + styles |
| 194 | + tls |
| 195 | + generic |
| 196 | + ) |
| 197 | + if (EXISTS \"\${_runtime_dir}/\${_subdir}\") |
| 198 | + file(INSTALL |
| 199 | + DESTINATION \"\${CMAKE_INSTALL_PREFIX}\" |
| 200 | + TYPE DIRECTORY |
| 201 | + FILES \"\${_runtime_dir}/\${_subdir}\" |
| 202 | + ) |
| 203 | + endif() |
| 204 | + endforeach() |
| 205 | + ") |
| 206 | +endif () |
| 207 | + |
| 208 | +set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION .) |
| 209 | +include(InstallRequiredSystemLibraries) |
| 210 | + |
| 211 | +set(CPACK_GENERATOR "ZIP") |
| 212 | +set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF) |
| 213 | +set(CPACK_PACKAGE_DIRECTORY "${CMAKE_BINARY_DIR}") |
| 214 | +set(CPACK_PACKAGE_FILE_NAME "ScopeOne-${PROJECT_VERSION}-win-x64") |
| 215 | +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE.txt") |
| 216 | +set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md") |
| 217 | + |
| 218 | +include(CPack) |
0 commit comments