]> git.mxchange.org Git - simgear.git/blobdiff - CMakeLists.txt
VS215 tweaks, warning fixes
[simgear.git] / CMakeLists.txt
index 7329f0bf5c9acfae6959ce8090be498d3e9ba12a..603c830f87e2669bf76fcb80f65a38ebecabf035 100644 (file)
@@ -22,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)
@@ -104,12 +117,14 @@ 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)
@@ -117,8 +132,7 @@ 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" 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)
@@ -138,14 +152,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 )
@@ -155,7 +172,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
@@ -177,10 +198,8 @@ endif (MSVC AND MSVC_3RDPARTY_ROOT)
 if(APPLE)
   find_library(COCOA_LIBRARY Cocoa)
 
-# this should be handled by setting CMAKE_OSX_DEPLOYMENT_TARGET
-# but it's not working reliably, so forcing it for now
+  # 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")
-  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmacosx-version-min=10.7")
 endif()
 
 if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR
@@ -210,11 +229,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")
@@ -349,15 +364,18 @@ 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
@@ -421,9 +439,16 @@ 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)
+
+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()