X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=CMakeLists.txt;h=603c830f87e2669bf76fcb80f65a38ebecabf035;hb=2aee9215533f30a664690b18b54659624f85d3a5;hp=6aa1768c0ca63ea41a8cf6853ab4b3bb1a53f6c3;hpb=3c204e84f4530522648f1a8035e43feb6ed32f79;p=simgear.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 6aa1768c..603c830f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6.4) +cmake_minimum_required (VERSION 2.8.11) if(COMMAND cmake_policy) if(POLICY CMP0054) @@ -14,6 +14,23 @@ 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) + +# 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) @@ -21,6 +38,9 @@ project(SimGear) 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) @@ -73,12 +93,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}") ##################################################################################### @@ -102,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) @@ -115,6 +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_DNS "Set to ON to use udns library and DNS service resolver" ON) if (MSVC) GET_FILENAME_COMPONENT(PARENT_DIR ${PROJECT_BINARY_DIR} PATH) @@ -134,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 ) @@ -151,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 @@ -172,7 +197,7 @@ 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() @@ -181,7 +206,7 @@ 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) @@ -204,6 +229,7 @@ else() endif(SIMGEAR_HEADLESS) find_package(ZLIB REQUIRED) +find_package(CURL REQUIRED) if (SYSTEM_EXPAT) message(STATUS "Requested to use system Expat library, forcing SIMGEAR_SHARED to true") @@ -338,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 @@ -370,6 +399,7 @@ include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR} ${OPENAL_INCLUDE_DIR} + ${CURL_INCLUDE_DIRS} ) add_definitions(-DHAVE_CONFIG_H) @@ -398,7 +428,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) @@ -409,9 +440,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 #----------------------------------------------------------------------------- @@ -421,5 +500,3 @@ CONFIGURE_FILE( IMMEDIATE @ONLY) ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") - -