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.
This commit is contained in:
Patric Stout
2019-04-07 11:57:55 +02:00
committed by glx22
parent 85315e2e31
commit 56d54cf60e
69 changed files with 3116 additions and 1144 deletions

3
src/3rdparty/CMakeLists.txt vendored Normal file
View File

@@ -0,0 +1,3 @@
add_subdirectory(md5)
add_subdirectory(squirrel)
add_subdirectory(os2)

4
src/3rdparty/md5/CMakeLists.txt vendored Normal file
View File

@@ -0,0 +1,4 @@
add_files(
md5.cpp
md5.h
)

7
src/3rdparty/os2/CMakeLists.txt vendored Normal file
View File

@@ -0,0 +1,7 @@
add_files(
getaddrinfo.c
getaddrinfo.h
getnameinfo.c
getnameinfo.h
CONDITION OPTION_OS2
)

3
src/3rdparty/squirrel/CMakeLists.txt vendored Normal file
View File

@@ -0,0 +1,3 @@
add_subdirectory(include)
add_subdirectory(sqstdlib)
add_subdirectory(squirrel)

View File

@@ -0,0 +1,6 @@
add_files(
sqstdaux.h
sqstdmath.h
sqstdstring.h
squirrel.h
)

View File

@@ -0,0 +1,4 @@
add_files(
sqstdaux.cpp
sqstdmath.cpp
)

View File

@@ -0,0 +1,30 @@
add_files(
sqapi.cpp
sqarray.h
sqbaselib.cpp
sqclass.cpp
sqclass.h
sqclosure.h
sqcompiler.cpp
sqcompiler.h
sqdebug.cpp
sqfuncproto.h
sqfuncstate.cpp
sqfuncstate.h
sqlexer.cpp
sqlexer.h
sqmem.cpp
sqobject.cpp
sqobject.h
sqopcodes.h
sqpcheader.h
sqstate.cpp
sqstate.h
sqstring.h
sqtable.cpp
sqtable.h
squserdata.h
squtils.h
sqvm.cpp
sqvm.h
)

479
src/CMakeLists.txt Normal file
View File

@@ -0,0 +1,479 @@
add_subdirectory(3rdparty)
add_subdirectory(ai)
add_subdirectory(blitter)
add_subdirectory(core)
add_subdirectory(game)
add_subdirectory(lang)
add_subdirectory(linkgraph)
add_subdirectory(misc)
add_subdirectory(music)
add_subdirectory(network)
add_subdirectory(os)
add_subdirectory(pathfinder)
add_subdirectory(saveload)
add_subdirectory(script)
add_subdirectory(settingsgen)
add_subdirectory(sound)
add_subdirectory(spriteloader)
add_subdirectory(strgen)
add_subdirectory(table)
add_subdirectory(video)
add_subdirectory(widgets)
add_files(
viewport_sprite_sorter_sse4.cpp
CONDITION SSE_FOUND
)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set_compile_flags(
viewport_sprite_sorter_sse4.cpp
COMPILE_FLAGS -msse4.1)
endif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
add_files(
aircraft.h
aircraft_cmd.cpp
aircraft_gui.cpp
airport.cpp
airport.h
airport_gui.cpp
animated_tile.cpp
animated_tile_func.h
articulated_vehicles.cpp
articulated_vehicles.h
autoreplace.cpp
autoreplace_base.h
autoreplace_cmd.cpp
autoreplace_func.h
autoreplace_gui.cpp
autoreplace_gui.h
autoreplace_type.h
autoslope.h
base_consist.cpp
base_consist.h
base_media_base.h
base_media_func.h
base_station_base.h
bitmap_type.h
bmp.cpp
bmp.h
bootstrap_gui.cpp
bridge.h
bridge_gui.cpp
bridge_map.cpp
bridge_map.h
build_vehicle_gui.cpp
cargo_type.h
cargoaction.cpp
cargoaction.h
cargomonitor.cpp
cargomonitor.h
cargopacket.cpp
cargopacket.h
cargotype.cpp
cargotype.h
cheat.cpp
cheat_func.h
cheat_gui.cpp
cheat_type.h
clear_cmd.cpp
clear_func.h
clear_map.h
cmd_helper.h
command.cpp
command_func.h
command_type.h
company_base.h
company_cmd.cpp
company_func.h
company_gui.cpp
company_gui.h
company_manager_face.h
company_type.h
console.cpp
console_cmds.cpp
console_func.h
console_gui.cpp
console_gui.h
console_internal.h
console_type.h
cpu.cpp
cpu.h
crashlog.cpp
crashlog.h
currency.cpp
currency.h
date.cpp
date_func.h
date_gui.cpp
date_gui.h
date_type.h
debug.cpp
debug.h
dedicated.cpp
depot.cpp
depot_base.h
depot_cmd.cpp
depot_func.h
depot_gui.cpp
depot_map.h
depot_type.h
direction_func.h
direction_type.h
disaster_vehicle.cpp
disaster_vehicle.h
dock_gui.cpp
driver.cpp
driver.h
economy.cpp
economy_base.h
economy_func.h
economy_type.h
effectvehicle.cpp
effectvehicle_base.h
effectvehicle_func.h
elrail.cpp
elrail_func.h
engine.cpp
engine_base.h
engine_func.h
engine_gui.cpp
engine_gui.h
engine_type.h
error.h
error_gui.cpp
fileio.cpp
fileio_func.h
fileio_type.h
fios.cpp
fios.h
fios_gui.cpp
fontcache.cpp
fontcache.h
fontdetection.cpp
fontdetection.h
framerate_gui.cpp
framerate_type.h
gamelog.cpp
gamelog.h
gamelog_internal.h
genworld.cpp
genworld.h
genworld_gui.cpp
gfx.cpp
gfx_func.h
gfx_layout.cpp
gfx_layout.h
gfx_type.h
gfxinit.cpp
gfxinit.h
goal.cpp
goal_base.h
goal_gui.cpp
goal_type.h
graph_gui.cpp
graph_gui.h
ground_vehicle.cpp
ground_vehicle.hpp
group.h
group_cmd.cpp
group_gui.cpp
group_gui.h
group_type.h
gui.h
guitimer_func.h
heightmap.cpp
heightmap.h
highscore.cpp
highscore.h
highscore_gui.cpp
hotkeys.cpp
hotkeys.h
house.h
house_type.h
industry.h
industry_cmd.cpp
industry_gui.cpp
industry_map.h
industry_type.h
industrytype.h
ini.cpp
ini_load.cpp
ini_type.h
intro_gui.cpp
landscape.cpp
landscape.h
landscape_type.h
language.h
livery.h
main_gui.cpp
map.cpp
map_func.h
map_type.h
misc.cpp
misc_cmd.cpp
misc_gui.cpp
mixer.cpp
mixer.h
music.cpp
music_gui.cpp
newgrf.cpp
newgrf.h
newgrf_airport.cpp
newgrf_airport.h
newgrf_airporttiles.cpp
newgrf_airporttiles.h
newgrf_animation_base.h
newgrf_animation_type.h
newgrf_callbacks.h
newgrf_canal.cpp
newgrf_canal.h
newgrf_cargo.cpp
newgrf_cargo.h
newgrf_class.h
newgrf_class_func.h
newgrf_commons.cpp
newgrf_commons.h
newgrf_config.cpp
newgrf_config.h
newgrf_debug.h
newgrf_debug_gui.cpp
newgrf_engine.cpp
newgrf_engine.h
newgrf_generic.cpp
newgrf_generic.h
newgrf_gui.cpp
newgrf_house.cpp
newgrf_house.h
newgrf_industries.cpp
newgrf_industries.h
newgrf_industrytiles.cpp
newgrf_industrytiles.h
newgrf_object.cpp
newgrf_object.h
newgrf_profiling.cpp
newgrf_profiling.h
newgrf_properties.h
newgrf_railtype.cpp
newgrf_railtype.h
newgrf_roadtype.cpp
newgrf_roadtype.h
newgrf_sound.cpp
newgrf_sound.h
newgrf_spritegroup.cpp
newgrf_spritegroup.h
newgrf_station.cpp
newgrf_station.h
newgrf_storage.cpp
newgrf_storage.h
newgrf_text.cpp
newgrf_text.h
newgrf_town.cpp
newgrf_town.h
newgrf_townname.cpp
newgrf_townname.h
news_func.h
news_gui.cpp
news_gui.h
news_type.h
object.h
object_base.h
object_cmd.cpp
object_gui.cpp
object_map.h
object_type.h
openttd.cpp
openttd.h
order_backup.cpp
order_backup.h
order_base.h
order_cmd.cpp
order_func.h
order_gui.cpp
order_type.h
osk_gui.cpp
pbs.cpp
pbs.h
progress.cpp
progress.h
querystring_gui.h
rail.cpp
rail.h
rail_cmd.cpp
rail_gui.cpp
rail_gui.h
rail_map.h
rail_type.h
rev.h
road.cpp
road.h
road_cmd.cpp
road_cmd.h
road_func.h
road_gui.cpp
road_gui.h
road_internal.h
road_map.cpp
road_map.h
road_type.h
roadstop.cpp
roadstop_base.h
roadveh.h
roadveh_cmd.cpp
roadveh_gui.cpp
safeguards.h
screenshot_gui.cpp
screenshot_gui.h
screenshot.cpp
screenshot.h
settings.cpp
settings_func.h
settings_gui.cpp
settings_gui.h
settings_internal.h
settings_type.h
ship.h
ship_cmd.cpp
ship_gui.cpp
signal.cpp
signal_func.h
signal_type.h
signs.cpp
signs_base.h
signs_cmd.cpp
signs_func.h
signs_gui.cpp
signs_type.h
slope_func.h
slope_type.h
smallmap_gui.cpp
smallmap_gui.h
sortlist_type.h
sound.cpp
sound_func.h
sound_type.h
sprite.cpp
sprite.h
spritecache.cpp
spritecache.h
station.cpp
station_base.h
station_cmd.cpp
station_func.h
station_gui.cpp
station_gui.h
station_kdtree.h
station_map.h
station_type.h
statusbar_gui.cpp
statusbar_gui.h
stdafx.h
story.cpp
story_base.h
story_gui.cpp
story_type.h
strgen/strgen.h
string.cpp
string_base.h
string_func.h
string_type.h
stringfilter.cpp
stringfilter_type.h
strings.cpp
strings_func.h
strings_type.h
subsidy.cpp
subsidy_base.h
subsidy_func.h
subsidy_gui.cpp
subsidy_type.h
tar_type.h
terraform_cmd.cpp
terraform_gui.cpp
terraform_gui.h
textbuf.cpp
textbuf_gui.h
textbuf_type.h
texteff.cpp
texteff.hpp
textfile_gui.cpp
textfile_gui.h
textfile_type.h
tgp.cpp
tgp.h
thread.h
tile_cmd.h
tile_map.cpp
tile_map.h
tile_type.h
tilearea.cpp
tilearea_type.h
tilehighlight_func.h
tilehighlight_type.h
tilematrix_type.hpp
timetable.h
timetable_cmd.cpp
timetable_gui.cpp
toolbar_gui.cpp
toolbar_gui.h
town.h
town_cmd.cpp
town_gui.cpp
town_kdtree.h
town_map.h
town_type.h
townname.cpp
townname_func.h
townname_type.h
track_func.h
track_type.h
train.h
train_cmd.cpp
train_gui.cpp
transparency.h
transparency_gui.cpp
transparency_gui.h
transport_type.h
tree_cmd.cpp
tree_gui.cpp
tree_map.h
tunnel_map.cpp
tunnel_map.h
tunnelbridge.h
tunnelbridge_cmd.cpp
tunnelbridge_map.h
vehicle.cpp
vehicle_base.h
vehicle_cmd.cpp
vehicle_func.h
vehicle_gui.cpp
vehicle_gui.h
vehicle_gui_base.h
vehicle_type.h
vehiclelist.cpp
vehiclelist.h
viewport.cpp
viewport_func.h
viewport_gui.cpp
viewport_kdtree.h
viewport_sprite_sorter.h
viewport_type.h
void_cmd.cpp
void_map.h
water.h
water_cmd.cpp
water_map.h
waypoint.cpp
waypoint_base.h
waypoint_cmd.cpp
waypoint_func.h
waypoint_gui.cpp
widget.cpp
widget_type.h
window.cpp
window_func.h
window_gui.h
window_type.h
zoom_func.h
zoom_type.h
)

14
src/ai/CMakeLists.txt Normal file
View File

@@ -0,0 +1,14 @@
add_files(
ai.hpp
ai_config.cpp
ai_config.hpp
ai_core.cpp
ai_gui.cpp
ai_gui.hpp
ai_info.cpp
ai_info.hpp
ai_instance.cpp
ai_instance.hpp
ai_scanner.cpp
ai_scanner.hpp
)

View File

@@ -0,0 +1,55 @@
add_files(
32bpp_anim.cpp
32bpp_anim.hpp
32bpp_base.cpp
32bpp_base.hpp
32bpp_optimized.cpp
32bpp_optimized.hpp
32bpp_simple.cpp
32bpp_simple.hpp
8bpp_base.cpp
8bpp_base.hpp
8bpp_optimized.cpp
8bpp_optimized.hpp
8bpp_simple.cpp
8bpp_simple.hpp
CONDITION NOT OPTION_DEDICATED
)
add_files(
32bpp_anim_sse2.cpp
32bpp_anim_sse2.hpp
32bpp_anim_sse4.cpp
32bpp_anim_sse4.hpp
32bpp_sse2.cpp
32bpp_sse2.hpp
32bpp_sse4.cpp
32bpp_sse4.hpp
32bpp_sse_func.hpp
32bpp_sse_type.h
32bpp_ssse3.cpp
32bpp_ssse3.hpp
CONDITION NOT OPTION_DEDICATED AND SSE_FOUND
)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set_compile_flags(
32bpp_anim_sse2.cpp
32bpp_sse2.cpp
COMPILE_FLAGS -msse2)
set_compile_flags(
32bpp_ssse3.cpp
COMPILE_FLAGS -mssse3)
set_compile_flags(
32bpp_anim_sse4.cpp
32bpp_sse4.cpp
COMPILE_FLAGS -msse4.1)
endif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
add_files(
base.hpp
common.hpp
factory.hpp
null.cpp
null.hpp
)

30
src/core/CMakeLists.txt Normal file
View File

@@ -0,0 +1,30 @@
add_files(
alloc_func.cpp
alloc_func.hpp
alloc_type.hpp
backup_type.hpp
bitmath_func.cpp
bitmath_func.hpp
endian_func.hpp
endian_type.hpp
enum_type.hpp
geometry_func.cpp
geometry_func.hpp
geometry_type.hpp
kdtree.hpp
math_func.cpp
math_func.hpp
mem_func.hpp
multimap.hpp
overflowsafe_type.hpp
pool_func.cpp
pool_func.hpp
pool_type.hpp
random_func.cpp
random_func.hpp
smallmap_type.hpp
smallmatrix_type.hpp
smallstack_type.hpp
smallvec_type.hpp
string_compare_type.hpp
)

View File

@@ -23,30 +23,8 @@
/** Big endian builds use this for TTD_ENDIAN. */
#define TTD_BIG_ENDIAN 1
/* Windows has always LITTLE_ENDIAN */
#if defined(_WIN32) || defined(__OS2__) || defined(__HAIKU__)
# define TTD_ENDIAN TTD_LITTLE_ENDIAN
#elif defined(OSX)
# include <sys/types.h>
# if __DARWIN_BYTE_ORDER == __DARWIN_LITTLE_ENDIAN
# define TTD_ENDIAN TTD_LITTLE_ENDIAN
# else
# define TTD_ENDIAN TTD_BIG_ENDIAN
# endif
#elif defined(__OpenBSD__)
# include <endian.h>
# if BYTE_ORDER == LITTLE_ENDIAN
# define TTD_ENDIAN TTD_LITTLE_ENDIAN
# else
# define TTD_ENDIAN TTD_BIG_ENDIAN
# endif
#elif !defined(TESTING)
# include <sys/param.h>
# if __BYTE_ORDER == __LITTLE_ENDIAN
# define TTD_ENDIAN TTD_LITTLE_ENDIAN
# else
# define TTD_ENDIAN TTD_BIG_ENDIAN
# endif
#endif /* _WIN32 || __OS2__ */
#if !defined(TTD_ENDIAN)
# error "TTD_ENDIAN is not defined; please set it to either TTD_LITTLE_ENDIAN or TTD_BIG_ENDIAN"
#endif /* !TTD_ENDIAN */
#endif /* ENDIAN_TYPE_HPP */

File diff suppressed because it is too large Load Diff

14
src/game/CMakeLists.txt Normal file
View File

@@ -0,0 +1,14 @@
add_files(
game.hpp
game_config.cpp
game_config.hpp
game_core.cpp
game_info.cpp
game_info.hpp
game_instance.cpp
game_instance.hpp
game_scanner.cpp
game_scanner.hpp
game_text.cpp
game_text.hpp
)

122
src/lang/CMakeLists.txt Normal file
View File

@@ -0,0 +1,122 @@
set(LANG_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/afrikaans.txt
${CMAKE_CURRENT_SOURCE_DIR}/arabic_egypt.txt
${CMAKE_CURRENT_SOURCE_DIR}/basque.txt
${CMAKE_CURRENT_SOURCE_DIR}/belarusian.txt
${CMAKE_CURRENT_SOURCE_DIR}/brazilian_portuguese.txt
${CMAKE_CURRENT_SOURCE_DIR}/bulgarian.txt
${CMAKE_CURRENT_SOURCE_DIR}/catalan.txt
${CMAKE_CURRENT_SOURCE_DIR}/croatian.txt
${CMAKE_CURRENT_SOURCE_DIR}/czech.txt
${CMAKE_CURRENT_SOURCE_DIR}/danish.txt
${CMAKE_CURRENT_SOURCE_DIR}/dutch.txt
${CMAKE_CURRENT_SOURCE_DIR}/english.txt
${CMAKE_CURRENT_SOURCE_DIR}/english_AU.txt
${CMAKE_CURRENT_SOURCE_DIR}/english_US.txt
${CMAKE_CURRENT_SOURCE_DIR}/esperanto.txt
${CMAKE_CURRENT_SOURCE_DIR}/estonian.txt
${CMAKE_CURRENT_SOURCE_DIR}/faroese.txt
${CMAKE_CURRENT_SOURCE_DIR}/finnish.txt
${CMAKE_CURRENT_SOURCE_DIR}/french.txt
${CMAKE_CURRENT_SOURCE_DIR}/gaelic.txt
${CMAKE_CURRENT_SOURCE_DIR}/galician.txt
${CMAKE_CURRENT_SOURCE_DIR}/german.txt
${CMAKE_CURRENT_SOURCE_DIR}/greek.txt
${CMAKE_CURRENT_SOURCE_DIR}/hebrew.txt
${CMAKE_CURRENT_SOURCE_DIR}/hungarian.txt
${CMAKE_CURRENT_SOURCE_DIR}/icelandic.txt
${CMAKE_CURRENT_SOURCE_DIR}/indonesian.txt
${CMAKE_CURRENT_SOURCE_DIR}/irish.txt
${CMAKE_CURRENT_SOURCE_DIR}/italian.txt
${CMAKE_CURRENT_SOURCE_DIR}/japanese.txt
${CMAKE_CURRENT_SOURCE_DIR}/korean.txt
${CMAKE_CURRENT_SOURCE_DIR}/latin.txt
${CMAKE_CURRENT_SOURCE_DIR}/latvian.txt
${CMAKE_CURRENT_SOURCE_DIR}/lithuanian.txt
${CMAKE_CURRENT_SOURCE_DIR}/luxembourgish.txt
${CMAKE_CURRENT_SOURCE_DIR}/malay.txt
${CMAKE_CURRENT_SOURCE_DIR}/norwegian_bokmal.txt
${CMAKE_CURRENT_SOURCE_DIR}/norwegian_nynorsk.txt
${CMAKE_CURRENT_SOURCE_DIR}/polish.txt
${CMAKE_CURRENT_SOURCE_DIR}/portuguese.txt
${CMAKE_CURRENT_SOURCE_DIR}/romanian.txt
${CMAKE_CURRENT_SOURCE_DIR}/russian.txt
${CMAKE_CURRENT_SOURCE_DIR}/serbian.txt
${CMAKE_CURRENT_SOURCE_DIR}/simplified_chinese.txt
${CMAKE_CURRENT_SOURCE_DIR}/slovak.txt
${CMAKE_CURRENT_SOURCE_DIR}/slovenian.txt
${CMAKE_CURRENT_SOURCE_DIR}/spanish.txt
${CMAKE_CURRENT_SOURCE_DIR}/spanish_MX.txt
${CMAKE_CURRENT_SOURCE_DIR}/swedish.txt
${CMAKE_CURRENT_SOURCE_DIR}/tamil.txt
${CMAKE_CURRENT_SOURCE_DIR}/thai.txt
${CMAKE_CURRENT_SOURCE_DIR}/traditional_chinese.txt
${CMAKE_CURRENT_SOURCE_DIR}/turkish.txt
${CMAKE_CURRENT_SOURCE_DIR}/ukrainian.txt
${CMAKE_CURRENT_SOURCE_DIR}/vietnamese.txt
${CMAKE_CURRENT_SOURCE_DIR}/welsh.txt
)
set(LANG_BINARY_DIR ${CMAKE_BINARY_DIR}/lang)
# Walk over all the (finished) language files, and generate a command to compile them
foreach(LANG_SOURCE_FILE IN LISTS LANG_SOURCE_FILES)
get_filename_component(LANG_SOURCE_FILE_NAME_WE ${LANG_SOURCE_FILE} NAME_WE)
set(LANG_BINARY_FILE ${LANG_BINARY_DIR}/${LANG_SOURCE_FILE_NAME_WE}.lng)
add_custom_command(OUTPUT ${LANG_BINARY_FILE}
COMMAND ${CMAKE_COMMAND} -E make_directory ${LANG_BINARY_DIR}
COMMAND strgen
-s ${CMAKE_CURRENT_SOURCE_DIR}
-d ${LANG_BINARY_DIR}
${LANG_SOURCE_FILE}
DEPENDS strgen
MAIN_DEPENDENCY ${LANG_SOURCE_FILE}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Compiling language ${LANG_SOURCE_FILE_NAME_WE}"
)
list(APPEND LANG_BINARY_FILES ${LANG_BINARY_FILE})
endforeach(LANG_SOURCE_FILE)
# Create a new target which compiles all language files
add_custom_target(language_files
DEPENDS
${LANG_BINARY_FILES}
)
set_target_properties(language_files
PROPERTIES LANG_SOURCE_FILES "${LANG_SOURCE_FILES}"
)
set(GENERATED_BINARY_DIR ${CMAKE_BINARY_DIR}/generated)
set(TABLE_BINARY_DIR ${GENERATED_BINARY_DIR}/table)
# Generate a command and target to create the strings table
add_custom_command_timestamp(OUTPUT ${TABLE_BINARY_DIR}/strings.h
COMMAND ${CMAKE_COMMAND} -E make_directory ${TABLE_BINARY_DIR}
COMMAND strgen
-s ${CMAKE_CURRENT_SOURCE_DIR}
-d ${TABLE_BINARY_DIR}
DEPENDS strgen ${LANG_SOURCE_FILES}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating table/strings.h"
)
add_custom_target_timestamp(table_strings
DEPENDS
${TABLE_BINARY_DIR}/strings.h
)
add_library(languages
INTERFACE
)
target_include_directories(languages
INTERFACE
${GENERATED_BINARY_DIR}
)
add_dependencies(languages
language_files
table_strings
)
add_library(openttd::languages ALIAS languages)

View File

@@ -0,0 +1,22 @@
add_files(
demands.cpp
demands.h
flowmapper.cpp
flowmapper.h
init.h
linkgraph.cpp
linkgraph.h
linkgraph_base.h
linkgraph_gui.cpp
linkgraph_gui.h
linkgraph_type.h
linkgraphjob.cpp
linkgraphjob.h
linkgraphjob_base.h
linkgraphschedule.cpp
linkgraphschedule.h
mcf.cpp
mcf.h
refresh.cpp
refresh.h
)

14
src/misc/CMakeLists.txt Normal file
View File

@@ -0,0 +1,14 @@
add_files(
array.hpp
binaryheap.hpp
blob.hpp
countedobj.cpp
countedptr.hpp
dbg_helpers.cpp
dbg_helpers.h
fixedsizearray.hpp
getoptdata.cpp
getoptdata.h
hashtable.hpp
str.hpp
)

54
src/music/CMakeLists.txt Normal file
View File

@@ -0,0 +1,54 @@
if (NOT OPTION_DEDICATED)
add_files(
allegro_m.cpp
allegro_m.h
CONDITION Allegro_FOUND
)
add_files(
fluidsynth.cpp
fluidsynth.h
CONDITION Fluidsynth_FOUND
)
add_files(
cocoa_m.cpp
cocoa_m.h
CONDITION APPLE
)
add_files(
dmusic.cpp
dmusic.h
win32_m.cpp
win32_m.h
CONDITION WIN32
)
add_files(
extmidi.cpp
extmidi.h
CONDITION UNIX
)
add_files(
bemidi.cpp
bemidi.h
CONDITION OPTION_HAIKU
)
add_files(
os2_m.cpp
os2_m.h
CONDITION OPTION_OS2
)
endif (NOT OPTION_DEDICATED)
add_files(
midi.h
midifile.cpp
midifile.hpp
music_driver.hpp
null_m.cpp
null_m.h
)

View File

@@ -0,0 +1,28 @@
add_subdirectory(core)
add_files(
network.cpp
network.h
network_admin.cpp
network_admin.h
network_base.h
network_chat_gui.cpp
network_client.cpp
network_client.h
network_command.cpp
network_content.cpp
network_content.h
network_content_gui.cpp
network_content_gui.h
network_func.h
network_gamelist.cpp
network_gamelist.h
network_gui.cpp
network_gui.h
network_internal.h
network_server.cpp
network_server.h
network_type.h
network_udp.cpp
network_udp.h
)

View File

@@ -0,0 +1,27 @@
add_files(
address.cpp
address.h
config.h
core.cpp
core.h
game.h
host.cpp
host.h
os_abstraction.h
packet.cpp
packet.h
tcp.cpp
tcp.h
tcp_admin.cpp
tcp_admin.h
tcp_connect.cpp
tcp_content.cpp
tcp_content.h
tcp_game.cpp
tcp_game.h
tcp_http.cpp
tcp_http.h
tcp_listen.h
udp.cpp
udp.h
)

4
src/os/CMakeLists.txt Normal file
View File

@@ -0,0 +1,4 @@
add_subdirectory(macosx)
add_subdirectory(os2)
add_subdirectory(unix)
add_subdirectory(windows)

View File

@@ -0,0 +1,11 @@
add_files(
crashlog_osx.cpp
macos.h
macos.mm
osx_stdafx.h
splash.cpp
splash.h
string_osx.cpp
string_osx.h
CONDITION APPLE
)

View File

@@ -0,0 +1,4 @@
add_files(
os2.cpp
CONDITION OPTION_OS2
)

View File

@@ -0,0 +1,9 @@
add_files(
crashlog_unix.cpp
CONDITION UNIX AND NOT APPLE AND NOT OPTION_OS2
)
add_files(
unix.cpp
CONDITION UNIX AND NOT OPTION_OS2
)

View File

@@ -0,0 +1,8 @@
add_files(
crashlog_win.cpp
string_uniscribe.cpp
string_uniscribe.h
win32.cpp
win32.h
CONDITION WIN32
)

View File

@@ -37,7 +37,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_DEFAULT
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
100 ICON DISCARDABLE "../../../media/openttd.ico"
100 ICON DISCARDABLE "${CMAKE_SOURCE_DIR}/os/windows/openttd.ico"
/////////////////////////////////////////////////////////////////////////////
//
@@ -77,8 +77,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,11,0,!!ISODATE!!
PRODUCTVERSION 1,11,0,!!ISODATE!!
FILEVERSION 1,11,0,${REV_ISODATE}
PRODUCTVERSION 1,11,0,${REV_ISODATE}
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -96,14 +96,14 @@ BEGIN
VALUE "Comments", "This program is licensed under the GNU General Public License version 2.\0"
VALUE "CompanyName", "OpenTTD Development Team\0"
VALUE "FileDescription", "OpenTTD\0"
VALUE "FileVersion", "!!VERSION!!\0"
VALUE "FileVersion", "${REV_VERSION}\0"
VALUE "InternalName", "openttd\0"
VALUE "LegalCopyright", "Copyright \xA9 OpenTTD Developers 2002-!!YEAR!!. All Rights Reserved.\0"
VALUE "LegalCopyright", "Copyright \xA9 OpenTTD Developers 2002-${REV_YEAR}. All Rights Reserved.\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "openttd.exe\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "OpenTTD\0"
VALUE "ProductVersion", "!!VERSION!!\0"
VALUE "ProductVersion", "${REV_VERSION}\0"
VALUE "SpecialBuild", "-\0"
END
END
@@ -116,7 +116,7 @@ END
#endif // !_MAC
#ifdef __MINGW32__
1 24 "..\\..\\..\\projects\\dpi_aware.manifest"
1 24 "${CMAKE_SOURCE_DIR}/os/windows/openttd.manifest"
#endif
#endif // Neutral (Default) resources

View File

@@ -0,0 +1,9 @@
add_subdirectory(npf)
add_subdirectory(yapf)
add_files(
follow_track.hpp
pathfinder_func.h
pathfinder_type.h
pf_performance_timer.hpp
)

View File

@@ -0,0 +1,8 @@
add_files(
aystar.cpp
aystar.h
npf.cpp
npf_func.h
queue.cpp
queue.h
)

View File

@@ -0,0 +1,20 @@
add_files(
nodelist.hpp
yapf.h
yapf.hpp
yapf_base.hpp
yapf_cache.h
yapf_common.hpp
yapf_costbase.hpp
yapf_costcache.hpp
yapf_costrail.hpp
yapf_destrail.hpp
yapf_node.hpp
yapf_node_rail.hpp
yapf_node_road.hpp
yapf_node_ship.hpp
yapf_rail.cpp
yapf_road.cpp
yapf_ship.cpp
yapf_type.hpp
)

View File

@@ -35,7 +35,7 @@ bool IsReleasedVersion()
*
* <modified> shows a "M", if the binary is made from modified source code.
*/
const char _openttd_revision[] = "!!VERSION!!";
const char _openttd_revision[] = "${REV_VERSION}";
/**
* The text version of OpenTTD's build date.
@@ -48,12 +48,12 @@ const char _openttd_build_date[] = __DATE__ " " __TIME__;
/**
* The git revision hash of this version.
*/
const char _openttd_revision_hash[] = "!!GITHASH!!";
const char _openttd_revision_hash[] = "${REV_HASH}";
/**
* The year of this version.
*/
const char _openttd_revision_year[] = "!!YEAR!!";
const char _openttd_revision_year[] = "${REV_YEAR}";
/**
* Let us know if current build was modified. This detection
@@ -63,14 +63,14 @@ const char _openttd_revision_year[] = "!!YEAR!!";
* (compiling from sources without any version control software)
* and 2 is for modified revision.
*/
const byte _openttd_revision_modified = !!MODIFIED!!;
const byte _openttd_revision_modified = ${REV_MODIFIED};
/**
* Indicate whether this is a tagged version.
* If this is non-0, then _openttd_revision is the name of the tag,
* and the version is likely a beta, release candidate, or real release.
*/
const byte _openttd_revision_tagged = !!ISTAG!!;
const byte _openttd_revision_tagged = ${REV_ISTAG};
/**
* The NewGRF revision of OTTD:
@@ -85,4 +85,4 @@ const byte _openttd_revision_tagged = !!ISTAG!!;
* final release will always have a lower version number than the released
* version, thus making comparisons on specific revisions easy.
*/
const uint32 _openttd_newgrf_version = 1 << 28 | 11 << 24 | 0 << 20 | !!ISSTABLETAG!! << 19 | 28004;
const uint32 _openttd_newgrf_version = 1 << 28 | 11 << 24 | 0 << 20 | ${REV_ISSTABLETAG} << 19 | 28004;

View File

@@ -0,0 +1,43 @@
add_files(
afterload.cpp
ai_sl.cpp
airport_sl.cpp
animated_tile_sl.cpp
autoreplace_sl.cpp
cargomonitor_sl.cpp
cargopacket_sl.cpp
cheat_sl.cpp
company_sl.cpp
depot_sl.cpp
economy_sl.cpp
engine_sl.cpp
game_sl.cpp
gamelog_sl.cpp
goal_sl.cpp
group_sl.cpp
industry_sl.cpp
labelmaps_sl.cpp
linkgraph_sl.cpp
map_sl.cpp
misc_sl.cpp
newgrf_sl.cpp
newgrf_sl.h
object_sl.cpp
oldloader.cpp
oldloader.h
oldloader_sl.cpp
order_sl.cpp
saveload.cpp
saveload.h
saveload_filter.h
saveload_internal.h
signs_sl.cpp
station_sl.cpp
storage_sl.cpp
strings_sl.cpp
story_sl.cpp
subsidy_sl.cpp
town_sl.cpp
vehicle_sl.cpp
waypoint_sl.cpp
)

23
src/script/CMakeLists.txt Normal file
View File

@@ -0,0 +1,23 @@
add_subdirectory(api)
add_files(
script_config.cpp
script_config.hpp
script_fatalerror.hpp
script_info.cpp
script_info.hpp
script_info_dummy.cpp
script_instance.cpp
script_instance.hpp
script_scanner.cpp
script_scanner.hpp
script_storage.hpp
script_suspend.hpp
squirrel.cpp
squirrel.hpp
squirrel_class.hpp
squirrel_helper.hpp
squirrel_helper_type.hpp
squirrel_std.cpp
squirrel_std.hpp
)

View File

@@ -0,0 +1,140 @@
add_files(
ai_changelog.hpp
game_changelog.hpp
script_accounting.hpp
script_admin.hpp
script_airport.hpp
script_base.hpp
script_basestation.hpp
script_bridge.hpp
script_bridgelist.hpp
script_cargo.hpp
script_cargolist.hpp
script_cargomonitor.hpp
script_client.hpp
script_clientlist.hpp
script_company.hpp
script_companymode.hpp
script_controller.hpp
script_date.hpp
script_depotlist.hpp
script_engine.hpp
script_enginelist.hpp
script_error.hpp
script_event.hpp
script_event_types.hpp
script_execmode.hpp
script_game.hpp
script_gamesettings.hpp
script_goal.hpp
script_group.hpp
script_grouplist.hpp
script_industry.hpp
script_industrylist.hpp
script_industrytype.hpp
script_industrytypelist.hpp
script_info_docs.hpp
script_infrastructure.hpp
script_list.hpp
script_log.hpp
script_map.hpp
script_marine.hpp
script_news.hpp
script_object.hpp
script_order.hpp
script_priorityqueue.hpp
script_rail.hpp
script_railtypelist.hpp
script_road.hpp
script_roadtypelist.hpp
script_sign.hpp
script_signlist.hpp
script_station.hpp
script_stationlist.hpp
script_story_page.hpp
script_storypagelist.hpp
script_storypageelementlist.hpp
script_subsidy.hpp
script_subsidylist.hpp
script_testmode.hpp
script_text.hpp
script_tile.hpp
script_tilelist.hpp
script_town.hpp
script_townlist.hpp
script_tunnel.hpp
script_types.hpp
script_vehicle.hpp
script_vehiclelist.hpp
script_viewport.hpp
script_waypoint.hpp
script_waypointlist.hpp
script_window.hpp
script_accounting.cpp
script_admin.cpp
script_airport.cpp
script_base.cpp
script_basestation.cpp
script_bridge.cpp
script_bridgelist.cpp
script_cargo.cpp
script_cargolist.cpp
script_cargomonitor.cpp
script_client.cpp
script_clientlist.cpp
script_company.cpp
script_companymode.cpp
script_controller.cpp
script_date.cpp
script_depotlist.cpp
script_engine.cpp
script_enginelist.cpp
script_error.cpp
script_event.cpp
script_event_types.cpp
script_execmode.cpp
script_game.cpp
script_gamesettings.cpp
script_goal.cpp
script_group.cpp
script_grouplist.cpp
script_industry.cpp
script_industrylist.cpp
script_industrytype.cpp
script_industrytypelist.cpp
script_infrastructure.cpp
script_list.cpp
script_log.cpp
script_map.cpp
script_marine.cpp
script_news.cpp
script_object.cpp
script_order.cpp
script_priorityqueue.cpp
script_rail.cpp
script_railtypelist.cpp
script_road.cpp
script_roadtypelist.cpp
script_sign.cpp
script_signlist.cpp
script_station.cpp
script_stationlist.cpp
script_story_page.cpp
script_storypagelist.cpp
script_storypageelementlist.cpp
script_subsidy.cpp
script_subsidylist.cpp
script_testmode.cpp
script_text.cpp
script_tile.cpp
script_tilelist.cpp
script_town.cpp
script_townlist.cpp
script_tunnel.cpp
script_vehicle.cpp
script_vehiclelist.cpp
script_viewport.cpp
script_waypoint.cpp
script_waypointlist.cpp
script_window.cpp
)

View File

@@ -0,0 +1,13 @@
cmake_minimum_required(VERSION 3.5)
project(settingsgen)
set(sourcefiles
settingsgen.cpp
../core/alloc_func.cpp
../misc/getoptdata.cpp
../ini_load.cpp
../string.cpp
)
add_definitions(-DSETTINGSGEN)
add_executable(settingsgen ${sourcefiles})

37
src/sound/CMakeLists.txt Normal file
View File

@@ -0,0 +1,37 @@
if (NOT OPTION_DEDICATED)
add_files(
allegro_s.cpp
allegro_s.h
CONDITION Allegro_FOUND
)
add_files(
sdl_s.cpp
sdl_s.h
CONDITION SDL_FOUND
)
add_files(
cocoa_s.cpp
cocoa_s.h
CONDITION APPLE
)
add_files(
win32_s.cpp
win32_s.h
CONDITION WIN32
)
add_files(
xaudio2_s.cpp
xaudio2_s.h
CONDITION WIN32 AND XAUDIO2_FOUND
)
endif (NOT OPTION_DEDICATED)
add_files(
sound_driver.hpp
null_s.cpp
null_s.h
)

View File

@@ -0,0 +1,5 @@
add_files(
grf.cpp
grf.hpp
spriteloader.hpp
)

View File

@@ -424,17 +424,14 @@ void NORETURN CDECL usererror(const char *str, ...) WARN_FORMAT(1, 2);
void NORETURN CDECL error(const char *str, ...) WARN_FORMAT(1, 2);
#define NOT_REACHED() error("NOT_REACHED triggered at line %i of %s", __LINE__, __FILE__)
/* For non-debug builds with assertions enabled use the special assertion handler:
* - For MSVC: NDEBUG is set for all release builds and WITH_ASSERT overrides the disabling of asserts.
* - For non MSVC: NDEBUG is set when assertions are disables, _DEBUG is set for non-release builds.
*/
#if (defined(_MSC_VER) && defined(NDEBUG) && defined(WITH_ASSERT)) || (!defined(_MSC_VER) && !defined(NDEBUG) && !defined(_DEBUG))
/* For non-debug builds with assertions enabled use the special assertion handler. */
#if defined(NDEBUG) && defined(WITH_ASSERT)
#undef assert
#define assert(expression) if (!(expression)) error("Assertion failed at line %i of %s: %s", __LINE__, __FILE__, #expression);
#endif
/* Asserts are enabled if NDEBUG isn't defined, or if we are using MSVC and WITH_ASSERT is defined. */
#if !defined(NDEBUG) || (defined(_MSC_VER) && defined(WITH_ASSERT))
/* Asserts are enabled if NDEBUG isn't defined or WITH_ASSERT is defined. */
#if !defined(NDEBUG) || defined(WITH_ASSERT)
#define OTTD_ASSERT
#endif

25
src/strgen/CMakeLists.txt Normal file
View File

@@ -0,0 +1,25 @@
cmake_minimum_required(VERSION 3.5)
project(strgen)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake")
set(sourcefiles
strgen.cpp
strgen_base.cpp
../core/alloc_func.cpp
../misc/getoptdata.cpp
../string.cpp
)
add_definitions(-DSTRGEN)
add_executable(strgen ${sourcefiles})
include(Endian)
add_endian_definition()
# Source Files
add_files(strgen_base.cpp)
# Header Files
add_files(strgen.h)

83
src/table/CMakeLists.txt Normal file
View File

@@ -0,0 +1,83 @@
set(GENERATED_BINARY_DIR ${CMAKE_BINARY_DIR}/generated)
set(TABLE_BINARY_DIR ${GENERATED_BINARY_DIR}/table)
set(TABLE_INI_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/company_settings.ini
${CMAKE_CURRENT_SOURCE_DIR}/currency_settings.ini
${CMAKE_CURRENT_SOURCE_DIR}/gameopt_settings.ini
${CMAKE_CURRENT_SOURCE_DIR}/misc_settings.ini
${CMAKE_CURRENT_SOURCE_DIR}/settings.ini
${CMAKE_CURRENT_SOURCE_DIR}/win32_settings.ini
${CMAKE_CURRENT_SOURCE_DIR}/window_settings.ini
)
# Generate a command and target to create the settings table
add_custom_command_timestamp(OUTPUT ${TABLE_BINARY_DIR}/settings.h
COMMAND ${CMAKE_COMMAND} -E make_directory ${TABLE_BINARY_DIR}
COMMAND settingsgen
-o ${TABLE_BINARY_DIR}/settings.h
-b ${CMAKE_SOURCE_DIR}/src/table/settings.h.preamble
-a ${CMAKE_SOURCE_DIR}/src/table/settings.h.postamble
${TABLE_INI_SOURCE_FILES}
DEPENDS settingsgen ${TABLE_INI_SOURCE_FILES}
${CMAKE_SOURCE_DIR}/src/table/settings.h.preamble
${CMAKE_SOURCE_DIR}/src/table/settings.h.postamble
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating table/settings.h"
)
add_custom_target_timestamp(table_settings
DEPENDS
${TABLE_BINARY_DIR}/settings.h
)
add_library(settings
INTERFACE
)
target_include_directories(settings
INTERFACE
${GENERATED_BINARY_DIR}
)
add_dependencies(settings
table_settings
)
add_library(openttd::settings ALIAS settings)
add_files(
airport_defaults.h
airport_movement.h
airporttile_ids.h
airporttiles.h
animcursors.h
autorail.h
bridge_land.h
build_industry.h
cargo_const.h
clear_land.h
control_codes.h
elrail_data.h
engines.h
genland.h
heightmap_colours.h
industry_land.h
landscape_sprite.h
newgrf_debug_data.h
object_land.h
palette_convert.h
palettes.h
pricebase.h
railtypes.h
road_land.h
roadtypes.h
roadveh_movement.h
sprites.h
station_land.h
strgen_tables.h
string_colours.h
town_land.h
townname.h
track_land.h
train_cmd.h
tree_land.h
unicode.h
water_land.h
)

35
src/video/CMakeLists.txt Normal file
View File

@@ -0,0 +1,35 @@
add_subdirectory(cocoa)
if (NOT OPTION_DEDICATED)
add_files(
allegro_v.cpp
allegro_v.h
CONDITION Allegro_FOUND
)
add_files(
sdl_v.cpp
sdl_v.h
CONDITION SDL_FOUND
)
add_files(
sdl2_v.cpp
sdl2_v.h
CONDITION SDL2_FOUND
)
add_files(
win32_v.cpp
win32_v.h
CONDITION WIN32
)
endif (NOT OPTION_DEDICATED)
add_files(
dedicated_v.cpp
dedicated_v.h
null_v.cpp
null_v.h
video_driver.hpp
)

View File

@@ -0,0 +1,8 @@
add_files(
cocoa_keys.h
cocoa_v.h
cocoa_v.mm
event.mm
wnd_quartz.mm
CONDITION APPLE
)

View File

@@ -0,0 +1,61 @@
add_files(
ai_widget.h
airport_widget.h
autoreplace_widget.h
bootstrap_widget.h
bridge_widget.h
build_vehicle_widget.h
cheat_widget.h
company_widget.h
console_widget.h
date_widget.h
depot_widget.h
dock_widget.h
dropdown.cpp
dropdown_func.h
dropdown_type.h
dropdown_widget.h
engine_widget.h
error_widget.h
fios_widget.h
framerate_widget.h
genworld_widget.h
goal_widget.h
graph_widget.h
group_widget.h
highscore_widget.h
industry_widget.h
intro_widget.h
link_graph_legend_widget.h
main_widget.h
misc_widget.h
music_widget.h
network_chat_widget.h
network_content_widget.h
network_widget.h
newgrf_debug_widget.h
newgrf_widget.h
news_widget.h
object_widget.h
order_widget.h
osk_widget.h
rail_widget.h
road_widget.h
screenshot_widget.h
settings_widget.h
sign_widget.h
smallmap_widget.h
station_widget.h
statusbar_widget.h
story_widget.h
subsidy_widget.h
terraform_widget.h
timetable_widget.h
toolbar_widget.h
town_widget.h
transparency_widget.h
tree_widget.h
vehicle_widget.h
viewport_widget.h
waypoint_widget.h
)