1 cmake_minimum_required (VERSION 2.8.11)
3 include (CheckFunctionExists)
4 include (CheckCSourceCompiles)
5 include (CheckCXXSourceCompiles)
6 include (CheckIncludeFile)
8 if(COMMAND cmake_policy)
10 cmake_policy(SET CMP0054 NEW)
13 cmake_policy(SET CMP0042 NEW)
17 # using 10.7 because boost requires libc++ and 10.6 doesn't include it
18 set(CMAKE_OSX_DEPLOYMENT_TARGET 10.7)
19 set(CMAKE_OSX_SYSROOT /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk)
23 # We have some custom .cmake scripts not in the official distribution.
24 set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}")
26 if(${CMAKE_VERSION} VERSION_GREATER 2.8.4)
27 # use official include provided by latest CMake
28 include(GNUInstallDirs)
29 else(${CMAKE_VERSION} VERSION_GREATER 2.8.4)
30 # backward compatibility: use our own module for older cmake versions
31 include(OldGNUInstallDirs)
32 endif(${CMAKE_VERSION} VERSION_GREATER 2.8.4)
34 # Warning when build is not an out-of-source build.
35 string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" InSourceBuild)
37 message(WARNING "Avoid building inside the source tree!")
38 message(WARNING "Create a separate build directory instead (i.e. 'fgbuild') and call CMake from there: ")
39 message(WARNING " mkdir ../fgbuild && cd ../fgbuild && cmake ${CMAKE_SOURCE_DIR}")
42 # System detection/default settings
43 include( DetectDistro )
44 include( DetectBrowser )
46 set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually d on windows")
47 set(CMAKE_RELEASE_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
48 set(CMAKE_RELWITHDEBINFO_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
49 set(CMAKE_MINSIZEREL_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
51 # read 'version' file into a variable (stripping any newlines or spaces)
52 file(READ version versionFile)
54 message(FATAL_ERROR "Unable to determine FlightGear version. Version file is missing.")
56 string(STRIP "${versionFile}" FLIGHTGEAR_VERSION)
58 # FlightGear packaging (to build a source tarball)
59 include( ConfigureCPack )
61 # FlightGear base package path
63 message(STATUS "Using explicit data directory for base package: ${FG_DATA_DIR}")
65 set(FG_DATA_DIR "${CMAKE_INSTALL_PREFIX}/lib/FlightGear" CACHE PATH "Default location where data files are located")
66 message(STATUS "Using default data directory for base package: ${FG_DATA_DIR}")
69 # Change the default build type to something fast
70 if(NOT CMAKE_BUILD_TYPE)
71 set(CMAKE_BUILD_TYPE Release CACHE STRING
72 "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
74 endif(NOT CMAKE_BUILD_TYPE)
76 if(NOT "$ENV{BUILD_ID}" STREQUAL "")
77 set(HUDSON_BUILD_ID $ENV{BUILD_ID})
78 set(HUDSON_BUILD_NUMBER $ENV{BUILD_NUMBER})
79 message(STATUS "running under Hudson/Jenkins, build-number is ${HUDSON_BUILD_NUMBER}")
81 set(HUDSON_BUILD_NUMBER 0)
82 set(HUDSON_BUILD_ID "none")
85 #####################################################################################
86 # Configure library search paths
87 #####################################################################################
90 if(NOT "${CMAKE_LIBRARY_ARCHITECTURE}" STREQUAL "")
91 # Workaround for Ubuntu/Debian which introduced the "multiarch" library
92 # directory structure, which is unsupported by CMake < 2.8.10, so we need to
94 # see http://www.cmake.org/Bug/view.php?id=12049 and
95 # http://www.cmake.org/Bug/view.php?id=12037
96 list(APPEND ADDITIONAL_LIBRARY_PATHS
97 /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE}
98 /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}
99 /lib/${CMAKE_LIBRARY_ARCHITECTURE})
100 message(STATUS "additional library directories: ${ADDITIONAL_LIBRARY_PATHS}")
103 #####################################################################################
106 set(EVENT_INPUT_DEFAULT 1)
108 find_library(CORESERVICES_LIBRARY CoreServices)
109 find_library(COCOA_LIBRARY Cocoa)
110 list(APPEND PLATFORM_LIBS ${COCOA_LIBRARY} ${CORESERVICES_LIBRARY})
111 elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR
112 ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
113 find_package(Threads REQUIRED)
114 find_package(X11 REQUIRED)
116 set(USE_DBUS_DEFAULT 1)
120 set(EVENT_INPUT_DEFAULT 1)
124 find_package(Speexdsp)
125 if(SPEEX_FOUND AND SPEEXDSP_FOUND)
126 set(SYSTEM_SPEEX_DEFAULT 1)
127 endif(SPEEX_FOUND AND SPEEXDSP_FOUND)
131 set(SYSTEM_GSM_DEFAULT 1)
136 set(SYSTEM_FLITE_DEFAULT 1)
139 find_package(HtsEngine)
141 set(SYSTEM_HTS_ENGINE_DEFAULT 1)
147 execute_process(COMMAND git --git-dir ${PROJECT_SOURCE_DIR}/.git rev-parse HEAD
148 OUTPUT_VARIABLE REVISION
149 OUTPUT_STRIP_TRAILING_WHITESPACE)
150 message(STATUS "Git revision is ${REVISION}")
155 # FlightGear build options
156 option(SIMGEAR_SHARED "Set to ON when SimGear was built as a shared library" OFF)
157 option(LOGGING "Set to ON to build FlightGear with logging support (default)" ON)
158 option(JSBSIM_TERRAIN "Set to ON to build FlightGear with JSBSim terrain handling code" ON)
159 option(SP_FDMS "Set to ON to build FlightGear with special-purpose FDMs" OFF)
160 option(ENABLE_UIUC_MODEL "Set to ON to build FlightGear with UIUCModel FDM" OFF)
161 option(ENABLE_LARCSIM "Set to ON to build FlightGear with LaRCsim FDM" OFF)
162 option(ENABLE_YASIM "Set to ON to build FlightGear with YASIM FDM (default)" ON)
163 option(ENABLE_JSBSIM "Set to ON to build FlightGear with JSBSim FDM (default)" ON)
164 option(EVENT_INPUT "Set to ON to build FlightGear with event-based Input support" ${EVENT_INPUT_DEFAULT})
165 option(ENABLE_RTI "Set to ON to build FlightGear with RTI support" OFF)
166 option(ENABLE_PROFILE "Set to ON to build FlightGear with gperftools profiling support" OFF)
167 option(SYSTEM_SQLITE "Set to ON to build FlightGear with the system's SQLite3 library" OFF)
168 option(ENABLE_IAX "Set to ON to build FlightGear with IAXClient/fgcom built-in (default)" ON)
169 option(USE_DBUS "Set to ON to build FlightGear with DBus screensaver interaction (default on Linux)" ${USE_DBUS_DEFAULT})
170 option(SYSTEM_SPEEX "Set to ON to build IAXClient with the system's speex and speexdsp library" ${SYSTEM_SPEEX_DEFAULT})
171 option(SYSTEM_GSM "Set to ON to build IAXClient with the system's GSM library" ${SYSTEM_GSM_DEFAULT})
172 option(SYSTEM_FLITE "Set to ON to build Flightgear with the system's Flite library" ${SYSTEM_FLITE_DEFAULT})
173 option(SYSTEM_HTS_ENGINE "Set to ON to build Flightgear with the system's HTS Engine library" ${SYSTEM_HTS_ENGINE_DEFAULT})
174 option(FG_NIGHTLY "Set to ON to mark this as a nightly build" OFF)
176 # additional utilities
177 option(ENABLE_FGADMIN "Set to ON to build the FGADMIN application (default)" ON)
178 option(ENABLE_FGELEV "Set to ON to build the fgelev application (default)" ON)
179 option(WITH_FGPANEL "Set to ON to build the fgpanel application (default)" ON)
180 option(ENABLE_FGVIEWER "Set to ON to build the fgviewer application (default)" ON)
181 option(ENABLE_GPSSMOOTH "Set to ON to build the GPSsmooth application (default)" ON)
182 option(ENABLE_TERRASYNC "Set to ON to build the terrasync application (default)" ON)
183 option(ENABLE_FGJS "Set to ON to build the fgjs application (default)" ON)
184 option(ENABLE_JS_DEMO "Set to ON to build the js_demo application (default)" ON)
185 option(ENABLE_METAR "Set to ON to build the metar application (default)" ON)
186 option(ENABLE_TESTS "Set to ON to build test applications (default)" ON)
187 option(ENABLE_FGCOM "Set to ON to build the FGCom application (default)" ON)
188 option(ENABLE_FLITE "Set to ON to build the Flite text-to-speech module" ON)
189 option(ENABLE_QT "Set to ON to build the internal Qt launcher" ON)
198 set(JSBSIM_USE_GROUNDREACTIONS 1)
207 include_directories(${PROJECT_SOURCE_DIR}/3rdparty/iaxclient/lib ) # for iaxclient.h
210 # Setup MSVC 3rd party directories
211 include( ConfigureMsvc3rdParty )
215 elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
217 message(WARNING "UDev not found, event input is disabled!")
220 add_definitions(-DWITH_EVENTINPUT)
221 set(EVENT_INPUT_LIBRARIES ${UDEV_LIBRARIES})
222 message(STATUS "event-based input enabled. Using ${UDEV_LIBRARIES}")
225 message(WARNING "event-based input is not supported on this platform yet")
228 # Keep PLIB INPUT enabled as long as EventInput does not replace current joystick configurations.
229 set(ENABLE_PLIB_JOYSTICK 1)
231 set(ENABLE_PLIB_JOYSTICK 1)
234 # check required dependencies
235 find_package(Boost REQUIRED)
236 find_package(ZLIB REQUIRED)
237 find_package(OpenGL REQUIRED)
238 find_package(OpenAL REQUIRED)
239 find_package(OpenSceneGraph 3.2.0 REQUIRED
251 find_package(CrashRpt)
254 message(STATUS "Using CrashRpt")
255 include_directories( ${CRASHRPT_INCLUDE_DIR})
259 ##############################################################################
263 find_package(SQLite3 REQUIRED)
265 message(STATUS "Using system SQLite3 library")
267 set(SQLITE3_INCLUDED_DIR "${CMAKE_SOURCE_DIR}/3rdparty/sqlite3")
268 # this target is defined in src/Navaids/CMakeLists.txt
269 list(APPEND SQLITE3_LIBRARY fgsqlite3)
270 endif (SYSTEM_SQLITE)
272 # Sqlite always depends on the threading lib
273 list(APPEND SQLITE3_LIBRARY ${CMAKE_THREAD_LIBS_INIT})
275 ##############################################################################
279 include(FindPkgConfig)
280 if (PKG_CONFIG_FOUND)
281 pkg_check_modules(DBUS dbus-1)
282 endif (PKG_CONFIG_FOUND) #if we don't have pkg-config, assume we don't have libdbus-1-dev either http://packages.debian.org/sid/libdbus-1-dev
285 message(STATUS "Using DBus")
286 include_directories( ${DBUS_INCLUDE_DIRS})
288 message(STATUS "DBus not found, screensaver control disabled")
293 ##############################################################################
296 message(STATUS "Qt launcher enabled, checking for Qt 5.1 / qmake")
297 find_package(Qt5 5.1 COMPONENTS Widgets)
298 if (Qt5Widgets_FOUND)
299 message(STATUS "Will enable Qt launcher GUI")
300 message(STATUS " Qt5Widgets version: ${Qt5Widgets_VERSION_STRING}")
301 message(STATUS " Qt5Widgets include dir: ${Qt5Widgets_INCLUDE_DIRS}")
305 ##############################################################################
307 find_package(PLIB REQUIRED puaux pu js fnt)
309 # FlightGear and SimGear versions need to match
310 find_package(SimGear ${FLIGHTGEAR_VERSION} REQUIRED)
312 ##############################################################################
314 check_include_file(unistd.h HAVE_UNISTD_H)
315 check_include_file(sys/time.h HAVE_SYS_TIME_H)
316 check_include_file(windows.h HAVE_WINDOWS_H)
319 find_package(GooglePerfTools REQUIRED)
320 set(FG_HAVE_GPERFTOOLS 1)
321 message(STATUS "Built-in profiler using gperftools available")
325 message(STATUS "RTI: ENABLED")
331 message(STATUS "RTI: DISABLED")
334 if(CMAKE_COMPILER_IS_GNUCXX)
335 set(WARNING_FLAGS_CXX "-Wall")
336 set(WARNING_FLAGS_C "-Wall")
337 endif(CMAKE_COMPILER_IS_GNUCXX)
339 if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
340 set (WARNING_FLAGS_CXX "-Wall -Wno-overloaded-virtual -Wno-redeclared-class-member")
341 set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
342 set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11")
343 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")
344 set (WARNING_FLAGS_C "-Wall")
350 # turn off various warnings
351 # foreach(warning 4244 4251 4267 4275 4290 4786 4305 4996)
352 # SET(WARNING_FLAGS "${WARNING_FLAGS} /wd${warning}")
353 # endforeach(warning)
355 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")
356 if (${MSVC_VERSION} GREATER 1599)
357 set( MSVC_LD_FLAGS "/FORCE:MULTIPLE" )
358 endif (${MSVC_VERSION} GREATER 1599)
364 set (BOOST_CXX_FLAGS "-DBOOST_BIMAP_DISABLE_SERIALIZATION")
366 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS_C} ${MSVC_FLAGS} -D_REENTRANT")
367 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS_CXX} ${MSVC_FLAGS} -D_REENTRANT ${BOOST_CXX_FLAGS}")
368 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MSVC_LD_FLAGS}")
370 include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS}
371 ${Boost_INCLUDE_DIRS}
373 ${OPENGL_INCLUDE_DIR}
374 ${OPENAL_INCLUDE_DIR}
375 ${SIMGEAR_INCLUDE_DIRS}
377 ${SQLITE3_INCLUDED_DIR} )
379 include_directories(${PROJECT_SOURCE_DIR})
380 include_directories(${PROJECT_SOURCE_DIR}/src)
381 # following is needed, because config.h is include 'bare', whereas
382 # version.h is included as <Include/version.h> - this should be cleaned up
383 include_directories(${PROJECT_BINARY_DIR}/src)
384 include_directories(${PROJECT_BINARY_DIR}/src/Include)
387 include_directories(${PROJECT_SOURCE_DIR}/3rdparty/hts_engine_API/include )
388 include_directories(${PROJECT_SOURCE_DIR}/3rdparty/flite_hts_engine/include )
391 add_definitions(-DHAVE_CONFIG_H)
393 check_function_exists(mkfifo HAVE_MKFIFO)
395 # configure a header file to pass some of the CMake settings
398 "${PROJECT_SOURCE_DIR}/src/Include/config_cmake.h.in"
399 "${PROJECT_BINARY_DIR}/src/Include/config.h"
402 #and the same for the version header
404 "${PROJECT_SOURCE_DIR}/src/Include/version.h.cmake-in"
405 "${PROJECT_BINARY_DIR}/src/Include/version.h"
408 add_subdirectory(3rdparty)
409 add_subdirectory(utils)
410 add_subdirectory(src)
411 add_subdirectory(man)
413 #-----------------------------------------------------------------------------
415 #-----------------------------------------------------------------------------
417 "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/cmake_uninstall.cmake.in"
418 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
420 ADD_CUSTOM_TARGET(uninstall
421 "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")