2021-02-05 01:00:36 +00:00
cmake_minimum_required ( VERSION 3.9 )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
2020-09-25 11:55:25 +00:00
if ( NOT BINARY_NAME )
2020-06-11 19:57:14 +00:00
set ( BINARY_NAME openttd )
2020-09-25 11:55:25 +00:00
endif ( )
2020-06-11 19:57:14 +00:00
2021-04-20 19:38:46 +00:00
project ( ${ BINARY_NAME }
2024-02-18 16:38:26 +00:00
V E R S I O N 1 5 . 0
2021-04-20 19:38:46 +00:00
)
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
2020-09-25 11:55:25 +00:00
if ( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR )
2021-04-06 11:54:27 +00:00
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." )
2020-09-25 11:55:25 +00:00
endif ( )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
2020-12-05 20:57:47 +00:00
if ( EMSCRIPTEN )
set ( CMAKE_MODULE_PATH ${ CMAKE_MODULE_PATH } "${CMAKE_SOURCE_DIR}/os/emscripten/cmake" )
endif ( )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
set ( CMAKE_MODULE_PATH ${ CMAKE_MODULE_PATH } "${CMAKE_SOURCE_DIR}/cmake" )
2023-06-11 16:55:22 +00:00
set ( CMAKE_OSX_DEPLOYMENT_TARGET 10.13 )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
2020-06-18 16:34:19 +00:00
# Use GNUInstallDirs to allow customisation
2021-02-07 15:19:30 +00:00
# but set our own default data and bin dir
2020-09-25 11:55:25 +00:00
if ( NOT CMAKE_INSTALL_DATADIR )
2020-06-18 16:34:19 +00:00
set ( CMAKE_INSTALL_DATADIR "share/games" )
2020-09-25 11:55:25 +00:00
endif ( )
2021-02-07 15:19:30 +00:00
if ( NOT CMAKE_INSTALL_BINDIR )
set ( CMAKE_INSTALL_BINDIR "games" )
endif ( )
2020-06-18 16:34:19 +00:00
include ( GNUInstallDirs )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
include ( Options )
set_options ( )
set_directory_options ( )
include ( Static )
set_static_if_needed ( )
2024-01-16 19:38:42 +00:00
set ( CMAKE_CXX_STANDARD 20 )
2020-12-12 23:24:55 +00:00
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 ( )
# Documentation
if ( DOXYGEN_EXECUTABLE )
add_custom_target ( docs )
add_custom_target ( docs_source
$ { C M A K E _ C O M M A N D } - E m a k e _ d i r e c t o r y $ { C M A K E _ B I N A R Y _ D I R } / d o c s
C O M M A N D $ { D O X Y G E N _ E X E C U T A B L E } $ { C M A K E _ B I N A R Y _ D I R } / D o x y f i l e
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ S O U R C E _ D I R }
C O M M E N T " G e n e r a t i n g d o c u m e n t a t i o n f o r s o u r c e "
)
add_dependencies ( docs_source
f i n d _ v e r s i o n
)
add_dependencies ( docs
d o c s _ s o u r c e
)
endif ( )
include ( AddCustomXXXTimestamp )
if ( OPTION_TOOLS_ONLY )
if ( HOST_BINARY_DIR )
unset ( HOST_BINARY_DIR CACHE )
endif ( )
add_subdirectory ( ${ CMAKE_SOURCE_DIR } /src )
2021-03-02 21:23:46 +00:00
# Cut down find_version which doesn't include cfg defines set in full configure
add_custom_target ( find_version
$ { C M A K E _ C O M M A N D }
- D F I N D _ V E R S I O N _ B I N A R Y _ D I R = $ { C M A K E _ B I N A R Y _ D I R } / g e n e r a t e d
- D C P A C K _ B I N A R Y _ D I R = $ { C M A K E _ B I N A R Y _ D I R }
2021-05-01 10:11:07 +00:00
- D R E V _ M A J O R = $ { P R O J E C T _ V E R S I O N _ M A J O R }
- D R E V _ M I N O R = $ { P R O J E C T _ V E R S I O N _ M I N O R }
2021-03-02 21:23:46 +00:00
$ < $ < P L A T F O R M _ I D : W i n d o w s > : - D W I N 3 2 = T R U E >
- P " $ { C M A K E _ S O U R C E _ D I R } / c m a k e / s c r i p t s / F i n d V e r s i o n . c m a k e "
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ S O U R C E _ D I R }
B Y P R O D U C T S $ { G E N E R A T E D _ S O U R C E _ F I L E S }
)
2020-12-12 23:24:55 +00:00
return ( )
endif ( )
2021-02-27 00:34:00 +00:00
if ( APPLE )
# Avoid searching for headers in Frameworks, and libraries in LIBDIR.
set ( CMAKE_FIND_FRAMEWORK LAST )
endif ( )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
# 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 )
2021-03-02 20:55:32 +00:00
find_package ( ZSTD 1.4 )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
find_package ( PNG )
2020-06-18 12:24:29 +00:00
2023-02-12 11:07:31 +00:00
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 ( )
2021-03-03 18:48:32 +00:00
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 )
2023-06-06 18:43:27 +00:00
if ( Freetype_FOUND )
find_package ( Fontconfig )
endif ( )
2023-04-30 18:37:40 +00:00
find_package ( Harfbuzz )
find_package ( ICU OPTIONAL_COMPONENTS i18n )
2020-09-25 11:55:25 +00:00
endif ( )
endif ( )
endif ( )
2021-03-03 18:48:32 +00:00
if ( APPLE )
find_package ( Iconv )
find_library ( AUDIOTOOLBOX_LIBRARY AudioToolbox )
find_library ( AUDIOUNIT_LIBRARY AudioUnit )
find_library ( COCOA_LIBRARY Cocoa )
find_library ( QUARTZCORE_LIBRARY QuartzCore )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
2021-03-04 15:31:10 +00:00
find_package ( MacUcontext )
2021-03-03 18:48:32 +00:00
endif ( )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
2021-03-03 18:48:32 +00:00
if ( NOT EMSCRIPTEN AND NOT OPTION_DEDICATED )
2021-01-16 15:43:04 +00:00
find_package ( OpenGL COMPONENTS OpenGL )
endif ( )
2020-09-25 11:55:25 +00:00
if ( MSVC )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
find_package ( Editbin REQUIRED )
2020-10-14 16:38:23 +00:00
else ( )
2020-06-30 20:04:20 +00:00
find_package ( Builtins )
2020-09-25 11:55:25 +00:00
endif ( )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
2020-06-27 13:33:32 +00:00
if ( UNIX )
find_package ( DL )
find_package ( Demangle )
2020-06-27 13:50:59 +00:00
find_package ( Sigaction )
find_package ( Sigaltstack )
find_package ( SelfDbg )
2020-06-27 13:58:10 +00:00
find_package ( Ucontext )
2020-06-28 12:59:53 +00:00
find_package ( BFD )
2020-12-11 22:29:27 +00:00
endif ( UNIX )
2021-03-04 15:31:10 +00:00
if ( UNIX AND NOT APPLE AND NOT OPTION_DEDICATED )
2020-12-15 17:47:57 +00:00
find_package ( Fcitx QUIET )
2020-06-27 14:14:41 +00:00
if ( Fcitx_FOUND )
2020-12-15 17:47:57 +00:00
message ( STATUS "Found: Fcitx: ${Fcitx_VERSION}" )
2020-06-27 14:14:41 +00:00
find_package ( DBus1 )
find_package ( X11 )
2020-12-15 17:47:57 +00:00
else ( Fcitx_FOUND )
message ( STATUS "Could not find Fcitx (Fcitx is OPTIONAL)" )
2020-06-27 14:14:41 +00:00
endif ( Fcitx_FOUND )
2020-12-11 22:29:27 +00:00
endif ( )
2020-06-27 13:33:32 +00:00
2020-06-29 11:04:05 +00:00
if ( MINGW )
find_package ( Demangle )
2022-06-25 10:29:06 +00:00
if ( OPTION_ENABLE_MINGW_BFD )
find_package ( BFD )
endif ( OPTION_ENABLE_MINGW_BFD )
2020-06-30 23:25:50 +00:00
find_package ( DbgHelp )
2020-06-29 11:04:05 +00:00
endif ( MINGW )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
find_package ( SSE )
find_package ( Xaudio2 )
find_package ( Grfcodec )
2021-02-05 01:00:36 +00:00
include ( CheckIPOSupported )
check_ipo_supported ( RESULT IPO_FOUND )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
show_options ( )
2020-09-25 11:55:25 +00:00
if ( UNIX AND NOT APPLE AND NOT OPTION_DEDICATED )
2021-02-21 21:53:35 +00:00
if ( NOT SDL_FOUND AND NOT SDL2_FOUND AND NOT ALLEGRO_FOUND )
message ( FATAL_ERROR "SDL, SDL2 or Allegro is required for this platform" )
2020-09-25 11:55:25 +00:00
endif ( )
2023-04-30 18:37:40 +00:00
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 ( )
2020-09-25 11:55:25 +00:00
endif ( )
if ( APPLE )
if ( NOT AUDIOTOOLBOX_LIBRARY )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
message ( FATAL_ERROR "AudioToolbox is required for this platform" )
2020-09-25 11:55:25 +00:00
endif ( )
if ( NOT AUDIOUNIT_LIBRARY )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
message ( FATAL_ERROR "AudioUnit is required for this platform" )
2020-09-25 11:55:25 +00:00
endif ( )
if ( NOT COCOA_LIBRARY )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
message ( FATAL_ERROR "Cocoa is required for this platform" )
2020-09-25 11:55:25 +00:00
endif ( )
2021-02-06 21:58:51 +00:00
if ( NOT QUARTZCORE_LIBRARY )
message ( FATAL_ERROR "QuartzCore is required for this platform" )
endif ( )
2020-09-25 11:55:25 +00:00
endif ( )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
2021-02-05 11:31:27 +00:00
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 )
2020-09-25 11:55:25 +00:00
endif ( )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
2023-12-13 17:26:37 +00:00
if ( OPTION_NO_SPLIT_LIB )
set ( OPENTTD_LIB openttd )
else ( )
set ( OPENTTD_LIB openttd_lib )
endif ( )
2023-04-10 17:02:31 +00:00
include ( CTest )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
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 )
2020-07-05 12:39:39 +00:00
include ( MSVCFilters )
2023-12-13 17:26:37 +00:00
if ( OPTION_NO_SPLIT_LIB )
add_executable ( openttd WIN32 ${ GENERATED_SOURCE_FILES } )
else ( )
add_library ( openttd_lib OBJECT ${ GENERATED_SOURCE_FILES } )
add_executable ( openttd WIN32 )
add_executable ( openttd_test )
set_target_properties ( openttd_test PROPERTIES EXCLUDE_FROM_ALL TRUE )
endif ( )
2023-04-10 17:02:31 +00:00
2023-12-13 17:26:37 +00:00
set_target_properties ( openttd PROPERTIES OUTPUT_NAME "${BINARY_NAME}" )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
# All other files are added via target_sources()
2024-01-28 23:23:44 +00:00
if ( MINGW AND OPTION_MINGW_STDTHREADS )
2023-12-13 20:29:05 +00:00
target_link_libraries ( ${ OPENTTD_LIB } mingw_stdthreads )
endif ( )
2020-06-29 17:15:28 +00:00
set ( host_tools_list strgen settingsgen )
2021-03-02 21:55:17 +00:00
if ( HOST_BINARY_DIR )
# Host tools already exist, nothing to do
elseif ( CMAKE_CROSSCOMPILING )
2020-06-29 17:15:28 +00:00
# Pawn off the creation of the host utilities into its own dedicated space
file ( MAKE_DIRECTORY ${ CMAKE_CURRENT_BINARY_DIR } /host_tools )
file ( TO_NATIVE_PATH ${ CMAKE_COMMAND } native_cmake_command )
file ( TO_NATIVE_PATH ${ CMAKE_CURRENT_SOURCE_DIR } native_cmake_current_source_dir )
execute_process (
C O M M A N D " $ { n a t i v e _ c m a k e _ c o m m a n d } " " - D C M A K E _ B U I L D _ T Y P E = $ { C M A K E _ B U I L D _ T Y P E } " " $ { n a t i v e _ c m a k e _ c u r r e n t _ s o u r c e _ d i r } "
" - D C M A K E _ C _ C O M P I L E R = / u s r / b i n / c c " " - D C M A K E _ C X X _ C O M P I L E R = / u s r / b i n / c + + "
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / h o s t _ t o o l s
)
add_custom_target ( host_tools
C O M M A N D $ { C M A K E _ C O M M A N D } - - b u i l d . - - t a r g e t h o s t _ t o o l s - - c o n f i g $ < C O N F I G >
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / h o s t _ t o o l s
)
include ( ${ CMAKE_CURRENT_BINARY_DIR } /host_tools/host_tools.cmake )
foreach ( tgt IN ITEMS ${ host_tools_list } )
add_dependencies ( host ${ tgt } host_tools )
endforeach ( )
else ( )
# Add an empty target, host tools are built inplace
add_custom_target ( host_tools
D E P E N D S $ { h o s t _ t o o l s _ l i s t }
)
endif ( )
2021-02-05 21:31:33 +00:00
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" )
2023-08-18 22:43:32 +00:00
# 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" )
2023-12-13 17:26:37 +00:00
set_property ( TARGET openttd_lib PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>" )
2023-08-18 22:43:32 +00:00
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 ( )
2021-02-05 21:31:33 +00:00
endif ( )
2021-04-02 08:15:45 +00:00
add_subdirectory ( ${ CMAKE_SOURCE_DIR } /bin )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
add_subdirectory ( ${ CMAKE_SOURCE_DIR } /src )
2021-03-09 17:00:37 +00:00
add_subdirectory ( ${ CMAKE_SOURCE_DIR } /media )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
2021-03-02 21:55:17 +00:00
if ( NOT CMAKE_CROSSCOMPILING AND NOT HOST_BINARY_DIR )
2020-06-29 17:15:28 +00:00
foreach ( tgt IN ITEMS ${ host_tools_list } )
add_executable ( host ${ tgt } ALIAS ${ tgt } )
endforeach ( )
export ( TARGETS ${ host_tools_list } NAMESPACE host FILE host_tools.cmake )
endif ( )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
add_dependencies ( openttd
f i n d _ v e r s i o n )
2023-12-13 17:26:37 +00:00
if ( NOT OPTION_NO_SPLIT_LIB )
target_link_libraries ( openttd openttd_lib )
target_link_libraries ( openttd_test PRIVATE openttd_lib )
2024-02-19 03:17:17 +00:00
if ( ANDROID )
target_link_libraries ( openttd_test PRIVATE log )
endif ( )
2023-12-13 17:26:37 +00:00
include ( Catch )
catch_discover_tests ( openttd_test )
endif ( )
target_link_libraries ( ${ OPENTTD_LIB }
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
o p e n t t d : : l a n g u a g e s
o p e n t t d : : s e t t i n g s
2019-03-05 14:52:41 +00:00
o p e n t t d : : s c r i p t _ a p i
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
T h r e a d s : : T h r e a d s
)
2023-12-13 17:26:37 +00:00
target_link_libraries ( openttd
o p e n t t d : : m e d i a
o p e n t t d : : b a s e s e t s
2023-12-29 18:47:23 +00:00
o p e n t t d : : b i n f i l e s
2023-12-13 17:26:37 +00:00
)
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
2021-05-20 22:21:38 +00:00
if ( HAIKU )
target_link_libraries ( openttd "be" "network" "midi" )
endif ( )
2023-08-01 19:51:15 +00:00
if ( IPO_FOUND AND NOT OPTION_NO_LTO )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
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 )
2020-09-25 11:55:25 +00:00
endif ( )
2021-04-02 08:15:45 +00:00
set_target_properties ( openttd PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
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 )
2020-12-06 19:13:00 +00:00
link_package ( LZO )
2021-03-01 23:08:23 +00:00
link_package ( ZSTD TARGET ZSTD::ZSTD RECOMMENDED )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
2023-02-12 11:07:31 +00:00
if ( NOT WIN32 AND NOT EMSCRIPTEN )
link_package ( CURL ENCOURAGED )
2024-01-10 21:38:58 +00:00
target_link_libraries ( openttd_lib ${ CMAKE_DL_LIBS } )
2023-02-12 11:07:31 +00:00
endif ( )
2020-09-25 11:55:25 +00:00
if ( NOT OPTION_DEDICATED )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
link_package ( Fluidsynth )
link_package ( SDL )
2020-06-07 10:06:40 +00:00
link_package ( SDL2 TARGET SDL2::SDL2 )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
link_package ( Allegro )
link_package ( FREETYPE TARGET Freetype::Freetype )
link_package ( Fontconfig TARGET Fontconfig::Fontconfig )
2023-04-30 18:37:40 +00:00
link_package ( Harfbuzz TARGET harfbuzz::harfbuzz )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
link_package ( ICU_i18n )
2020-06-27 14:14:41 +00:00
link_package ( Fcitx )
link_package ( DBus1 )
link_package ( X11 )
Fix: don't link to OpenGL with SDL2 as backend; SDL2 dynamically loads it (#8745)
Although for developers this doesn't change anything, for our
linux-generic binary it changes everything. Without this, the
OpenGL dynamic library is dragged in as dependency, and as it
depends on X11, that will be dragged in too. This is not
something we prefer to have, as that won't run on as many
machines as it could.
SDL2 doesn't depend on OpenGL directly, as it tries to load it
in on runtime. If found, it would work in exactly the same way
as if we would link to OpenGL ourselves. As such, this is
the best of both worlds: our linux-generics have less linked
dependencies, and developers won't notice any difference.
As a side-effect, if someone uses linux-generic on a machine
that does not have any OpenGL package installed, it will
gracefully fall back to the default backend of SDL instead.
2021-02-26 23:34:41 +00:00
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 ( )
2020-09-25 11:55:25 +00:00
endif ( )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
2023-02-26 11:39:09 +00:00
include ( CheckAtomic )
2020-09-25 11:55:25 +00:00
if ( APPLE )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
link_package ( Iconv TARGET Iconv::Iconv )
2023-12-13 17:26:37 +00:00
target_link_libraries ( ${ OPENTTD_LIB }
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
$ { A U D I O T O O L B O X _ L I B R A R Y }
$ { A U D I O U N I T _ L I B R A R Y }
$ { C O C O A _ L I B R A R Y }
2021-02-06 21:58:51 +00:00
$ { Q U A R T Z C O R E _ L I B R A R Y }
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
)
add_definitions (
- D W I T H _ C O C O A
)
2020-09-25 11:55:25 +00:00
endif ( )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
2020-12-05 20:57:47 +00:00
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" )
2020-12-25 19:04:48 +00:00
target_link_libraries ( WASM::WASM INTERFACE "-s DISABLE_EXCEPTION_CATCHING=0" )
2023-07-07 20:32:33 +00:00
target_link_libraries ( WASM::WASM INTERFACE "-s WASM_BIGINT" )
2020-12-25 19:04:48 +00:00
add_definitions ( -s DISABLE_EXCEPTION_CATCHING=0 )
2020-12-05 20:57:47 +00:00
# Export functions to Javascript.
2021-10-03 14:20:05 +00:00
target_link_libraries ( WASM::WASM INTERFACE "-s EXPORTED_FUNCTIONS='[\" _main\ ", \" _em_openttd_add_server\ "]' -s EXPORTED_RUNTIME_METHODS='[\" cwrap\ "]'" )
2020-12-05 20:57:47 +00:00
# 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" )
2021-04-03 10:01:29 +00:00
# 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" )
2023-06-18 15:10:08 +00:00
target_link_libraries ( WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/docs/eints.md@/docs/eints.md" )
2021-04-03 10:01:29 +00:00
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" )
2023-06-18 15:10:08 +00:00
target_link_libraries ( WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/docs/symbol_server.md@/docs/symbol_server.md" )
2020-12-05 20:57:47 +00:00
# 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 ( )
2020-09-25 11:55:25 +00:00
if ( NOT PERSONAL_DIR STREQUAL "(not set)" )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
add_definitions (
- D W I T H _ P E R S O N A L _ D I R
- D P E R S O N A L _ D I R = " $ { P E R S O N A L _ D I R } "
)
2020-09-25 11:55:25 +00:00
endif ( )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
2020-09-25 11:55:25 +00:00
if ( NOT SHARED_DIR STREQUAL "(not set)" )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
add_definitions (
- D W I T H _ S H A R E D _ D I R
- D S H A R E D _ D I R = " $ { S H A R E D _ D I R } "
)
2020-09-25 11:55:25 +00:00
endif ( )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
2020-09-25 11:55:25 +00:00
if ( NOT GLOBAL_DIR STREQUAL "(not set)" )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
add_definitions (
- D G L O B A L _ D A T A _ D I R = " $ { G L O B A L _ D I R } "
)
2020-09-25 11:55:25 +00:00
endif ( )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
link_package ( SSE )
add_definitions_based_on_options ( )
2020-09-25 11:55:25 +00:00
if ( WIN32 )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
add_definitions (
- D U N I C O D E
- D _ U N I C O D E
- D W I T H _ U N I S C R I B E
2021-05-20 16:28:14 +00:00
- D P S A P I _ V E R S I O N = 1
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
)
2023-12-13 17:26:37 +00:00
target_link_libraries ( ${ OPENTTD_LIB }
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
w s 2 _ 3 2
w i n m m
i m m 3 2
2020-07-01 23:04:31 +00:00
u s p 1 0
2021-05-20 16:28:14 +00:00
p s a p i
2023-02-12 11:07:31 +00:00
w i n h t t p
2024-01-18 22:52:53 +00:00
b c r y p t
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
)
2020-09-25 11:55:25 +00:00
endif ( )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
2020-09-25 11:55:25 +00:00
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
2021-05-30 08:40:03 +00:00
add_definitions ( -DPOINTER_IS_64BIT )
2020-09-25 11:55:25 +00:00
endif ( )
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 09:57:55 +00:00
2024-02-27 20:17:18 +00:00
if ( OPTION_NO_TAGGED_PTRS )
add_definitions ( -DNO_TAGGED_PTRS )
endif ( )
2023-12-05 14:37:53 +00:00
enable_testing ( )
add_subdirectory ( regression )
2019-04-07 10:00:36 +00:00
2021-01-30 09:36:20 +00:00
if ( APPLE OR WIN32 )
find_package ( Pandoc )
endif ( )
2019-04-07 10:00:36 +00:00
include ( InstallAndPackage )
2020-06-27 18:10:11 +00:00
get_property ( CFG_DEFS DIRECTORY . PROPERTY COMPILE_OPTIONS )
list ( FILTER CFG_DEFS INCLUDE REGEX "^-D" )
2020-07-13 20:20:17 +00:00
# list TRANSFORM requires 3.12 or later
#list(TRANSFORM CFG_DEFS REPLACE "^-D" "")
string ( REGEX REPLACE "(^|;)-D" "\\1" CFG_DEFS "${CFG_DEFS}" )
2020-06-27 18:10:11 +00:00
get_property ( CFG_DEFS_2 DIRECTORY . PROPERTY COMPILE_DEFINITIONS )
list ( APPEND CFG_DEFS ${ CFG_DEFS_2 } )
list ( FILTER CFG_DEFS EXCLUDE REGEX "_DIR=" )
2023-12-29 19:55:16 +00:00
list ( FILTER CFG_DEFS EXCLUDE REGEX "SURVEY_KEY=" )
2020-06-27 18:10:11 +00:00
# Generate a target to determine version, which is execute every 'make' run
add_custom_target ( find_version
$ { C M A K E _ C O M M A N D }
- D F I N D _ V E R S I O N _ B I N A R Y _ D I R = $ { C M A K E _ B I N A R Y _ D I R } / g e n e r a t e d
- D C P A C K _ B I N A R Y _ D I R = $ { C M A K E _ B I N A R Y _ D I R }
2021-05-12 16:52:46 +00:00
- D R E V _ M A J O R = $ { P R O J E C T _ V E R S I O N _ M A J O R }
- D R E V _ M I N O R = $ { P R O J E C T _ V E R S I O N _ M I N O R }
2020-06-27 18:10:11 +00:00
- D C O N F I G U R E _ D E F I N E S = " $ { C F G _ D E F S } "
2020-06-29 17:15:28 +00:00
$ < $ < P L A T F O R M _ I D : W i n d o w s > : - D W I N 3 2 = T R U E >
2020-06-27 18:10:11 +00:00
- P " $ { C M A K E _ S O U R C E _ D I R } / c m a k e / s c r i p t s / F i n d V e r s i o n . c m a k e "
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ S O U R C E _ D I R }
B Y P R O D U C T S $ { G E N E R A T E D _ S O U R C E _ F I L E S }
)