-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
390 lines (321 loc) · 13.6 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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
cmake_minimum_required (VERSION 2.6.4)
include (CheckFunctionExists)
include (CheckCSourceCompiles)
include (CheckCXXSourceCompiles)
include (CheckIncludeFile)
project(FlightGear)
# We have some custom .cmake scripts not in the official distribution.
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}")
if(${CMAKE_VERSION} VERSION_GREATER 2.8.4)
# use official include provided by latest CMake
include(GNUInstallDirs)
else(${CMAKE_VERSION} VERSION_GREATER 2.8.4)
# backward compatibility: use our own module for older cmake versions
include(OldGNUInstallDirs)
endif(${CMAKE_VERSION} VERSION_GREATER 2.8.4)
# Warning when build is not an out-of-source build.
string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" InSourceBuild)
if(InSourceBuild)
message(WARNING "Avoid building inside the source tree!")
message(WARNING "Create a separate build directory instead (i.e. 'fgbuild') and call CMake from there: ")
message(WARNING " mkdir ../fgbuild && cd ../fgbuild && cmake ${CMAKE_SOURCE_DIR}")
endif(InSourceBuild)
# System detection/default settings
include( DetectDistro )
include( DetectBrowser )
set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually d on windows")
set(CMAKE_RELEASE_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
set(CMAKE_RELWITHDEBINFO_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
set(CMAKE_MINSIZEREL_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
# read 'version' file into a variable (stripping any newlines or spaces)
file(READ version versionFile)
if (NOT versionFile)
message(FATAL_ERROR "Unable to determine FlightGear version. Version file is missing.")
endif()
string(STRIP "${versionFile}" FLIGHTGEAR_VERSION)
# FlightGear packaging (to build a source tarball)
include( ConfigureCPack )
# FlightGear base package path
if (FG_DATA_DIR)
message(STATUS "Using explicit data directory for base package: ${FG_DATA_DIR}")
else()
set(FG_DATA_DIR "${CMAKE_INSTALL_PREFIX}/lib/FlightGear" CACHE PATH "Default location where data files are located")
message(STATUS "Using default data directory for base package: ${FG_DATA_DIR}")
endif()
# Change the default build type to something fast
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif(NOT CMAKE_BUILD_TYPE)
if(NOT "$ENV{BUILD_ID}" STREQUAL "")
set(HUDSON_BUILD_ID $ENV{BUILD_ID})
set(HUDSON_BUILD_NUMBER $ENV{BUILD_NUMBER})
message(STATUS "running under Hudson/Jenkins, build-number is ${HUDSON_BUILD_NUMBER}")
else()
set(HUDSON_BUILD_NUMBER 0)
set(HUDSON_BUILD_ID "none")
endif()
#####################################################################################
# Configure library search paths
#####################################################################################
if(APPLE)
# Custom library directories for Mac, which should have precedence over any other
list(APPEND ADDITIONAL_LIBRARY_PATHS
~/Library/Frameworks
/Library/Frameworks)
endif(APPLE)
if(NOT "${CMAKE_LIBRARY_ARCHITECTURE}" STREQUAL "")
# Workaround for Ubuntu/Debian which introduced the "multiarch" library
# directory structure, which is unsupported by CMake < 2.8.10, so we need to
# add paths manually
# see http://www.cmake.org/Bug/view.php?id=12049 and
# http://www.cmake.org/Bug/view.php?id=12037
list(APPEND ADDITIONAL_LIBRARY_PATHS
/usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE}
/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}
/lib/${CMAKE_LIBRARY_ARCHITECTURE})
message(STATUS "additional library directories: ${ADDITIONAL_LIBRARY_PATHS}")
endif()
if(NOT MSVC)
# TBD: are these really necessary? Aren't they considered by cmake automatically?
list(APPEND ADDITIONAL_LIBRARY_PATHS
/opt/local
/usr/local
/usr)
endif()
#####################################################################################
IF(APPLE)
set(EVENT_INPUT_DEFAULT 1)
find_library(CORESERVICES_LIBRARY CoreServices)
find_library(COCOA_LIBRARY Cocoa)
list(APPEND PLATFORM_LIBS ${COCOA_LIBRARY} ${CORESERVICES_LIBRARY})
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
find_package(UDev)
if(UDEV_FOUND)
set(EVENT_INPUT_DEFAULT 1)
endif(UDEV_FOUND)
endif()
find_package(Git)
if (GIT_FOUND)
execute_process(COMMAND git --git-dir ${PROJECT_SOURCE_DIR}/.git rev-parse HEAD
OUTPUT_VARIABLE REVISION
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Git revision is ${REVISION}")
else()
set(REVISION "none")
endif()
# FlightGear build options
option(SIMGEAR_SHARED "Set to ON when SimGear was built as a shared library" OFF)
option(LOGGING "Set to ON to build FlightGear with logging support (default)" ON)
option(SP_FDMS "Set to ON to build FlightGear with special-purpose FDMs" OFF)
option(ENABLE_UIUC_MODEL "Set to ON to build FlightGear with UIUCModel FDM" OFF)
option(ENABLE_LARCSIM "Set to ON to build FlightGear with LaRCsim FDM" OFF)
option(ENABLE_YASIM "Set to ON to build FlightGear with YASIM FDM (default)" ON)
option(ENABLE_JSBSIM "Set to ON to build FlightGear with JSBSim FDM (default)" ON)
option(EVENT_INPUT "Set to ON to build FlightGear with event-based Input support" ${EVENT_INPUT_DEFAULT})
option(ENABLE_LIBSVN "Set to ON to build FlightGear/terrasync with libsvnclient support (default)" ON)
option(ENABLE_RTI "Set to ON to build FlightGear with RTI support" OFF)
option(ENABLE_PROFILE "Set to ON to build FlightGear with gperftools profiling support" OFF)
option(JPEG_FACTORY "Set to ON to build FlightGear with JPEG-factory support" OFF)
option(SYSTEM_SQLITE "Set to ON to build FlightGear with the system's SQLite3 library" OFF)
# additional utilities
option(ENABLE_FGADMIN "Set to ON to build the FGADMIN application (default)" ON)
option(ENABLE_FGELEV "Set to ON to build the fgelev application (default)" ON)
option(WITH_FGPANEL "Set to ON to build the fgpanel application (default)" ON)
option(ENABLE_FGVIEWER "Set to ON to build the fgviewer application (default)" ON)
option(ENABLE_GPSSMOOTH "Set to ON to build the GPSsmooth application (default)" ON)
option(ENABLE_TERRASYNC "Set to ON to build the terrasync application (default)" ON)
option(ENABLE_FGJS "Set to ON to build the fgjs application (default)" ON)
option(ENABLE_JS_DEMO "Set to ON to build the js_demo application (default)" ON)
option(ENABLE_METAR "Set to ON to build the metar application (default)" ON)
option(ENABLE_TESTS "Set to ON to build test applications (default)" ON)
if(LOGGING)
# nothing
else()
set(FG_NDEBUG 1)
endif()
if(SP_FDMS)
set(ENABLE_SP_FDM 1)
endif()
# Setup MSVC 3rd party directories
include( ConfigureMsvc3rdParty )
if(EVENT_INPUT)
if(APPLE)
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
if(NOT UDEV_FOUND)
message(WARNING "UDev not found, event input is disabled!")
set(EVENT_INPUT 0)
else()
add_definitions(-DWITH_EVENTINPUT)
set(EVENT_INPUT_LIBRARIES ${UDEV_LIBRARIES})
message(STATUS "event-based input enabled. Using ${UDEV_LIBRARIES}")
endif()
else()
message(WARNING "event-based input is not supported on this platform yet")
endif()
# Keep PLIB INPUT enabled as long as EventInput does not replace current joystick configurations.
set(ENABLE_PLIB_JOYSTICK 1)
else(EVENT_INPUT)
set(ENABLE_PLIB_JOYSTICK 1)
endif(EVENT_INPUT)
# check required dependencies
find_package(Boost REQUIRED)
find_package(ZLIB REQUIRED)
find_package(Threads REQUIRED)
find_package(OpenGL REQUIRED)
find_package(OpenAL REQUIRED)
find_package(OpenSceneGraph 3.0.0 REQUIRED osgText osgSim osgDB osgParticle osgFX osgUtil osgViewer osgGA)
if(ENABLE_FGADMIN)
find_package(FLTK)
if ( FLTK_FOUND )
if ( X11_Xinerama_FOUND )
message(STATUS "Found X11_Xinerama...")
list(APPEND FLTK_LIBRARIES ${X11_Xinerama_LIB})
endif()
if ( X11_Xft_FOUND )
message(STATUS "Found X11_Xft...")
list(APPEND FLTK_LIBRARIES ${X11_Xft_LIB})
endif()
message(STATUS "Using FLTK_LIBRARIES for fgadmin: ${FLTK_LIBRARIES}")
endif ( FLTK_FOUND )
endif(ENABLE_FGADMIN)
if(ENABLE_LIBSVN)
find_package(SvnClient)
if(LIBSVN_FOUND)
message(STATUS "libsvn found, enabling in terrasync")
set(HAVE_SVN_CLIENT_H 1)
set(HAVE_LIBSVN_CLIENT_1 1)
else()
message(STATUS "libsvn missing. Disabling...")
endif(LIBSVN_FOUND)
endif(ENABLE_LIBSVN)
if (SYSTEM_SQLITE)
find_package(SQLite3 REQUIRED)
set(CMAKE_REQUIRED_INCLUDES ${SQLITE3_INCLUDED_DIR})
message(STATUS "Using system SQLite3 library")
endif (SYSTEM_SQLITE)
# Sqlite always depends on the threading lib
list(APPEND SQLITE3_LIBRARY ${CMAKE_THREAD_LIBS_INIT})
find_package(PLIB REQUIRED puaux pu js fnt)
if (EMBEDDED_SIMGEAR)
message(STATUS "Using embedded SimGear")
# create the same variables that FindSimGear would define
set(SIMGEAR_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/simgear)
set(SIMGEAR_CORE_LIBRARIES SimGearCore)
set(SIMGEAR_LIBRARIES SimGearScene)
if (NOT SIMGEAR_SHARED)
set(SIMGEAR_CORE_LIBRARY_DEPENDENCIES
${CMAKE_THREAD_LIBS_INIT}
${ZLIB_LIBRARY}
${LIBSVN_LIBRARIES}
${WINMM_LIBRARY})
set(SIMGEAR_SCENE_LIBRARY_DEPENDENCIES
${OPENAL_LIBRARY})
endif()
else(EMBEDDED_SIMGEAR)
# FlightGear and SimGear versions need to match
find_package(SimGear ${FLIGHTGEAR_VERSION} REQUIRED)
endif (EMBEDDED_SIMGEAR)
if (JPEG_FACTORY)
# check simgear was built with JPEG-factory support
find_package(JPEG REQUIRED)
include_directories(${JPEG_INCLUDE_DIR})
set(CMAKE_REQUIRED_INCLUDES
${SIMGEAR_INCLUDE_DIR}
${JPEG_INCLUDE_DIR}
${OPENSCENEGRAPH_INCLUDE_DIRS})
check_cxx_source_compiles(
"#include <simgear/screen/jpgfactory.hxx>
int main() { return 0; } "
FG_JPEG_SERVER)
if (NOT FG_JPEG_SERVER)
message(STATUS "JPEG server support requested, but SimGear was built without JPEG support")
endif()
endif()
check_include_file(unistd.h HAVE_UNISTD_H)
check_include_file(sys/time.h HAVE_SYS_TIME_H)
check_include_file(windows.h HAVE_WINDOWS_H)
if(ENABLE_PROFILE)
find_package(GooglePerfTools REQUIRED)
set(FG_HAVE_GPERFTOOLS 1)
message(STATUS "Built-in profiler using gperftools available")
endif()
if(ENABLE_RTI)
message(STATUS "RTI: ENABLED")
find_package(RTI)
if(RTI_FOUND)
set(FG_HAVE_HLA 1)
endif(RTI_FOUND)
else()
message(STATUS "RTI: DISABLED")
endif(ENABLE_RTI)
if(CMAKE_COMPILER_IS_GNUCXX)
set(WARNING_FLAGS_CXX "-Wall")
set(WARNING_FLAGS_C "-Wall")
endif(CMAKE_COMPILER_IS_GNUCXX)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set (WARNING_FLAGS_CXX "-Wall -Wno-overloaded-virtual")
set (WARNING_FLAGS_C "-Wall")
endif()
if(WIN32)
if(MSVC)
# turn off various warnings
# foreach(warning 4244 4251 4267 4275 4290 4786 4305 4996)
# SET(WARNING_FLAGS "${WARNING_FLAGS} /wd${warning}")
# endforeach(warning)
set(MSVC_FLAGS "-DNOMINMAX -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS -D__CRT_NONSTDC_NO_WARNINGS -Dstrdup=_strdup")
if (${MSVC_VERSION} GREATER 1599)
set( MSVC_LD_FLAGS "/FORCE:MULTIPLE" )
endif (${MSVC_VERSION} GREATER 1599)
endif(MSVC)
set(NOMINMAX 1)
endif(WIN32)
set (BOOST_CXX_FLAGS "-DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_BIMAP_DISABLE_SERIALIZATION")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS_C} ${MSVC_FLAGS} -D_REENTRANT")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS_CXX} ${MSVC_FLAGS} -D_REENTRANT ${BOOST_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MSVC_LD_FLAGS}")
include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIR}
${OPENGL_INCLUDE_DIR}
${OPENAL_INCLUDE_DIR}
${SIMGEAR_INCLUDE_DIR}
${PLIB_INCLUDE_DIR} )
include_directories(${PROJECT_SOURCE_DIR}/src)
# following is needed, because config.h is include 'bare', whereas
# version.h is included as <Include/version.h> - this should be cleaned up
include_directories(${PROJECT_BINARY_DIR}/src)
include_directories(${PROJECT_BINARY_DIR}/src/Include)
add_definitions(-DHAVE_CONFIG_H)
check_function_exists(mkfifo HAVE_MKFIFO)
# configure a header file to pass some of the CMake settings
# to the source code
configure_file (
"${PROJECT_SOURCE_DIR}/src/Include/config_cmake.h.in"
"${PROJECT_BINARY_DIR}/src/Include/config.h"
)
#and the same for the version header
configure_file (
"${PROJECT_SOURCE_DIR}/src/Include/version.h.cmake-in"
"${PROJECT_BINARY_DIR}/src/Include/version.h"
)
if (EMBEDDED_SIMGEAR)
add_subdirectory(simgear)
# since we build without SimGear installed, we need to
# search this path directly to find the generated
# simgear_config.h
include_directories(${PROJECT_BINARY_DIR}/simgear)
endif(EMBEDDED_SIMGEAR)
add_subdirectory(src)
add_subdirectory(utils)
add_subdirectory(man)
#-----------------------------------------------------------------------------
### uninstall target
#-----------------------------------------------------------------------------
CONFIGURE_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
ADD_CUSTOM_TARGET(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")