1 cmake_minimum_required (VERSION 2.6)
2 include (CheckFunctionExists)
3 include (CheckIncludeFile)
4 include (CheckCXXSourceCompiles)
9 # read 'version' file into a variable (stripping any newlines or spaces)
10 file(READ version versionFile)
11 string(STRIP ${versionFile} SIMGEAR_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 option(SIMGEAR_SHARED "Set to ON to build SimGear as a shared library/framework" OFF)
21 option(SIMGEAR_HEADLESS "Set to ON to build SimGear with GUI/graphics support" OFF)
22 option(JPEG_FACTORY "Enable JPEG-factory support" OFF)
23 option(ENABLE_LIBSVN "Set to ON to build SimGear with libsvnclient support" OFF)
25 set(MSVC_3RDPARTY_ROOT NOT_FOUND CACHE PATH "Location where the third-party dependencies are extracted")
27 if (MSVC AND MSVC_3RDPARTY_ROOT)
28 message(STATUS "3rdparty files located in ${MSVC_3RDPARTY_ROOT}")
29 set( OSG_MSVC "msvc" )
30 if (${MSVC_VERSION} EQUAL 1600)
31 set( OSG_MSVC ${OSG_MSVC}100 )
32 else (${MSVC_VERSION} EQUAL 1600)
33 set( OSG_MSVC ${OSG_MSVC}90 )
34 endif (${MSVC_VERSION} EQUAL 1600)
36 set( OSG_MSVC ${OSG_MSVC}-64 )
37 set( MSVC_3RDPARTY_DIR 3rdParty.x64 )
39 set( MSVC_3RDPARTY_DIR 3rdParty )
42 set (CMAKE_LIBRARY_PATH ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/lib ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenScenegraph/lib )
43 set (CMAKE_INCLUDE_PATH ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenScenegraph/include)
44 set (BOOST_ROOT ${MSVC_3RDPARTY_ROOT}/boost_1_44_0)
45 set (OPENAL_INCLUDE_DIR ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include)
46 set (ALUT_INCLUDE_DIR ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include)
47 set (OPENAL_LIBRARY_DIR ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/lib)
48 endif (MSVC AND MSVC_3RDPARTY_ROOT)
50 find_package(Boost REQUIRED)
51 set (BOOST_CXX_FLAGS "-DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_BIMAP_DISABLE_SERIALIZATION")
53 find_package(ZLIB REQUIRED)
54 find_package(Threads REQUIRED)
56 if (${SIMGEAR_HEADLESS})
57 message(STATUS "headlesss mode")
58 set(NO_OPENSCENEGRAPH_INTERFACE 1)
60 find_package(OpenGL REQUIRED)
61 find_package(OpenAL REQUIRED)
62 find_package(ALUT REQUIRED)
63 find_package(OpenSceneGraph 2.8.1 REQUIRED osgText osgSim osgDB osgParticle osgUtil)
67 message(STATUS "JPEG-factory enabled")
68 find_package(JPEG REQUIRED)
69 include_directories(${JPEG_INCLUDE_DIR})
73 find_package(SvnClient)
76 message(STATUS "libsvn found, enabling in SimGear")
77 set(HAVE_SVN_CLIENT_H 1)
78 set(HAVE_LIBSVN_CLIENT_1 1)
82 check_include_file(sys/time.h HAVE_SYS_TIME_H)
83 check_include_file(sys/timeb.h HAVE_SYS_TIMEB_H)
84 check_include_file(unistd.h HAVE_UNISTD_H)
85 check_include_file(windows.h HAVE_WINDOWS_H)
87 # See if we have any rti library variant installed
90 check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
91 check_function_exists(ftime HAVE_FTIME)
92 check_function_exists(timegm HAVE_TIMEGM)
93 check_function_exists(rint HAVE_RINT)
95 SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually d on windows")
96 SET(CMAKE_RELEASE_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
97 SET(CMAKE_RELWITHDEBINFO_POSTFIX "rd" CACHE STRING "add a postfix, usually empty on windows")
98 SET(CMAKE_MINSIZEREL_POSTFIX "s" CACHE STRING "add a postfix, usually empty on windows")
100 # isnan might not be real symbol, so can't check using function_exists
101 check_cxx_source_compiles(
103 void f() { isnan(0.0);} "
106 if(CMAKE_COMPILER_IS_GNUCXX)
107 set(WARNING_FLAGS -Wall)
108 endif(CMAKE_COMPILER_IS_GNUCXX)
113 # turn off various warnings
114 # foreach(warning 4244 4251 4267 4275 4290 4786 4305 4996)
115 # SET(WARNING_FLAGS "${WARNING_FLAGS} /wd${warning}")
116 # endforeach(warning)
118 set(MSVC_FLAGS "-DWIN32 -DNOMINMAX -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D__CRT_NONSTDC_NO_WARNINGS")
122 set(HAVE_GETLOCALTIME 1)
125 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS} ${MSVC_FLAGS}")
126 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS} ${MSVC_FLAGS} ${BOOST_CXX_FLAGS}")
128 include_directories(${PROJECT_SOURCE_DIR})
129 include_directories(${PROJECT_BINARY_DIR}/simgear)
131 include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS}
132 ${Boost_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR}
133 ${ALUT_INCLUDE_DIR} ${OPENAL_INCLUDE_DIR} )
136 add_definitions(-DHAVE_CONFIG_H)
138 # configure a header file to pass some of the CMake settings
141 "${PROJECT_SOURCE_DIR}/simgear/simgear_config_cmake.h.in"
142 "${PROJECT_BINARY_DIR}/simgear/simgear_config.h"
145 install (FILES ${PROJECT_BINARY_DIR}/simgear/simgear_config.h DESTINATION include/simgear/)
146 add_subdirectory(simgear)
148 #-----------------------------------------------------------------------------
150 #-----------------------------------------------------------------------------
152 "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/cmake_uninstall.cmake.in"
153 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
155 ADD_CUSTOM_TARGET(uninstall
156 "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")