cmake: Use target_compile_features()

Problem at hand: dependents (like FairRoot) need to know the
minimum C++ standard level that FairMQ (and its headers)
requires.

The first idea is to let the targets export their
CXX_STANDARD value. First, this doesn't seem to work as
expected.

Second, target_compile_features() seems to be the better
way to go. It has a much better granularity, automatically
has the export feature, and thus should make dependents
behave correctly.

Also drop all of this enforeced CMAKE_CXX_STANDARD*
setting. If it's given, check it. But that's it.

See: https://gitlab.kitware.com/cmake/cmake/-/issues/18446
See: https://cmake.org/cmake/help/latest/manual/cmake-compile-features.7.html#requiring-language-standards
This commit is contained in:
Christian Tacke
2021-02-20 20:03:09 +01:00
committed by Dennis Klein
parent 2c7c46f2fd
commit cf12379afa
6 changed files with 10 additions and 6 deletions

View File

@@ -47,6 +47,7 @@ if(BUILD_FAIRMQ OR BUILD_SDK)
${TOOLS_SOURCE_FILES}
${TOOLS_PUBLIC_HEADER_FILES}
)
target_compile_features(${target} PUBLIC cxx_std_17)
target_compile_definitions(${target} PUBLIC BOOST_ERROR_CODE_HEADER_ONLY)
# workaround https://github.com/boostorg/asio/commit/43874d5497414c67655d901e48c939ef01337edb
if( Boost_VERSION VERSION_LESS 1.69
@@ -106,6 +107,7 @@ if(BUILD_FAIRMQ OR BUILD_SDK)
${FSM_SOURCE_FILES}
${FSM_PUBLIC_HEADER_FILES}
)
target_compile_features(${target} PUBLIC cxx_std_17)
target_compile_definitions(${target} PUBLIC BOOST_ERROR_CODE_HEADER_ONLY)
target_include_directories(${target}
PUBLIC
@@ -267,6 +269,7 @@ if(BUILD_FAIRMQ)
${FAIRMQ_PUBLIC_HEADER_FILES} # for IDE integration
${FAIRMQ_PRIVATE_HEADER_FILES} # for IDE integration
)
target_compile_features(${_target} PUBLIC cxx_std_17)
set_target_properties(${_target} PROPERTIES LABELS coverage)
if(FAST_BUILD)
set_target_properties(${_target} PROPERTIES OUTPUT_NAME FairMQ)
@@ -375,6 +378,7 @@ if(BUILD_FAIRMQ)
target_link_libraries(fairmq-splitter FairMQ)
add_executable(fairmq-shmmonitor shmem/Monitor.cxx shmem/Monitor.h shmem/runMonitor.cxx)
target_compile_features(fairmq-shmmonitor PUBLIC cxx_std_17)
target_compile_definitions(fairmq-shmmonitor PUBLIC BOOST_ERROR_CODE_HEADER_ONLY)
if(FAIRMQ_DEBUG_MODE)
target_compile_definitions(fairmq-shmmonitor PUBLIC FAIRMQ_DEBUG_MODE)