File: CMakeLists.txt

package info (click to toggle)
spring 106.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 55,260 kB
  • sloc: cpp: 543,946; ansic: 44,800; python: 12,575; java: 12,201; awk: 5,889; sh: 1,796; asm: 1,546; xml: 655; perl: 405; php: 211; objc: 194; makefile: 76; sed: 2
file content (145 lines) | stat: -rw-r--r-- 4,439 bytes parent folder | download | duplicates (2)
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
# 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")


option(TRACE_SYNC "Enable sync tracker" FALSE)
if (TRACE_SYNC)
	add_definitions(-DTRACE_SYNC)
endif ()

option(SYNCDEBUG "Enable sync debugger (needs SYNCCHECK=true)" FALSE)
if (SYNCDEBUG)
	add_definitions(-DSYNCDEBUG)
	if     (NOT "${CMAKE_BUILD_TYPE}" STREQUAL "DEBUG")
		message(WARNING "It is recommended to set CMAKE_BUILD_TYPE to DEBUG 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 ()

option(DEBUG_GLSTATE "enable GL_STATE_CHECKER" FALSE)
if(DEBUG_GLSTATE)
	add_definitions(-DDEBUG_GLSTATE)
endif ()

### 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(${IL_INCLUDE_DIR})

### Assemble common libraries
add_subdirectory(System/Sound)
if    (NO_SOUND)
	add_definitions(-DNO_SOUND)
endif ()

### 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 ()

	# Needed for dynamically loading shared libraries (on some OS)
	list(APPEND engineCommonLibraries ${CMAKE_DL_LIBS})

	# Needed for backtrace* on some systems
	if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
		list(APPEND engineCommonLibraries execinfo)
	endif ()
endif ()

find_package_static(ZLIB REQUIRED)
list(APPEND engineCommonLibraries ${IL_LIBRARIES} ${JPEG_LIBRARY} ${PNG_LIBRARY} ${TIFF_LIBRARY} ${GIF_LIBRARY})
list(APPEND engineCommonLibraries 7zip ${SPRING_MINIZIP_LIBRARY} ${ZLIB_LIBRARY})
list(APPEND engineCommonLibraries lua luasocket archives assimp gflags)
if (ENABLE_STREFLOP)
	list(APPEND engineCommonLibraries streflop)
endif ()

include_directories(${ZLIB_INCLUDE_DIR})

if (WIN32)
	list(APPEND engineCommonLibraries ${WIN32_LIBRARIES})
endif ()

if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
	#tcmalloc on freebsd is broken, default disable it (#4754)
	set(USE_TCMALLOC_DEFAULT FALSE)
else ()
	set(USE_TCMALLOC_DEFAULT TRUE)
endif ()

find_package_static(TCMalloc)
option(USE_TCMALLOC "use tcmalloc (part of google's perftools)" ${USE_TCMALLOC_DEFAULT})
if    (USE_TCMALLOC AND TCMALLOC_LIBRARY)
	message(STATUS "Using tcmalloc")
	list(APPEND engineCommonLibraries ${TCMALLOC_LIBRARY})
endif ()


if(UNIX)
	find_package_static(Libunwind REQUIRED)
	list(APPEND engineCommonLibraries ${LIBUNWIND_LIBRARIES})
	if(LIBUNWIND_FOUND)
		message(STATUS "Found libunwind libraries at ${LIBUNWIND_LIBRARIES}")
	else ()
		message(FATAL_ERROR "Couldn't find libunwind")
	endif ()
endif ()



### 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(Net)
add_subdirectory(Sim)
#add_subdirectory(System) # this is already added in ../

make_global_var(engineSources
		${sources_engine_Game}
		${sources_engine_Net}
		${sources_engine_Lua}
		${sources_engine_Map}
		${sources_engine_Rendering}
		${sources_engine_Menu}
		${sources_engine_System}
		${sources_engine_ExternalAI}
	)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib/assimp/include) #FIXME: hack for rts/Rendering/Models/IModelParser.cpp

### Add headers for generated project files (e.g. Code::Blocks)
file(GLOB_RECURSE engineHeaders "*.h" "*.hpp" "*.inl")


add_subdirectory(builds)