2020-07-13 20:20:17 +00:00
|
|
|
cmake_minimum_required(VERSION 3.6)
|
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
|
|
|
|
|
|
|
project(${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
|
|
|
|
2020-09-25 11:55:25 +00:00
|
|
|
if(CMAKE_SOURCE_DIR STREQUAL 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
|
|
|
message(FATAL_ERROR "In-source builds not allowed. Please run \"cmake ..\" from the bin directory")
|
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")
|
2020-06-04 19:59:30 +00:00
|
|
|
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.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-06-18 16:34:19 +00:00
|
|
|
# Use GNUInstallDirs to allow customisation
|
|
|
|
# but set our own default data 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()
|
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()
|
|
|
|
|
2020-12-13 21:24:36 +00:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
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
|
|
|
|
${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()
|
|
|
|
|
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)
|
|
|
|
find_package(PNG)
|
2020-06-18 12:24:29 +00:00
|
|
|
|
2020-09-25 11:55:25 +00:00
|
|
|
if(NOT 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
|
|
|
find_package(Allegro)
|
2020-09-14 19:50:31 +00:00
|
|
|
find_package(Freetype)
|
2020-09-25 11:55:25 +00:00
|
|
|
if(NOT APPLE)
|
2020-06-18 12:24:29 +00:00
|
|
|
find_package(SDL2)
|
2020-09-25 11:55:25 +00:00
|
|
|
if(NOT SDL2_FOUND)
|
2020-06-18 12:24:29 +00:00
|
|
|
find_package(SDL)
|
2020-09-25 11:55:25 +00:00
|
|
|
endif()
|
2020-06-18 12:24:29 +00:00
|
|
|
find_package(Fluidsynth)
|
|
|
|
find_package(Fontconfig)
|
2020-06-04 07:48:59 +00:00
|
|
|
find_package(ICU OPTIONAL_COMPONENTS i18n lx)
|
2020-09-25 11:55:25 +00:00
|
|
|
else()
|
2020-06-18 12:24:29 +00:00
|
|
|
find_package(Iconv)
|
|
|
|
|
|
|
|
find_library(AUDIOTOOLBOX_LIBRARY AudioToolbox)
|
|
|
|
find_library(AUDIOUNIT_LIBRARY AudioUnit)
|
|
|
|
find_library(COCOA_LIBRARY Cocoa)
|
2020-06-30 20:43:04 +00:00
|
|
|
|
|
|
|
find_package(MacUcontext)
|
2020-09-25 11:55:25 +00:00
|
|
|
endif()
|
|
|
|
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(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)
|
|
|
|
|
|
|
|
if(UNIX AND NOT APPLE)
|
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)
|
|
|
|
find_package(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)
|
|
|
|
|
|
|
|
# IPO is only properly supported from CMake 3.9. Despite the fact we are
|
|
|
|
# CMake 3.5, still enable IPO if we detect we are 3.9+.
|
2020-09-25 11:55:25 +00:00
|
|
|
if(POLICY CMP0069)
|
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
|
|
|
cmake_policy(SET CMP0069 NEW)
|
|
|
|
include(CheckIPOSupported)
|
|
|
|
check_ipo_supported(RESULT IPO_FOUND)
|
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
|
|
|
|
|
|
|
show_options()
|
|
|
|
|
2020-09-25 11:55:25 +00:00
|
|
|
if(UNIX AND NOT APPLE AND NOT OPTION_DEDICATED)
|
|
|
|
if(NOT SDL_FOUND AND NOT SDL2_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
|
|
|
message(FATAL_ERROR "SDL or SDL2 is required for this platform")
|
2020-09-25 11:55:25 +00:00
|
|
|
endif()
|
|
|
|
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()
|
|
|
|
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
|
|
|
|
|
|
|
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)
|
|
|
|
|
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_executable(openttd WIN32 ${GENERATED_SOURCE_FILES})
|
2020-06-11 19:57:14 +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()
|
|
|
|
|
2020-06-29 17:15:28 +00:00
|
|
|
set(host_tools_list strgen settingsgen)
|
|
|
|
|
|
|
|
if(CMAKE_CROSSCOMPILING)
|
|
|
|
# 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(
|
|
|
|
COMMAND "${native_cmake_command}" "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" "${native_cmake_current_source_dir}"
|
|
|
|
"-DCMAKE_C_COMPILER=/usr/bin/cc" "-DCMAKE_CXX_COMPILER=/usr/bin/c++"
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/host_tools
|
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_target(host_tools
|
|
|
|
COMMAND ${CMAKE_COMMAND} --build . --target host_tools --config $<CONFIG>
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/host_tools
|
|
|
|
)
|
|
|
|
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
|
|
|
|
DEPENDS ${host_tools_list}
|
|
|
|
)
|
|
|
|
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_subdirectory(${CMAKE_SOURCE_DIR}/src)
|
|
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/media/baseset)
|
2020-07-04 20:03:01 +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
|
|
|
|
2020-06-29 17:15:28 +00:00
|
|
|
if(NOT CMAKE_CROSSCOMPILING)
|
|
|
|
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
|
|
|
|
find_version)
|
|
|
|
|
|
|
|
target_link_libraries(openttd
|
|
|
|
openttd::languages
|
|
|
|
openttd::settings
|
|
|
|
openttd::basesets
|
2019-03-05 14:52:41 +00:00
|
|
|
openttd::script_api
|
2020-07-04 20:03:01 +00:00
|
|
|
openttd::binfiles
|
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
|
|
|
Threads::Threads
|
|
|
|
)
|
|
|
|
|
2020-09-25 11:55:25 +00:00
|
|
|
if(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
|
|
|
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()
|
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 VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")
|
|
|
|
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)
|
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 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)
|
|
|
|
link_package(ICU_lx)
|
|
|
|
link_package(ICU_i18n)
|
2020-06-27 14:14:41 +00:00
|
|
|
link_package(Fcitx)
|
|
|
|
link_package(DBus1)
|
|
|
|
link_package(X11)
|
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(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)
|
|
|
|
|
|
|
|
target_link_libraries(openttd
|
|
|
|
${AUDIOTOOLBOX_LIBRARY}
|
|
|
|
${AUDIOUNIT_LIBRARY}
|
|
|
|
${COCOA_LIBRARY}
|
|
|
|
)
|
|
|
|
|
|
|
|
add_definitions(
|
|
|
|
-DWITH_COCOA
|
|
|
|
)
|
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")
|
|
|
|
add_definitions(-s DISABLE_EXCEPTION_CATCHING=0)
|
2020-12-05 20:57:47 +00:00
|
|
|
|
|
|
|
# Export functions to Javascript.
|
|
|
|
target_link_libraries(WASM::WASM INTERFACE "-s EXPORTED_FUNCTIONS='[\"_main\", \"_em_openttd_add_server\"]' -s EXTRA_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")
|
|
|
|
|
|
|
|
# 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(
|
|
|
|
-DWITH_PERSONAL_DIR
|
|
|
|
-DPERSONAL_DIR="${PERSONAL_DIR}"
|
|
|
|
)
|
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(
|
|
|
|
-DWITH_SHARED_DIR
|
|
|
|
-DSHARED_DIR="${SHARED_DIR}"
|
|
|
|
)
|
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(
|
|
|
|
-DGLOBAL_DATA_DIR="${GLOBAL_DIR}"
|
|
|
|
)
|
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(
|
|
|
|
-DUNICODE
|
|
|
|
-D_UNICODE
|
|
|
|
-DWITH_UNISCRIBE
|
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries(openttd
|
|
|
|
ws2_32
|
|
|
|
winmm
|
|
|
|
imm32
|
2020-07-01 23:04:31 +00:00
|
|
|
usp10
|
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)
|
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_SQ64)
|
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
|
|
|
|
|
|
|
include(CreateRegression)
|
|
|
|
create_regression()
|
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=")
|
|
|
|
|
|
|
|
# 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}
|
|
|
|
-DCONFIGURE_DEFINES="${CFG_DEFS}"
|
2020-06-29 17:15:28 +00:00
|
|
|
$<$<PLATFORM_ID:Windows>:-DWIN32=TRUE>
|
2020-06-27 18:10:11 +00:00
|
|
|
-P "${CMAKE_SOURCE_DIR}/cmake/scripts/FindVersion.cmake"
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
|
|
BYPRODUCTS ${GENERATED_SOURCE_FILES}
|
|
|
|
)
|