]> git.mxchange.org Git - simgear.git/blob - CMakeLists.txt
SGExpression bugfix: allow <sin> within <product>
[simgear.git] / CMakeLists.txt
1 cmake_minimum_required (VERSION 2.6)
2 include (CheckFunctionExists)
3 include (CheckIncludeFile)
4 include (CheckCXXSourceCompiles)
5 include (CPack)
6
7 project(SimGear)
8
9 set(SIMGEAR_VERSION "2.2.0")
10
11 #packaging
12 SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING")
13 SET(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README")
14
15 # We have some custom .cmake scripts not in the official distribution.
16 set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}")
17
18 option(SIMGEAR_SHARED "Set to ON to build SimGear as a shared library/framework" OFF)
19 option(SIMGEAR_HEADLESS "Set to ON to build SimGear with GUI/graphics support" OFF)
20 option(JPEG_FACTORY "Enable JPEG-factory support" OFF)
21 set(MSVC_3RDPARTY_DIR NOT_FOUND CACHE PATH "Location where the third-party dependencies are extracted")
22
23 if (MSVC_3RDPARTY_DIR)
24   message(STATUS "3rdparty files located in ${MSVC_3RDPARTY_DIR}")
25   set (CMAKE_LIBRARY_PATH ${MSVC_3RDPARTY_DIR}/3rdParty/lib ${MSVC_3RDPARTY_DIR}/install/msvc90/OpenScenegraph/lib )
26   set (CMAKE_INCLUDE_PATH ${MSVC_3RDPARTY_DIR}/3rdParty/include ${MSVC_3RDPARTY_DIR}/install/msvc90/OpenScenegraph/include)
27   set (BOOST_ROOT ${MSVC_3RDPARTY_DIR}/boost_1_44_0)
28   set (OPENAL_INCLUDE_DIR ${MSVC_3RDPARTY_DIR}/3rdParty/include)
29   set (ALUT_INCLUDE_DIR ${MSVC_3RDPARTY_DIR}/3rdParty/include)
30   set (OPENAL_LIBRARY_DIR ${MSVC_3RDPARTY_DIR}/3rdParty/lib) 
31 endif (MSVC_3RDPARTY_DIR)
32
33 find_package(Boost REQUIRED)
34 set (BOOST_CXX_FLAGS "-DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_BIMAP_DISABLE_SERIALIZATION")
35
36 find_package(ZLIB REQUIRED)
37 find_package(Threads REQUIRED)
38
39 if (${SIMGEAR_HEADLESS})
40     message(STATUS "headlesss mode")
41     set(NO_OPENSCENEGRAPH_INTERFACE 1)
42 else()
43     find_package(OpenGL REQUIRED)
44     find_package(OpenAL REQUIRED)
45     find_package(ALUT REQUIRED)
46     find_package(OpenSceneGraph 2.8.2 REQUIRED osgText osgSim osgDB osgParticle osgUtil)
47 endif()
48
49 if(JPEG_FACTORY)
50     message(STATUS "JPEG-factory enabled")
51     find_package(JPEG REQUIRED)
52     include_directories(${JPEG_INCLUDE_DIR})
53 endif()
54
55 check_include_file(sys/time.h HAVE_SYS_TIME_H)
56 check_include_file(sys/timeb.h HAVE_SYS_TIMEB_H)
57 check_include_file(unistd.h HAVE_UNISTD_H)
58 check_include_file(windows.h HAVE_WINDOWS_H)
59
60 check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
61 check_function_exists(ftime HAVE_FTIME)
62 check_function_exists(timegm HAVE_TIMEGM)
63 check_function_exists(rint HAVE_RINT)
64
65 SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually d on windows")
66 SET(CMAKE_RELEASE_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
67 SET(CMAKE_RELWITHDEBINFO_POSTFIX "rd" CACHE STRING "add a postfix, usually empty on windows")
68 SET(CMAKE_MINSIZEREL_POSTFIX "s" CACHE STRING "add a postfix, usually empty on windows")
69
70 # isnan might not be real symbol, so can't check using function_exists
71 check_cxx_source_compiles(
72     "#include <cmath> 
73     void f() { isnan(0.0);} "
74     HAVE_ISNAN)
75
76 if(CMAKE_COMPILER_IS_GNUCXX)
77     set(WARNING_FLAGS -Wall)
78 endif(CMAKE_COMPILER_IS_GNUCXX)
79
80 if(WIN32)
81
82     if(MSVC)
83         # turn off various warnings
84         # foreach(warning 4244 4251 4267 4275 4290 4786 4305 4996)
85         #     SET(WARNING_FLAGS "${WARNING_FLAGS} /wd${warning}")
86         # endforeach(warning)
87         
88         set(MSVC_FLAGS "-DWIN32 -DNOMINMAX -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D__CRT_NONSTDC_NO_WARNINGS")
89     endif(MSVC)
90     
91     # assumed on Windows
92     set(HAVE_GETLOCALTIME 1)
93 endif(WIN32)    
94
95 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS} ${MSVC_FLAGS}")
96 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS} ${MSVC_FLAGS} ${BOOST_CXX_FLAGS}")
97
98 include_directories(${PROJECT_SOURCE_DIR})
99 include_directories(${PROJECT_BINARY_DIR}/simgear)
100
101 include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS} 
102     ${Boost_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR} 
103     ${ALUT_INCLUDE_DIR} ${OPENAL_INCLUDE_DIR} )
104
105
106 add_definitions(-DHAVE_CONFIG_H)
107
108 # configure a header file to pass some of the CMake settings
109 # to the source code
110 configure_file (
111   "${PROJECT_SOURCE_DIR}/simgear/simgear_config_cmake.h.in"
112   "${PROJECT_BINARY_DIR}/simgear/simgear_config.h"
113   )
114   
115 install (FILES ${PROJECT_BINARY_DIR}/simgear/simgear_config.h  DESTINATION include/simgear/)
116 add_subdirectory(simgear)
117
118 #-----------------------------------------------------------------------------
119 ### uninstall target
120 #-----------------------------------------------------------------------------
121 CONFIGURE_FILE(
122   "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/cmake_uninstall.cmake.in"
123   "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
124   IMMEDIATE @ONLY)
125 ADD_CUSTOM_TARGET(uninstall
126   "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
127
128