|
| 1 | +cmake_minimum_required(VERSION 3.20) |
| 2 | + |
| 3 | +set(CMAKE_OSX_DEPLOYMENT_TARGET 10.15 CACHE STRING "Minimum macOS version targeted by sACNView on macOS") |
| 4 | + |
| 5 | +project(sACNView DESCRIPTION "A tool for sending and receiving the ANSI E1.31 Streaming ACN control protocol") |
| 6 | + |
| 7 | +# Workaround for cmake bug |
| 8 | +# Ninja generator will often exceed command line limits, but cmake doesn't use the response file by default |
| 9 | +SET(CMAKE_NINJA_FORCE_RESPONSE_FILE 1 CACHE INTERNAL "") |
| 10 | + |
| 11 | +# Only do these if this is the main project, and not if it is included through add_subdirectory |
| 12 | +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) |
| 13 | + ### Require out-of-source builds |
| 14 | + file(TO_CMAKE_PATH "${PROJECT_BINARY_DIR}/CMakeLists.txt" LOC_PATH) |
| 15 | + if(EXISTS "${LOC_PATH}") |
| 16 | + message(FATAL_ERROR "You cannot build in a source directory (or any directory with a CMakeLists.txt file). Please make a build subdirectory. Feel free to remove CMakeCache.txt and CMakeFiles.") |
| 17 | + endif() |
| 18 | + |
| 19 | + # Nicer IDE |
| 20 | + set_property(GLOBAL PROPERTY USE_FOLDERS ON) |
| 21 | + |
| 22 | + # Workaround for CMake bug https://gitlab.kitware.com/cmake/cmake/-/issues/20812 |
| 23 | + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") |
| 24 | + add_compile_options( |
| 25 | + $<$<CONFIG:RELEASE>:/Zi> |
| 26 | + ) |
| 27 | + |
| 28 | + add_link_options( |
| 29 | + $<$<CONFIG:RELEASE>:/DEBUG> |
| 30 | + $<$<CONFIG:RELEASE>:/OPT:REF> |
| 31 | + $<$<CONFIG:RELEASE>:/OPT:ICF> |
| 32 | + ) |
| 33 | + endif() |
| 34 | + |
| 35 | + if (WIN32) |
| 36 | + # Qt5 does not automatically set these, but Qt6 does |
| 37 | + add_compile_definitions(UNICODE _UNICODE) |
| 38 | + endif() |
| 39 | + |
| 40 | +endif() |
| 41 | + |
| 42 | +set(SACNVIEW_HEADER_PATHS |
| 43 | + ${CMAKE_CURRENT_LIST_DIR} |
| 44 | + ${CMAKE_CURRENT_LIST_DIR}/src |
| 45 | + ${CMAKE_CURRENT_LIST_DIR}/src/sacn |
| 46 | + ${CMAKE_CURRENT_LIST_DIR}/src/sacn/ACNShare |
| 47 | + ${CMAKE_CURRENT_LIST_DIR}/src/widgets |
| 48 | + ${CMAKE_CURRENT_LIST_DIR}/src/models |
| 49 | + ${CMAKE_CURRENT_LIST_DIR}/src/pcap |
| 50 | + ${CMAKE_CURRENT_LIST_DIR}/src/ui |
| 51 | +) |
| 52 | + |
| 53 | +set(SACNVIEW_HEADERS |
| 54 | + src/ui/mdimainwindow.h |
| 55 | + src/sacn/securesacn.h |
| 56 | + src/widgets/monitorspinbox.h |
| 57 | + src/widgets/qpushbutton_rightclick.h |
| 58 | + src/widgets/qspinbox_resizetocontent.h |
| 59 | + src/ui/newversiondialog.h |
| 60 | + src/ui/scopewindow.h |
| 61 | + src/ui/universeview.h |
| 62 | + src/sacn/sacnsynchronization.h |
| 63 | + src/models/sacnsynclistmodel.h |
| 64 | + src/sacn/ACNShare/CID.h |
| 65 | + src/sacn/ACNShare/defpack.h |
| 66 | + src/sacn/ACNShare/ipaddr.h |
| 67 | + src/sacn/ACNShare/tock.h |
| 68 | + src/sacn/ACNShare/VHD.h |
| 69 | + src/sacn/streamcommon.h |
| 70 | + src/ui/nicselectdialog.h |
| 71 | + src/sacn/streamingacn.h |
| 72 | + src/ui/preferencesdialog.h |
| 73 | + src/preferences.h |
| 74 | + src/sacn/sacnlistener.h |
| 75 | + src/widgets/universedisplay.h |
| 76 | + src/ui/transmitwindow.h |
| 77 | + src/consts.h |
| 78 | + src/sacn/sacnsender.h |
| 79 | + src/ui/configureperchanpriodlg.h |
| 80 | + src/widgets/gridwidget.h |
| 81 | + src/widgets/scopewidget.h |
| 82 | + src/ui/aboutdialog.h |
| 83 | + src/sacn/sacneffectengine.h |
| 84 | + src/models/sacnuniverselistmodel.h |
| 85 | + src/ui/snapshot.h |
| 86 | + src/commandline.h |
| 87 | + src/fontdata.h |
| 88 | + src/ui/multiuniverse.h |
| 89 | + src/ui/flickerfinderinfoform.h |
| 90 | + src/sacn/sacnsocket.h |
| 91 | + src/ui/logwindow.h |
| 92 | + src/firewallcheck.h |
| 93 | + src/ui/bigdisplay.h |
| 94 | + src/ui/addmultidialog.h |
| 95 | + src/sacn/e1_11.h |
| 96 | + src/ipc.h |
| 97 | + src/sacn/sacndiscovery.h |
| 98 | + src/models/sacndiscoveredsourcelistmodel.h |
| 99 | + src/widgets/clssnapshot.h |
| 100 | + src/sacn/fpscounter.h |
| 101 | + src/widgets/grideditwidget.h |
| 102 | + src/ui/multiview.h |
| 103 | + src/models/sacnsourcetablemodel.h |
| 104 | + src/models/csvmodelexport.h |
| 105 | +) |
| 106 | + |
| 107 | +set(SACNVIEW_SOURCES |
| 108 | + src/commandline.cpp |
| 109 | + src/firewallcheck.cpp |
| 110 | + src/ipc.cpp |
| 111 | + src/main.cpp |
| 112 | + src/preferences.cpp |
| 113 | + src/models/sacnsynclistmodel.cpp |
| 114 | + src/models/sacndiscoveredsourcelistmodel.cpp |
| 115 | + src/models/sacnuniverselistmodel.cpp |
| 116 | + src/sacn/fpscounter.cpp |
| 117 | + src/sacn/sacndiscovery.cpp |
| 118 | + src/sacn/sacneffectengine.cpp |
| 119 | + src/sacn/sacnlistener.cpp |
| 120 | + src/sacn/sacnsender.cpp |
| 121 | + src/sacn/sacnsocket.cpp |
| 122 | + src/sacn/sacnsynchronization.cpp |
| 123 | + src/sacn/securesacn.cpp |
| 124 | + src/sacn/streamcommon.cpp |
| 125 | + src/sacn/streamingacn.cpp |
| 126 | + src/sacn/ACNShare/CID.cpp |
| 127 | + src/sacn/ACNShare/ipaddr.cpp |
| 128 | + src/sacn/ACNShare/tock.cpp |
| 129 | + src/sacn/ACNShare/VHD.cpp |
| 130 | + src/pcap/pcapplayback.cpp |
| 131 | + src/pcap/pcapplaybacksender.cpp |
| 132 | + src/ui/aboutdialog.cpp |
| 133 | + src/ui/configureperchanpriodlg.cpp |
| 134 | + src/ui/newversiondialog.cpp |
| 135 | + src/ui/mdimainwindow.cpp |
| 136 | + src/ui/scopewindow.cpp |
| 137 | + src/ui/universeview.cpp |
| 138 | + src/ui/nicselectdialog.cpp |
| 139 | + src/ui/preferencesdialog.cpp |
| 140 | + src/ui/snapshot.cpp |
| 141 | + src/ui/transmitwindow.cpp |
| 142 | + src/ui/multiuniverse.cpp |
| 143 | + src/ui/flickerfinderinfoform.cpp |
| 144 | + src/ui/logwindow.cpp |
| 145 | + src/ui/bigdisplay.cpp |
| 146 | + src/ui/addmultidialog.cpp |
| 147 | + src/ui/multiview.cpp |
| 148 | + src/widgets/monitorspinbox.cpp |
| 149 | + src/widgets/qpushbutton_rightclick.cpp |
| 150 | + src/widgets/qspinbox_resizetocontent.cpp |
| 151 | + src/widgets/universedisplay.cpp |
| 152 | + src/widgets/gridwidget.cpp |
| 153 | + src/widgets/scopewidget.cpp |
| 154 | + src/widgets/clssnapshot.cpp |
| 155 | + src/widgets/grideditwidget.cpp |
| 156 | + src/models/sacnsourcetablemodel.cpp |
| 157 | + src/models/csvmodelexport.cpp |
| 158 | +) |
| 159 | + |
| 160 | +set(SACNVIEW_FORMS |
| 161 | + ui/mdimainwindow.ui |
| 162 | + ui/scopewindow.ui |
| 163 | + ui/universeview.ui |
| 164 | + ui/nicselectdialog.ui |
| 165 | + ui/preferencesdialog.ui |
| 166 | + ui/transmitwindow.ui |
| 167 | + ui/configureperchanpriodlg.ui |
| 168 | + ui/aboutdialog.ui |
| 169 | + ui/snapshot.ui |
| 170 | + ui/multiuniverse.ui |
| 171 | + ui/flickerfinderinfoform.ui |
| 172 | + ui/logwindow.ui |
| 173 | + ui/bigdisplay.ui |
| 174 | + ui/newversiondialog.ui |
| 175 | + ui/addmultidialog.ui |
| 176 | + ui/pcapplayback.ui |
| 177 | + ui/multiview.ui |
| 178 | +) |
| 179 | + |
| 180 | +set(SACNVIEW_RCC |
| 181 | + res/resources.qrc |
| 182 | + res/sacnview.rc |
| 183 | +) |
| 184 | + |
| 185 | +# Theming |
| 186 | +include(themes/sources.cmake) |
| 187 | + |
| 188 | +# Translation |
| 189 | +include(translations/sources.cmake) |
| 190 | + |
| 191 | +# 3rd party libraries |
| 192 | +include(libs/libs.cmake) |
| 193 | + |
| 194 | +# Enable automatic Qt handling |
| 195 | +set(CMAKE_AUTOMOC ON) |
| 196 | +set(CMAKE_AUTOUIC ON) |
| 197 | +set(CMAKE_AUTORCC ON) |
| 198 | + |
| 199 | +# Find Qt 5.15 or Qt 6 |
| 200 | +find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core) |
| 201 | +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Network Multimedia Widgets REQUIRED) |
| 202 | + |
| 203 | +add_executable(sACNView WIN32 |
| 204 | + ${SACNVIEW_HEADERS} |
| 205 | + ${SACNVIEW_SOURCES} |
| 206 | + ${SACNVIEW_FORMS} |
| 207 | + ${SACNVIEW_RCC} |
| 208 | +) |
| 209 | + |
| 210 | +target_include_directories(sACNView PRIVATE |
| 211 | + ${SACNVIEW_HEADER_PATHS} |
| 212 | +) |
| 213 | + |
| 214 | +target_compile_features(sACNView PRIVATE cxx_std_17) |
| 215 | + |
| 216 | +set_target_properties(sACNView PROPERTIES |
| 217 | + CXX_EXTENSIONS OFF |
| 218 | + AUTOUIC_SEARCH_PATHS ui |
| 219 | +) |
| 220 | + |
| 221 | +# Link Qt libraries |
| 222 | +target_link_libraries(sACNView PRIVATE Qt::Core Qt::Gui Qt::Network Qt::Multimedia Qt::Widgets) |
| 223 | + |
| 224 | +# Link PCap/WinPCap libraries |
| 225 | +target_link_libraries(sACNView PRIVATE ${PCAP_LIBS}) |
| 226 | + |
| 227 | +if(WIN32) |
| 228 | + # Copy WinPCap DLLs |
| 229 | + foreach(DLLFILE IN LISTS PCAP_LIBS) |
| 230 | + add_custom_command (TARGET sACNView POST_BUILD |
| 231 | + COMMAND ${CMAKE_COMMAND} -E copy_if_different |
| 232 | + $<TARGET_FILE:${DLLFILE}> $<TARGET_FILE_DIR:sACNView>) |
| 233 | + endforeach() |
| 234 | +endif() |
| 235 | + |
| 236 | +# Blake2 |
| 237 | +target_compile_definitions(sACNView PRIVATE ${BLAKE2_DEFINES}) |
| 238 | +target_sources(sACNView PRIVATE ${BLAKE2_SOURCES}) |
| 239 | +target_include_directories(sACNView PRIVATE ${BLAKE2_PATH}) |
| 240 | + |
| 241 | +## Git Version info |
| 242 | + |
| 243 | +# sha or tag |
| 244 | +execute_process( |
| 245 | + COMMAND git describe --always --tags |
| 246 | + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} |
| 247 | + OUTPUT_VARIABLE GIT_VERSION |
| 248 | + OUTPUT_STRIP_TRAILING_WHITESPACE |
| 249 | +) |
| 250 | + |
| 251 | +# date |
| 252 | +execute_process( |
| 253 | + COMMAND git show -1 -s --date=format:"%a" --format="%cd" ${GIT_VERSION} |
| 254 | + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} |
| 255 | + OUTPUT_VARIABLE GIT_DATE_DAY |
| 256 | + OUTPUT_STRIP_TRAILING_WHITESPACE |
| 257 | +) |
| 258 | + |
| 259 | +execute_process( |
| 260 | + COMMAND git show -1 -s --date=format:"%d" --format="%cd" ${GIT_VERSION} |
| 261 | + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} |
| 262 | + OUTPUT_VARIABLE GIT_DATE_DATE |
| 263 | + OUTPUT_STRIP_TRAILING_WHITESPACE |
| 264 | +) |
| 265 | + |
| 266 | +execute_process( |
| 267 | + COMMAND git show -1 -s --date=format:"%b" --format="%cd" ${GIT_VERSION} |
| 268 | + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} |
| 269 | + OUTPUT_VARIABLE GIT_DATE_MONTH |
| 270 | + OUTPUT_STRIP_TRAILING_WHITESPACE |
| 271 | +) |
| 272 | + |
| 273 | +execute_process( |
| 274 | + COMMAND git show -1 -s --date=format:"%Y" --format="%cd" ${GIT_VERSION} |
| 275 | + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} |
| 276 | + OUTPUT_VARIABLE GIT_DATE_YEAR |
| 277 | + OUTPUT_STRIP_TRAILING_WHITESPACE |
| 278 | +) |
| 279 | + |
| 280 | +# most recent tag |
| 281 | +execute_process( |
| 282 | + COMMAND git describe --abbrev=0 --always --tags |
| 283 | + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} |
| 284 | + OUTPUT_VARIABLE GIT_TAG |
| 285 | + OUTPUT_STRIP_TRAILING_WHITESPACE |
| 286 | +) |
| 287 | + |
| 288 | +target_compile_definitions(sACNView PRIVATE |
| 289 | + "GIT_CURRENT_SHA1=\"${GIT_VERSION}\"" |
| 290 | + "GIT_DATE_DAY=\"${GIT_DATE_DAY}\"" |
| 291 | + "GIT_DATE_DATE=\"${GIT_DATE_DATE}\"" |
| 292 | + "GIT_DATE_MONTH=\"${GIT_DATE_MONTH}\"" |
| 293 | + "GIT_DATE_YEAR=\"${GIT_DATE_YEAR}\"" |
| 294 | + "VERSION=\"${GIT_TAG}\"" |
| 295 | +) |
| 296 | + |
| 297 | +# Deploy the build using windeployqt |
| 298 | +option(SACNVIEW_CREATE_INSTALLER "Create the sACNView installer" OFF) |
| 299 | + |
| 300 | +if(SACNVIEW_CREATE_INSTALLER) |
| 301 | + include(install/install.cmake) |
| 302 | +endif() |
0 commit comments