]> git.mxchange.org Git - simgear.git/blob - CMakeLists.txt
974671c754e62d1aca7b7c75814456f9b25964d0
[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 option(MSVC_3RDPARTY_DIR "Location where the third-party dependencies are extracted" NOT_FOUND)
21
22 if (MSVC_3RDPARTY_DIR)
23   message(STATUS "3rdparty files located in ${MSVC_3RDPARTY_DIR}")
24   set (CMAKE_LIBRARY_PATH ${MSVC_3RDPARTY_DIR}/3rdParty/lib)
25   set (CMAKE_INCLUDE_PATH ${MSVC_3RDPARTY_DIR}/3rdParty/include)
26   set (BOOST_ROOT ${MSVC_3RDPARTY_DIR}/boost_1_44_0)
27   set (OPENAL_INCLUDE_DIR ${MSVC_3RDPARTY_DIR}/3rdParty/include)
28   set (OPENAL_LIBRARY_DIR ${MSVC_3RDPARTY_DIR}/3rdParty/lib) 
29   set (OSGDIR ${MSVC_3RDPARTY_DIR}/install/msvc90/OpenScenegraph)
30 endif (MSVC_3RDPARTY_DIR)
31
32 find_package(Boost REQUIRED)
33 find_package(ZLIB REQUIRED)
34 find_package(Threads REQUIRED)
35
36 if (${SIMGEAR_HEADLESS})
37     message(STATUS "headlesss mode")
38     set(NO_OPENSCENEGRAPH_INTERFACE 1)
39 else()
40     find_package(OpenGL REQUIRED)
41     find_package(OpenAL REQUIRED)
42     find_package(ALUT REQUIRED)
43     find_package(OpenSceneGraph 2.8.2 REQUIRED osgText osgSim osgDB osgParticle osgUtil)
44 endif()
45
46 if(JPEG_FACTORY)
47     message(STATUS "JPEG-factory enabled")
48     find_package(JPEG REQUIRED)
49     include_directories(${JPEG_INCLUDE_DIR})
50 endif()
51
52 find_path (HAVE_SYS_TIME_H sys/time.h )
53 find_path (HAVE_SYS_TIMEB_H sys/timeb.h )
54 find_path (HAVE_UNISTD_H unistd.h )
55 find_path (HAVE_WINDOWS_H windows.h)
56
57 check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
58 check_function_exists(ftime HAVE_FTIME)
59 check_function_exists(timegm HAVE_TIMEGM)
60 check_function_exists(rint HAVE_RINT)
61
62 # isnan might not be real symbol, so can't check using function_exists
63 check_cxx_source_compiles(
64     "#include <cmath> 
65     void f() { isnan(0.0);} "
66     HAVE_ISNAN)
67
68 if(CMAKE_COMPILER_IS_GNUCXX)
69     set(WARNING_FLAGS -Wall)
70 endif(CMAKE_COMPILER_IS_GNUCXX)
71
72 if(WIN32)
73
74     if(MSVC)
75         # turn off various warnings
76         # foreach(warning 4244 4251 4267 4275 4290 4786 4305 4996)
77         #     SET(WARNING_FLAGS "${WARNING_FLAGS} /wd${warning}")
78         # endforeach(warning)
79         
80         set(MSVC_FLAGS "-DWIN32 -DNOMINMAX -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D__CRT_NONSTDC_NO_WARNINGS")
81     endif(MSVC)
82     
83     # assumed on Windows
84     set(HAVE_GETLOCALTIME 1)
85 endif(WIN32)    
86
87 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS} ${MSVC_FLAGS}")
88 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS} ${MSVC_FLAGS}")
89
90 include_directories(${PROJECT_SOURCE_DIR})
91 include_directories(${PROJECT_BINARY_DIR}/simgear)
92
93 include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS} 
94     ${Boost_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR} 
95     ${ALUT_INCLUDE_DIR} ${OPENAL_INCLUDE_DIR} )
96
97
98 add_definitions(-DHAVE_CONFIG_H)
99
100 # configure a header file to pass some of the CMake settings
101 # to the source code
102 configure_file (
103   "${PROJECT_SOURCE_DIR}/simgear/simgear_config_cmake.h.in"
104   "${PROJECT_BINARY_DIR}/simgear/simgear_config.h"
105   )
106   
107 install (FILES ${PROJECT_BINARY_DIR}/simgear/simgear_config.h  DESTINATION include/simgear/)
108 add_subdirectory(simgear)
109
110 #-----------------------------------------------------------------------------
111 ### uninstall target
112 #-----------------------------------------------------------------------------
113 CONFIGURE_FILE(
114   "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/cmake_uninstall.cmake.in"
115   "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
116   IMMEDIATE @ONLY)
117 ADD_CUSTOM_TARGET(uninstall
118   "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
119
120