1 cmake_minimum_required (VERSION 2.6)
3 include (CheckFunctionExists)
4 include (CheckCSourceCompiles)
5 include (CheckCXXSourceCompiles)
6 include (CheckIncludeFile)
11 file(READ version FLIGHTGEAR_VERSION)
14 SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING")
15 SET(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README")
17 # We have some custom .cmake scripts not in the official distribution.
18 set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}")
20 # autoconf compatibility
23 option(LOGGING "Set to OFF to build FlightGear without logging" ON)
25 option(SP_FDMS "Set to ON to build FlightGear with special-purpose FDMs" OFF)
26 option(ENABLE_UIUC_MODEL "Set to ON to build FlightGear with UIUCModel FDM" ON)
27 option(ENABLE_LARCSIM "Set to ON to build FlightGear with LaRCsim FDM" ON)
28 option(ENABLE_YASIM "Set to ON to build FlightGear with YASIM FDM" ON)
29 option(ENABLE_JSBSIM "Set to ON to build FlightGear with JSBSim FDM" ON)
30 option(EVENT_INPUT "Set to ON to build FlightGear with event-based Input support" OFF)
43 message(STATUS "checking event-based Input")
46 elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
49 message(WARNING "event input is not supported on this platform yet")
52 set(ENABLE_PLIB_JOYSTICK 1)
55 # check required dependencies
57 # on MSVC, Olaf reports that the serialization library is required at
58 # link time. No one has you explained why, unfortunately.
59 set(Boost_USE_STATIC_LIBS ON)
60 set(Boost_USE_MULTITHREADED ON)
61 set(Boost_USE_STATIC_RUNTIME OFF)
62 find_package(Boost REQUIRED COMPONENTS serialization)
64 find_package(Boost REQUIRED)
67 find_package(ZLIB REQUIRED)
68 find_package(Threads REQUIRED)
69 find_package(OpenGL REQUIRED)
70 find_package(OpenAL REQUIRED)
71 find_package(ALUT REQUIRED)
72 find_package(OpenSceneGraph 2.8.2 REQUIRED osgText osgSim osgDB osgParticle osgFX osgUtil osgViewer osgGA)
73 find_package(PLIB REQUIRED puaux pu js fnt)
74 find_package(SimGear 2.0.0 REQUIRED)
76 check_include_file(unistd.h HAVE_UNISTD_H)
77 check_include_file(sys/time.h HAVE_SYS_TIME_H)
79 # definition depends on OSG version
80 set(CMAKE_REQUIRED_INCLUDES ${OPENSCENEGRAPH_INCLUDE_DIRS})
82 check_cxx_source_compiles(
83 "#include <osg/CullSettings>
86 osg::CullSettings::VariablesMask mask = osg::CullSettings::CLEAR_MASK;
90 HAVE_CULLSETTINGS_CLEAR_MASK)
92 # library required by simgear
93 # XXX This should go in a module and only run if simgear is not shared.
96 set(CMAKE_REQUIRED_INCLUDES ${CMAKE_INCLUDE_PATH})
97 check_cxx_source_compiles(
99 #if !defined(_POSIX_TIMERS) || (0 >= _POSIX_TIMERS)
100 #error clock_gettime is not supported
103 int main() { return 0; }
109 if(HAVE_CLOCK_GETTIME)
110 check_function_exists(clock_gettime CLOCK_GETTIME_IN_LIBC)
111 if(NOT CLOCK_GETTIME_IN_LIBC)
112 check_library_exists(rt clock_gettime "" HAVE_RT)
116 endif(NOT CLOCK_GETTIME_IN_LIBC)
117 endif(HAVE_CLOCK_GETTIME)
119 if(CMAKE_COMPILER_IS_GNUCXX)
120 set(WARNING_FLAGS -Wall)
121 endif(CMAKE_COMPILER_IS_GNUCXX)
126 # turn off various warnings
127 # foreach(warning 4244 4251 4267 4275 4290 4786 4305 4996)
128 # SET(WARNING_FLAGS "${WARNING_FLAGS} /wd${warning}")
129 # endforeach(warning)
131 set(MSVC_FLAGS "-DNOMINMAX -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D__CRT_NONSTDC_NO_WARNINGS")
137 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS} ${MSVC_FLAGS} -D_REENTRANT")
138 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS} ${MSVC_FLAGS} -D_REENTRANT")
140 include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS}
141 ${Boost_INCLUDE_DIRS}
144 ${OPENAL_INCLUDE_DIR}
145 ${SIMGEAR_INCLUDE_DIR}
146 ${PLIB_INCLUDE_DIR} )
148 include_directories(${PROJECT_SOURCE_DIR}/src)
149 include_directories(${PROJECT_BINARY_DIR}/src/Include)
151 add_definitions(-DHAVE_CONFIG_H)
153 # configure a header file to pass some of the CMake settings
156 "${PROJECT_SOURCE_DIR}/src/Include/config_cmake.h.in"
157 "${PROJECT_BINARY_DIR}/src/Include/config.h"
160 add_subdirectory(src)
161 add_subdirectory(utils)
163 #-----------------------------------------------------------------------------
165 #-----------------------------------------------------------------------------
167 "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/cmake_uninstall.cmake.in"
168 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
170 ADD_CUSTOM_TARGET(uninstall
171 "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")