diff options
author | 2023-02-23 12:30:02 -0800 | |
---|---|---|
committer | 2023-02-23 12:30:51 -0800 | |
commit | 6d16237574fed8538a4864954a5e2b5a098f32f2 (patch) | |
tree | 377880ab3960bdb30d6c7a1db8313824a186b9c2 | |
parent | 0f35765048ea9b9fce70dc7c7781bed3321d99cd (diff) |
cleanup: remove pre-CMake 3.8 workarounds
Since Abseil requires CMake >= 3.10, we can remove some workarounds.
PiperOrigin-RevId: 511856584
Change-Id: I0385fa87b51147b69df7e2dd18b317cf6cde83c2
-rw-r--r-- | CMake/AbseilDll.cmake | 21 | ||||
-rw-r--r-- | CMake/AbseilHelpers.cmake | 31 | ||||
-rw-r--r-- | CMakeLists.txt | 2 |
3 files changed, 5 insertions, 49 deletions
diff --git a/CMake/AbseilDll.cmake b/CMake/AbseilDll.cmake index 40219207..01aa2c19 100644 --- a/CMake/AbseilDll.cmake +++ b/CMake/AbseilDll.cmake @@ -594,14 +594,6 @@ set(ABSL_INTERNAL_TEST_DLL_TARGETS "scoped_mock_log" ) -function(_absl_target_compile_features_if_available TARGET TYPE FEATURE) - if(FEATURE IN_LIST CMAKE_CXX_COMPILE_FEATURES) - target_compile_features(${TARGET} ${TYPE} ${FEATURE}) - else() - message(WARNING "Feature ${FEATURE} is unknown for the CXX compiler") - endif() -endfunction() - include(CheckCXXSourceCompiles) check_cxx_source_compiles( @@ -789,18 +781,7 @@ Cflags: -I\${includedir}${PC_CFLAGS}\n") # Abseil libraries require C++14 as the current minimum standard. When # compiled with C++17 (either because it is the compiler's default or # explicitly requested), then Abseil requires C++17. - _absl_target_compile_features_if_available(${_dll} PUBLIC ${ABSL_INTERNAL_CXX_STD_FEATURE}) - else() - # Note: This is legacy (before CMake 3.8) behavior. Setting the - # target-level CXX_STANDARD property to ABSL_CXX_STANDARD (which is - # initialized by CMAKE_CXX_STANDARD) should have no real effect, since - # that is the default value anyway. - # - # CXX_STANDARD_REQUIRED does guard against the top-level CMake project - # not having enabled CMAKE_CXX_STANDARD_REQUIRED (which prevents - # "decaying" to an older standard if the requested one isn't available). - set_property(TARGET ${_dll} PROPERTY CXX_STANDARD ${ABSL_CXX_STANDARD}) - set_property(TARGET ${_dll} PROPERTY CXX_STANDARD_REQUIRED ON) + target_compile_features(${_dll} PUBLIC ${ABSL_INTERNAL_CXX_STD_FEATURE}) endif() install(TARGETS ${_dll} EXPORT ${PROJECT_NAME}Targets diff --git a/CMake/AbseilHelpers.cmake b/CMake/AbseilHelpers.cmake index 0c91aadf..8d303c22 100644 --- a/CMake/AbseilHelpers.cmake +++ b/CMake/AbseilHelpers.cmake @@ -291,18 +291,7 @@ Cflags: -I\${includedir}${PC_CFLAGS}\n") # Abseil libraries require C++14 as the current minimum standard. When # compiled with C++17 (either because it is the compiler's default or # explicitly requested), then Abseil requires C++17. - _absl_target_compile_features_if_available(${_NAME} PUBLIC ${ABSL_INTERNAL_CXX_STD_FEATURE}) - else() - # Note: This is legacy (before CMake 3.8) behavior. Setting the - # target-level CXX_STANDARD property to ABSL_CXX_STANDARD (which is - # initialized by CMAKE_CXX_STANDARD) should have no real effect, since - # that is the default value anyway. - # - # CXX_STANDARD_REQUIRED does guard against the top-level CMake project - # not having enabled CMAKE_CXX_STANDARD_REQUIRED (which prevents - # "decaying" to an older standard if the requested one isn't available). - set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD ${ABSL_CXX_STANDARD}) - set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD_REQUIRED ON) + target_compile_features(${_NAME} PUBLIC ${ABSL_INTERNAL_CXX_STD_FEATURE}) endif() # When being installed, we lose the absl_ prefix. We want to put it back @@ -339,10 +328,7 @@ Cflags: -I\${includedir}${PC_CFLAGS}\n") # Abseil libraries require C++14 as the current minimum standard. # Top-level application CMake projects should ensure a consistent C++ # standard for all compiled sources by setting CMAKE_CXX_STANDARD. - _absl_target_compile_features_if_available(${_NAME} INTERFACE ${ABSL_INTERNAL_CXX_STD_FEATURE}) - - # (INTERFACE libraries can't have the CXX_STANDARD property set, so there - # is no legacy behavior else case). + target_compile_features(${_NAME} INTERFACE ${ABSL_INTERNAL_CXX_STD_FEATURE}) endif() endif() @@ -452,18 +438,7 @@ function(absl_cc_test) # Abseil libraries require C++14 as the current minimum standard. # Top-level application CMake projects should ensure a consistent C++ # standard for all compiled sources by setting CMAKE_CXX_STANDARD. - _absl_target_compile_features_if_available(${_NAME} PUBLIC ${ABSL_INTERNAL_CXX_STD_FEATURE}) - else() - # Note: This is legacy (before CMake 3.8) behavior. Setting the - # target-level CXX_STANDARD property to ABSL_CXX_STANDARD (which is - # initialized by CMAKE_CXX_STANDARD) should have no real effect, since - # that is the default value anyway. - # - # CXX_STANDARD_REQUIRED does guard against the top-level CMake project - # not having enabled CMAKE_CXX_STANDARD_REQUIRED (which prevents - # "decaying" to an older standard if the requested one isn't available). - set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD ${ABSL_CXX_STANDARD}) - set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD_REQUIRED ON) + target_compile_features(${_NAME} PUBLIC ${ABSL_INTERNAL_CXX_STD_FEATURE}) endif() add_test(NAME ${_NAME} COMMAND ${_NAME}) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e102578..ae799811 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,7 +68,7 @@ endif() option(ABSL_PROPAGATE_CXX_STD "Use CMake C++ standard meta features (e.g. cxx_std_14) that propagate to targets that link to Abseil" OFF) # TODO: Default to ON for CMake 3.8 and greater. -if((${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.8) AND (NOT ABSL_PROPAGATE_CXX_STD)) +if(NOT ABSL_PROPAGATE_CXX_STD) message(WARNING "A future Abseil release will default ABSL_PROPAGATE_CXX_STD to ON for CMake 3.8 and up. We recommend enabling this option to ensure your project still builds correctly.") endif() |