-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
132 lines (107 loc) · 5.11 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
project(ColdestAZ CXX C)
cmake_minimum_required(VERSION 2.6)
cmake_policy(VERSION 2.6)
#TODO: Project version handling
set(PROJECT_VERSION "99999")
set(EXENAME coldestaz)
# Allow control over what to build
option(BUILD_CLIENT "Build the main game." ON)
option(BUILD_DEDICATED_SERVER "Build dedicated server." OFF)
option(BUILD_MASTER_SERVER "Build master server." OFF)
option(CHECKED_ITERATORS "Checked iterators." OFF)
option(NO_OMIT_FRAME_POINTER "Don't omit frame pointer." OFF)
# Avoid source tree pollution
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "In-source builds are not permitted. Make a separate folder for building:\nmkdir build; cd build; cmake ..\nBefore that, remove the files already created:\nrm -rf CMakeCache.txt CMakeFiles")
endif(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
# Where are our modules stored
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
# Add a sensible build type default and warning because empty means no optimization and no debug info
if(NOT CMAKE_BUILD_TYPE)
message("WARNING: CMAKE_BUILD_TYPE is not defined!\n Defaulting to CMAKE_BUILD_TYPE=RelWithDebInfo. Use ccmake to set a proper value.")
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif(NOT CMAKE_BUILD_TYPE)
# Set default compile flags for GCC
if(CMAKE_COMPILER_IS_GNUCXX)
message(STATUS "GCC detected, adding compile flags")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-missing-field-initializers -Wno-deprecated")
# -pthread is unrecognized on Windows and ansi standard causes errors
if(NOT WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98 -pthread")
if (CHECKED_ITERATORS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_DEBUG")
endif (CHECKED_ITERATORS)
if (NO_OMIT_FRAME_POINTER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer")
endif (NO_OMIT_FRAME_POINTER)
endif(NOT WIN32)
endif(CMAKE_COMPILER_IS_GNUCXX)
# Sources
file(GLOB GUI_SOURCES gui/*.cpp) # GUI is nicely in its own directory so let's GLOB it
set(COMMON_SOURCES
coldest.cpp Vector3.cpp GraphicMatrix.cpp CollisionDetection.cpp
Particle.cpp ProceduralTree.cpp Hit.cpp Vertex.cpp
Console.cpp server.cpp IDGen.cpp Weapon.cpp Recorder.cpp Replayer.cpp
ObjectKDTree.cpp Packet.cpp MeshData.cpp
Timer.cpp ServerInfo.cpp ParticleEmitter.cpp StableRandom.cpp
renderdefs.cpp globals.cpp PlayerData.cpp Log.cpp logout.cpp
NTreeReader.cpp Material.cpp ResourceManager.cpp Mesh.cpp Triangle.cpp
Quad.cpp MeshNode.cpp ServerState.cpp MeshCache.cpp tsint.cpp Bot.cpp
Item.cpp util.cpp Mutex.cpp Map.cpp NetCode.cpp ServerNetCode.cpp BotNetCode.cpp
SoundSource.cpp PathNode.cpp
)
set(CLIENT_SOURCES
actions.cpp ALBuffer.cpp ALSource.cpp Camera.cpp editor.cpp FBO.cpp Light.cpp
render.cpp settings.cpp Shader.cpp SoundManager.cpp TextureHandler.cpp
Updater.cpp ClientMap.cpp ClientNetCode.cpp VBO.cpp TextureManager.cpp
)
set(DEDICATED_SERVER_SOURCES "") # Nothing apparently
set(MASTER_SERVER_SOURCES
master.cpp util.cpp Packet.cpp ServerInfo.cpp Vector3.cpp GraphicMatrix.cpp
tsint.cpp logout.cpp Log.cpp IDGen.cpp
)
# Libraries
# Boost
find_package(Boost 1.35 REQUIRED COMPONENTS filesystem system)
include_directories(${Boost_INCLUDE_DIRS})
list(APPEND LIBS ${Boost_LIBRARIES})
list(APPEND CLIENTLIBS ${Boost_LIBRARIES})
set(FINDLIBS SDL SDL_image SDL_net SDL_ttf XercesC CURL)
# These aren't needed (and cause problems) for the dedicated server
set(FINDCLIENTLIBS GLEW OpenGL OpenAL ALUT OGG Vorbis VorbisFile)
# Find all the libs that don't require extra parameters
foreach(lib ${FINDLIBS})
find_package(${lib} REQUIRED)
include_directories(${${lib}_INCLUDE_DIRS})
list(APPEND LIBS ${${lib}_LIBRARIES})
list(APPEND CLIENTLIBS ${${lib}_LIBRARIES})
add_definitions(${${lib}_DEFINITIONS})
# Poor modules don't do this automatically :(
mark_as_advanced(${lib}_INCLUDE_DIRS ${lib}_LIBRARIES ${lib}_LIBRARIES_DEBUG)
endforeach(lib)
# Client only libs
foreach(lib ${FINDCLIENTLIBS})
find_package(${lib} REQUIRED)
include_directories(${${lib}_INCLUDE_DIRS})
list(APPEND CLIENTLIBS ${${lib}_LIBRARIES})
add_definitions(${${lib}_DEFINITIONS})
# Poor modules don't do this automatically :(
mark_as_advanced(${lib}_INCLUDE_DIRS ${lib}_LIBRARIES ${lib}_LIBRARIES_DEBUG)
endforeach(lib)
# Master server has fewer deps
list(APPEND MASTER_SERVER_LIBS ${SDL_LIBRARIES} ${SDL_net_LIBRARIES})
# Targets
if(BUILD_CLIENT)
add_executable(${EXENAME} ${CLIENT_SOURCES} ${COMMON_SOURCES} ${GUI_SOURCES})
set_target_properties(${EXENAME} PROPERTIES COMPILE_FLAGS "-UDEDICATED")
target_link_libraries(${EXENAME} ${CLIENTLIBS})
endif(BUILD_CLIENT)
if(BUILD_DEDICATED_SERVER)
add_executable(cazserver ${DEDICATED_SERVER_SOURCES} ${COMMON_SOURCES})
set_target_properties(cazserver PROPERTIES COMPILE_FLAGS "-DDEDICATED")
target_link_libraries(cazserver ${LIBS})
endif(BUILD_DEDICATED_SERVER)
if(BUILD_MASTER_SERVER)
add_executable(cazmaster ${MASTER_SERVER_SOURCES})
target_link_libraries(cazmaster ${MASTER_SERVER_LIBS})
endif(BUILD_MASTER_SERVER)