]> git.mxchange.org Git - simgear.git/blobdiff - CMakeLists.txt
Activate AeonWave by setting USE_AEONWAVE to ON
[simgear.git] / CMakeLists.txt
index e8d493ea6476c51f66f1d03e414448df450c9252..22ecd3e07773ea93082fb0950828159d8c5bb1bd 100644 (file)
@@ -14,6 +14,7 @@ include (CheckIncludeFile)
 include (CheckLibraryExists)
 include (CheckCXXSourceCompiles)
 include (CheckCXXCompilerFlag)
+include (GenerateExportHeader)
 
 # using 10.7 because boost requires libc++ and 10.6 doesn't include it
 set(CMAKE_OSX_DEPLOYMENT_TARGET 10.7)
@@ -21,12 +22,25 @@ set(CMAKE_OSX_DEPLOYMENT_TARGET 10.7)
 # only relevant for building shared libs but let's set it regardless
 set(CMAKE_OSX_RPATH 1)
 
+# Set the C++ standard to C++98 to avoid compilation errors on GCC 6 (which
+# defaults to C++14).
+if(CMAKE_VERSION VERSION_LESS "3.1")
+  if(CMAKE_COMPILER_IS_GNUCXX)
+    set (CMAKE_CXX_FLAGS "-std=gnu++98 ${CMAKE_CXX_FLAGS}")
+  endif()
+else()
+  set (CMAKE_CXX_STANDARD 98)
+endif()
+
 project(SimGear)
 
 # read 'version' file into a variable (stripping any newlines or spaces)
 file(READ version versionFile)
 string(STRIP ${versionFile} SIMGEAR_VERSION)
 
+# add a dependency on the versino file
+set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS version)
+
 set(FIND_LIBRARY_USE_LIB64_PATHS ON)
 
 # use simgear version also as the SO version (if building SOs)
@@ -103,20 +117,23 @@ endif()
 
 if (NOT MSVC)
 option(SIMGEAR_SHARED   "Set to ON to build SimGear as a shared library/framework" OFF)
-option(SYSTEM_EXPAT     "Set to ON to build SimGear using the system libExpat" OFF)
+option(SYSTEM_EXPAT     "Set to ON to build SimGear using the system expat library" OFF)
+option(SYSTEM_UDNS      "Set to ON to build SimGear using the system udns library" OFF)
 else()
 # Building SimGear DLLs is currently not supported for MSVC.
 set(SIMGEAR_SHARED OFF)
-# Using a system expat is currently not supported for MSVC - it would require shared simgear (DLL).
+# Using external 3rd party libraries is currently not supported for MSVC - it would require shared simgear (DLL).
 set(SYSTEM_EXPAT OFF)
+set(SYSTEM_UDNS OFF)
 endif()
 
 option(SIMGEAR_HEADLESS "Set to ON to build SimGear without GUI/graphics support" OFF)
 option(ENABLE_RTI       "Set to ON to build SimGear with RTI support" OFF)
 option(ENABLE_TESTS     "Set to OFF to disable building SimGear's test applications" ON)
 option(ENABLE_SOUND     "Set to OFF to disable building SimGear's sound support" ON)
+option(USE_AEONWAVE     "Set to ON to use AeonWave instead of OpenAL" ON)
 option(ENABLE_PKGUTIL   "Set to ON to build the sg_pkgutil application (default)" ON)
-option(ENABLE_CURL      "Set to ON to use libCurl as the HTTP client backend" OFF)
+option(ENABLE_DNS       "Set to ON to use udns library and DNS service resolver" ON)
 
 if (MSVC)
   GET_FILENAME_COMPONENT(PARENT_DIR ${PROJECT_BINARY_DIR} PATH)
@@ -136,14 +153,17 @@ endif (MSVC)
 
 if (MSVC AND MSVC_3RDPARTY_ROOT)
   message(STATUS "3rdparty files located in ${MSVC_3RDPARTY_ROOT}")
+
   set( OSG_MSVC "msvc" )
-  if (${MSVC_VERSION} EQUAL 1700)
+  if (${MSVC_VERSION} EQUAL 1900)
+      set( OSG_MSVC ${OSG_MSVC}140 )
+  elseif (${MSVC_VERSION} EQUAL 1800)
+      set( OSG_MSVC ${OSG_MSVC}120 )
+  elseif (${MSVC_VERSION} EQUAL 1700)
       set( OSG_MSVC ${OSG_MSVC}110 )
   elseif (${MSVC_VERSION} EQUAL 1600)
       set( OSG_MSVC ${OSG_MSVC}100 )
-  else (${MSVC_VERSION} EQUAL 1700)
-      set( OSG_MSVC ${OSG_MSVC}90 )
-  endif (${MSVC_VERSION} EQUAL 1700)
+  endif ()
   if (CMAKE_CL_64)
       set( OSG_MSVC ${OSG_MSVC}-64 )
       set( MSVC_3RDPARTY_DIR 3rdParty.x64 )
@@ -153,7 +173,11 @@ if (MSVC AND MSVC_3RDPARTY_ROOT)
 
   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 )
   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)
+
+  GET_FILENAME_COMPONENT(MSVC_ROOT_PARENT_DIR ${MSVC_3RDPARTY_ROOT} PATH)
   find_path(BOOST_ROOT boost/version.hpp
+      PATHS
+      ${MSVC_ROOT_PARENT_DIR}
                        ${MSVC_3RDPARTY_ROOT}/boost
                        ${MSVC_3RDPARTY_ROOT}/boost_1_52_0
                        ${MSVC_3RDPARTY_ROOT}/boost_1_51_0
@@ -168,12 +192,19 @@ if (MSVC AND MSVC_3RDPARTY_ROOT)
                        )
   # set (BOOST_ROOT ${MSVC_3RDPARTY_ROOT}/boost_1_44_0)
   message(STATUS "BOOST_ROOT is ${BOOST_ROOT}")
-  set (OPENAL_INCLUDE_DIR ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include)
-  set (OPENAL_LIBRARY_DIR ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/lib)
+  if (USE_AEONWAVE)
+    find_package(AAX COMPONENTS aax REQUIRED)
+  else()
+    set (OPENAL_INCLUDE_DIR ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include)
+    set (OPENAL_LIBRARY_DIR ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/lib)
+  endif()
 endif (MSVC AND MSVC_3RDPARTY_ROOT)
 
 if(APPLE)
   find_library(COCOA_LIBRARY Cocoa)
+
+  # using 10.7 because boost requires libc++ and 10.6 doesn't include it
+  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.7")
 endif()
 
 if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR
@@ -181,11 +212,9 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR
     find_package(Threads REQUIRED)
 endif()
 
-# Somehow this only works if included before searching for Boost...
-include(BoostTestTargets)
-
 find_package(Boost REQUIRED)
 set (BOOST_CXX_FLAGS "-DBOOST_BIMAP_DISABLE_SERIALIZATION")
+include(BoostTestTargets)
 
 if(SIMGEAR_HEADLESS)
     message(STATUS "SimGear mode: HEADLESS")
@@ -203,11 +232,7 @@ else()
 endif(SIMGEAR_HEADLESS)
 
 find_package(ZLIB REQUIRED)
-
-if (ENABLE_CURL)
-  find_package(Curl REQUIRED)
-  message(STATUS "Curl HTTP client: ENABLED")
-endif()
+find_package(CURL REQUIRED)
 
 if (SYSTEM_EXPAT)
     message(STATUS "Requested to use system Expat library, forcing SIMGEAR_SHARED to true")
@@ -342,21 +367,25 @@ if(WIN32)
     endif()
 
     if(MSVC)
-        # turn off various warnings
-        # foreach(warning 4244 4251 4267 4275 4290 4786 4305 4996)
-        #     SET(WARNING_FLAGS "${WARNING_FLAGS} /wd${warning}")
-        # endforeach(warning)
+        set(MSVC_FLAGS "-DWIN32 -DNOMINMAX -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D__CRT_NONSTDC_NO_WARNINGS /MP")
 
-        set(MSVC_FLAGS "-DWIN32 -DNOMINMAX -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D__CRT_NONSTDC_NO_WARNINGS /wd4996 /wd4250 -Dstrdup=_strdup")
         if (${MSVC_VERSION} GREATER 1599)
+          # needed to avoid link errors on multiply-defined standard C++
+          # symbols. Suspect this may be an OSG-DB export bug
             set( MSVC_LD_FLAGS "/FORCE:MULTIPLE" )
         endif (${MSVC_VERSION} GREATER 1599)
+
+        if (${MSVC_VERSION} GREATER 1899)
+            # needed for debug builds with VS2015
+            set( MSVC_FLAGS "${MSVC_FLAGS} /bigobj" )
+        endif()
     endif(MSVC)
 
     # assumed on Windows
     set(HAVE_GETLOCALTIME 1)
 
     set( WINSOCK_LIBRARY "ws2_32.lib" )
+    set( SHLWAPI_LIBRARY "Shlwapi.lib" )
     set( RT_LIBRARY "winmm" )
 endif(WIN32)
 
@@ -373,10 +402,20 @@ include_directories(BEFORE ${PROJECT_BINARY_DIR}/simgear)
 include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS}
     ${Boost_INCLUDE_DIRS}
     ${ZLIB_INCLUDE_DIR}
-    ${OPENAL_INCLUDE_DIR}
     ${CURL_INCLUDE_DIRS}
 )
 
+if (USE_AEONWAVE)
+    find_package(AAX COMPONENTS aax REQUIRED)
+    include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS}
+        ${AAX_INCLUDE_DIR}
+    )
+else()
+    include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS}
+        ${OPENAL_INCLUDE_DIR}
+    )
+endif()
+
 add_definitions(-DHAVE_CONFIG_H)
 
 # configure a header file to pass some of the CMake settings
@@ -401,6 +440,7 @@ set(TEST_LIBS_INTERNAL_CORE
     ${CMAKE_THREAD_LIBS_INIT}
     ${ZLIB_LIBRARY}
     ${WINSOCK_LIBRARY}
+    ${SHLWAPI_LIBRARY}
     ${RT_LIBRARY}
     ${DL_LIBRARY}
     ${COCOA_LIBRARY}
@@ -415,9 +455,57 @@ install (FILES ${PROJECT_BINARY_DIR}/simgear/simgear_config.h  DESTINATION inclu
 
 include_directories(3rdparty/utf8/source)
 
+if(ENABLE_DNS)
+    if(SYSTEM_UDNS)
+        message(STATUS "Requested to use system udns library, forcing SIMGEAR_SHARED to true")
+        set(SIMGEAR_SHARED ON)
+        find_package(Udns REQUIRED)
+    else()
+        message(STATUS "DNS resolver: ENABLED")
+        include_directories(3rdparty/udns)
+    endif()
+else()
+    message(STATUS "DNS resolver: DISABLED")
+endif()
+
+
 add_subdirectory(3rdparty)
 add_subdirectory(simgear)
 
+#-----------------------------------------------------------------------------
+### Export stuff, see https://cmake.org/cmake/help/v3.2/manual/cmake-packages.7.html#creating-packages
+#-----------------------------------------------------------------------------
+
+generate_export_header(SimGearCore)
+if(NOT SIMGEAR_HEADLESS)
+  generate_export_header(SimGearScene)
+endif()
+
+include(CMakePackageConfigHelpers)
+
+write_basic_package_version_file(
+  "${CMAKE_CURRENT_BINARY_DIR}/SimGear/SimGearConfigVersion.cmake"
+  VERSION ${SIMGEAR_VERSION}
+  COMPATIBILITY AnyNewerVersion
+)
+
+configure_file(SimGearConfig.cmake.in
+  "${CMAKE_CURRENT_BINARY_DIR}/SimGear/SimGearConfig.cmake"
+  @ONLY
+)
+
+set(ConfigPackageLocation lib/cmake/SimGear)
+install(EXPORT SimGearTargets
+  DESTINATION ${ConfigPackageLocation}
+)
+install(
+  FILES
+    "${CMAKE_CURRENT_BINARY_DIR}/SimGear/SimGearConfig.cmake"
+    "${CMAKE_CURRENT_BINARY_DIR}/SimGear/SimGearConfigVersion.cmake"
+  DESTINATION ${ConfigPackageLocation}
+  COMPONENT Devel
+)
+
 #-----------------------------------------------------------------------------
 ### uninstall target
 #-----------------------------------------------------------------------------