forked from beyond-all-reason/spring
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
186 lines (164 loc) · 7.12 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
add_definitions (-DDEDICATED ${PIC_FLAG} -DNOT_USING_CREG)
add_definitions (-DHEADLESS -DNO_SOUND)
remove_definitions (-DSTREFLOP_SSE -DAVI_CAPTURING)
remove_definitions (-DTRACE_SYNC -DSYNCDEBUG)
remove_definitions (-DTHREADPOOL)
# deactivate signaling-NANs for this library
remove_flag("-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 cpuid)
list(APPEND engineDedicatedLibraries ${Boost_REGEX_LIBRARY})
list(APPEND engineDedicatedLibraries lua archives 7zip prd::jsoncpp ${SPRING_MINIZIP_LIBRARY} ${ZLIB_LIBRARY} gflags Tracy::TracyClient)
list(APPEND engineDedicatedLibraries headlessStubs engineSystemNet)
list(APPEND engineDedicatedLibraries ${LIBUNWIND_LIBRARIES})
list(APPEND engineDedicatedLibraries ${LZMA_LIBRARY})
### smmalloc
list(APPEND engineDedicatedLibraries "smmalloc")
if (WIN32)
list(APPEND engineDedicatedLibraries ${WINMM_LIBRARY})
endif (WIN32)
if (UNIX AND NOT MINGW)
if (PREFER_STATIC_LIBS)
list(APPEND engineDedicatedLibraries ${C_LIBRARY} ${MATH_LIBRARY} ${REALTIME_LIBRARY})
endif (PREFER_STATIC_LIBS)
# Needed for dynamically loading shared libraries (on some OS)
list(APPEND engineDedicatedLibraries ${CMAKE_DL_LIBS})
# Needed for backtrace* on some systems
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
list(APPEND engineDedicatedLibraries execinfo)
endif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
endif (UNIX AND NOT MINGW)
find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIR})
if("${SDL2_VERSION_STRING}" VERSION_LESS "2")
message(FATAL_ERROR "Found SDL v${SDL2_VERSION_STRING} while 2 is required!")
endif()
### 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)
include_directories(${ENGINE_SRC_ROOT_DIR}/lib/asio/include)
### Assemble sources
if (APPLE)
set(sources_engine_Platform_CrashHandler
${ENGINE_SRC_ROOT_DIR}/System/Platform/CpuID.cpp
${ENGINE_SRC_ROOT_DIR}/System/Platform/Threading.cpp
${ENGINE_SRC_ROOT_DIR}/System/Platform/Mac/CrashHandler.cpp)
elseif (WIN32)
set(sources_engine_Platform_CrashHandler
${ENGINE_SRC_ROOT_DIR}/System/Platform/Win/seh.cpp
${ENGINE_SRC_ROOT_DIR}/System/Platform/Win/CrashHandler.cpp)
else ()
set(sources_engine_Platform_CrashHandler
${ENGINE_SRC_ROOT_DIR}/System/Platform/CpuID.cpp
${ENGINE_SRC_ROOT_DIR}/System/Platform/Threading.cpp
${ENGINE_SRC_ROOT_DIR}/System/Platform/Linux/CrashHandler.cpp
${ENGINE_SRC_ROOT_DIR}/System/Platform/Linux/ThreadSupport.cpp)
endif ()
set(system_files
${sources_engine_System_FileSystem}
${sources_engine_System_Threading}
${sources_engine_System_Log}
${sources_engine_Platform_CrashHandler}
${ENGINE_SRC_ROOT_DIR}/Net/AutohostInterface.cpp
${ENGINE_SRC_ROOT_DIR}/System/Config/ConfigHandler.cpp
${ENGINE_SRC_ROOT_DIR}/System/Config/ConfigLocater.cpp
${ENGINE_SRC_ROOT_DIR}/System/Config/ConfigSource.cpp
${ENGINE_SRC_ROOT_DIR}/System/Config/ConfigVariable.cpp
${ENGINE_SRC_ROOT_DIR}/System/LoadSave/Demo.cpp
${ENGINE_SRC_ROOT_DIR}/System/LoadSave/DemoReader.cpp
${ENGINE_SRC_ROOT_DIR}/System/LoadSave/DemoRecorder.cpp
${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/Log/TracySink.cpp
${ENGINE_SRC_ROOT_DIR}/System/Misc/SpringTime.cpp
${ENGINE_SRC_ROOT_DIR}/System/Platform/errorhandler.cpp
${ENGINE_SRC_ROOT_DIR}/System/Platform/CpuID.cpp
${ENGINE_SRC_ROOT_DIR}/System/Platform/Misc.cpp
${ENGINE_SRC_ROOT_DIR}/System/Platform/ScopedFileLock.cpp
${ENGINE_SRC_ROOT_DIR}/System/Platform/Threading.cpp
${ENGINE_SRC_ROOT_DIR}/System/Sync/SHA512.cpp
${ENGINE_SRC_ROOT_DIR}/System/CRC.cpp
${ENGINE_SRC_ROOT_DIR}/System/TdfParser.cpp
${ENGINE_SRC_ROOT_DIR}/System/GlobalConfig.cpp
${ENGINE_SRC_ROOT_DIR}/System/Info.cpp
${ENGINE_SRC_ROOT_DIR}/System/LogOutput.cpp
${ENGINE_SRC_ROOT_DIR}/System/TimeUtil.cpp
${ENGINE_SRC_ROOT_DIR}/System/SafeCStrings.c
${ENGINE_SRC_ROOT_DIR}/System/SafeVector.cpp
${ENGINE_SRC_ROOT_DIR}/System/UriParser.cpp
${ENGINE_SRC_ROOT_DIR}/System/StringUtil.cpp
${ENGINE_SRC_ROOT_DIR}/System/float4.cpp
)
if (WIN32)
list(APPEND system_files ${ENGINE_SRC_ROOT_DIR}/System/Platform/Win/WinVersion.cpp)
endif (WIN32)
set(engineDedicatedSources
${system_files}
${sources_engine_NetServer}
${sources_engine_System_Log}
${ENGINE_SRC_ROOT_DIR}/Game/ClientSetup.cpp
${ENGINE_SRC_ROOT_DIR}/Game/GameSetup.cpp
${ENGINE_SRC_ROOT_DIR}/Game/GameData.cpp
${ENGINE_SRC_ROOT_DIR}/Game/Players/PlayerBase.cpp
${ENGINE_SRC_ROOT_DIR}/Game/Players/PlayerStatistics.cpp
${ENGINE_SRC_ROOT_DIR}/Game/GameVersion.cpp
${ENGINE_SRC_ROOT_DIR}/Game/IVideoCapturing.cpp
${ENGINE_SRC_ROOT_DIR}/Game/DummyVideoCapturing.cpp
${ENGINE_SRC_ROOT_DIR}/Game/CommandMessage.cpp
${ENGINE_SRC_ROOT_DIR}/Game/ChatMessage.cpp
${ENGINE_SRC_ROOT_DIR}/Game/Action.cpp
${ENGINE_SRC_ROOT_DIR}/Sim/Misc/TeamBase.cpp
${ENGINE_SRC_ROOT_DIR}/Sim/Misc/TeamStatistics.cpp
${ENGINE_SRC_ROOT_DIR}/Sim/Misc/AllyTeam.cpp
${ENGINE_SRC_ROOT_DIR}/Sim/Units/CommandAI/Command.cpp ## LuaUtils::ParseCommand*
${ENGINE_SRC_ROOT_DIR}/Lua/LuaConstEngine.cpp
${ENGINE_SRC_ROOT_DIR}/Lua/LuaIO.cpp
${ENGINE_SRC_ROOT_DIR}/Lua/LuaMemPool.cpp
${ENGINE_SRC_ROOT_DIR}/Lua/LuaParser.cpp
${ENGINE_SRC_ROOT_DIR}/Lua/LuaUtils.cpp
${ENGINE_SRC_ROOT_DIR}/Map/MapParser.cpp
)
# Compile dedicated server executable
add_executable(engine-dedicated
${ENGINE_SRC_ROOT_DIR}/Map/MapParser.cpp
${engineDedicatedSources}
${sources_engine_System_Log_sinkConsole}
${sources_engine_System_Log_sinkFile}
${sources_engine_System_Log_sinkOutputDebugString}
${ENGINE_ICON}
main.cpp
)
target_link_libraries(engine-dedicated ${engineDedicatedLibraries})
if (MINGW)
target_link_libraries(engine-dedicated ${WS2_32_LIBRARY} ${IMAGEHLP_LIBRARY} ${IPHLPAPI_LIBRARY} ${WINMM_LIBRARY})
endif (MINGW)
if (MSVC)
target_link_libraries(engine-dedicated ${DBGHELP_LIBRARY})
set_property(TARGET engine-dedicated PROPERTY EXCLUDE_FROM_DEFAULT_BUILD_DEBUG TRUE)
endif (MSVC)
add_dependencies(engine-dedicated generateVersionFiles)
if (MINGW)
# To enable console output/force a console window to open
set_target_properties(engine-dedicated PROPERTIES LINK_FLAGS "-Wl,-subsystem,console")
endif (MINGW)
install(TARGETS engine-dedicated DESTINATION ${BINDIR})
# Only build & install spring-dedicated executable & dependencies
# use cases:
# * make spring-dedicated
# * make install-spring-dedicated
create_engine_build_and_install_target(dedicated)