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

@@ -8,6 +8,7 @@
set(plugin FairMQPlugin_dds)
add_library(${plugin} SHARED ${CMAKE_CURRENT_SOURCE_DIR}/DDS.cxx ${CMAKE_CURRENT_SOURCE_DIR}/DDS.h)
target_compile_features(${plugin} PUBLIC cxx_std_17)
target_link_libraries(${plugin} PUBLIC FairMQ StateMachine DDS::dds_intercom_lib DDS::dds_protocol_lib Boost::boost PRIVATE Commands)
target_include_directories(${plugin} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
set_target_properties(${plugin} PROPERTIES CXX_VISIBILITY_PRESET hidden)

View File

@@ -13,6 +13,7 @@ add_library(${plugin} SHARED
${CMAKE_CURRENT_SOURCE_DIR}/PMIxCommands.h
${CMAKE_CURRENT_SOURCE_DIR}/PMIx.hpp
)
target_compile_features(${plugin} PUBLIC cxx_std_17)
target_link_libraries(${plugin} PUBLIC FairMQ PMIx::libpmix PRIVATE Commands)
target_include_directories(${plugin} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
set_target_properties(${plugin} PROPERTIES