about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--CMake/README.md7
-rw-r--r--CMakeLists.txt33
-rw-r--r--absl/time/CMakeLists.txt2
3 files changed, 25 insertions, 17 deletions
diff --git a/CMake/README.md b/CMake/README.md
index 0ae9c2686a88..404d248e3851 100644
--- a/CMake/README.md
+++ b/CMake/README.md
@@ -28,8 +28,11 @@
 
     Note: Abseil requires CCTZ and the googletest framework. Consequently,
     the targets  `gtest`, `gtest_main`, `gmock` and `cctz` need
-    to be declared in your project before including abseil with `add_subdirectory`.
-
+    to be declared in your project before including abseil with
+    `add_subdirectory`. However, if abseil is compiled with
+    `-DBUILD_TESTING=OFF`, then `gtest`, `gmock` and `gtest_main` are not
+    required. In addition, it's possible to override the name of the `cctz`
+    target to a custom one with option `-DABSL_CCTZ_TARGET=*my_cctz*`.
 
   4- Add the absl:: target you wish to use to the `target_link_libraries()`
     section of your executable or of your library
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9d3262393317..6d3789e8031c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -58,29 +58,34 @@ list(APPEND ABSL_COMMON_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR})
 set(CMAKE_CXX_FLAGS "${ABSL_STD_CXX_FLAG} ${CMAKE_CXX_FLAGS}")
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_WARNING_VLA} ${CMAKE_CXX_FLAGS} ")
 
+# -fexceptions
+set(ABSL_EXCEPTIONS_FLAG "${CMAKE_CXX_EXCEPTIONS}")
 
 # find dependencies
 ## pthread
 find_package(Threads REQUIRED)
 
+if(NOT ABSL_CCTZ_TARGET)
+  set(ABSL_CCTZ_TARGET cctz)
+endif()
+
 # commented: used only for standalone test
 #add_subdirectory(cctz)
 #add_subdirectory(googletest)
+check_target(${ABSL_CCTZ_TARGET})
 
 ## check targets
-check_target(cctz)
-check_target(gtest)
-check_target(gtest_main)
-check_target(gmock)
-
-# -fexceptions
-set(ABSL_EXCEPTIONS_FLAG "${CMAKE_CXX_EXCEPTIONS}")
-
-list(APPEND ABSL_TEST_COMMON_LIBRARIES
-  gtest_main
-  gtest
-  gmock
-  ${CMAKE_THREAD_LIBS_INIT}
-)
+if(BUILD_TESTING)
+  check_target(gtest)
+  check_target(gtest_main)
+  check_target(gmock)
+
+  list(APPEND ABSL_TEST_COMMON_LIBRARIES
+    gtest_main
+    gtest
+    gmock
+    ${CMAKE_THREAD_LIBS_INIT}
+  )
+endif()
 
 add_subdirectory(absl)
diff --git a/absl/time/CMakeLists.txt b/absl/time/CMakeLists.txt
index 60f61483e9a3..5c317fb01cc6 100644
--- a/absl/time/CMakeLists.txt
+++ b/absl/time/CMakeLists.txt
@@ -32,7 +32,7 @@ list(APPEND TIME_SRC
   ${TIME_PUBLIC_HEADERS}
   ${TIME_INTERNAL_HEADERS}
 )
-set(TIME_PUBLIC_LIBRARIES absl::base absl::stacktrace absl::int128 cctz)
+set(TIME_PUBLIC_LIBRARIES absl::base absl::stacktrace absl::int128 ${ABSL_CCTZ_TARGET})
 
 absl_library(
   TARGET