-
Notifications
You must be signed in to change notification settings - Fork 845
/
CMakeLists.txt
121 lines (99 loc) · 4.02 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
# 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")
SET(TRACE_SYNC FALSE CACHE BOOL "Enable sync tracker")
if (TRACE_SYNC)
ADD_DEFINITIONS(-DTRACE_SYNC)
endif (TRACE_SYNC)
SET(SYNCDEBUG FALSE CACHE BOOL "Enable sync debugger (needs SYNCCHECK=true)")
if (SYNCDEBUG)
ADD_DEFINITIONS(-DSYNCDEBUG)
If (NOT "${CMAKE_BUILD_TYPE}" STREQUAL "DEBUG2" AND NOT "${CMAKE_BUILD_TYPE}" STREQUAL "DEBUG3")
Message(FATAL_ERROR "You need CMAKE_BUILD_TYPE set to either DEBUG2 or DEBUG3 for a SYNCDEBUG build")
EndIf ()
If (NOT SYNCCHECK)
Message(FATAL_ERROR "You need SYNCCHECK=TRUE for a SYNCDEBUG build")
EndIf ()
If (NOT TRACE_SYNC)
Message(WARNING "It is recommended to use TRACE_SYNC=TRUE for a SYNCDEBUG build")
EndIf ()
endif (SYNCDEBUG)
# Only used by GML build, but used in builds/GML and lib/gml
SET(USE_GML_DEBUG FALSE CACHE BOOL "Use GML call debugging?")
### give error when not found
FIND_PACKAGE_STATIC(DevIL REQUIRED)
### Assemble common incude dirs
INCLUDE_DIRECTORIES(BEFORE lib/lua/include)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/AL)
INCLUDE_DIRECTORIES(${SPRING_MINIZIP_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
INCLUDE_DIRECTORIES(${DEVIL_INCLUDE_DIR})
### Assemble common libraries
Add_Subdirectory(System/Sound)
if (NO_SOUND)
ADD_DEFINITIONS(-DNO_SOUND)
endif (NO_SOUND)
### Find include directories and add platform specific libraries
IF (UNIX AND NOT MINGW)
IF (PREFER_STATIC_LIBS)
PREFER_STATIC_LIBS()
FIND_LIBRARY(C_LIBRARY c)
FIND_LIBRARY(MATH_LIBRARY m)
#FIND_LIBRARY(PTHREAD_LIBRARY pthread)
#FIND_LIBRARY(OMP_LIBRARY gomp) FIXME it's hidden in some subfolders
UNPREFER_STATIC_LIBS()
LIST(APPEND engineCommonLibraries ${C_LIBRARY} ${MATH_LIBRARY})
#LIST(APPEND engineCommonLibraries ${PTHREAD_LIBRARY} ${OMP_LIBRARY})
ENDIF (PREFER_STATIC_LIBS)
# Needed for dynamically loading shared libraries (on some OS)
LIST(APPEND engineCommonLibraries dl)
ENDIF (UNIX AND NOT MINGW)
FIND_PACKAGE_STATIC(ZLIB REQUIRED)
LIST(APPEND engineCommonLibraries ${DEVIL_IL_LIBRARY} ${JPEG_LIBRARY} ${PNG_LIBRARY} ${TIFF_LIBRARY} ${GIF_LIBRARY})
LIST(APPEND engineCommonLibraries ${Boost_REGEX_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_SIGNALS_LIBRARY} ${Boost_SYSTEM_LIBRARY})
LIST(APPEND engineCommonLibraries 7zip ${SPRING_MINIZIP_LIBRARY} ${ZLIB_LIBRARY})
LIST(APPEND engineCommonLibraries lua luasocket archives streflop assimp)
include_directories(${ZLIB_INCLUDE_DIR})
if (MINGW AND Boost_CHRONO_FOUND)
# in newer boost versions the thread library depends on it
LIST(APPEND engineCommonLibraries ${Boost_CHRONO_LIBRARY})
endif (MINGW AND Boost_CHRONO_FOUND)
IF (WIN32)
LIST(APPEND engineCommonLibraries ${WIN32_LIBRARIES})
ENDIF (WIN32)
FIND_PACKAGE_STATIC(TCMalloc)
set(USE_TCMALLOC TRUE CACHE BOOL "use tcmalloc (part of google's perftools)")
if (USE_TCMALLOC AND TCMALLOC_LIBRARY)
MESSAGE(STATUS "Using tcmalloc")
LIST(APPEND engineCommonLibraries ${TCMALLOC_LIBRARY})
endif (USE_TCMALLOC AND TCMALLOC_LIBRARY)
### Assemble engine sources
Add_Subdirectory(Game)
Add_Subdirectory(Lua)
Add_Subdirectory(ExternalAI)
Add_Subdirectory(Rendering)
Add_Subdirectory(aGui)
Add_Subdirectory(Menu)
Add_Subdirectory(Map)
Add_Subdirectory(Sim)
#Add_Subdirectory(System) # this is already added in ../
SET(engineSources
${sources_engine_Game}
${sources_engine_Lua}
${sources_engine_Map}
${sources_engine_Rendering}
${sources_engine_aGui}
${sources_engine_Menu}
${sources_engine_Sim}
${sources_engine_System}
${sources_engine_ExternalAI}
)
### Add headers for generated project files (e.g. Code::Blocks)
file(GLOB_RECURSE engineHeaders "*.h" "*.hpp")
Add_Subdirectory(builds)