]> git.mxchange.org Git - simgear.git/blobdiff - CMakeLists.txt
Don't continue parsing after processing version line
[simgear.git] / CMakeLists.txt
index b1bc64b2c2ddb2e14fcb8b749c9aeb368fb655d9..e0d09808d9fcbf6c52d8b7b37ac04d5a6766b13f 100644 (file)
@@ -1,21 +1,27 @@
-cmake_minimum_required (VERSION 2.6.4)
+cmake_minimum_required (VERSION 2.8.11)
 
 if(COMMAND cmake_policy)
-    if(${CMAKE_MAJOR_VERSION} GREATER 2) # version 3 or higher
-        cmake_policy(SET CMP0054 NEW)
-        cmake_policy(SET CMP0042 NEW)
-    endif()
+   if(POLICY CMP0054)
+       cmake_policy(SET CMP0054 NEW)
+   endif()
+   if(POLICY CMP0042)
+       cmake_policy(SET CMP0042 NEW)
+   endif()
 endif()
 
 include (CheckFunctionExists)
 include (CheckIncludeFile)
+include (CheckLibraryExists)
 include (CheckCXXSourceCompiles)
 include (CheckCXXCompilerFlag)
+include (GenerateExportHeader)
 
-# set this before project()
 # using 10.7 because boost requires libc++ and 10.6 doesn't include it
 set(CMAKE_OSX_DEPLOYMENT_TARGET 10.7)
 
+# only relevant for building shared libs but let's set it regardless
+set(CMAKE_OSX_RPATH 1)
+
 project(SimGear)
 
 # read 'version' file into a variable (stripping any newlines or spaces)
@@ -74,12 +80,7 @@ endif(NOT CMAKE_BUILD_TYPE)
 # Determine name of library installation directory, i.e. "lib" vs "lib64", which
 # differs between all Debian-based vs all other Linux distros.
 # See cmake bug #11964, http://cmake.org/gitweb?p=cmake.git;a=commit;h=126c993d
-# GNUInstallDirs requires CMake >= 2.8.5, use own file for older cmake
-if(${CMAKE_VERSION} VERSION_GREATER 2.8.4)
-  include(GNUInstallDirs)
-else(${CMAKE_VERSION} VERSION_GREATER 2.8.4)
-  include(OldGNUInstallDirs)
-endif(${CMAKE_VERSION} VERSION_GREATER 2.8.4)
+include(GNUInstallDirs)
 message(STATUS "Library installation directory: ${CMAKE_INSTALL_LIBDIR}")
 
 #####################################################################################
@@ -116,6 +117,8 @@ 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(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)
@@ -173,13 +176,21 @@ 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
+       ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
+    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_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_BIMAP_DISABLE_SERIALIZATION")
+set (BOOST_CXX_FLAGS "-DBOOST_BIMAP_DISABLE_SERIALIZATION")
 
 if(SIMGEAR_HEADLESS)
     message(STATUS "SimGear mode: HEADLESS")
@@ -197,7 +208,11 @@ else()
 endif(SIMGEAR_HEADLESS)
 
 find_package(ZLIB REQUIRED)
-find_package(Threads REQUIRED)
+
+if (ENABLE_CURL)
+  find_package(CURL REQUIRED)
+  message(STATUS "Curl HTTP client: ENABLED")
+endif()
 
 if (SYSTEM_EXPAT)
     message(STATUS "Requested to use system Expat library, forcing SIMGEAR_SHARED to true")
@@ -309,8 +324,12 @@ if(CMAKE_COMPILER_IS_GNUCXX)
 endif(CMAKE_COMPILER_IS_GNUCXX)
 
 if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
-   set(WARNING_FLAGS_CXX "-Wall -Wno-overloaded-virtual")
-   set(WARNING_FLAGS_C   "-Wall")
+    # Boost redeclares class members
+    set(WARNING_FLAGS_CXX "-Wall -Wno-overloaded-virtual -Wno-redeclared-class-member")
+    set(WARNING_FLAGS_C   "-Wall")
+    set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
+    set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")
 endif()
 
 if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
@@ -360,6 +379,7 @@ include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS}
     ${Boost_INCLUDE_DIRS}
     ${ZLIB_INCLUDE_DIR}
     ${OPENAL_INCLUDE_DIR}
+    ${CURL_INCLUDE_DIRS}
 )
 
 add_definitions(-DHAVE_CONFIG_H)
@@ -388,7 +408,8 @@ set(TEST_LIBS_INTERNAL_CORE
     ${WINSOCK_LIBRARY}
     ${RT_LIBRARY}
     ${DL_LIBRARY}
-    ${COCOA_LIBRARY})
+    ${COCOA_LIBRARY}
+    ${CURL_LIBRARIES})
 set(TEST_LIBS SimGearCore ${TEST_LIBS_INTERNAL_CORE})
 
 if(NOT SIMGEAR_HEADLESS)
@@ -398,10 +419,51 @@ endif()
 install (FILES ${PROJECT_BINARY_DIR}/simgear/simgear_config.h  DESTINATION include/simgear/)
 
 include_directories(3rdparty/utf8/source)
+if (ENABLE_DNS)
+    message(STATUS "DNS resolver: ENABLED")
+    include_directories(3rdparty/udns)
+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
 #-----------------------------------------------------------------------------
@@ -411,5 +473,3 @@ CONFIGURE_FILE(
   IMMEDIATE @ONLY)
 ADD_CUSTOM_TARGET(uninstall
   "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
-
-