Files
@ r28060:53690f1ef210
Branch filter:
Location: cpp/openttd-patchpack/source/CMakeLists.txt - annotation
r28060:53690f1ef210
15.0 KiB
text/plain
Feature: Base graphics can offer parameters for additional settings.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 | r27281:4110b04e30a9 r24244:556df3f1e087 r24349:3fa910f6f5ee r24312:91e366a9aaa0 r24349:3fa910f6f5ee r24312:91e366a9aaa0 r25204:16fd5c9120b0 r26708:fcfe8e5e499a r27281:4110b04e30a9 r25204:16fd5c9120b0 r24244:556df3f1e087 r24349:3fa910f6f5ee r25121:50a122ed1c36 r24349:3fa910f6f5ee r24244:556df3f1e087 r24352:0af03fb87f42 r24352:0af03fb87f42 r24352:0af03fb87f42 r24352:0af03fb87f42 r24352:0af03fb87f42 r24439:3207de2680bf r24439:3207de2680bf r24439:3207de2680bf r24439:3207de2680bf r24244:556df3f1e087 r27463:e90580341f85 r24244:556df3f1e087 r24272:3711e3433a2d r24731:b653a5e52e14 r24349:3fa910f6f5ee r24272:3711e3433a2d r24349:3fa910f6f5ee r24731:b653a5e52e14 r24731:b653a5e52e14 r24731:b653a5e52e14 r24272:3711e3433a2d r24272:3711e3433a2d r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24431:6e701b659438 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r25340:36c2ea7568db r25340:36c2ea7568db r25624:c1d8d2ba6a32 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24427:8a2677a5edb7 r24955:8887b648b3e5 r24955:8887b648b3e5 r24955:8887b648b3e5 r24955:8887b648b3e5 r24955:8887b648b3e5 r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24308:77fdaccb9342 r26874:065b6bc49f35 r26874:065b6bc49f35 r26874:065b6bc49f35 r26874:065b6bc49f35 r26874:065b6bc49f35 r26874:065b6bc49f35 r26874:065b6bc49f35 r26874:065b6bc49f35 r27813:6b3a5970aa1b r27813:6b3a5970aa1b r27813:6b3a5970aa1b r27813:6b3a5970aa1b r27813:6b3a5970aa1b r24992:1be2c2ebb781 r24992:1be2c2ebb781 r24992:1be2c2ebb781 r24992:1be2c2ebb781 r24992:1be2c2ebb781 r24992:1be2c2ebb781 r24992:1be2c2ebb781 r24992:1be2c2ebb781 r24992:1be2c2ebb781 r24992:1be2c2ebb781 r27540:2cd7b1239ac3 r27540:2cd7b1239ac3 r27540:2cd7b1239ac3 r27221:3735cc2cef6b r27221:3735cc2cef6b r24349:3fa910f6f5ee r24349:3fa910f6f5ee r24349:3fa910f6f5ee r24992:1be2c2ebb781 r27281:4110b04e30a9 r27281:4110b04e30a9 r24992:1be2c2ebb781 r24244:556df3f1e087 r24992:1be2c2ebb781 r24992:1be2c2ebb781 r24992:1be2c2ebb781 r24992:1be2c2ebb781 r24992:1be2c2ebb781 r24992:1be2c2ebb781 r24992:1be2c2ebb781 r24879:89d0ee92066a r24879:89d0ee92066a r24879:89d0ee92066a r24349:3fa910f6f5ee r24244:556df3f1e087 r24349:3fa910f6f5ee r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24733:1771b85df64c r24733:1771b85df64c r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24349:3fa910f6f5ee r24870:8e3c3de1cd5e r24870:8e3c3de1cd5e r24349:3fa910f6f5ee r27221:3735cc2cef6b r27221:3735cc2cef6b r27221:3735cc2cef6b r27221:3735cc2cef6b r27221:3735cc2cef6b r27221:3735cc2cef6b r24349:3fa910f6f5ee r24349:3fa910f6f5ee r24349:3fa910f6f5ee r24244:556df3f1e087 r24349:3fa910f6f5ee r24349:3fa910f6f5ee r24244:556df3f1e087 r24349:3fa910f6f5ee r24349:3fa910f6f5ee r24244:556df3f1e087 r24349:3fa910f6f5ee r24778:ede24664c30a r24778:ede24664c30a r24778:ede24664c30a r24349:3fa910f6f5ee r24244:556df3f1e087 r24724:5c9094f9aa48 r24724:5c9094f9aa48 r24724:5c9094f9aa48 r24724:5c9094f9aa48 r24724:5c9094f9aa48 r24724:5c9094f9aa48 r24724:5c9094f9aa48 r24724:5c9094f9aa48 r24724:5c9094f9aa48 r24724:5c9094f9aa48 r24724:5c9094f9aa48 r24724:5c9094f9aa48 r24724:5c9094f9aa48 r24724:5c9094f9aa48 r24724:5c9094f9aa48 r24724:5c9094f9aa48 r24724:5c9094f9aa48 r24724:5c9094f9aa48 r24724:5c9094f9aa48 r24724:5c9094f9aa48 r24724:5c9094f9aa48 r27103:bc9d171a796b r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24321:b65c5ca3b7c7 r24321:b65c5ca3b7c7 r27101:890608293788 r27101:890608293788 r27103:bc9d171a796b r24312:91e366a9aaa0 r24244:556df3f1e087 r24244:556df3f1e087 r24726:eaf6e855b503 r24726:eaf6e855b503 r24726:eaf6e855b503 r27807:e05ad71f5a50 r27807:e05ad71f5a50 r27807:e05ad71f5a50 r27807:e05ad71f5a50 r27807:e05ad71f5a50 r27807:e05ad71f5a50 r27807:e05ad71f5a50 r27807:e05ad71f5a50 r24726:eaf6e855b503 r24726:eaf6e855b503 r27281:4110b04e30a9 r27281:4110b04e30a9 r27281:4110b04e30a9 r27415:cd7d225c26b7 r27281:4110b04e30a9 r27281:4110b04e30a9 r25109:3ff77dcc2f0b r24244:556df3f1e087 r25026:4bfcbf422a4d r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r27101:890608293788 r24244:556df3f1e087 r24244:556df3f1e087 r24325:ed063eed3f1c r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r27101:890608293788 r27101:890608293788 r27101:890608293788 r27101:890608293788 r27101:890608293788 r27101:890608293788 r27103:bc9d171a796b r27103:bc9d171a796b r27103:bc9d171a796b r27103:bc9d171a796b r25510:fb7980bf2415 r27101:890608293788 r25510:fb7980bf2415 r25510:fb7980bf2415 r24349:3fa910f6f5ee r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24349:3fa910f6f5ee r25109:3ff77dcc2f0b r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24407:b31fe81ff707 r24244:556df3f1e087 r26874:065b6bc49f35 r26874:065b6bc49f35 r26874:065b6bc49f35 r26874:065b6bc49f35 r27813:6b3a5970aa1b r27813:6b3a5970aa1b r27813:6b3a5970aa1b r27813:6b3a5970aa1b r24349:3fa910f6f5ee r24244:556df3f1e087 r24244:556df3f1e087 r24253:6837363646bc r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r27221:3735cc2cef6b r24244:556df3f1e087 r24951:81438f03702b r24951:81438f03702b r24951:81438f03702b r24951:81438f03702b r24951:81438f03702b r24951:81438f03702b r24951:81438f03702b r24951:81438f03702b r24951:81438f03702b r24951:81438f03702b r24349:3fa910f6f5ee r24244:556df3f1e087 r26927:aa05e903a207 r26927:aa05e903a207 r24349:3fa910f6f5ee r24244:556df3f1e087 r24244:556df3f1e087 r27101:890608293788 r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24778:ede24664c30a r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24349:3fa910f6f5ee r24244:556df3f1e087 r24439:3207de2680bf r24439:3207de2680bf r24439:3207de2680bf r24439:3207de2680bf r24439:3207de2680bf r24439:3207de2680bf r24503:d2ba17388b17 r27707:ecb4cdc74504 r24503:d2ba17388b17 r24439:3207de2680bf r24439:3207de2680bf r26007:20bc49d0c3a9 r24439:3207de2680bf r24439:3207de2680bf r24439:3207de2680bf r24439:3207de2680bf r24439:3207de2680bf r24439:3207de2680bf r24439:3207de2680bf r24439:3207de2680bf r24439:3207de2680bf r24439:3207de2680bf r24439:3207de2680bf r27902:3286f4946dfc r27902:3286f4946dfc r27902:3286f4946dfc r27902:3286f4946dfc r27902:3286f4946dfc r27902:3286f4946dfc r27902:3286f4946dfc r27902:3286f4946dfc r27902:3286f4946dfc r27902:3286f4946dfc r27902:3286f4946dfc r27903:a7a9733e21aa r27902:3286f4946dfc r27902:3286f4946dfc r27902:3286f4946dfc r27902:3286f4946dfc r27903:a7a9733e21aa r24439:3207de2680bf r24439:3207de2680bf r24439:3207de2680bf r24439:3207de2680bf r24439:3207de2680bf r24439:3207de2680bf r24439:3207de2680bf r24439:3207de2680bf r24439:3207de2680bf r24439:3207de2680bf r24439:3207de2680bf r24439:3207de2680bf r24439:3207de2680bf r24349:3fa910f6f5ee r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24349:3fa910f6f5ee r24244:556df3f1e087 r24349:3fa910f6f5ee r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24349:3fa910f6f5ee r24244:556df3f1e087 r24349:3fa910f6f5ee r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24349:3fa910f6f5ee r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24349:3fa910f6f5ee r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r25627:a3297d91e516 r24244:556df3f1e087 r24244:556df3f1e087 r27101:890608293788 r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r25422:fb3214e67e4a r25627:a3297d91e516 r26874:065b6bc49f35 r24244:556df3f1e087 r24349:3fa910f6f5ee r24244:556df3f1e087 r24349:3fa910f6f5ee r25577:385ff5be874e r24349:3fa910f6f5ee r24244:556df3f1e087 r24244:556df3f1e087 r24244:556df3f1e087 r24245:1e4a8434fc12 r24738:fcbbb366d074 r24738:fcbbb366d074 r24738:fcbbb366d074 r24738:fcbbb366d074 r24245:1e4a8434fc12 | cmake_minimum_required(VERSION 3.16)
if(NOT BINARY_NAME)
set(BINARY_NAME openttd)
endif()
project(${BINARY_NAME}
VERSION 14.0
LANGUAGES CXX
)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "In-source builds not allowed. Please run \"cmake ..\" from the build directory. You may need to delete \"${CMAKE_SOURCE_DIR}/CMakeCache.txt\" first.")
endif()
# Debug mode by default.
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
if (EMSCRIPTEN)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/os/emscripten/cmake")
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.15)
# Use GNUInstallDirs to allow customisation
# but set our own default data and bin dir
if(NOT CMAKE_INSTALL_DATADIR)
set(CMAKE_INSTALL_DATADIR "share/games")
endif()
if(NOT CMAKE_INSTALL_BINDIR)
set(CMAKE_INSTALL_BINDIR "games")
endif()
include(GNUInstallDirs)
include(Options)
set_options()
set_directory_options()
include(Static)
set_static_if_needed()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS NO)
set(CMAKE_EXPORT_COMPILE_COMMANDS YES)
# An empty target for the tools
add_custom_target(tools)
include(Endian)
add_endian_definition()
include(CompileFlags)
compile_flags()
if(APPLE OR UNIX)
add_definitions(-DUNIX)
endif()
if(UNIX)
find_package(Doxygen)
endif()
list(APPEND GENERATED_SOURCE_FILES "${CMAKE_BINARY_DIR}/generated/rev.cpp")
if(WIN32)
list(APPEND GENERATED_SOURCE_FILES "${CMAKE_BINARY_DIR}/generated/ottdres.rc")
endif()
# Generate a target to determine version, which is execute every 'make' run
add_custom_target(find_version
${CMAKE_COMMAND}
-DFIND_VERSION_BINARY_DIR=${CMAKE_BINARY_DIR}/generated
-DCPACK_BINARY_DIR=${CMAKE_BINARY_DIR}
-DREV_MAJOR=${PROJECT_VERSION_MAJOR}
-DREV_MINOR=${PROJECT_VERSION_MINOR}
-DWINDOWS=${WIN32}
-P "${CMAKE_SOURCE_DIR}/cmake/scripts/FindVersion.cmake"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
BYPRODUCTS ${GENERATED_SOURCE_FILES}
)
# Documentation
if(DOXYGEN_EXECUTABLE)
add_custom_target(docs)
add_custom_target(docs_source
${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/docs
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Generating documentation for source"
)
add_dependencies(docs_source
find_version
)
add_dependencies(docs
docs_source
)
endif()
include(AddCustomXXXTimestamp)
if(OPTION_TOOLS_ONLY)
if(HOST_BINARY_DIR)
unset(HOST_BINARY_DIR CACHE)
endif()
add_subdirectory(${CMAKE_SOURCE_DIR}/src)
return()
endif()
if(APPLE)
# Avoid searching for headers in Frameworks, and libraries in LIBDIR.
set(CMAKE_FIND_FRAMEWORK LAST)
endif()
# Prefer -pthread over -lpthread, which is often the better option of the two.
set(CMAKE_THREAD_PREFER_PTHREAD YES)
# Make sure we have Threads available.
find_package(Threads REQUIRED)
find_package(ZLIB)
find_package(LibLZMA)
find_package(LZO)
find_package(PNG)
if(WIN32 OR EMSCRIPTEN)
# Windows uses WinHttp for HTTP requests.
# Emscripten uses Javascript for HTTP requests.
else()
# All other targets use libcurl.
find_package(CURL)
endif()
# Breakpad doesn't support emscripten.
if(NOT EMSCRIPTEN)
find_package(unofficial-breakpad)
endif()
if(NOT OPTION_DEDICATED)
if(NOT WIN32)
find_package(Allegro)
if(NOT APPLE)
find_package(Freetype)
find_package(SDL2)
if(NOT SDL2_FOUND)
find_package(SDL)
endif()
find_package(Fluidsynth)
if(Freetype_FOUND)
find_package(Fontconfig)
endif()
find_package(Harfbuzz)
find_package(ICU OPTIONAL_COMPONENTS i18n)
endif()
endif()
endif()
if(APPLE)
enable_language(OBJCXX)
find_package(Iconv)
find_library(AUDIOTOOLBOX_LIBRARY AudioToolbox)
find_library(AUDIOUNIT_LIBRARY AudioUnit)
find_library(COCOA_LIBRARY Cocoa)
find_library(QUARTZCORE_LIBRARY QuartzCore)
endif()
if(NOT EMSCRIPTEN AND NOT OPTION_DEDICATED)
find_package(OpenGL COMPONENTS OpenGL)
endif()
if(MSVC)
find_package(Editbin REQUIRED)
endif()
find_package(SSE)
find_package(Xaudio2)
find_package(Grfcodec)
include(CheckIPOSupported)
check_ipo_supported(RESULT IPO_FOUND)
show_options()
if(UNIX AND NOT APPLE AND NOT OPTION_DEDICATED)
if(NOT SDL_FOUND AND NOT SDL2_FOUND AND NOT ALLEGRO_FOUND)
message(FATAL_ERROR "SDL, SDL2 or Allegro is required for this platform")
endif()
if(HARFBUZZ_FOUND AND NOT ICU_i18n_FOUND)
message(WARNING "HarfBuzz depends on ICU i18n to function; HarfBuzz will be disabled")
endif()
if(NOT HARFBUZZ_FOUND)
message(WARNING "Without HarfBuzz and ICU i18n the game will not be able to render right-to-left languages correctly")
endif()
endif()
if(APPLE)
if(NOT AUDIOTOOLBOX_LIBRARY)
message(FATAL_ERROR "AudioToolbox is required for this platform")
endif()
if(NOT AUDIOUNIT_LIBRARY)
message(FATAL_ERROR "AudioUnit is required for this platform")
endif()
if(NOT COCOA_LIBRARY)
message(FATAL_ERROR "Cocoa is required for this platform")
endif()
if(NOT QUARTZCORE_LIBRARY)
message(FATAL_ERROR "QuartzCore is required for this platform")
endif()
endif()
if(OPTION_PACKAGE_DEPENDENCIES)
if(NOT UNIX)
message(FATAL_ERROR "Can only package dependencies on Linux")
endif()
if(OPTION_INSTALL_FHS)
message(FATAL_ERROR "Cannot install in FHS folders when we are packaging dependencies")
endif()
if(${CMAKE_VERSION} VERSION_LESS "3.16.0")
message(FATAL_ERROR "OPTION_PACKAGE_DEPENDENCIES can only work with CMake 3.16+; you are using ${CMAKE_VERSION}")
endif()
# If we are packaging dependencies, we do two things:
# 1) set the RPATH to include $ORIGIN/lib; $ORIGIN (that literal string)
# is a Linux indicator for "path where application is". In CMake, we
# have to do this before add_executable() is executed.
# 2) copy the libraries that we compile against to the "lib" folder.
# This is done in InstallAndPackage.cmake.
set(CMAKE_INSTALL_RPATH "\$ORIGIN/lib")
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
endif()
include(CTest)
include(SourceList)
# Needed by rev.cpp
include_directories(${CMAKE_SOURCE_DIR}/src)
# Needed by everything that uses Squirrel
include_directories(${CMAKE_SOURCE_DIR}/src/3rdparty/squirrel/include)
include(MSVCFilters)
add_library(openttd_lib OBJECT ${GENERATED_SOURCE_FILES})
add_executable(openttd WIN32)
add_executable(openttd_test)
set_target_properties(openttd PROPERTIES OUTPUT_NAME "${BINARY_NAME}")
# All other files are added via target_sources()
if(MSVC)
# Add DPI manifest to project; other WIN32 targets get this via ottdres.rc
target_sources(openttd PRIVATE "${CMAKE_SOURCE_DIR}/os/windows/openttd.manifest")
# If target -static is used, switch our project to static (/MT) too.
# If the target ends on -static-md, it will remain dynamic (/MD).
if(VCPKG_TARGET_TRIPLET MATCHES "-static" AND NOT VCPKG_TARGET_TRIPLET MATCHES "-md")
set_property(TARGET openttd_lib PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set_property(TARGET openttd PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set_property(TARGET openttd_test PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
endif()
target_precompile_headers(openttd_lib
PRIVATE
src/stdafx.h
src/core/format.hpp
)
add_subdirectory(${CMAKE_SOURCE_DIR}/bin)
add_subdirectory(${CMAKE_SOURCE_DIR}/src)
add_subdirectory(${CMAKE_SOURCE_DIR}/media)
add_dependencies(openttd
find_version)
target_link_libraries(openttd_lib
openttd::languages
openttd::settings
openttd::script_api
Threads::Threads
)
target_link_libraries(openttd
openttd_lib
openttd::media
openttd::basesets
)
target_link_libraries(openttd_test PRIVATE openttd_lib)
include(Catch)
catch_discover_tests(openttd_test)
if(HAIKU)
target_link_libraries(openttd_lib "be" "network" "midi")
endif()
if(IPO_FOUND)
set_target_properties(openttd PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE True)
set_target_properties(openttd PROPERTIES INTERPROCEDURAL_OPTIMIZATION_MINSIZEREL True)
set_target_properties(openttd PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO True)
endif()
set_target_properties(openttd PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")
process_compile_flags()
include(LinkPackage)
link_package(PNG TARGET PNG::PNG ENCOURAGED)
link_package(ZLIB TARGET ZLIB::ZLIB ENCOURAGED)
link_package(LIBLZMA TARGET LibLZMA::LibLZMA ENCOURAGED)
link_package(LZO)
if(NOT WIN32 AND NOT EMSCRIPTEN)
link_package(CURL ENCOURAGED)
endif()
if(NOT EMSCRIPTEN)
link_package(unofficial-breakpad TARGET unofficial::breakpad::libbreakpad_client ENCOURAGED)
endif()
if(NOT OPTION_DEDICATED)
link_package(Fluidsynth)
link_package(SDL)
link_package(SDL2 TARGET SDL2::SDL2)
link_package(Allegro)
link_package(FREETYPE TARGET Freetype::Freetype)
link_package(Fontconfig TARGET Fontconfig::Fontconfig)
link_package(Harfbuzz TARGET harfbuzz::harfbuzz)
link_package(ICU_i18n)
if(SDL2_FOUND AND OPENGL_FOUND AND UNIX)
# SDL2 dynamically loads OpenGL if needed, so do not link to OpenGL when
# on Linux. For Windows, we need to link to OpenGL as we also have a win32
# driver using it.
add_definitions(-DWITH_OPENGL)
message(STATUS "OpenGL found -- -DWITH_OPENGL -- (via SDL2)")
else()
link_package(OpenGL TARGET OpenGL::GL)
endif()
endif()
include(CheckAtomic)
if(APPLE)
link_package(Iconv TARGET Iconv::Iconv)
target_link_libraries(openttd_lib
${AUDIOTOOLBOX_LIBRARY}
${AUDIOUNIT_LIBRARY}
${COCOA_LIBRARY}
${QUARTZCORE_LIBRARY}
)
add_definitions(
-DWITH_COCOA
)
endif()
if(EMSCRIPTEN)
add_library(WASM::WASM INTERFACE IMPORTED)
# Allow heap-growth, and start with a bigger memory size.
target_link_libraries(WASM::WASM INTERFACE "-s ALLOW_MEMORY_GROWTH=1")
target_link_libraries(WASM::WASM INTERFACE "-s INITIAL_MEMORY=33554432")
target_link_libraries(WASM::WASM INTERFACE "-s DISABLE_EXCEPTION_CATCHING=0")
target_link_libraries(WASM::WASM INTERFACE "-s WASM_BIGINT")
add_definitions(-s DISABLE_EXCEPTION_CATCHING=0)
# Export functions to Javascript.
target_link_libraries(WASM::WASM INTERFACE "-s EXPORTED_FUNCTIONS='[\"_main\", \"_em_openttd_add_server\"]' -s EXPORTED_RUNTIME_METHODS='[\"cwrap\"]'")
# Preload all the files we generate during build.
# As we do not compile with FreeType / FontConfig, we also have no way to
# render several languages (like Chinese, ..), so where do you draw the
# line what languages to include and which not? In the end, especially as
# the more languages you add the slower downloading becomes, we decided to
# only ship the English language.
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_BINARY_DIR}/baseset@/baseset")
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_BINARY_DIR}/lang/english.lng@/lang/english.lng")
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/bin/ai@/ai")
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/bin/game@/game")
# Documentation files for the in-game text file viewer
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/README.md@/README.md")
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/CREDITS.md@/CREDITS.md")
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/CONTRIBUTING.md@/CONTRIBUTING.md")
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/COPYING.md@/COPYING.md")
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/known-bugs.txt@/known-bugs.txt")
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/changelog.txt@/changelog.txt")
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/docs/admin_network.md@/docs/admin_network.md")
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/docs/debugging_desyncs.md@/docs/debugging_desyncs.md")
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/docs/desync.md@/docs/desync.md")
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/docs/directory_structure.md@/docs/directory_structure.md")
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/docs/eints.md@/docs/eints.md")
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/docs/linkgraph.md@/docs/linkgraph.md")
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/docs/logging_and_performance_metrics.md@/docs/logging_and_performance_metrics.md")
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/docs/multiplayer.md@/docs/multiplayer.md")
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/docs/savegame_format.md@/docs/savegame_format.md")
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/docs/symbol_server.md@/docs/symbol_server.md")
# We use IDBFS for persistent storage.
target_link_libraries(WASM::WASM INTERFACE "-lidbfs.js")
# Use custom pre-js and shell.html.
target_link_libraries(WASM::WASM INTERFACE "--pre-js ${CMAKE_SOURCE_DIR}/os/emscripten/pre.js")
target_link_libraries(WASM::WASM INTERFACE "--shell-file ${CMAKE_SOURCE_DIR}/os/emscripten/shell.html")
# Build the .html (which builds the .js, .wasm, and .data too).
set_target_properties(openttd PROPERTIES SUFFIX ".html")
target_link_libraries(openttd WASM::WASM)
endif()
if(NOT PERSONAL_DIR STREQUAL "(not set)")
add_definitions(
-DWITH_PERSONAL_DIR
-DPERSONAL_DIR="${PERSONAL_DIR}"
)
endif()
if(NOT SHARED_DIR STREQUAL "(not set)")
add_definitions(
-DWITH_SHARED_DIR
-DSHARED_DIR="${SHARED_DIR}"
)
endif()
if(NOT GLOBAL_DIR STREQUAL "(not set)")
add_definitions(
-DGLOBAL_DATA_DIR="${GLOBAL_DIR}"
)
endif()
link_package(SSE)
add_definitions_based_on_options()
if(WIN32)
add_definitions(
-DUNICODE
-D_UNICODE
-DWITH_UNISCRIBE
-DPSAPI_VERSION=1
)
target_link_libraries(openttd_lib
ws2_32
winmm
imm32
usp10
psapi
winhttp
)
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
add_definitions(-DPOINTER_IS_64BIT)
endif()
include(CreateRegression)
create_regression()
if(APPLE OR WIN32)
find_package(Pandoc)
endif()
include(InstallAndPackage)
|