From: Matthias Maier Date: Thu, 30 Mar 2023 22:11:48 +0000 (+0000) Subject: Merge pull request #14992 from tamiko/use_cmake_target_properties_2 X-Git-Tag: v9.5.0-rc1~394 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd40e7bc4c9c3d1505204390caeef605d99e7cb7;p=dealii.git Merge pull request #14992 from tamiko/use_cmake_target_properties_2 CMake: prefer CMAKE_CXX_STANDARD and export cxx_std_?? COMPILE_FEATURES target property --- cd40e7bc4c9c3d1505204390caeef605d99e7cb7 diff --cc source/CMakeLists.txt index a264a44f51,e73819c424..feea4a680b --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@@ -116,19 -97,29 +116,29 @@@ foreach(build ${DEAL_II_BUILD_TYPES} # Add compile flags, definitions and (public) feature (recorded in # DEAL_II_TARGETS(|_DEBUG|_RELEASE)). # - populate_target_properties(${DEAL_II_NAMESPACE}_${build_lowercase} ${build}) + populate_target_properties(${DEAL_II_TARGET_NAME}_${build_lowercase} ${build}) + # + # Record the expected C++ standard as a compile feature. This target + # property ensures that support for our expected C++ standard is always + # enabled in client user code irrespective of what compile flags/options + # they have set. + # + target_compile_features(${DEAL_II_NAMESPACE}_${build_lowercase} + INTERFACE cxx_std_${CMAKE_CXX_STANDARD} + ) + if(BUILD_SHARED_LIBS) # # Add all object targets as private link targets # get_property(_object_targets GLOBAL PROPERTY DEAL_II_OBJECT_TARGETS_${build}) - target_link_libraries(${DEAL_II_NAMESPACE}_${build_lowercase} + target_link_libraries(${DEAL_II_TARGET_NAME}_${build_lowercase} PRIVATE ${_object_targets} ) - endif() + endif() - set_target_properties(${DEAL_II_NAMESPACE}_${build_lowercase} + set_target_properties(${DEAL_II_TARGET_NAME}_${build_lowercase} PROPERTIES LINKER_LANGUAGE "CXX" VERSION "${DEAL_II_PACKAGE_VERSION}"