-
Notifications
You must be signed in to change notification settings - Fork 845
/
CMakeLists.txt
196 lines (175 loc) · 7 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
ADD_DEFINITIONS (-DDEDICATED ${PIC_FLAG} -DNOT_USING_CREG)
ADD_DEFINITIONS (-DHEADLESS -DNO_SOUND)
REMOVE_DEFINITIONS (-DSTREFLOP_SSE -DAVI_CAPTURING)
REMOVE_DEFINITIONS (-DUSE_MMGR -DTRACE_SYNC -DSYNCDEBUG)
# deactivate signaling-NANs for this library
RemoveFlag("-fsignaling-nans")
# Place executables and shared libs under "build-dir/",
# instead of under "build-dir/rts/"
# This way, we have the build-dir structure more like the install-dir one,
# which makes testing spring in the builddir easier, eg. like this:
# cd build-dir
# SPRING_DATADIR=$(pwd) ./spring
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
SET(ENGINE_SRC_ROOT_DIR "${CMAKE_SOURCE_DIR}/rts")
### Assemble libraries
LIST(APPEND engineDedicatedLibraries ${Boost_REGEX_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY})
LIST(APPEND engineDedicatedLibraries 7zip ${SPRING_MINIZIP_LIBRARY} ${ZLIB_LIBRARY} lua)
LIST(APPEND engineDedicatedLibraries headlessStubs)
if (MINGW AND Boost_CHRONO_FOUND)
# in newer boost versions the thread library depends on it
LIST(APPEND engineDedicatedLibraries ${Boost_CHRONO_LIBRARY})
endif (MINGW AND Boost_CHRONO_FOUND)
IF (UNIX)
# Needed for dynamically loading shared libraries (on some OS)
LIST(APPEND engineDedicatedLibraries dl)
ENDIF (UNIX)
IF (MINGW OR APPLE)
# Windows:
# We still need these header files,
# even if we are not going to link with SDL.
# We have them available anyway (mingwlibs).
# OS X:
# Cocoa requires the SDL libary, whenever the SDL headers are used,
# due to some #define magic, which is practically impossible to workaround.
FIND_PACKAGE(SDL REQUIRED)
INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR})
ELSE (MINGW OR APPLE)
# Use a direct copy of the GL and SDL headers,
# as these may not be available on headless systems.
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/SDL)
ENDIF (MINGW OR APPLE)
### Assemble the incude dirs
INCLUDE_DIRECTORIES(${ENGINE_SRC_ROOT_DIR}/)
INCLUDE_DIRECTORIES(${ENGINE_SRC_ROOT_DIR}/lib/lua/include/)
INCLUDE_DIRECTORIES(${ENGINE_SRC_ROOT_DIR}/lib/7zip)
### Assemble sources
IF (UNIX)
SET(sources_engine_Platform_CrashHandler
${ENGINE_SRC_ROOT_DIR}/System/Platform/Threading
${ENGINE_SRC_ROOT_DIR}/System/Platform/Linux/thread_backtrace
${ENGINE_SRC_ROOT_DIR}/System/Platform/Linux/CrashHandler)
ELSEIF (WIN32)
SET(sources_engine_Platform_CrashHandler
${ENGINE_SRC_ROOT_DIR}/System/Platform/Win/seh
${ENGINE_SRC_ROOT_DIR}/System/Platform/Win/CrashHandler)
ELSE ()
SET(sources_engine_Platform_CrashHandler
${ENGINE_SRC_ROOT_DIR}/System/Platform/Threading
${ENGINE_SRC_ROOT_DIR}/System/Platform/Mac/CrashHandler)
ENDIF ()
SET(system_files
${sources_engine_System_FileSystem}
${sources_engine_System_Log}
${sources_engine_System_Net}
${sources_engine_Platform_CrashHandler}
${ENGINE_SRC_ROOT_DIR}/System/Config/ConfigHandler
${ENGINE_SRC_ROOT_DIR}/System/Config/ConfigLocater
${ENGINE_SRC_ROOT_DIR}/System/Config/ConfigSource
${ENGINE_SRC_ROOT_DIR}/System/Config/ConfigVariable
${ENGINE_SRC_ROOT_DIR}/System/CRC
${ENGINE_SRC_ROOT_DIR}/System/Platform/errorhandler
${ENGINE_SRC_ROOT_DIR}/System/Platform/Misc
${ENGINE_SRC_ROOT_DIR}/System/Platform/CmdLineParams
${ENGINE_SRC_ROOT_DIR}/System/Platform/ScopedFileLock
${ENGINE_SRC_ROOT_DIR}/System/Platform/Threading
${ENGINE_SRC_ROOT_DIR}/System/TdfParser
${ENGINE_SRC_ROOT_DIR}/System/GlobalConfig
${ENGINE_SRC_ROOT_DIR}/System/Info
${ENGINE_SRC_ROOT_DIR}/System/LogOutput
${ENGINE_SRC_ROOT_DIR}/System/TimeUtil
${ENGINE_SRC_ROOT_DIR}/System/BaseNetProtocol
${ENGINE_SRC_ROOT_DIR}/System/LoadSave/Demo
${ENGINE_SRC_ROOT_DIR}/System/LoadSave/DemoReader
${ENGINE_SRC_ROOT_DIR}/System/LoadSave/DemoRecorder
${ENGINE_SRC_ROOT_DIR}/System/AutohostInterface
${ENGINE_SRC_ROOT_DIR}/System/SafeCStrings
${ENGINE_SRC_ROOT_DIR}/System/UnsyncedRNG
${ENGINE_SRC_ROOT_DIR}/System/Util
${ENGINE_SRC_ROOT_DIR}/System/float4
${ENGINE_SRC_ROOT_DIR}/System/Log/Backend.cpp
${ENGINE_SRC_ROOT_DIR}/System/Log/DefaultFilter.cpp
${ENGINE_SRC_ROOT_DIR}/System/Log/DefaultFormatter.cpp
${ENGINE_SRC_ROOT_DIR}/System/Log/FramePrefixer.cpp
${ENGINE_SRC_ROOT_DIR}/System/Log/LogSinkHandler.cpp
${ENGINE_SRC_ROOT_DIR}/System/Log/LogUtil.c
${ENGINE_SRC_ROOT_DIR}/System/Log/ConsoleSink.cpp
${ENGINE_SRC_ROOT_DIR}/System/Misc/SpringTime.cpp
)
IF (WIN32)
LIST(APPEND system_files ${ENGINE_SRC_ROOT_DIR}/System/Platform/Win/WinVersion)
ENDIF (WIN32)
SET(engineDedicatedSources
${system_files}
${sources_engine_Game_Server}
${sources_engine_System_Log}
${ENGINE_SRC_ROOT_DIR}/Game/GameServer
${ENGINE_SRC_ROOT_DIR}/Game/ClientSetup
${ENGINE_SRC_ROOT_DIR}/Game/GameSetup
${ENGINE_SRC_ROOT_DIR}/Game/GameData
${ENGINE_SRC_ROOT_DIR}/Game/PlayerBase
${ENGINE_SRC_ROOT_DIR}/Game/PlayerStatistics
${ENGINE_SRC_ROOT_DIR}/Game/GameVersion
${ENGINE_SRC_ROOT_DIR}/Game/IVideoCapturing
${ENGINE_SRC_ROOT_DIR}/Game/DummyVideoCapturing
${ENGINE_SRC_ROOT_DIR}/Game/CommandMessage
${ENGINE_SRC_ROOT_DIR}/Game/ChatMessage
${ENGINE_SRC_ROOT_DIR}/Game/Action
${ENGINE_SRC_ROOT_DIR}/Sim/Misc/TeamBase
${ENGINE_SRC_ROOT_DIR}/Sim/Misc/TeamStatistics
${ENGINE_SRC_ROOT_DIR}/Sim/Misc/AllyTeam
${ENGINE_SRC_ROOT_DIR}/Lua/LuaIO
${ENGINE_SRC_ROOT_DIR}/Lua/LuaParser
${ENGINE_SRC_ROOT_DIR}/Lua/LuaUtils
${ENGINE_SRC_ROOT_DIR}/Map/MapParser
)
# Compile dedicated server shared library
ADD_LIBRARY(springserver-static STATIC EXCLUDE_FROM_ALL ${engineDedicatedSources})
Add_Dependencies(springserver-static generateVersionFiles)
TARGET_LINK_LIBRARIES(springserver-static ${engineDedicatedLibraries})
IF (MINGW)
TARGET_LINK_LIBRARIES (springserver-static ${WS2_32_LIBRARY} ${IMAGEHLP_LIBRARY})
ENDIF (MINGW)
ADD_LIBRARY(springserver SHARED
${ENGINE_SRC_ROOT_DIR}/Map/MapParser
${sources_engine_System_Log_sinkFile}
${sources_engine_System_Log_sinkOutputDebugString}
)
TARGET_LINK_LIBRARIES(springserver springserver-static)
# Compile dedicated server executable
ADD_EXECUTABLE(engine-dedicated
${ENGINE_SRC_ROOT_DIR}/Map/MapParser
${sources_engine_System_Log_sinkConsole}
${sources_engine_System_Log_sinkFile}
${sources_engine_System_Log_sinkOutputDebugString}
main
)
TARGET_LINK_LIBRARIES(engine-dedicated springserver-static)
### Install the executable
INSTALL(TARGETS springserver DESTINATION ${LIBDIR})
INSTALL(TARGETS engine-dedicated DESTINATION ${BINDIR})
SET_TARGET_PROPERTIES(engine-dedicated PROPERTIES OUTPUT_NAME "spring-dedicated")
# Only build & install spring-dedicated executable & dependencies
# use cases:
# * make spring-dedicated
# * make install-spring-dedicated
set(springDsDeps
engine-dedicated
springserver
gamedata
unitsync
)
add_custom_target(spring-dedicated
WORKING_DIRECTORY
"${CMAKE_BINARY_DIR}"
COMMENT
" spring-dedicated: Building all dependencies ..." VERBATIM
)
add_dependencies(spring-dedicated ${springDsDeps}) # This also works for custom targets
set(springDsInstallDirs
"rts/builds/dedicated"
"tools/unitsync"
"cont"
)
CreateInstallTarget(spring-dedicated springDsDeps springDsInstallDirs)