cmake_minimum_required ( VERSION 3.16 )
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.
6 years ago
if ( NOT BINARY_NAME )
set ( BINARY_NAME openttd )
endif ( )
project ( ${ BINARY_NAME }
V E R S I O N 1 4 . 0
L A N G U A G E S C X X
)
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.
6 years ago
if ( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR )
message ( FATAL_ERROR "In-source builds not allowed. Please run \" cmake ..\ " from the build directory. You may need to delete \" ${ CMAKE_SOURCE_DIR } /CMakeCache.txt\ " first." )
endif ( )
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.
6 years ago
# Debug mode by default.
if ( NOT CMAKE_BUILD_TYPE )
set ( CMAKE_BUILD_TYPE Debug )
endif ( )
if ( EMSCRIPTEN )
set ( CMAKE_MODULE_PATH ${ CMAKE_MODULE_PATH } "${CMAKE_SOURCE_DIR}/os/emscripten/cmake" )
endif ( )
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.
6 years ago
set ( CMAKE_MODULE_PATH ${ CMAKE_MODULE_PATH } "${CMAKE_SOURCE_DIR}/cmake" )
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.
6 years ago
# Use GNUInstallDirs to allow customisation
# but set our own default data and bin dir
if ( NOT CMAKE_INSTALL_DATADIR )
set ( CMAKE_INSTALL_DATADIR "share/games" )
endif ( )
if ( NOT CMAKE_INSTALL_BINDIR )
set ( CMAKE_INSTALL_BINDIR "games" )
endif ( )
include ( GNUInstallDirs )
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.
6 years ago
include ( Options )
set_options ( )
set_directory_options ( )
include ( Static )
set_static_if_needed ( )
set ( CMAKE_CXX_STANDARD 17 )
set ( CMAKE_CXX_STANDARD_REQUIRED YES )
set ( CMAKE_CXX_EXTENSIONS NO )
set ( CMAKE_EXPORT_COMPILE_COMMANDS YES )
# An empty target for the tools
add_custom_target ( tools )
include ( Endian )
add_endian_definition ( )
include ( CompileFlags )
compile_flags ( )
if ( APPLE OR UNIX )
add_definitions ( -DUNIX )
endif ( )
if ( UNIX )
find_package ( Doxygen )
endif ( )
list ( APPEND GENERATED_SOURCE_FILES "${CMAKE_BINARY_DIR}/generated/rev.cpp" )
if ( WIN32 )
list ( APPEND GENERATED_SOURCE_FILES "${CMAKE_BINARY_DIR}/generated/ottdres.rc" )
endif ( )
# Generate a target to determine version, which is execute every 'make' run
add_custom_target ( find_version
$ { 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 }
- 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 }
- D W I N D O W S = $ { WIN32 }
- 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 }
)
# 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 )
return ( )
endif ( )
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.
6 years ago
# 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 )
find_package ( nlohmann_json )
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 ( )
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 )
find_package ( Fontconfig )
find_package ( Harfbuzz )
find_package ( ICU OPTIONAL_COMPONENTS i18n )
endif ( )
endif ( )
endif ( )
if ( APPLE )
enable_language ( OBJCXX )
find_package ( Iconv )
find_library ( AUDIOTOOLBOX_LIBRARY AudioToolbox )
find_library ( AUDIOUNIT_LIBRARY AudioUnit )
find_library ( COCOA_LIBRARY Cocoa )
find_library ( QUARTZCORE_LIBRARY QuartzCore )
endif ( )
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.
6 years ago
if ( NOT EMSCRIPTEN AND NOT OPTION_DEDICATED )
find_package ( OpenGL COMPONENTS OpenGL )
endif ( )
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.
6 years ago
find_package ( Editbin REQUIRED )
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.
6 years ago
find_package ( SSE )
find_package ( Xaudio2 )
find_package ( Grfcodec )
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.
6 years ago
show_options ( )
if ( UNIX AND NOT APPLE AND NOT OPTION_DEDICATED )
if ( NOT SDL_FOUND AND NOT SDL2_FOUND AND NOT ALLEGRO_FOUND )
message ( FATAL_ERROR "SDL, SDL2 or Allegro is required for this platform" )
endif ( )
if ( HARFBUZZ_FOUND AND NOT ICU_i18n_FOUND )
message ( WARNING "HarfBuzz depends on ICU i18n to function; HarfBuzz will be disabled" )
endif ( )
if ( NOT HARFBUZZ_FOUND )
message ( WARNING "Without HarfBuzz and ICU i18n the game will not be able to render right-to-left languages correctly" )
endif ( )
endif ( )
if ( APPLE )
if ( NOT AUDIOTOOLBOX_LIBRARY )
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.
6 years ago
message ( FATAL_ERROR "AudioToolbox is required for this platform" )
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.
6 years ago
message ( FATAL_ERROR "AudioUnit is required for this platform" )
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.
6 years ago
message ( FATAL_ERROR "Cocoa is required for this platform" )
endif ( )
if ( NOT QUARTZCORE_LIBRARY )
message ( FATAL_ERROR "QuartzCore is required for this platform" )
endif ( )
endif ( )
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.
6 years ago
if ( OPTION_PACKAGE_DEPENDENCIES )
if ( NOT UNIX )
message ( FATAL_ERROR "Can only package dependencies on Linux" )
endif ( )
if ( OPTION_INSTALL_FHS )
message ( FATAL_ERROR "Cannot install in FHS folders when we are packaging dependencies" )
endif ( )
if ( ${ CMAKE_VERSION } VERSION_LESS "3.16.0" )
message ( FATAL_ERROR "OPTION_PACKAGE_DEPENDENCIES can only work with CMake 3.16+; you are using ${CMAKE_VERSION}" )
endif ( )
# If we are packaging dependencies, we do two things:
# 1) set the RPATH to include $ORIGIN/lib; $ORIGIN (that literal string)
# is a Linux indicator for "path where application is". In CMake, we
# have to do this before add_executable() is executed.
# 2) copy the libraries that we compile against to the "lib" folder.
# This is done in InstallAndPackage.cmake.
set ( CMAKE_INSTALL_RPATH "\$ORIGIN/lib" )
set ( CMAKE_BUILD_WITH_INSTALL_RPATH ON )
endif ( )
include ( CTest )
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.
6 years ago
include ( SourceList )
# Needed by rev.cpp
include_directories ( ${ CMAKE_SOURCE_DIR } /src )
# Needed by everything that uses Squirrel
include_directories ( ${ CMAKE_SOURCE_DIR } /src/3rdparty/squirrel/include )
include ( MSVCFilters )
add_library ( openttd_lib OBJECT ${ GENERATED_SOURCE_FILES } )
add_executable ( openttd WIN32 )
add_executable ( openttd_test )
set_target_properties ( openttd PROPERTIES OUTPUT_NAME "${BINARY_NAME}" )
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.
6 years ago
# All other files are added via target_sources()
if ( MSVC )
# Add DPI manifest to project; other WIN32 targets get this via ottdres.rc
target_sources ( openttd PRIVATE "${CMAKE_SOURCE_DIR}/os/windows/openttd.manifest" )
endif ( )
target_precompile_headers ( openttd_lib
P R I V A T E
s r c / s t d a f x . h
s r c / 3 r d p a r t y / f m t / f o r m a t . h
)
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.
6 years ago
add_subdirectory ( ${ CMAKE_SOURCE_DIR } /src )
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.
6 years ago
add_dependencies ( openttd
f i n d _ v e r s i o n )
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.
6 years ago
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
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.
6 years ago
T h r e a d s : : T h r e a d s
)
target_link_libraries ( openttd
o p e n t t d _ l i b
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
)
target_link_libraries ( openttd_test PRIVATE openttd_lib )
include ( Catch )
catch_discover_tests ( openttd_test )
if ( HAIKU )
target_link_libraries ( openttd_lib "be" "network" "midi" )
endif ( )
if ( IPO_FOUND )
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.
6 years ago
set_target_properties ( openttd PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE True )
set_target_properties ( openttd PROPERTIES INTERPROCEDURAL_OPTIMIZATION_MINSIZEREL True )
set_target_properties ( openttd PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO True )
endif ( )
set_target_properties ( openttd PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" )
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.
6 years ago
process_compile_flags ( )
include ( LinkPackage )
link_package ( PNG TARGET PNG::PNG ENCOURAGED )
link_package ( ZLIB TARGET ZLIB::ZLIB ENCOURAGED )
link_package ( LIBLZMA TARGET LibLZMA::LibLZMA ENCOURAGED )
link_package ( LZO )
link_package ( nlohmann_json ENCOURAGED )
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.
6 years ago
if ( NOT WIN32 AND NOT EMSCRIPTEN )
link_package ( CURL ENCOURAGED )
endif ( )
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.
6 years ago
link_package ( Fluidsynth )
link_package ( SDL )
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.
6 years ago
link_package ( Allegro )
link_package ( FREETYPE TARGET Freetype::Freetype )
link_package ( Fontconfig TARGET Fontconfig::Fontconfig )
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.
6 years ago
link_package ( ICU_i18n )
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.
4 years ago
if ( SDL2_FOUND AND OPENGL_FOUND AND UNIX )
# SDL2 dynamically loads OpenGL if needed, so do not link to OpenGL when
# on Linux. For Windows, we need to link to OpenGL as we also have a win32
# driver using it.
add_definitions ( -DWITH_OPENGL )
message ( STATUS "OpenGL found -- -DWITH_OPENGL -- (via SDL2)" )
else ( )
link_package ( OpenGL TARGET OpenGL::GL )
endif ( )
endif ( )
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.
6 years ago
include ( CheckAtomic )
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.
6 years ago
link_package ( Iconv TARGET Iconv::Iconv )
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.
6 years ago
$ { 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 }
$ { 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.
6 years ago
)
add_definitions (
- D W I T H _ C O C O A
)
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.
6 years ago
if ( EMSCRIPTEN )
add_library ( WASM::WASM INTERFACE IMPORTED )
# Allow heap-growth, and start with a bigger memory size.
target_link_libraries ( WASM::WASM INTERFACE "-s ALLOW_MEMORY_GROWTH=1" )
target_link_libraries ( WASM::WASM INTERFACE "-s INITIAL_MEMORY=33554432" )
target_link_libraries ( WASM::WASM INTERFACE "-s DISABLE_EXCEPTION_CATCHING=0" )
add_definitions ( -s DISABLE_EXCEPTION_CATCHING=0 )
# Export functions to Javascript.
target_link_libraries ( WASM::WASM INTERFACE "-s EXPORTED_FUNCTIONS='[\" _main\ ", \" _em_openttd_add_server\ "]' -s EXPORTED_RUNTIME_METHODS='[\" cwrap\ "]'" )
# Preload all the files we generate during build.
# As we do not compile with FreeType / FontConfig, we also have no way to
# render several languages (like Chinese, ..), so where do you draw the
# line what languages to include and which not? In the end, especially as
# the more languages you add the slower downloading becomes, we decided to
# only ship the English language.
target_link_libraries ( WASM::WASM INTERFACE "--preload-file ${CMAKE_BINARY_DIR}/baseset@/baseset" )
target_link_libraries ( WASM::WASM INTERFACE "--preload-file ${CMAKE_BINARY_DIR}/lang/english.lng@/lang/english.lng" )
target_link_libraries ( WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/bin/ai@/ai" )
target_link_libraries ( WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/bin/game@/game" )
# We use IDBFS for persistent storage.
target_link_libraries ( WASM::WASM INTERFACE "-lidbfs.js" )
# Use custom pre-js and shell.html.
target_link_libraries ( WASM::WASM INTERFACE "--pre-js ${CMAKE_SOURCE_DIR}/os/emscripten/pre.js" )
target_link_libraries ( WASM::WASM INTERFACE "--shell-file ${CMAKE_SOURCE_DIR}/os/emscripten/shell.html" )
# Build the .html (which builds the .js, .wasm, and .data too).
set_target_properties ( openttd PROPERTIES SUFFIX ".html" )
target_link_libraries ( openttd WASM::WASM )
endif ( )
if ( NOT PERSONAL_DIR STREQUAL "(not set)" )
Add: 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.
6 years ago
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 } "
)
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.
6 years ago
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.
6 years ago
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 } "
)
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.
6 years ago
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.
6 years ago
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 } "
)
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.
6 years ago
link_package ( SSE )
add_definitions_based_on_options ( )
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.
6 years ago
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
- 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.
6 years ago
)
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.
6 years ago
w s 2 _ 3 2
w i n m m
i m m 3 2
u s p 1 0
p s a p i
w i n h t t p
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.
6 years ago
)
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.
6 years ago
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
add_definitions ( -DPOINTER_IS_64BIT )
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.
6 years ago
include ( CreateRegression )
create_regression ( )
if ( APPLE OR WIN32 )
find_package ( Pandoc )
endif ( )
include ( InstallAndPackage )