aboutsummaryrefslogtreecommitdiff
path: root/third_party/abseil-cpp/CMake/AbseilHelpers.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/abseil-cpp/CMake/AbseilHelpers.cmake')
-rw-r--r--third_party/abseil-cpp/CMake/AbseilHelpers.cmake51
1 files changed, 28 insertions, 23 deletions
diff --git a/third_party/abseil-cpp/CMake/AbseilHelpers.cmake b/third_party/abseil-cpp/CMake/AbseilHelpers.cmake
index f2ce567511..8e08d3fc8d 100644
--- a/third_party/abseil-cpp/CMake/AbseilHelpers.cmake
+++ b/third_party/abseil-cpp/CMake/AbseilHelpers.cmake
@@ -26,6 +26,12 @@ if(NOT DEFINED ABSL_IDE_FOLDER)
set(ABSL_IDE_FOLDER Abseil)
endif()
+if(ABSL_USE_SYSTEM_INCLUDES)
+ set(ABSL_INTERNAL_INCLUDE_WARNING_GUARD SYSTEM)
+else()
+ set(ABSL_INTERNAL_INCLUDE_WARNING_GUARD "")
+endif()
+
# absl_cc_library()
#
# CMake function to imitate Bazel's cc_library rule.
@@ -40,7 +46,8 @@ endif()
# LINKOPTS: List of link options
# PUBLIC: Add this so that this library will be exported under absl::
# Also in IDE, target will appear in Abseil folder while non PUBLIC will be in Abseil/internal.
-# TESTONLY: When added, this target will only be built if BUILD_TESTING=ON.
+# TESTONLY: When added, this target will only be built if both
+# BUILD_TESTING=ON and ABSL_BUILD_TESTING=ON.
#
# Note:
# By default, absl_cc_library will always create a library named absl_${NAME},
@@ -82,7 +89,9 @@ function(absl_cc_library)
${ARGN}
)
- if(ABSL_CC_LIB_TESTONLY AND NOT BUILD_TESTING)
+ if(ABSL_CC_LIB_TESTONLY AND
+ NOT ((BUILD_TESTING AND ABSL_BUILD_TESTING) OR
+ (ABSL_BUILD_TEST_HELPERS AND ABSL_CC_LIB_PUBLIC)))
return()
endif()
@@ -164,10 +173,14 @@ function(absl_cc_library)
set(PC_CFLAGS "${PC_CFLAGS} ${cflag}")
elseif(${cflag} MATCHES "^(-W|/w[1234eo])")
# Don't impose our warnings on others.
+ elseif(${cflag} MATCHES "^-m")
+ # Don't impose CPU instruction requirements on others, as
+ # the code performs feature detection on runtime.
else()
set(PC_CFLAGS "${PC_CFLAGS} ${cflag}")
endif()
endforeach()
+ string(REPLACE ";" " " PC_LINKOPTS "${ABSL_CC_LIB_LINKOPTS}")
FILE(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/lib/pkgconfig/absl_${_NAME}.pc" CONTENT "\
prefix=${CMAKE_INSTALL_PREFIX}\n\
exec_prefix=\${prefix}\n\
@@ -179,7 +192,7 @@ Description: Abseil ${_NAME} library\n\
URL: https://abseil.io/\n\
Version: ${PC_VERSION}\n\
Requires:${PC_DEPS}\n\
-Libs: -L\${libdir} $<JOIN:${ABSL_CC_LIB_LINKOPTS}, > $<$<NOT:$<BOOL:${ABSL_CC_LIB_IS_INTERFACE}>>:-labsl_${_NAME}>\n\
+Libs: -L\${libdir} ${PC_LINKOPTS} $<$<NOT:$<BOOL:${ABSL_CC_LIB_IS_INTERFACE}>>:-labsl_${_NAME}>\n\
Cflags: -I\${includedir}${PC_CFLAGS}\n")
INSTALL(FILES "${CMAKE_BINARY_DIR}/lib/pkgconfig/absl_${_NAME}.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
@@ -236,7 +249,7 @@ Cflags: -I\${includedir}${PC_CFLAGS}\n")
# unconditionally.
set_property(TARGET ${_NAME} PROPERTY LINKER_LANGUAGE "CXX")
- target_include_directories(${_NAME}
+ target_include_directories(${_NAME} ${ABSL_INTERNAL_INCLUDE_WARNING_GUARD}
PUBLIC
"$<BUILD_INTERFACE:${ABSL_COMMON_INCLUDE_DIRS}>"
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
@@ -255,10 +268,10 @@ Cflags: -I\${includedir}${PC_CFLAGS}\n")
endif()
if(ABSL_PROPAGATE_CXX_STD)
- # Abseil libraries require C++11 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.
- target_compile_features(${_NAME} PUBLIC cxx_std_11)
+ # 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
@@ -278,13 +291,13 @@ Cflags: -I\${includedir}${PC_CFLAGS}\n")
if(ABSL_ENABLE_INSTALL)
set_target_properties(${_NAME} PROPERTIES
OUTPUT_NAME "absl_${_NAME}"
- SOVERSION "2111.0.0"
+ SOVERSION 0
)
endif()
else()
# Generating header-only library
add_library(${_NAME} INTERFACE)
- target_include_directories(${_NAME}
+ target_include_directories(${_NAME} ${ABSL_INTERNAL_INCLUDE_WARNING_GUARD}
INTERFACE
"$<BUILD_INTERFACE:${ABSL_COMMON_INCLUDE_DIRS}>"
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
@@ -303,10 +316,10 @@ Cflags: -I\${includedir}${PC_CFLAGS}\n")
target_compile_definitions(${_NAME} INTERFACE ${ABSL_CC_LIB_DEFINES})
if(ABSL_PROPAGATE_CXX_STD)
- # Abseil libraries require C++11 as the current minimum standard.
+ # 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.
- target_compile_features(${_NAME} INTERFACE cxx_std_11)
+ _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).
@@ -364,7 +377,7 @@ endfunction()
# GTest::gtest_main
# )
function(absl_cc_test)
- if(NOT BUILD_TESTING)
+ if(NOT (BUILD_TESTING AND ABSL_BUILD_TESTING))
return()
endif()
@@ -415,10 +428,10 @@ function(absl_cc_test)
set_property(TARGET ${_NAME} PROPERTY FOLDER ${ABSL_IDE_FOLDER}/test)
if(ABSL_PROPAGATE_CXX_STD)
- # Abseil libraries require C++11 as the current minimum standard.
+ # 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.
- target_compile_features(${_NAME} PUBLIC cxx_std_11)
+ _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
@@ -434,11 +447,3 @@ function(absl_cc_test)
add_test(NAME ${_NAME} COMMAND ${_NAME})
endfunction()
-
-
-function(check_target my_target)
- if(NOT TARGET ${my_target})
- message(FATAL_ERROR " ABSL: compiling absl requires a ${my_target} CMake target in your project,
- see CMake/README.md for more details")
- endif(NOT TARGET ${my_target})
-endfunction()