From 765541cd5e964396bc22f19ae688599663edeeb9 Mon Sep 17 00:00:00 2001 From: Roman Gershman Date: Sat, 23 Dec 2017 00:25:36 +0200 Subject: Relax dependency on googletest and allow customization of cctz target --- CMakeLists.txt | 35 ++++++++++++++++++++--------------- absl/time/CMakeLists.txt | 2 +- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c65805eb..52acb361 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} ") - # find dependencies ## pthread find_package(Threads REQUIRED) +if(NOT CCTZ_TARGET) + set(CCTZ_TARGET cctz) +endif() + # commented: used only for standalone test #add_subdirectory(cctz) #add_subdirectory(googletest) +check_target({${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) + + # -fexceptions + set(ABSL_EXCEPTIONS_FLAG "${CMAKE_CXX_EXCEPTIONS}") + + 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 60f61483..5ee5d0b3 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 {CCTZ_TARGET}) absl_library( TARGET -- cgit v1.2.3 From 7994c57a901ddab6df6526e7e450d0ad73a1af96 Mon Sep 17 00:00:00 2001 From: Roman Gershman Date: Sat, 23 Dec 2017 00:43:35 +0200 Subject: Typo fix --- CMakeLists.txt | 2 +- absl/time/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 52acb361..15e3d9d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,7 +69,7 @@ endif() # commented: used only for standalone test #add_subdirectory(cctz) #add_subdirectory(googletest) -check_target({${CCTZ_TARGET}) +check_target(${ABSL_CCTZ_TARGET}) ## check targets if(BUILD_TESTING) diff --git a/absl/time/CMakeLists.txt b/absl/time/CMakeLists.txt index 5ee5d0b3..e7af9ca3 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_TARGET}) +set(TIME_PUBLIC_LIBRARIES absl::base absl::stacktrace absl::int128 {ABSL_CCTZ_TARGET}) absl_library( TARGET -- cgit v1.2.3 From fe2006e91fca5379bb7f5c7ad1ff33799573b394 Mon Sep 17 00:00:00 2001 From: Roman Gershman Date: Mon, 29 Jan 2018 21:08:17 +0200 Subject: Update README.md --- CMake/README.md | 3 ++- CMakeLists.txt | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CMake/README.md b/CMake/README.md index 0ae9c268..15658c68 100644 --- a/CMake/README.md +++ b/CMake/README.md @@ -29,7 +29,8 @@ 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`. - + 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 cctz target to 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 15e3d9d5..b5a1d779 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,8 +62,8 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_WARNING_VLA} ${CMAKE_CXX_FLAGS} ") ## pthread find_package(Threads REQUIRED) -if(NOT CCTZ_TARGET) - set(CCTZ_TARGET cctz) +if(NOT ABSL_CCTZ_TARGET) + set(ABSL_CCTZ_TARGET cctz) endif() # commented: used only for standalone test -- cgit v1.2.3 From 1c8ace4e513bce6fbb045fad716b960bea700926 Mon Sep 17 00:00:00 2001 From: Roman Gershman Date: Mon, 29 Jan 2018 22:56:05 +0200 Subject: Fix a typo --- absl/time/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/absl/time/CMakeLists.txt b/absl/time/CMakeLists.txt index e7af9ca3..5c317fb0 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 {ABSL_CCTZ_TARGET}) +set(TIME_PUBLIC_LIBRARIES absl::base absl::stacktrace absl::int128 ${ABSL_CCTZ_TARGET}) absl_library( TARGET -- cgit v1.2.3 From cc23e7554a1e312c33248df1599f6835c0170d4c Mon Sep 17 00:00:00 2001 From: Roman Gershman Date: Mon, 29 Jan 2018 23:30:54 +0200 Subject: Move ABSL_EXCEPTIONS_FLAG define --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b5a1d779..142898c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,6 +58,9 @@ 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) @@ -77,9 +80,6 @@ if(BUILD_TESTING) check_target(gtest_main) check_target(gmock) - # -fexceptions - set(ABSL_EXCEPTIONS_FLAG "${CMAKE_CXX_EXCEPTIONS}") - list(APPEND ABSL_TEST_COMMON_LIBRARIES gtest_main gtest -- cgit v1.2.3 From 10c79457fca05df92319235eab6e75c56adc841b Mon Sep 17 00:00:00 2001 From: Roman Gershman Date: Tue, 30 Jan 2018 21:40:27 +0200 Subject: Doc fixed --- CMake/README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CMake/README.md b/CMake/README.md index 15658c68..404d248e 100644 --- a/CMake/README.md +++ b/CMake/README.md @@ -28,9 +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`. - 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 cctz target to custom one with option -DABSL_CCTZ_TARGET=my_cctz + 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 -- cgit v1.2.3