forked from RigsOfRods/ror-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
98 lines (79 loc) · 3.91 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
# ensure cmake features we need
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0)
if (COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif (COMMAND cmake_policy)
# done with cmake check
project(rorserver)
# setup paths
SET(RUNTIME_OUTPUT_DIRECTORY "${rorserver_SOURCE_DIR}/bin/")
SET(LIBRARY_OUTPUT_DIRECTORY "${rorserver_SOURCE_DIR}/lib/")
SET(ARCHIVE_OUTPUT_DIRECTORY "${rorserver_SOURCE_DIR}/lib/")
SET(EXECUTABLE_OUTPUT_PATH ${RUNTIME_OUTPUT_DIRECTORY})
SET(LIBRARY_OUTPUT_PATH ${RUNTIME_OUTPUT_DIRECTORY})
# hide some settings
mark_as_advanced(
CMAKE_DEBUG_POSTFIX
CMAKE_BACKWARDS_COMPATIBILITY
EXECUTABLE_OUTPUT_PATH
LIBRARY_OUTPUT_PATH
)
if (WIN32)
# add multi processor compilation flags
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MP /GL /Ox /Ob2 /Oi /Ot /Oy /fp:fast /GS- /MP /Zi")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MP /Zi")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MP /Od /Zi")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MP /Od /Zi")
# some general flags
add_definitions("-D_CRT_SECURE_NO_WARNINGS")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /DEBUG ")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /LTCG /OPT:REF")
set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} /DEBUG /LTCG /OPT:REF")
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /DEBUG /LTCG /OPT:REF")
ELSEIF (UNIX)
set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og -g -Wall")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -DNDEBUG -Wno-deprecated-declarations -Wno-attributes")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 -g -Wno-deprecated-declarations -Wno-attributes")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -Os -DNDEBUG")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}")
# add additional gdb debugging stuff
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -Og -ggdb")
set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG} -Og -ggdb")
endif (WIN32)
# fix executable paths for windows
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${RUNTIME_OUTPUT_DIRECTORY})
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${RUNTIME_OUTPUT_DIRECTORY})
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${RUNTIME_OUTPUT_DIRECTORY})
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${RUNTIME_OUTPUT_DIRECTORY})
# some additional compiler flags
IF (NOT WIN32)
ADD_DEFINITIONS(-Wall)
endif ()
#options
option(RORSERVER_GUI "build server GUI, experimental" FALSE)
option(RORSERVER_WITH_ANGELSCRIPT "adds scripting support" FALSE)
option(RORSERVER_WITH_WEBSERVER "adds the webserver" FALSE)
IF (NOT WIN32)
option(RORSERVER_CRASHHANDLER "enables linux startup script crashhandling" FALSE)
FIND_PROGRAM(GDB_EXECUTABLE gdb)
IF (NOT GDB_EXECUTABLE)
message("gdb not found, crashhandler disabled")
set(RORSERVER_CRASHHANDLER FALSE)
ENDIF ()
mark_as_advanced(GDB_EXECUTABLE)
endif ()
add_subdirectory("dependencies/socketw")
add_subdirectory("dependencies/jsoncpp")
add_subdirectory("source/server")
if (RORSERVER_WITH_ANGELSCRIPT)
add_subdirectory("dependencies/angelscript")
endif (RORSERVER_WITH_ANGELSCRIPT)
if (RORSERVER_GUI)
add_subdirectory("source/gui")
endif (RORSERVER_GUI)
if (RORSERVER_WITH_WEBSERVER)
add_subdirectory("dependencies/ctemplate")
endif (RORSERVER_WITH_WEBSERVER)