| 1 |
cmake_minimum_required(VERSION 3.5) |
| 2 |
|
| 3 |
if(EXISTS "${CMAKE_SOURCE_DIR}/.git") |
| 4 |
find_package(Git QUIET) |
| 5 |
if(NOT Git_FOUND) |
| 6 |
message(WARNING "Git not found") |
| 7 |
return() |
| 8 |
endif() |
| 9 |
|
| 10 |
execute_process( |
| 11 |
COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=0 |
| 12 |
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} |
| 13 |
OUTPUT_VARIABLE RAILCONTROL_VERSION |
| 14 |
OUTPUT_STRIP_TRAILING_WHITESPACE |
| 15 |
) |
| 16 |
execute_process( |
| 17 |
COMMAND ${GIT_EXECUTABLE} log -1 --format=%H |
| 18 |
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} |
| 19 |
OUTPUT_VARIABLE GIT_HASH |
| 20 |
OUTPUT_STRIP_TRAILING_WHITESPACE |
| 21 |
) |
| 22 |
execute_process( |
| 23 |
COMMAND ${GIT_EXECUTABLE} log -1 --format=%at |
| 24 |
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} |
| 25 |
OUTPUT_VARIABLE GIT_TIMESTAMP |
| 26 |
OUTPUT_STRIP_TRAILING_WHITESPACE |
| 27 |
) |
| 28 |
execute_process( |
| 29 |
COMMAND ${GIT_EXECUTABLE} status -s |
| 30 |
COMMAND wc -l |
| 31 |
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} |
| 32 |
OUTPUT_VARIABLE GIT_DIRTY |
| 33 |
OUTPUT_STRIP_TRAILING_WHITESPACE |
| 34 |
) |
| 35 |
else() |
| 36 |
file(READ VERSION RAILCONTROL_VERSION) |
| 37 |
string(STRIP ${RAILCONTROL_VERSION} RAILCONTROL_VERSION) |
| 38 |
file(READ VERSION_GIT_HASH GIT_HASH) |
| 39 |
string(STRIP ${GIT_HASH} GIT_HASH) |
| 40 |
file(READ VERSION_GIT_TIMESTAMP GIT_TIMESTAMP) |
| 41 |
string(STRIP ${GIT_TIMESTAMP} GIT_TIMESTAMP) |
| 42 |
set(GIT_DIRTY 0) |
| 43 |
endif() |
| 44 |
|
| 45 |
# Version starts with v |
| 46 |
string(REGEX REPLACE "^v" "" RAILCONTROL_VERSION "${RAILCONTROL_VERSION}") |
| 47 |
|
| 48 |
project(railcontrol VERSION ${RAILCONTROL_VERSION}) |
| 49 |
|
| 50 |
STRING(TIMESTAMP COMPILE_TIMESTAMP "%s" UTC) |
| 51 |
|
| 52 |
add_executable(${PROJECT_NAME} |
| 53 |
Manager.cpp |
| 54 |
Manager.h |
| 55 |
Server/Web/WebClient.cpp |
| 56 |
Server/Web/WebClient.h |
| 57 |
ArgumentHandler.cpp |
| 58 |
ArgumentHandler.h |
| 59 |
Config.cpp |
| 60 |
Config.h |
| 61 |
ControlInterface.h |
| 62 |
DataModel/Accessory.cpp |
| 63 |
DataModel/Accessory.h |
| 64 |
DataModel/AccessoryBase.cpp |
| 65 |
DataModel/AccessoryBase.h |
| 66 |
DataModel/AccessoryConfig.h |
| 67 |
DataModel/Cluster.cpp |
| 68 |
DataModel/Cluster.h |
| 69 |
DataModel/Counter.cpp |
| 70 |
DataModel/Counter.h |
| 71 |
DataModel/DataModel.h |
| 72 |
DataModel/Feedback.cpp |
| 73 |
DataModel/Feedback.h |
| 74 |
DataModel/FeedbackConfig.h |
| 75 |
DataModel/HardwareHandle.cpp |
| 76 |
DataModel/HardwareHandle.h |
| 77 |
DataModel/Layer.h |
| 78 |
DataModel/LayoutItem.cpp |
| 79 |
DataModel/LayoutItem.h |
| 80 |
DataModel/LockableItem.cpp |
| 81 |
DataModel/LockableItem.h |
| 82 |
DataModel/Loco.cpp |
| 83 |
DataModel/Loco.h |
| 84 |
DataModel/LocoBase.cpp |
| 85 |
DataModel/LocoBase.h |
| 86 |
DataModel/LocoConfig.h |
| 87 |
DataModel/LocoFunctions.cpp |
| 88 |
DataModel/LocoFunctions.h |
| 89 |
DataModel/MultipleUnit.cpp |
| 90 |
DataModel/MultipleUnit.h |
| 91 |
DataModel/Object.cpp |
| 92 |
DataModel/Object.h |
| 93 |
DataModel/ObjectIdentifier.cpp |
| 94 |
DataModel/ObjectIdentifier.h |
| 95 |
DataModel/Relation.cpp |
| 96 |
DataModel/Relation.h |
| 97 |
DataModel/Route.cpp |
| 98 |
DataModel/Route.h |
| 99 |
DataModel/Serializable.cpp |
| 100 |
DataModel/Serializable.h |
| 101 |
DataModel/Signal.cpp |
| 102 |
DataModel/Signal.h |
| 103 |
DataModel/Switch.cpp |
| 104 |
DataModel/Switch.h |
| 105 |
DataModel/Text.cpp |
| 106 |
DataModel/Text.h |
| 107 |
DataModel/Track.cpp |
| 108 |
DataModel/Track.h |
| 109 |
DataTypes.h |
| 110 |
Fallthrough.h |
| 111 |
Hardware/AccessoryCache.cpp |
| 112 |
Hardware/AccessoryCache.h |
| 113 |
Hardware/CS1.h |
| 114 |
Hardware/CS2Tcp.cpp |
| 115 |
Hardware/CS2Tcp.h |
| 116 |
Hardware/CS2Udp.cpp |
| 117 |
Hardware/CS2Udp.h |
| 118 |
Hardware/Capabilities.h |
| 119 |
Hardware/CcSchnitte.cpp |
| 120 |
Hardware/CcSchnitte.h |
| 121 |
Hardware/DR5000.h |
| 122 |
Hardware/DccPpExSerial.cpp |
| 123 |
Hardware/DccPpExSerial.h |
| 124 |
Hardware/DccPpExTcp.cpp |
| 125 |
Hardware/DccPpExTcp.h |
| 126 |
Hardware/Ecos.h |
| 127 |
Hardware/FeedbackCache.cpp |
| 128 |
Hardware/FeedbackCache.h |
| 129 |
Hardware/HardwareHandler.cpp |
| 130 |
Hardware/HardwareHandler.h |
| 131 |
Hardware/HardwareInterface.h |
| 132 |
Hardware/HardwareParams.h |
| 133 |
Hardware/Hsi88.cpp |
| 134 |
Hardware/Hsi88.h |
| 135 |
Hardware/Intellibox.h |
| 136 |
Hardware/Intellibox2.h |
| 137 |
Hardware/LocoCache.cpp |
| 138 |
Hardware/LocoCache.h |
| 139 |
Hardware/LocoNetAdapter63120.h |
| 140 |
Hardware/LocoNetAdapter63820.h |
| 141 |
Hardware/M6051.cpp |
| 142 |
Hardware/M6051.h |
| 143 |
Hardware/MasterControl.h |
| 144 |
Hardware/MasterControl2.h |
| 145 |
Hardware/OpenDcc.h |
| 146 |
Hardware/Protocols/DccPpEx.cpp |
| 147 |
Hardware/Protocols/DccPpEx.h |
| 148 |
Hardware/Protocols/EsuCAN.cpp |
| 149 |
Hardware/Protocols/EsuCAN.h |
| 150 |
Hardware/Protocols/LocoNet.cpp |
| 151 |
Hardware/Protocols/LocoNet.h |
| 152 |
Hardware/Protocols/LocoNetLocoCache.h |
| 153 |
Hardware/Protocols/MaerklinCAN.h |
| 154 |
Hardware/Protocols/MaerklinCANCommon.cpp |
| 155 |
Hardware/Protocols/MaerklinCANCommon.h |
| 156 |
Hardware/Protocols/P50x.cpp |
| 157 |
Hardware/Protocols/P50x.h |
| 158 |
Hardware/Protocols/P50xCache.h |
| 159 |
Hardware/Protocols/P50xEthernet.h |
| 160 |
Hardware/Protocols/P50xSerial.h |
| 161 |
Hardware/Protocols/P50xUhlenbrock.h |
| 162 |
Hardware/Protocols/Z21.cpp |
| 163 |
Hardware/Protocols/Z21.h |
| 164 |
Hardware/Protocols/Z21FeedbackCache.h |
| 165 |
Hardware/Protocols/Z21LocoCache.h |
| 166 |
Hardware/Protocols/Z21TurnoutCache.h |
| 167 |
Hardware/RedBox.h |
| 168 |
Hardware/Rektor.h |
| 169 |
Hardware/TwinCenter.h |
| 170 |
Hardware/Virtual.cpp |
| 171 |
Hardware/Virtual.h |
| 172 |
Hardware/Z21.h |
| 173 |
Hardware/ZLib.cpp |
| 174 |
Hardware/ZLib.h |
| 175 |
Languages.cpp |
| 176 |
Languages.h |
| 177 |
Logger/Logger.cpp |
| 178 |
Logger/Logger.h |
| 179 |
Logger/LoggerClient.h |
| 180 |
Logger/LoggerClientConsole.h |
| 181 |
Logger/LoggerClientFile.h |
| 182 |
Logger/LoggerClientTcp.h |
| 183 |
Logger/LoggerServer.cpp |
| 184 |
Logger/LoggerServer.h |
| 185 |
Network/Select.h |
| 186 |
Network/Serial.cpp |
| 187 |
Network/Serial.h |
| 188 |
Network/TcpClient.cpp |
| 189 |
Network/TcpClient.h |
| 190 |
Network/TcpConnection.cpp |
| 191 |
Network/TcpConnection.h |
| 192 |
Network/TcpServer.cpp |
| 193 |
Network/TcpServer.h |
| 194 |
Network/UdpClient.h |
| 195 |
Network/UdpConnection.cpp |
| 196 |
Network/UdpConnection.h |
| 197 |
Network/UdpServer.cpp |
| 198 |
Network/UdpServer.h |
| 199 |
RailControl.cpp |
| 200 |
RailControl.h |
| 201 |
Server/CS2/CS2Client.cpp |
| 202 |
Server/CS2/CS2Client.h |
| 203 |
Server/CS2/CS2Server.cpp |
| 204 |
Server/CS2/CS2Server.h |
| 205 |
Server/Web/HtmlTag.cpp |
| 206 |
Server/Web/HtmlTag.h |
| 207 |
Server/Web/HtmlTagAccessory.cpp |
| 208 |
Server/Web/HtmlTagAccessory.h |
| 209 |
Server/Web/HtmlTagButton.cpp |
| 210 |
Server/Web/HtmlTagButton.h |
| 211 |
Server/Web/HtmlTagButtonCancel.h |
| 212 |
Server/Web/HtmlTagButtonCommand.cpp |
| 213 |
Server/Web/HtmlTagButtonCommand.h |
| 214 |
Server/Web/HtmlTagButtonCommandFullScreen.cpp |
| 215 |
Server/Web/HtmlTagButtonCommandFullScreen.h |
| 216 |
Server/Web/HtmlTagButtonCommandPressRelease.cpp |
| 217 |
Server/Web/HtmlTagButtonCommandPressRelease.h |
| 218 |
Server/Web/HtmlTagButtonCommandToggle.cpp |
| 219 |
Server/Web/HtmlTagButtonCommandToggle.h |
| 220 |
Server/Web/HtmlTagButtonCommandWide.h |
| 221 |
Server/Web/HtmlTagButtonMinus.h |
| 222 |
Server/Web/HtmlTagButtonOK.h |
| 223 |
Server/Web/HtmlTagButtonPlus.h |
| 224 |
Server/Web/HtmlTagButtonPopup.cpp |
| 225 |
Server/Web/HtmlTagButtonPopup.h |
| 226 |
Server/Web/HtmlTagButtonPopupWide.h |
| 227 |
Server/Web/HtmlTagCounter.cpp |
| 228 |
Server/Web/HtmlTagCounter.h |
| 229 |
Server/Web/HtmlTagFeedback.cpp |
| 230 |
Server/Web/HtmlTagFeedback.h |
| 231 |
Server/Web/HtmlTagInput.cpp |
| 232 |
Server/Web/HtmlTagInput.h |
| 233 |
Server/Web/HtmlTagInputCheckbox.h |
| 234 |
Server/Web/HtmlTagInputCheckboxWithLabel.h |
| 235 |
Server/Web/HtmlTagInputHidden.h |
| 236 |
Server/Web/HtmlTagInputInteger.cpp |
| 237 |
Server/Web/HtmlTagInputInteger.h |
| 238 |
Server/Web/HtmlTagInputIntegerWithLabel.h |
| 239 |
Server/Web/HtmlTagInputSlider.cpp |
| 240 |
Server/Web/HtmlTagInputSlider.h |
| 241 |
Server/Web/HtmlTagInputSliderLocoSpeed.cpp |
| 242 |
Server/Web/HtmlTagInputSliderLocoSpeed.h |
| 243 |
Server/Web/HtmlTagInputText.h |
| 244 |
Server/Web/HtmlTagInputTextWithLabel.h |
| 245 |
Server/Web/HtmlTagLabel.h |
| 246 |
Server/Web/HtmlTagLayoutItem.cpp |
| 247 |
Server/Web/HtmlTagLayoutItem.h |
| 248 |
Server/Web/HtmlTagRoute.cpp |
| 249 |
Server/Web/HtmlTagRoute.h |
| 250 |
Server/Web/HtmlTagSelect.cpp |
| 251 |
Server/Web/HtmlTagSelect.h |
| 252 |
Server/Web/HtmlTagSelectMultiple.cpp |
| 253 |
Server/Web/HtmlTagSelectMultiple.h |
| 254 |
Server/Web/HtmlTagSelectMultipleWithLabel.cpp |
| 255 |
Server/Web/HtmlTagSelectMultipleWithLabel.h |
| 256 |
Server/Web/HtmlTagSelectOrientation.h |
| 257 |
Server/Web/HtmlTagSelectOrientationWithLabel.h |
| 258 |
Server/Web/HtmlTagSelectWithLabel.cpp |
| 259 |
Server/Web/HtmlTagSelectWithLabel.h |
| 260 |
Server/Web/HtmlTagSignal.cpp |
| 261 |
Server/Web/HtmlTagSignal.h |
| 262 |
Server/Web/HtmlTagSwitch.cpp |
| 263 |
Server/Web/HtmlTagSwitch.h |
| 264 |
Server/Web/HtmlTagText.cpp |
| 265 |
Server/Web/HtmlTagText.h |
| 266 |
Server/Web/HtmlTagTrack.cpp |
| 267 |
Server/Web/HtmlTagTrack.h |
| 268 |
Server/Web/Response.cpp |
| 269 |
Server/Web/Response.h |
| 270 |
Server/Web/ResponseCsv.cpp |
| 271 |
Server/Web/ResponseCsv.h |
| 272 |
Server/Web/ResponseHtml.cpp |
| 273 |
Server/Web/ResponseHtml.h |
| 274 |
Server/Web/ResponseHtmlFull.cpp |
| 275 |
Server/Web/ResponseHtmlFull.h |
| 276 |
Server/Web/ResponseHtmlNotFound.cpp |
| 277 |
Server/Web/ResponseHtmlNotFound.h |
| 278 |
Server/Web/ResponseHtmlNotImplemented.cpp |
| 279 |
Server/Web/ResponseHtmlNotImplemented.h |
| 280 |
Server/Web/WebClientCluster.cpp |
| 281 |
Server/Web/WebClientCluster.h |
| 282 |
Server/Web/WebClientCounter.cpp |
| 283 |
Server/Web/WebClientCounter.h |
| 284 |
Server/Web/WebClientRoute.cpp |
| 285 |
Server/Web/WebClientRoute.h |
| 286 |
Server/Web/WebClientSignal.cpp |
| 287 |
Server/Web/WebClientSignal.h |
| 288 |
Server/Web/WebClientStatic.cpp |
| 289 |
Server/Web/WebClientStatic.h |
| 290 |
Server/Web/WebClientText.cpp |
| 291 |
Server/Web/WebClientText.h |
| 292 |
Server/Web/WebClientTrack.cpp |
| 293 |
Server/Web/WebClientTrack.h |
| 294 |
Server/Web/WebServer.cpp |
| 295 |
Server/Web/WebServer.h |
| 296 |
Server/Z21/Z21Client.cpp |
| 297 |
Server/Z21/Z21Client.h |
| 298 |
Server/Z21/Z21Server.cpp |
| 299 |
Server/Z21/Z21Server.h |
| 300 |
Storage/Sqlite.cpp |
| 301 |
Storage/Sqlite.h |
| 302 |
Storage/StorageHandler.cpp |
| 303 |
Storage/StorageHandler.h |
| 304 |
Storage/StorageInterface.h |
| 305 |
Storage/StorageParams.h |
| 306 |
Storage/TransactionGuard.cpp |
| 307 |
Storage/TransactionGuard.h |
| 308 |
Utils/Integer.cpp |
| 309 |
Utils/Integer.h |
| 310 |
Utils/Network.cpp |
| 311 |
Utils/Network.h |
| 312 |
Utils/ThreadSafeQueue.h |
| 313 |
Utils/Utils.cpp |
| 314 |
Utils/Utils.h |
| 315 |
${CMAKE_CURRENT_BINARY_DIR}/Version.cpp |
| 316 |
Version.h |
| 317 |
) |
| 318 |
|
| 319 |
option(USE_SYSTEM_LIBRARIES "Build with system libraries" OFF) |
| 320 |
|
| 321 |
if (USE_SYSTEM_LIBRARIES) |
| 322 |
find_package(SQLite3) |
| 323 |
target_link_libraries(${PROJECT_NAME} PRIVATE SQLite::SQLite3) |
| 324 |
|
| 325 |
find_package(ZLIB) |
| 326 |
target_link_libraries(${PROJECT_NAME} PRIVATE ZLIB::ZLIB) |
| 327 |
else() |
| 328 |
target_include_directories(${PROJECT_NAME} PRIVATE Storage/sqlite) |
| 329 |
add_library(sqlite3 STATIC |
| 330 |
Storage/sqlite/sqlite3.c |
| 331 |
Storage/sqlite/sqlite3.h |
| 332 |
Storage/sqlite/sqlite3ext.h |
| 333 |
) |
| 334 |
target_link_libraries(${PROJECT_NAME} PRIVATE sqlite3) |
| 335 |
|
| 336 |
target_include_directories(${PROJECT_NAME} PRIVATE Hardware/zlib) |
| 337 |
add_library(zlib STATIC |
| 338 |
Hardware/zlib/adler32.c |
| 339 |
Hardware/zlib/compress.c |
| 340 |
Hardware/zlib/crc32.c |
| 341 |
Hardware/zlib/crc32.h |
| 342 |
Hardware/zlib/deflate.c |
| 343 |
Hardware/zlib/deflate.h |
| 344 |
Hardware/zlib/gzclose.c |
| 345 |
Hardware/zlib/gzguts.h |
| 346 |
Hardware/zlib/gzlib.c |
| 347 |
Hardware/zlib/gzread.c |
| 348 |
Hardware/zlib/gzwrite.c |
| 349 |
Hardware/zlib/infback.c |
| 350 |
Hardware/zlib/inffast.c |
| 351 |
Hardware/zlib/inffast.h |
| 352 |
Hardware/zlib/inffixed.h |
| 353 |
Hardware/zlib/inflate.c |
| 354 |
Hardware/zlib/inflate.h |
| 355 |
Hardware/zlib/inftrees.c |
| 356 |
Hardware/zlib/inftrees.h |
| 357 |
Hardware/zlib/trees.c |
| 358 |
Hardware/zlib/trees.h |
| 359 |
Hardware/zlib/uncompr.c |
| 360 |
Hardware/zlib/zconf.h |
| 361 |
Hardware/zlib/zlib.h |
| 362 |
Hardware/zlib/zutil.c |
| 363 |
Hardware/zlib/zutil.h |
| 364 |
) |
| 365 |
target_link_libraries(${PROJECT_NAME} PRIVATE zlib) |
| 366 |
endif() |
| 367 |
|
| 368 |
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") |
| 369 |
set(CMAKE_CXX_STANDARD 11) |
| 370 |
set(CMAKE_CXX_STANDARD_REQUIRED True) |
| 371 |
set(CMAKE_CXX_FLAGS_DEBUG "-O0") |
| 372 |
set(CMAKE_CXX_FLAGS_RELEASE "-O2") |
| 373 |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -pedantic -Werror") |
| 374 |
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_RTREE -DHAVE_USLEEP -Wno-implicit-function-declaration -Wno-return-local-addr") |
| 375 |
|
| 376 |
set(THREADS_PREFER_PTHREAD_FLAG ON) |
| 377 |
find_package(Threads REQUIRED) |
| 378 |
target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads dl) |
| 379 |
|
| 380 |
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}) |
| 381 |
|
| 382 |
configure_file(Version.cpp.in Version.cpp @ONLY) |
| 383 |
|
| 384 |
set(CMAKE_INSTALL_BINDIR ".") |
| 385 |
set(DATADIR ".") |
| 386 |
|
| 387 |
install(TARGETS ${PROJECT_NAME}) |
| 388 |
install(FILES railcontrol.conf.dist DESTINATION ${DATADIR}) |
| 389 |
install(DIRECTORY html DESTINATION ${DATADIR}) |
| 390 |
|
| 391 |
include(CPack) |