about summary refs log tree commit diff
path: root/third_party/abseil_cpp/CMake
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2020-11-21T13·43+0100
committerVincent Ambo <mail@tazj.in>2020-11-21T14·48+0100
commit082c006c04343a78d87b6c6ab3608c25d6213c3f (patch)
tree16e6f04f8d1d1d2d67e8e917d5e7bb48c1b60375 /third_party/abseil_cpp/CMake
parentcc27324d0226953943f408ce3c69ad7d648e005e (diff)
merge(3p/absl): subtree merge of Abseil up to e19260f r/1889
... notably, this includes Abseil's own StatusOr type, which
conflicted with our implementation (that was taken from TensorFlow).

Change-Id: Ie7d6764b64055caaeb8dc7b6b9d066291e6b538f
Diffstat (limited to 'third_party/abseil_cpp/CMake')
-rw-r--r--third_party/abseil_cpp/CMake/AbseilDll.cmake8
-rw-r--r--third_party/abseil_cpp/CMake/AbseilHelpers.cmake53
-rw-r--r--third_party/abseil_cpp/CMake/AbseilInstallDirs.cmake4
-rw-r--r--third_party/abseil_cpp/CMake/Googletest/CMakeLists.txt.in30
-rwxr-xr-xthird_party/abseil_cpp/CMake/install_test_project/test.sh18
5 files changed, 86 insertions, 27 deletions
diff --git a/third_party/abseil_cpp/CMake/AbseilDll.cmake b/third_party/abseil_cpp/CMake/AbseilDll.cmake
index e25174a3ba..e0ff2492e7 100644
--- a/third_party/abseil_cpp/CMake/AbseilDll.cmake
+++ b/third_party/abseil_cpp/CMake/AbseilDll.cmake
@@ -8,7 +8,6 @@ set(ABSL_INTERNAL_DLL_FILES
   "base/casts.h"
   "base/config.h"
   "base/const_init.h"
-  "base/dynamic_annotations.cc"
   "base/dynamic_annotations.h"
   "base/internal/atomic_hook.h"
   "base/internal/bits.h"
@@ -139,7 +138,6 @@ set(ABSL_INTERNAL_DLL_FILES
   "random/internal/distribution_caller.h"
   "random/internal/fastmath.h"
   "random/internal/fast_uniform_bits.h"
-  "random/internal/gaussian_distribution_gentables.cc"
   "random/internal/generate_real.h"
   "random/internal/iostream_state_saver.h"
   "random/internal/mock_helpers.h"
@@ -176,8 +174,12 @@ set(ABSL_INTERNAL_DLL_FILES
   "random/uniform_int_distribution.h"
   "random/uniform_real_distribution.h"
   "random/zipf_distribution.h"
+  "status/internal/status_internal.h"
+  "status/internal/statusor_internal.h"
   "status/status.h"
   "status/status.cc"
+  "status/statusor.h"
+  "status/statusor.cc"
   "status/status_payload_printer.h"
   "status/status_payload_printer.cc"
   "strings/ascii.cc"
@@ -194,6 +196,7 @@ set(ABSL_INTERNAL_DLL_FILES
   "strings/internal/charconv_parse.cc"
   "strings/internal/charconv_parse.h"
   "strings/internal/stl_type_traits.h"
+  "strings/internal/string_constant.h"
   "strings/match.cc"
   "strings/match.h"
   "strings/numbers.cc"
@@ -248,6 +251,7 @@ set(ABSL_INTERNAL_DLL_FILES
   "synchronization/notification.h"
   "synchronization/internal/create_thread_identity.cc"
   "synchronization/internal/create_thread_identity.h"
+  "synchronization/internal/futex.h"
   "synchronization/internal/graphcycles.cc"
   "synchronization/internal/graphcycles.h"
   "synchronization/internal/kernel_timeout.h"
diff --git a/third_party/abseil_cpp/CMake/AbseilHelpers.cmake b/third_party/abseil_cpp/CMake/AbseilHelpers.cmake
index 86ff9eba2a..e88507de56 100644
--- a/third_party/abseil_cpp/CMake/AbseilHelpers.cmake
+++ b/third_party/abseil_cpp/CMake/AbseilHelpers.cmake
@@ -23,7 +23,9 @@ include(AbseilInstallDirs)
 # project that sets
 #    set_property(GLOBAL PROPERTY USE_FOLDERS ON)
 # For example, Visual Studio supports folders.
-set(ABSL_IDE_FOLDER Abseil)
+if(NOT DEFINED ABSL_IDE_FOLDER)
+  set(ABSL_IDE_FOLDER Abseil)
+endif()
 
 # absl_cc_library()
 #
@@ -120,7 +122,11 @@ function(absl_cc_library)
   # 4. "static"  -- This target does not depend on the DLL and should be built
   #                 statically.
   if (${ABSL_BUILD_DLL})
-    absl_internal_dll_contains(TARGET ${_NAME} OUTPUT _in_dll)
+    if(ABSL_ENABLE_INSTALL)
+      absl_internal_dll_contains(TARGET ${_NAME} OUTPUT _in_dll)
+    else()
+      absl_internal_dll_contains(TARGET ${ABSL_CC_LIB_NAME} OUTPUT _in_dll)
+    endif()
     if (${_in_dll})
       # This target should be replaced by the DLL
       set(_build_type "dll")
@@ -135,6 +141,47 @@ function(absl_cc_library)
     set(_build_type "static")
   endif()
 
+  # Generate a pkg-config file for every library:
+  if(${_build_type} STREQUAL "static" OR ${_build_type} STREQUAL "shared")
+    if(NOT ABSL_CC_LIB_TESTONLY)
+      if(absl_VERSION)
+        set(PC_VERSION "${absl_VERSION}")
+      else()
+        set(PC_VERSION "head")
+      endif()
+      foreach(dep ${ABSL_CC_LIB_DEPS})
+        if(${dep} MATCHES "^absl::(.*)")
+          set(PC_DEPS "${PC_DEPS} absl_${CMAKE_MATCH_1} = ${PC_VERSION}")
+        endif()
+      endforeach()
+      foreach(cflag ${ABSL_CC_LIB_COPTS})
+        if(${cflag} MATCHES "^(-Wno|/wd)")
+          # These flags are needed to suppress warnings that might fire in our headers.
+          set(PC_CFLAGS "${PC_CFLAGS} ${cflag}")
+        elseif(${cflag} MATCHES "^(-W|/w[1234eo])")
+          # Don't impose our warnings on others.
+        else()
+          set(PC_CFLAGS "${PC_CFLAGS} ${cflag}")
+        endif()
+      endforeach()
+      FILE(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/lib/pkgconfig/absl_${_NAME}.pc" CONTENT "\
+prefix=${CMAKE_INSTALL_PREFIX}\n\
+exec_prefix=\${prefix}\n\
+libdir=\${prefix}/lib\n\
+includedir=\${prefix}/include\n\
+\n\
+Name: absl_${_NAME}\n\
+Description: Abseil ${_NAME} library\n\
+URL: https://abseil.io/\n\
+Version: ${PC_VERSION}\n\
+Requires.private:${PC_DEPS}\n\
+Libs: -L\${libdir} $<JOIN:${ABSL_CC_LIB_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_PREFIX}/lib/pkgconfig")
+    endif()
+  endif()
+
   if(NOT ABSL_CC_LIB_IS_INTERFACE)
     if(${_build_type} STREQUAL "dll_dep")
       # This target depends on the DLL. When adding dependencies to this target,
@@ -213,6 +260,8 @@ function(absl_cc_library)
     if(ABSL_ENABLE_INSTALL)
       set_target_properties(${_NAME} PROPERTIES
         OUTPUT_NAME "absl_${_NAME}"
+        # TODO(b/173696973): Figure out how to set SOVERSION for LTS releases.
+        SOVERSION 0
       )
     endif()
   else()
diff --git a/third_party/abseil_cpp/CMake/AbseilInstallDirs.cmake b/third_party/abseil_cpp/CMake/AbseilInstallDirs.cmake
index b67272f830..6fc914b60f 100644
--- a/third_party/abseil_cpp/CMake/AbseilInstallDirs.cmake
+++ b/third_party/abseil_cpp/CMake/AbseilInstallDirs.cmake
@@ -10,11 +10,11 @@ if(absl_VERSION)
   set(ABSL_SUBDIR "${PROJECT_NAME}_${PROJECT_VERSION}")
   set(ABSL_INSTALL_BINDIR "${CMAKE_INSTALL_BINDIR}/${ABSL_SUBDIR}")
   set(ABSL_INSTALL_CONFIGDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${ABSL_SUBDIR}")
-  set(ABSL_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/{ABSL_SUBDIR}")
+  set(ABSL_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/${ABSL_SUBDIR}")
   set(ABSL_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/${ABSL_SUBDIR}")
 else()
   set(ABSL_INSTALL_BINDIR "${CMAKE_INSTALL_BINDIR}")
   set(ABSL_INSTALL_CONFIGDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
   set(ABSL_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}")
   set(ABSL_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}")
-endif()
\ No newline at end of file
+endif()
diff --git a/third_party/abseil_cpp/CMake/Googletest/CMakeLists.txt.in b/third_party/abseil_cpp/CMake/Googletest/CMakeLists.txt.in
index 994dac0bf7..5769e3a97b 100644
--- a/third_party/abseil_cpp/CMake/Googletest/CMakeLists.txt.in
+++ b/third_party/abseil_cpp/CMake/Googletest/CMakeLists.txt.in
@@ -3,24 +3,12 @@ cmake_minimum_required(VERSION 2.8.2)
 project(googletest-external NONE)
 
 include(ExternalProject)
-if(${ABSL_USE_GOOGLETEST_HEAD})
-  ExternalProject_Add(googletest
-    GIT_REPOSITORY    https://github.com/google/googletest.git
-    GIT_TAG           master
-    SOURCE_DIR        "${absl_gtest_src_dir}"
-    BINARY_DIR        "${absl_gtest_build_dir}"
-    CONFIGURE_COMMAND ""
-    BUILD_COMMAND     ""
-    INSTALL_COMMAND   ""
-    TEST_COMMAND      ""
-  )
-else()
-  ExternalProject_Add(googletest
-    SOURCE_DIR        "${absl_gtest_src_dir}"
-    BINARY_DIR        "${absl_gtest_build_dir}"
-    CONFIGURE_COMMAND ""
-    BUILD_COMMAND     ""
-    INSTALL_COMMAND   ""
-    TEST_COMMAND      ""
-  )
-endif()
\ No newline at end of file
+ExternalProject_Add(googletest
+  URL               "${absl_gtest_download_url}"  # May be empty
+  SOURCE_DIR        "${absl_gtest_src_dir}"
+  BINARY_DIR        "${absl_gtest_build_dir}"
+  CONFIGURE_COMMAND ""
+  BUILD_COMMAND     ""
+  INSTALL_COMMAND   ""
+  TEST_COMMAND      ""
+)
diff --git a/third_party/abseil_cpp/CMake/install_test_project/test.sh b/third_party/abseil_cpp/CMake/install_test_project/test.sh
index 99989b031d..ddc7726b6c 100755
--- a/third_party/abseil_cpp/CMake/install_test_project/test.sh
+++ b/third_party/abseil_cpp/CMake/install_test_project/test.sh
@@ -118,6 +118,24 @@ if ! grep absl::strings "${libdir}/cmake/${absl_subdir}/abslTargets.cmake"; then
   exit 1
 fi
 
+pushd "${HOME}"
+cat > hello-abseil.cc << EOF
+#include <cstdlib>
+
+#include "absl/strings/str_format.h"
+
+int main(int argc, char **argv) {
+  absl::PrintF("Hello Abseil!\n");
+  return EXIT_SUCCESS;
+}
+EOF
+export PKG_CONFIG_PATH="${install_dir}/${libdir}/pkgconfig"
+pc_args=($(pkg-config --cflags --libs --static absl_str_format))
+g++ -static -o hello-abseil hello-abseil.cc "${pc_args[@]}"
+hello="$(./hello-abseil)"
+[[ "${hello}" == "Hello Abseil!" ]]
+popd
+
 uninstall_absl
 popd