]> git.mxchange.org Git - simgear.git/blob - CMakeLists.txt
20c254e39116af1cd1b05572d5307af938172d61
[simgear.git] / CMakeLists.txt
1 cmake_minimum_required (VERSION 2.6)
2 include (CheckFunctionExists)
3 include (CheckCXXSourceCompiles)
4 include (CPack)
5
6 project(SimGear)
7
8 set(SIMGEAR_VERSION "2.2.0")
9
10 #packaging
11 SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING")
12 SET(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README")
13
14 # We have some custom .cmake scripts not in the official distribution.
15 set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}")
16
17 option(SIMGEAR_SHARED "Set to ON to build SimGear as a shared library/framework" OFF)
18 option(SIMGEAR_HEADLESS "Set to ON to build SimGear with GUI/graphics support" OFF)
19 option(JPEG_FACTORY "Enable JPEG-factory support" OFF)
20
21 # check required dependencies
22 find_package(Boost REQUIRED)
23 find_package(ZLIB REQUIRED)
24 find_package(Threads REQUIRED)
25
26 if (${SIMGEAR_HEADLESS})
27     message(STATUS "headlesss mode")
28     set(NO_OPENSCENEGRAPH_INTERFACE 1)
29 else()
30     find_package(OpenGL REQUIRED)
31     find_package(OpenAL REQUIRED)
32     find_package(ALUT REQUIRED)
33     find_package(OpenSceneGraph 2.8.2 REQUIRED osgText osgSim osgDB osgParticle osgUtil)
34 endif()
35
36 if(JPEG_FACTORY)
37     message(STATUS "JPEG-factory enabled")
38     find_package(JPEG REQUIRED)
39     include_directories(${JPEG_INCLUDE_DIR})
40 endif()
41
42 find_path (HAVE_SYS_TIME_H sys/time.h )
43 find_path (HAVE_SYS_TIMEB_H sys/timeb.h )
44 find_path (HAVE_UNISTD_H unistd.h )
45
46 check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
47 check_function_exists(ftime HAVE_FTIME)
48 check_function_exists(timegm HAVE_TIMEGM)
49 check_function_exists(rint HAVE_RINT)
50
51 # isnan might not be real symbol, so can't check using function_exists
52 check_cxx_source_compiles(
53     "#include <cmath> void f() { isnan(0.0);} "
54     HAVE_ISNAN)
55
56 if(CMAKE_COMPILER_IS_GNUCXX)
57     set(WARNING_FLAGS -Wall)
58 endif(CMAKE_COMPILER_IS_GNUCXX)
59
60 if(WIN32)
61
62     if(MSVC)
63         # turn off various warnings
64         # foreach(warning 4244 4251 4267 4275 4290 4786 4305 4996)
65         #     SET(WARNING_FLAGS "${WARNING_FLAGS} /wd${warning}")
66         # endforeach(warning)
67         
68         set(MSVC_FLAGS "-DNOMINMAX -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D__CRT_NONSTDC_NO_WARNINGS")
69     endif(MSVC)
70     
71     # assumed on Windows
72     set(HAVE_GETLOCALTIME 1)
73 endif(WIN32)    
74
75 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS} ${MSVC_FLAGS}")
76 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS} ${MSVC_FLAGS}")
77
78 include_directories(${PROJECT_SOURCE_DIR})
79 include_directories(${PROJECT_BINARY_DIR}/simgear)
80
81 include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS} 
82     ${Boost_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR} 
83     ${ALUT_INCLUDE_DIR} ${OPENAL_INCLUDE_DIR} )
84
85
86 add_definitions(-DHAVE_CONFIG_H)
87
88 # configure a header file to pass some of the CMake settings
89 # to the source code
90 configure_file (
91   "${PROJECT_SOURCE_DIR}/simgear/simgear_config_cmake.h.in"
92   "${PROJECT_BINARY_DIR}/simgear/simgear_config.h"
93   )
94   
95 install (FILES ${PROJECT_BINARY_DIR}/simgear/simgear_config.h  DESTINATION include/simgear/)
96 add_subdirectory(simgear)
97