]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Merge pull request #14992 from tamiko/use_cmake_target_properties_2
authorMatthias Maier <tamiko@43-1.org>
Thu, 30 Mar 2023 22:11:48 +0000 (22:11 +0000)
committerGitHub <noreply@github.com>
Thu, 30 Mar 2023 22:11:48 +0000 (22:11 +0000)
CMake: prefer CMAKE_CXX_STANDARD and export cxx_std_?? COMPILE_FEATURES target property

1  2 
cmake/checks/check_01_cxx_features.cmake
source/CMakeLists.txt

index a264a44f513f193933056163d4faa4dee99119bb,e73819c42499ec1cc2e46e996bb7cec97fba43c9..feea4a680bc900716f08d8319d5a5f9e10ee3606
@@@ -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}"

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.