]> icculus.org git repositories - taylor/freespace2.git/blob - CMakeLists.txt
vector/matrix initialization that MSVC is happy with
[taylor/freespace2.git] / CMakeLists.txt
1
2 project(freespace2)
3
4 cmake_minimum_required(VERSION 2.8)
5
6 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
7
8
9 find_package(SDL2 "2.0.1" REQUIRED)
10 find_package(OpenGL REQUIRED)
11 find_package(OpenAL REQUIRED)
12
13 find_package(wxWidgets COMPONENTS core base gl)
14 include(${wxWidgets_USE_FILE})
15
16
17 # ##############################################################################
18
19 option(FS1 "Build original FreeSpace" OFF)
20 option(DEMO "Create demo build" OFF)
21
22 if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
23   message(STATUS "Setting build type to 'Debug' as none was specified.")
24   set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
25   # Set the possible values of build type for cmake-gui
26   set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
27     "MinSizeRel" "RelWithDebInfo")
28 endif()
29
30
31 if(FS1)
32   add_definitions(-DMAKE_FS1)
33
34   if(DEMO)
35         add_definitions(-DDEMO -DFS1_DEMO)
36   endif()
37 else()
38   if(DEMO)
39         add_definitions(-DFS2_DEMO)
40   endif()
41 endif()
42
43 if(NOT WIN32)
44   set(PLATFORM_LIBRARIES "")
45
46   add_definitions(-DPLAT_UNIX)
47   add_definitions(-Wall -Wno-format-y2k -Wno-deprecated)
48   add_definitions(-fsigned-char)
49
50   set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DNDEBUG -g -O2")
51   set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -DNDEBUG -Os")
52   set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -O2")
53   set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3")
54 else()
55   set(PLATFORM_LIBRARIES
56         wsock32.lib
57         winmm.lib
58   )
59 endif()
60
61
62 # ##############################################################################
63
64
65 include_directories(
66   ${PROJECT_SOURCE_DIR}/include
67   ${SDL2_INCLUDE_DIR}
68   ${OPENAL_INCLUDE_DIR}
69   ${wxWidgets_INCLUDE_DIRS}
70 )
71
72
73 add_subdirectory(src)
74 add_subdirectory(include)
75
76
77 # ##############################################################################
78 #
79
80 #
81 # main code/game library
82 #
83
84 add_library(code
85   STATIC
86   ${code_SOURCE}
87   ${code_HEADERS}
88   ${platform_SOURCE}
89 )
90
91 #
92 # the game itself
93 #
94
95 if(FS1)
96   if(DEMO)
97     set(FS_BINARY freespace_demo)
98   else()
99     set(FS_BINARY freespace)
100   endif()
101 else()
102   if(DEMO)
103     set(FS_BINARY freespace2_demo)
104   else()
105         set(FS_BINARY freespace2)
106   endif()
107 endif()
108
109 add_executable(${FS_BINARY}
110   WIN32
111   ${freespace_SOURCE}
112   ${freespace_HEADERS}
113 )
114
115 target_link_libraries(
116   ${FS_BINARY}
117   code
118   ${SDL2_LIBRARY}
119   ${OPENGL_LIBRARIES}
120   ${OPENAL_LIBRARY}
121   ${PLATFORM_LIBRARIES}
122 )
123
124 #
125 # ##############################################################################
126
127 # ##############################################################################
128 #
129 # toolset: targets for creating/modifying game assets
130 #
131
132 #
133 # AC: anim converter
134 #
135
136 add_executable(ac
137   EXCLUDE_FROM_ALL
138   ${ac_SOURCE}
139   ${ac_HEADERS}
140 )
141
142 target_link_libraries(
143   ac
144   code
145   ${SDL2_LIBRARY}
146   ${OPENGL_LIBRARIES}
147   ${OPENAL_LIBRARY}
148 )
149
150 #
151 # CFILEARCHIVER: to create VP file archives
152 #
153
154 add_executable(cfilearchiver
155   EXCLUDE_FROM_ALL
156   ${cfilearchiver_SOURCE}
157 )
158
159 #
160 # CRYPTSTRING: string encryption (for embedded cheat codes)
161 #
162
163 add_executable(cryptstring
164   EXCLUDE_FROM_ALL
165   ${cryptstring_SOURCE}
166 )
167
168 #
169 # NEBEDIT: FS1 style nebula editor/creator
170 #
171
172 add_executable(nebedit
173   EXCLUDE_FROM_ALL
174   WIN32
175   ${nebedit_SOURCE}
176 )
177
178 target_link_libraries(
179   nebedit
180   code
181   ${SDL2_LIBRARY}
182   ${OPENGL_LIBRARIES}
183   ${OPENAL_LIBRARY}
184   ${wxWidgets_LIBRARIES}
185 )
186
187 #
188 # POFVIEW: model viewer
189 #
190
191 add_executable(pofview
192   EXCLUDE_FROM_ALL
193   WIN32
194   ${pofview_SOURCE}
195   ${pofview_HEADERS}
196 )
197
198 target_link_libraries(
199   pofview
200   code
201   ${SDL2_LIBRARY}
202   ${OPENGL_LIBRARIES}
203   ${OPENAL_LIBRARY}
204   ${wxWidgets_LIBRARIES}
205 )
206
207 # wxWidgets appears to need c++11 for one or more headers
208 if(NOT WIN32)
209   set_target_properties(pofview PROPERTIES COMPILE_FLAGS -std=c++11)
210 endif()
211
212 #
213 # SCRAMBLE: file-based encryption for TBLs
214 #
215
216 add_executable(scramble
217   EXCLUDE_FROM_ALL
218   ${scramble_SOURCE}
219   ${scramble_HEADERS}
220 )
221
222 #
223 # FONTTOOL: create font files / edit kerning data
224 #
225
226 add_executable(fonttool
227   EXCLUDE_FROM_ALL
228   WIN32
229   ${fonttool_SOURCE}
230   ${fonttool_HEADERS}
231 )
232
233 # background setup, to allow running from build location without installing
234 add_custom_command(TARGET fonttool
235   POST_BUILD
236   COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/src/fonttool"
237   COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/src/fonttool/fonttool.pcx" "${CMAKE_CURRENT_BINARY_DIR}/src/fonttool"
238 )
239
240 target_link_libraries(
241   fonttool
242   code
243   ${SDL2_LIBRARY}
244   ${OPENGL_LIBRARIES}
245   ${OPENAL_LIBRARY}
246 )
247
248 #
249 # custom target to build all tools in one pass
250 #
251
252 add_custom_target(tools)
253
254 add_dependencies(tools
255   ac
256   cfilearchiver
257   cryptstring
258   nebedit
259   pofview
260   scramble
261   fonttool
262 )
263
264 #
265 # ##############################################################################
266
267 #
268 # optionally include any dev/user preferred build commands and/or options
269 #
270
271 include(custom.cmake OPTIONAL)