C++17: use an OBJECT_LIBRARY to build HLA

This allows us to easily have different CXX version for the HLA code,
to the rest of the project.
This commit is contained in:
James Turner 2020-06-21 19:31:35 +01:00
parent 26b207f20c
commit 346344ee09
4 changed files with 39 additions and 33 deletions

View File

@ -213,7 +213,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD
endif()
find_package(Boost REQUIRED)
set (BOOST_CXX_FLAGS "-DBOOST_BIMAP_DISABLE_SERIALIZATION -DBOOST_NO_STDLIB_CONFIG")
set (BOOST_CXX_FLAGS "-DBOOST_BIMAP_DISABLE_SERIALIZATION -DBOOST_NO_STDLIB_CONFIG -DBOOST_NO_AUTO_PTR -DBOOST_NO_CXX98_BINDERS")
include(BoostTestTargets)
if(SIMGEAR_HEADLESS)
@ -287,7 +287,7 @@ if(ENABLE_RTI)
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
SET(ENV{PKG_CONFIG_PATH} "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig:$ENV{PKG_CONFIG_PATH}")
pkg_check_modules(RTI hla-rti13)
pkg_check_modules(RTI IMPORTED_TARGET hla-rti13)
endif(PKG_CONFIG_FOUND)
if(RTI_FOUND)
message(STATUS "RTI: ENABLED")
@ -360,16 +360,6 @@ SET(CMAKE_RELEASE_POSTFIX "" CACHE STRING "add a postfix, usually empty on windo
SET(CMAKE_RELWITHDEBINFO_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
SET(CMAKE_MINSIZEREL_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
# isnan might not be real symbol, so can't check using function_exists
check_cxx_source_compiles(
"#include <cmath>
int main() { return std::isnan(0.0);} "
HAVE_STD_ISNAN)
if (NOT ${HAVE_STD_ISNAN})
message(FATAL_ERROR "Your compiler lacks C++11 std::isnan, please update it")
endif()
# Check if the <regex> implementation in the C++ standard library is usable.
# This is necessary because g++ 4.8 lies about its C++11 compliance: its
# <regex> is utterly unusable, cf. [1].

View File

@ -2,6 +2,7 @@ include(CMakeFindDependencyMacro)
find_dependency(ZLIB)
find_dependency(Threads)
find_dependency(CURL)
# OSG
@ -21,11 +22,10 @@ set(ENABLE_SIMD @ENABLE_SIMD@)
# OpenRTI support
set(ENABLE_RTI @ENABLE_RTI@)
if(ENABLE_RTI)
set(RTI_FOUND @RTI_FOUND@)
if(RTI_FOUND)
set(RTI_INCLUDE_DIRS @RTI_INCLUDE_DIRS@)
set(RTI_LDFLAGS @RTI_LDFLAGS@)
endif(RTI_FOUND)
find_dependency(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_check_modules(RTI IMPORTED_TARGET hla-rti13)
endif(PKG_CONFIG_FOUND)
endif(ENABLE_RTI)
# Alternative terrain engine based on pagedLOD

View File

@ -124,9 +124,9 @@ target_include_directories(SimGearCore BEFORE PUBLIC
$<INSTALL_INTERFACE:include>)
target_include_directories(SimGearCore PUBLIC
${Boost_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR})
${Boost_INCLUDE_DIRS})
target_include_directories(SimGearCore PRIVATE
${EXPAT_INCLUDE_DIRS} ${CURL_INCLUDE_DIRS})
${EXPAT_INCLUDE_DIRS} )
if (NOT SYSTEM_EXPAT)
# XML_STATIC is important to avoid sg_expat_external.h
@ -159,14 +159,19 @@ if (NOT SIMGEAR_HEADLESS)
endif()
# we expose ZLib in some of our headers
target_link_libraries(SimGearCore PUBLIC ${ZLIB_LIBRARY})
target_link_libraries(SimGearCore PUBLIC ZLIB::ZLIB)
if (ENABLE_RTI)
target_sources(SimGearCore PRIVATE $<TARGET_OBJECTS:rti> $<TARGET_OBJECTS:rti13>)
target_link_libraries(SimGearCore PRIVATE PkgConfig::RTI)
endif()
target_link_libraries(SimGearCore PRIVATE
${RT_LIBRARY}
${DL_LIBRARY}
${CMAKE_THREAD_LIBS_INIT}
${COCOA_LIBRARY}
${CURL_LIBRARIES}
CURL::libcurl
${WINSOCK_LIBRARY})
if(SYSTEM_EXPAT)
@ -186,7 +191,7 @@ if(NOT SIMGEAR_HEADLESS)
)
target_link_libraries(SimGearScene PRIVATE
${ZLIB_LIBRARY}
ZLIB::ZLIB
${OPENAL_LIBRARY}
${OPENGL_LIBRARY}
${JPEG_LIBRARY})
@ -198,11 +203,3 @@ if(NOT SIMGEAR_HEADLESS)
# only actually needed by canvas/KeyboardEvent.cxx
target_include_directories(SimGearScene PRIVATE ${PROJECT_SOURCE_DIR}/3rdparty/utf8/source)
endif()
if(ENABLE_RTI)
# Ugly first aid to make hla compile agian
set_property(SOURCE hla/RTI13InteractionClass.cxx hla/RTI13ObjectClass.cxx
hla/RTI13ObjectInstance.cxx hla/RTI13Federate.cxx
hla/RTI13FederateFactory.cxx
APPEND PROPERTY COMPILE_FLAGS "-I${RTI_INCLUDE_DIRS}")
endif(ENABLE_RTI)

View File

@ -50,6 +50,7 @@ set(HLA_SOURCES
HLAVariantRecordDataElement.cxx
HLAVariantRecordDataType.cxx
)
simgear_component(hla hla "${HLA_SOURCES}" "${HLA_HEADERS}")
if(RTI_FOUND)
@ -60,7 +61,16 @@ if(RTI_FOUND)
RTI13Federate.cxx
RTI13FederateFactory.cxx
)
simgear_component(rti13 hla "${RTI13_SOURCES}" "")
add_library(rti13 OBJECT ${RTI13_SOURCES})
target_include_directories(rti13 PUBLIC ${PROJECT_SOURCE_DIR})
target_include_directories(rti13 PUBLIC ${PROJECT_BINARY_DIR})
#target_include_directories(rti13 PRIVATE ${RTI_INCLUDE_DIRS})
target_link_libraries(rti13 PRIVATE PkgConfig::RTI)
set_property(TARGET rti13 PROPERTY CXX_STANDARD 11)
#simgear_component(rti13 hla "${RTI13_SOURCES}" "")
endif()
set(RTI_SOURCES
@ -71,4 +81,13 @@ set(RTI_SOURCES
RTIFederateFactory.cxx
RTIFederateFactoryRegistry.cxx
)
simgear_component(rti hla "${RTI_SOURCES}" "")
add_library(rti OBJECT ${RTI_SOURCES})
target_include_directories(rti PUBLIC ${PROJECT_SOURCE_DIR})
target_include_directories(rti PUBLIC ${PROJECT_BINARY_DIR})
#target_include_directories(rti PRIVATE ${RTI_INCLUDE_DIRS})
target_link_libraries(rti PRIVATE PkgConfig::RTI)
set_property(TARGET rti PROPERTY CXX_STANDARD 11)
#simgear_component(rti hla "${RTI_SOURCES}" "")