]> git.mxchange.org Git - simgear.git/blob - CMakeLists.txt
Merge branch 'next' of git.mxchange.org:/var/cache/git/repos/simgear into next
[simgear.git] / CMakeLists.txt
1 cmake_minimum_required (VERSION 2.8.11)
2
3 if(COMMAND cmake_policy)
4    if(POLICY CMP0054)
5        cmake_policy(SET CMP0054 NEW)
6    endif()
7    if(POLICY CMP0042)
8        cmake_policy(SET CMP0042 NEW)
9    endif()
10 endif()
11
12 include (CheckFunctionExists)
13 include (CheckIncludeFile)
14 include (CheckLibraryExists)
15 include (CheckCXXSourceCompiles)
16 include (CheckCXXCompilerFlag)
17 include (GenerateExportHeader)
18
19 # using 10.7 because boost requires libc++ and 10.6 doesn't include it
20 set(CMAKE_OSX_DEPLOYMENT_TARGET 10.7)
21
22 # only relevant for building shared libs but let's set it regardless
23 set(CMAKE_OSX_RPATH 1)
24
25 # Set the C++ standard to C++98 to avoid compilation errors on GCC 6 (which
26 # defaults to C++14).
27 if(CMAKE_VERSION VERSION_LESS "3.1")
28   if(CMAKE_COMPILER_IS_GNUCXX)
29     set (CMAKE_CXX_FLAGS "-std=gnu++98 ${CMAKE_CXX_FLAGS}")
30   endif()
31 else()
32   set (CMAKE_CXX_STANDARD 98)
33 endif()
34
35 project(SimGear)
36
37 # read 'version' file into a variable (stripping any newlines or spaces)
38 file(READ version versionFile)
39 string(STRIP ${versionFile} SIMGEAR_VERSION)
40
41 # add a dependency on the versino file
42 set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS version)
43
44 set(FIND_LIBRARY_USE_LIB64_PATHS ON)
45
46 # use simgear version also as the SO version (if building SOs)
47 SET(SIMGEAR_SOVERSION ${SIMGEAR_VERSION})
48
49 # Warning when build is not an out-of-source build.
50 string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" InSourceBuild)
51 if(InSourceBuild)
52     message(WARNING  "Avoid building inside the source tree!")
53     message(WARNING  "Create a separate build directory instead (i.e. 'sgbuild') and call CMake from there: ")
54     message(WARNING  "  mkdir ../sgbuild && cd ../sgbuild && cmake ${CMAKE_SOURCE_DIR}")
55 endif(InSourceBuild)
56
57 #packaging
58 SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING")
59 SET(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README")
60 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Simulation support libraries for FlightGear and related projects")
61 SET(CPACK_PACKAGE_VENDOR "The FlightGear project")
62 SET(CPACK_GENERATOR "TBZ2")
63 SET(CPACK_INSTALL_CMAKE_PROJECTS  ${CMAKE_CURRENT_BINARY_DIR};SimGear;ALL;/)
64
65
66 # split version string into components, note CMAKE_MATCH_0 is the entire regexp match
67 string(REGEX MATCH "([0-9]+)\\.([0-9]+)\\.([0-9]+)" CPACK_PACKAGE_VERSION ${SIMGEAR_VERSION} )
68 set(CPACK_PACKAGE_VERSION_MAJOR ${CMAKE_MATCH_1})
69 set(CPACK_PACKAGE_VERSION_MINOR ${CMAKE_MATCH_2})
70 set(CPACK_PACKAGE_VERSION_PATCH ${CMAKE_MATCH_3})
71
72 message(STATUS "version is ${CPACK_PACKAGE_VERSION_MAJOR} dot ${CPACK_PACKAGE_VERSION_MINOR} dot ${CPACK_PACKAGE_VERSION_PATCH}")
73
74 set(CPACK_SOURCE_GENERATOR TBZ2)
75 set(CPACK_SOURCE_PACKAGE_FILE_NAME "simgear-${SIMGEAR_VERSION}" CACHE INTERNAL "tarball basename")
76 set(CPACK_SOURCE_IGNORE_FILES
77   "^${PROJECT_SOURCE_DIR}/.git;\\\\.gitignore;Makefile.am;~$;${CPACK_SOURCE_IGNORE_FILES}")
78
79 message(STATUS "ignoring: ${CPACK_SOURCE_IGNORE_FILES}")
80
81 include (CPack)
82
83 # We have some custom .cmake scripts not in the official distribution.
84 set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}")
85
86 # Change the default build type to something fast
87 if(NOT CMAKE_BUILD_TYPE)
88   set(CMAKE_BUILD_TYPE Release CACHE STRING
89       "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
90       FORCE)
91 endif(NOT CMAKE_BUILD_TYPE)
92
93 # Determine name of library installation directory, i.e. "lib" vs "lib64", which
94 # differs between all Debian-based vs all other Linux distros.
95 # See cmake bug #11964, http://cmake.org/gitweb?p=cmake.git;a=commit;h=126c993d
96 include(GNUInstallDirs)
97 message(STATUS "Library installation directory: ${CMAKE_INSTALL_LIBDIR}")
98
99 #####################################################################################
100 # Configure library search paths
101 #####################################################################################
102
103 if(NOT "${CMAKE_LIBRARY_ARCHITECTURE}" STREQUAL "")
104     # Workaround for Ubuntu/Debian which introduced the "multiarch" library
105     # directory structure, which is unsupported by CMake < 2.8.10, so we need to
106     # add paths manually
107     # see http://www.cmake.org/Bug/view.php?id=12049 and
108     # http://www.cmake.org/Bug/view.php?id=12037
109     list(APPEND ADDITIONAL_LIBRARY_PATHS
110          /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE}
111          /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}
112          /lib/${CMAKE_LIBRARY_ARCHITECTURE})
113     message(STATUS "additional library directories: ${ADDITIONAL_LIBRARY_PATHS}")
114 endif()
115
116 #####################################################################################
117
118 if (NOT MSVC)
119 option(SIMGEAR_SHARED   "Set to ON to build SimGear as a shared library/framework" OFF)
120 option(SYSTEM_EXPAT     "Set to ON to build SimGear using the system expat library" OFF)
121 option(SYSTEM_UDNS      "Set to ON to build SimGear using the system udns library" OFF)
122 else()
123 # Building SimGear DLLs is currently not supported for MSVC.
124 set(SIMGEAR_SHARED OFF)
125 # Using external 3rd party libraries is currently not supported for MSVC - it would require shared simgear (DLL).
126 set(SYSTEM_EXPAT OFF)
127 set(SYSTEM_UDNS OFF)
128 endif()
129
130 option(SIMGEAR_HEADLESS "Set to ON to build SimGear without GUI/graphics support" OFF)
131 option(ENABLE_RTI       "Set to ON to build SimGear with RTI support" OFF)
132 option(ENABLE_TESTS     "Set to OFF to disable building SimGear's test applications" ON)
133 option(ENABLE_SOUND     "Set to OFF to disable building SimGear's sound support" ON)
134 option(USE_AEONWAVE     "Set to ON to use AeonWave instead of OpenAL" OFF)
135 option(ENABLE_PKGUTIL   "Set to ON to build the sg_pkgutil application (default)" ON)
136 option(ENABLE_DNS       "Set to ON to use udns library and DNS service resolver" ON)
137
138 if (MSVC)
139   GET_FILENAME_COMPONENT(PARENT_DIR ${PROJECT_BINARY_DIR} PATH)
140   if (CMAKE_CL_64)
141     SET(TEST_3RDPARTY_DIR "${PARENT_DIR}/3rdparty.x64")
142   else (CMAKE_CL_64)
143     SET(TEST_3RDPARTY_DIR "${PARENT_DIR}/3rdparty")
144   endif (CMAKE_CL_64)
145   if (EXISTS ${TEST_3RDPARTY_DIR})
146     set(MSVC_3RDPARTY_ROOT ${PARENT_DIR} CACHE PATH "Location where the third-party dependencies are extracted")
147   else (EXISTS ${TEST_3RDPARTY_DIR})
148     set(MSVC_3RDPARTY_ROOT NOT_FOUND CACHE PATH "Location where the third-party dependencies are extracted")
149   endif (EXISTS ${TEST_3RDPARTY_DIR})
150 else (MSVC)
151   set(MSVC_3RDPARTY_ROOT NOT_FOUND CACHE PATH "Location where the third-party dependencies are extracted")
152 endif (MSVC)
153
154 if (MSVC AND MSVC_3RDPARTY_ROOT)
155   message(STATUS "3rdparty files located in ${MSVC_3RDPARTY_ROOT}")
156
157   set( OSG_MSVC "msvc" )
158   if (${MSVC_VERSION} EQUAL 1900)
159       set( OSG_MSVC ${OSG_MSVC}140 )
160   elseif (${MSVC_VERSION} EQUAL 1800)
161       set( OSG_MSVC ${OSG_MSVC}120 )
162   elseif (${MSVC_VERSION} EQUAL 1700)
163       set( OSG_MSVC ${OSG_MSVC}110 )
164   elseif (${MSVC_VERSION} EQUAL 1600)
165       set( OSG_MSVC ${OSG_MSVC}100 )
166   endif ()
167   if (CMAKE_CL_64)
168       set( OSG_MSVC ${OSG_MSVC}-64 )
169       set( MSVC_3RDPARTY_DIR 3rdParty.x64 )
170   else (CMAKE_CL_64)
171       set( MSVC_3RDPARTY_DIR 3rdParty )
172   endif (CMAKE_CL_64)
173
174   set (CMAKE_LIBRARY_PATH ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/lib ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenScenegraph/lib ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenRTI/lib )
175   set (CMAKE_INCLUDE_PATH ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenScenegraph/include ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenRTI/include)
176
177   GET_FILENAME_COMPONENT(MSVC_ROOT_PARENT_DIR ${MSVC_3RDPARTY_ROOT} PATH)
178   find_path(BOOST_ROOT boost/version.hpp
179       PATHS
180       ${MSVC_ROOT_PARENT_DIR}
181                         ${MSVC_3RDPARTY_ROOT}/boost
182                         ${MSVC_3RDPARTY_ROOT}/boost_1_52_0
183                         ${MSVC_3RDPARTY_ROOT}/boost_1_51_0
184                         ${MSVC_3RDPARTY_ROOT}/boost_1_50_0
185                         ${MSVC_3RDPARTY_ROOT}/boost_1_49_0
186                         ${MSVC_3RDPARTY_ROOT}/boost_1_48_0
187                         ${MSVC_3RDPARTY_ROOT}/boost_1_47_0
188                         ${MSVC_3RDPARTY_ROOT}/boost_1_46_1
189                         ${MSVC_3RDPARTY_ROOT}/boost_1_46_0
190                         ${MSVC_3RDPARTY_ROOT}/boost_1_45_0
191                         ${MSVC_3RDPARTY_ROOT}/boost_1_44_0
192                         )
193   # set (BOOST_ROOT ${MSVC_3RDPARTY_ROOT}/boost_1_44_0)
194   message(STATUS "BOOST_ROOT is ${BOOST_ROOT}")
195   if (NOT USE_AEONWAVE)
196     set (OPENAL_INCLUDE_DIR ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include)
197     set (OPENAL_LIBRARY_DIR ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/lib)
198     message(STATUS "OPENAL_INCLUDE_DIR is ${OPENAL_INCLUDE_DIR}")
199   endif()
200 endif (MSVC AND MSVC_3RDPARTY_ROOT)
201
202 if(APPLE)
203   find_library(COCOA_LIBRARY Cocoa)
204
205   # using 10.7 because boost requires libc++ and 10.6 doesn't include it
206   SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.7")
207 endif()
208
209 if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR
210         ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
211     find_package(Threads REQUIRED)
212 endif()
213
214 find_package(Boost REQUIRED)
215 set (BOOST_CXX_FLAGS "-DBOOST_BIMAP_DISABLE_SERIALIZATION")
216 include(BoostTestTargets)
217
218 if(SIMGEAR_HEADLESS)
219     message(STATUS "SimGear mode: HEADLESS")
220     set(ENABLE_SOUND 0)
221 else()
222     message(STATUS "SimGear mode: NORMAL")
223     find_package(OpenGL REQUIRED)
224
225     if (ENABLE_SOUND)
226         if (USE_AEONWAVE)
227             find_package(AAX COMPONENTS aax REQUIRED)
228             include_directories( ${AAX_INCLUDE_DIR} )
229         else()
230             find_package(OpenAL REQUIRED)
231             include_directories( ${OPENAL_INCLUDE_DIR} )
232         endif()
233
234         message(STATUS "Sound support: ENABLED")
235     endif(ENABLE_SOUND)
236
237     find_package(OpenSceneGraph 3.2.0 REQUIRED osgText osgSim osgDB osgParticle osgGA osgViewer osgUtil)
238 endif(SIMGEAR_HEADLESS)
239
240 find_package(ZLIB REQUIRED)
241 find_package(CURL REQUIRED)
242
243 if (SYSTEM_EXPAT)
244     message(STATUS "Requested to use system Expat library, forcing SIMGEAR_SHARED to true")
245     set(SIMGEAR_SHARED ON)
246     find_package(EXPAT REQUIRED)
247
248 else()
249     message(STATUS "Using built-in expat code")
250     # XML_STATIC is important to avoid sg_expat_external.h
251     # declaring symbols as declspec(import)
252     add_definitions(-DHAVE_EXPAT_CONFIG_H -DXML_STATIC)
253     set(EXPAT_INCLUDE_DIRS
254             ${PROJECT_SOURCE_DIR}/3rdparty/expat
255             ${PROJECT_BINARY_DIR}/3rdparty/expat)
256 endif(SYSTEM_EXPAT)
257
258 include_directories(${EXPAT_INCLUDE_DIRS})
259
260 check_include_file(inttypes.h HAVE_INTTYPES_H)
261 check_include_file(sys/time.h HAVE_SYS_TIME_H)
262 check_include_file(sys/timeb.h HAVE_SYS_TIMEB_H)
263 check_include_file(unistd.h HAVE_UNISTD_H)
264 check_include_file(windows.h HAVE_WINDOWS_H)
265
266 if(HAVE_INTTYPES_H)
267   # ShivaVG needs inttypes.h
268   add_definitions(-DHAVE_INTTYPES_H)
269 endif()
270
271 if(ENABLE_RTI)
272     # See if we have any rti library variant installed
273     message(STATUS "RTI: ENABLED")
274     find_package(RTI)
275 else()
276     message(STATUS "RTI: DISABLED")
277 endif(ENABLE_RTI)
278
279 check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
280 check_function_exists(ftime HAVE_FTIME)
281 check_function_exists(timegm HAVE_TIMEGM)
282 check_function_exists(rint HAVE_RINT)
283 check_function_exists(mkdtemp HAVE_MKDTEMP)
284 check_function_exists(bcopy HAVE_BCOPY)
285 check_function_exists(mmap HAVE_MMAP)
286
287 if(HAVE_UNISTD_H)
288     set(CMAKE_REQUIRED_INCLUDES ${CMAKE_INCLUDE_PATH})
289     check_cxx_source_compiles(
290        "#include <unistd.h>
291         #if !defined(_POSIX_TIMERS) || (0 >= _POSIX_TIMERS)
292             #error clock_gettime is not supported
293         #endif
294
295         int main() { return 0; }
296         "
297         HAVE_CLOCK_GETTIME)
298 endif(HAVE_UNISTD_H)
299
300 set(RT_LIBRARY "")
301 if(HAVE_CLOCK_GETTIME)
302     check_library_exists(rt clock_gettime "" HAVE_RT)
303     if(HAVE_RT)
304         set(RT_LIBRARY rt)
305     endif(HAVE_RT)
306 endif(HAVE_CLOCK_GETTIME)
307
308 set(DL_LIBRARY "")
309 check_cxx_source_compiles(
310     "#include <dlfcn.h>
311     int main(void) {
312         return 0;
313     }
314     "
315     HAVE_DLFCN_H)
316
317 if(HAVE_DLFCN_H)
318     check_library_exists(dl dlerror "" HAVE_DL)
319     if(HAVE_DL)
320         set(DL_LIBRARY "dl")
321     endif()
322 endif()
323
324 SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually 'd' on windows")
325 SET(CMAKE_RELEASE_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
326 SET(CMAKE_RELWITHDEBINFO_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
327 SET(CMAKE_MINSIZEREL_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
328
329 # isnan might not be real symbol, so can't check using function_exists
330 check_cxx_source_compiles(
331     "#include <cmath>
332     int main() { return isnan(0.0);} "
333     HAVE_ISNAN)
334
335 check_cxx_source_compiles(
336     "#include <cmath>
337     int main() { return std::isnan(0.0);} "
338     HAVE_STD_ISNAN)
339
340 if(CMAKE_COMPILER_IS_GNUCXX)
341     set(WARNING_FLAGS_CXX "-Wall")
342     set(WARNING_FLAGS_C   "-Wall")
343
344     # certain GCC versions don't provide the atomic builds, and hence
345     # require is to provide them in SGAtomic.cxx
346     set(CMAKE_REQUIRED_INCLUDES ${CMAKE_INCLUDE_PATH})
347     check_cxx_source_compiles(
348        "int main() { unsigned mValue; return __sync_add_and_fetch(&mValue, 1); }"
349         GCC_ATOMIC_BUILTINS_FOUND)
350 endif(CMAKE_COMPILER_IS_GNUCXX)
351
352 if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
353     # Boost redeclares class members
354     set(WARNING_FLAGS_CXX "-Wall -Wno-overloaded-virtual -Wno-redeclared-class-member")
355     set(WARNING_FLAGS_C   "-Wall")
356     set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
357     set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11")
358     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")
359 endif()
360
361 if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
362 # boost goes haywire wrt static asserts
363     check_cxx_compiler_flag(-Wno-unused-local-typedefs HAS_NOWARN_UNUSED_TYPEDEFS)
364     if(HAS_NOWARN_UNUSED_TYPEDEFS)
365         set(WARNING_FLAGS_CXX " ${WARNING_FLAGS_CXX} -Wno-unused-local-typedefs")
366     endif()
367 endif()
368
369 if(WIN32)
370
371     if(MINGW)
372         add_definitions(-D_WIN32_WINNT=0x501)
373     endif()
374
375     if(MSVC)
376         set(MSVC_FLAGS "-DWIN32 -DNOMINMAX -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D__CRT_NONSTDC_NO_WARNINGS /MP")
377
378         if (${MSVC_VERSION} GREATER 1599)
379           # needed to avoid link errors on multiply-defined standard C++
380           # symbols. Suspect this may be an OSG-DB export bug
381             set( MSVC_LD_FLAGS "/FORCE:MULTIPLE" )
382         endif (${MSVC_VERSION} GREATER 1599)
383
384         if (${MSVC_VERSION} GREATER 1899)
385             # needed for debug builds with VS2015
386             set( MSVC_FLAGS "${MSVC_FLAGS} /bigobj" )
387         endif()
388     endif(MSVC)
389
390     # assumed on Windows
391     set(HAVE_GETLOCALTIME 1)
392
393     set( WINSOCK_LIBRARY "ws2_32.lib" )
394     set( SHLWAPI_LIBRARY "Shlwapi.lib" )
395     set( RT_LIBRARY "winmm" )
396 endif(WIN32)
397
398 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS_C} ${MSVC_FLAGS}")
399 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS_CXX} ${MSVC_FLAGS} ${BOOST_CXX_FLAGS}")
400 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MSVC_LD_FLAGS}")
401
402 # use BEFORE to ensure local directories are used first,
403 # ahead of system-installed libs
404 include_directories(BEFORE ${PROJECT_SOURCE_DIR})
405 include_directories(BEFORE ${PROJECT_SOURCE_DIR}/simgear/canvas/ShivaVG/include)
406 include_directories(BEFORE ${PROJECT_BINARY_DIR}/simgear)
407
408 include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS}
409     ${Boost_INCLUDE_DIRS}
410     ${ZLIB_INCLUDE_DIR}
411     ${CURL_INCLUDE_DIRS}
412 )
413
414 add_definitions(-DHAVE_CONFIG_H)
415
416 # configure a header file to pass some of the CMake settings
417 # to the source code
418 configure_file (
419   "${PROJECT_SOURCE_DIR}/simgear/simgear_config_cmake.h.in"
420   "${PROJECT_BINARY_DIR}/simgear/simgear_config.h"
421   )
422
423 if(ENABLE_TESTS)
424     # enable CTest / make test target
425     message(STATUS "Tests: ENABLED")
426
427     include (Dart)
428     enable_testing()
429 else()
430     message(STATUS "Tests: DISABLED")
431 endif(ENABLE_TESTS)
432
433 # always set TEST_LIBS as it is also used by other tools/applications
434 set(TEST_LIBS_INTERNAL_CORE
435     ${CMAKE_THREAD_LIBS_INIT}
436     ${ZLIB_LIBRARY}
437     ${WINSOCK_LIBRARY}
438     ${SHLWAPI_LIBRARY}
439     ${RT_LIBRARY}
440     ${DL_LIBRARY}
441     ${COCOA_LIBRARY}
442     ${CURL_LIBRARIES})
443 set(TEST_LIBS SimGearCore ${TEST_LIBS_INTERNAL_CORE})
444
445 if(NOT SIMGEAR_HEADLESS)
446     set(TEST_LIBS SimGearScene ${OPENGL_LIBRARIES} ${TEST_LIBS})
447 endif()
448
449 install (FILES ${PROJECT_BINARY_DIR}/simgear/simgear_config.h  DESTINATION include/simgear/)
450
451 include_directories(3rdparty/utf8/source)
452
453 if(ENABLE_DNS)
454     if(SYSTEM_UDNS)
455         message(STATUS "Requested to use system udns library, forcing SIMGEAR_SHARED to true")
456         set(SIMGEAR_SHARED ON)
457         find_package(Udns REQUIRED)
458     else()
459         message(STATUS "DNS resolver: ENABLED")
460         include_directories(3rdparty/udns)
461     endif()
462 else()
463     message(STATUS "DNS resolver: DISABLED")
464 endif()
465
466
467 add_subdirectory(3rdparty)
468 add_subdirectory(simgear)
469
470 #-----------------------------------------------------------------------------
471 ### Export stuff, see https://cmake.org/cmake/help/v3.2/manual/cmake-packages.7.html#creating-packages
472 #-----------------------------------------------------------------------------
473
474 generate_export_header(SimGearCore)
475 if(NOT SIMGEAR_HEADLESS)
476   generate_export_header(SimGearScene)
477 endif()
478
479 include(CMakePackageConfigHelpers)
480
481 write_basic_package_version_file(
482   "${CMAKE_CURRENT_BINARY_DIR}/SimGear/SimGearConfigVersion.cmake"
483   VERSION ${SIMGEAR_VERSION}
484   COMPATIBILITY AnyNewerVersion
485 )
486
487 configure_file(SimGearConfig.cmake.in
488   "${CMAKE_CURRENT_BINARY_DIR}/SimGear/SimGearConfig.cmake"
489   @ONLY
490 )
491
492 set(ConfigPackageLocation lib/cmake/SimGear)
493 install(EXPORT SimGearTargets
494   DESTINATION ${ConfigPackageLocation}
495 )
496 install(
497   FILES
498     "${CMAKE_CURRENT_BINARY_DIR}/SimGear/SimGearConfig.cmake"
499     "${CMAKE_CURRENT_BINARY_DIR}/SimGear/SimGearConfigVersion.cmake"
500   DESTINATION ${ConfigPackageLocation}
501   COMPONENT Devel
502 )
503
504 #-----------------------------------------------------------------------------
505 ### uninstall target
506 #-----------------------------------------------------------------------------
507 CONFIGURE_FILE(
508   "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/cmake_uninstall.cmake.in"
509   "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
510   IMMEDIATE @ONLY)
511 ADD_CUSTOM_TARGET(uninstall
512   "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")