-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
292 lines (255 loc) · 8.24 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
# This is just a first try of a CMakeLists.txt. It will certainly not
# make CRRCSim build on much more than a standard linux installation yet.
# It is only meant for dev purposes. Please look at the documentation
# on how to compile/install CRRCSim and so on.
#
# There is a script called cmake.sh for your convenience.
cmake_minimum_required(VERSION 2.4.6)
cmake_policy(VERSION 2.6)
project (crrcsim)
set(CMAKE_PACKAGE_NAME "${PROJECT_NAME}")
set(CMAKE_PACKAGE_VERSION "0.9.12")
INCLUDE (CheckIncludeFiles)
INCLUDE (CheckIncludeFileCXX)
INCLUDE (CheckSymbolExists)
INCLUDE (CheckLibraryExists)
INCLUDE (CheckCXXSourceCompiles)
# uncomment to get verbose output
#set (CMAKE_VERBOSE_MAKEFILE ON)
#
# Host-specific checks
#
if (WIN32)
add_definitions(-DWIN32)
else (WIN32)
if (APPLE)
# Mac OS X
add_definitions(-DMACOSX -DCRRC_DATA_PATH="${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}")
else (APPLE)
add_definitions(-Dlinux -DCRRC_DATA_PATH="${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}")
endif (APPLE)
endif (WIN32)
#
# enable compiler warnings
#
add_definitions(-Wall)
#
#
#
CHECK_INCLUDE_FILES("sys/io.h" HAVE_SYS_IO_H)
#
# Search for a portaudio lib
#
CHECK_INCLUDE_FILES ("portaudio.h" USE_PORTAUDIO)
if (USE_PORTAUDIO)
check_library_exists(portaudio Pa_CountDevices "${PORTAUDIO18_LIBRARY_DIR}" HAVE_PORTAUDIO18)
if (HAVE_PORTAUDIO18)
set(PORTAUDIO_LIBRARIES portaudio)
set(PORTAUDIO 18)
else (HAVE_PORTAUDIO18)
check_library_exists(portaudio Pa_GetDeviceCount "${PORTAUDIO19_LIBRARY_DIR}" HAVE_PORTAUDIO19)
if (HAVE_PORTAUDIO19)
set(PORTAUDIO_LIBRARIES portaudio)
set(PORTAUDIO 19)
else (HAVE_PORTAUDIO19)
check_library_exists(portaudio2 Pa_GetDeviceCount "${PORTAUDIO19_LIBRARY_DIR}" HAVE_PORTAUDIO19)
if (HAVE_PORTAUDIO19)
set(PORTAUDIO_LIBRARIES portaudio2)
set(PORTAUDIO 19)
endif (HAVE_PORTAUDIO19)
endif (HAVE_PORTAUDIO19)
endif (HAVE_PORTAUDIO18)
else (USE_PORTAUDIO)
set(PORTAUDIO 0)
endif (USE_PORTAUDIO)
#
# Search for SDL
#
INCLUDE (FindSDL)
if (SDL_FOUND)
CHECK_SYMBOL_EXISTS(SDL_BUTTON_WHEELUP ${SDL_INCLUDE_DIR}/SDL.h HAS_SDL_MOUSEWHEEL)
if (NOT HAS_SDL_MOUSEWHEEL)
set(SDL_WITHOUT_MOUSEWHEEL 1)
endif (NOT HAS_SDL_MOUSEWHEEL)
else (SDL_FOUND)
message(FATAL_ERROR "SDL not found, but it is needed to compile ${PROJECT_NAME}")
endif (SDL_FOUND)
#
# Search for OpenGL and GLU
#
INCLUDE (FindOpenGL)
if (NOT OPENGL_FOUND OR NOT OPENGL_GLU_FOUND)
message(FATAL_ERROR "OpenGL and GLU not found, but are needed to compile ${PROJECT_NAME}")
endif (NOT OPENGL_FOUND OR NOT OPENGL_GLU_FOUND)
#
# Search for PLIB 1.8.4
#
# PLIB consist of several more or less independent
# components, so we better check each component we need.
# Checking via "CHECK_INCLUDE_FILES" fails because gcc is used instead of g++.
# How to change this?
#SET(PLIB_CHECK_INCLUDE
# "plib/ul.h"
# "plib/sg.h"
# "plib/ssg.h"
# "plib/ssgaSky.h"
# "plib/pu.h"
# "plib/puAux.h")
#CHECK_INCLUDE_FILES (${PLIB_CHECK_INCLUDE} USE_PLIB)
# As the above doesn't work I use a program which determines
# PLIB is >= 1.8.4, which is needed anyway.
#CHECK_CXX_SOURCE_COMPILES("#include <plib/ul.h>
# #include <plib/sg.h>
# #include <plib/ssg.h>
# #include <plib/ssgaSky.h>
# #include <plib/pu.h>
# #include <plib/puAux.h>
# int main(void)
# {
# return 0;
# }
# " USE_PLIB)
#if (NOT USE_PLIB)
# message(FATAL_ERROR "PLIB not found, but is needed to compile ${PROJECT_NAME}")
#endif (NOT USE_PLIB)
TRY_RUN(TEST_RETURNCODE TEST_DID_COMPILE "${CMAKE_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/test_plib.cpp")
if (TEST_DID_COMPILE AND TEST_RETURNCODE EQUAL 42)
set(PLIB_LIBRARIES plibssg plibsg plibpuaux plibpu plibul plibfnt)
else (TEST_DID_COMPILE AND TEST_RETURNCODE EQUAL 42)
message(FATAL_ERROR "PLIB >= 1.8.4 not found, but is needed to compile ${PROJECT_NAME}")
endif (TEST_DID_COMPILE AND TEST_RETURNCODE EQUAL 42)
#
# Check for libjpeg
#
find_package(JPEG)
#
# Check for CGAL
#
SET(CMAKE_REQUIRED_LIBRARIES CGAL)
CHECK_CXX_SOURCE_COMPILES(" #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_3.h>
#include <CGAL/Triangulation_vertex_base_with_info_3.h>
int main(void)
{
return 0;
}
" HAS_CGAL)
if (HAS_CGAL)
set(CGAL_LIBRARIES CGAL)
add_definitions(-frounding-math)
CHECK_INCLUDE_FILE_CXX ("CGAL/assertions_behaviour.h" CGAL_IS_V3)
if (NOT CGAL_IS_V3)
set(CGAL_IS_V3 0)
set(CGAL_MESSAGE "yes (found CGAL > v3)")
else (NOT CGAL_IS_V3)
set(CGAL_MESSAGE "yes (found CGAL v3)")
endif (NOT CGAL_IS_V3)
else (HAS_CGAL)
set(HAS_CGAL 0)
set(CGAL_MESSAGE "no (CGAL not found)")
endif (HAS_CGAL)
#
#
# set variables...
#
#
set(CMAKE_CXX_FLAGS_DEBUG "-g3 -O0")
set(CRRCSIM_INCDIRS ${SDL_INCLUDE_DIR}
${CMAKE_BINARY_DIR}
${HAVE_SYS_IO_H}
)
set(GUI_EXT_INCDIRS ${CRRCSIM_INCDIRS})
set(MOD_CHARDEVICE_EXT_INCDIRS ${CRRCSIM_INCDIRS})
set(MOD_FDM_EXT_INCDIRS ${CRRCSIM_INCDIRS})
set(MOD_INPUTDEV_EXT_INCDIRS ${CRRCSIM_INCDIRS})
set(MOD_LANDSCAPE_EXT_INCDIRS ${CRRCSIM_INCDIRS})
set(MOD_MAIN_EXT_INCDIRS ${CRRCSIM_INCDIRS})
set(MOD_MODE_EXT_INCDIRS ${CRRCSIM_INCDIRS})
set(MOD_WINDFIELD_EXT_INCDIRS ${CRRCSIM_INCDIRS})
set(MOD_VIDEO_EXT_INCDIRS ${CRRCSIM_INCDIRS})
set(CRRCSIM_SRCS
src/aircraft.cpp
src/config.cpp
src/crrc_fdm.cpp
src/crrc_keyboard.cpp
src/crrc_loadair.cpp
src/crrc_main.cpp
src/crrc_sound.cpp
src/crrc_soundserver.cpp
src/crrc_system.cpp
src/CTime.cpp
src/global.cpp
src/ImageLoaderTGA.cpp
src/mouse_kbd.cpp
src/record.cpp
src/robots.cpp
src/SimStateHandler.cpp
src/zoom.cpp
)
add_subdirectory(src/mod_chardevice)
add_subdirectory(src/GUI)
add_subdirectory(src/mod_cntrl)
add_subdirectory(src/mod_env)
add_subdirectory(src/mod_fdm)
add_subdirectory(src/mod_inputdev)
add_subdirectory(src/mod_landscape)
add_subdirectory(src/mod_main)
add_subdirectory(src/mod_math)
add_subdirectory(src/mod_misc)
add_subdirectory(src/mod_mode)
add_subdirectory(src/mod_robots)
add_subdirectory(src/mod_video)
add_subdirectory(src/mod_windfield)
set (CRRCSIM_LIBS
GUI
mod_cntrl
mod_env
mod_fdm
mod_inputdev
mod_video
mod_landscape
mod_main
mod_math
mod_misc
mod_mode
mod_robots
mod_windfield
mod_chardevice
${SDL_LIBRARY}
${OPENGL_LIBRARIES}
${PORTAUDIO_LIBRARIES}
${CGAL_LIBRARIES}
${JPEG_LIBRARIES}
${PLIB_LIBRARIES}
)
include_directories(${CRRCSIM_INCDIRS})
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.h.in ${CMAKE_BINARY_DIR}/crrc_config.h)
add_executable (crrcsim WIN32 ${CRRCSIM_SRCS})
target_link_libraries ( crrcsim ${CRRCSIM_LIBS} )
message("")
message("Build options:")
message("")
message(" Mousewheel support: "${HAS_SDL_MOUSEWHEEL})
message(" Audio interface: "${PORTAUDIO})
message(" Wind data import: "${CGAL_MESSAGE})
message("")
if (PORTAUDIO EQUAL 19)
message("")
message("Attention:")
message("")
message(" Using Portaudio V19 is not recommended by the CRRCsim team. If")
message(" you experience frequent crashes when using the audio")
message(" interface, please install Portaudio V18 and recompile CRRCsim.")
message("")
endif (PORTAUDIO EQUAL 19)
INSTALL(TARGETS crrcsim
RUNTIME DESTINATION bin)
INSTALL(DIRECTORY models/ DESTINATION share/${PROJECT_NAME}/models)
INSTALL(DIRECTORY objects/ DESTINATION share/${PROJECT_NAME}/objects)
INSTALL(DIRECTORY scenery/ DESTINATION share/${PROJECT_NAME}/scenery)
INSTALL(DIRECTORY sounds/ DESTINATION share/${PROJECT_NAME}/sounds)
INSTALL(DIRECTORY textures/ DESTINATION share/${PROJECT_NAME}/textures)
INSTALL(DIRECTORY documentation/ DESTINATION share/doc/${PROJECT_NAME}
PATTERN "Makefile" EXCLUDE
PATTERN "Makefile.in" EXCLUDE
PATTERN "Makefile.am" EXCLUDE)