diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 57261a633..434c593bd 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -18,7 +18,7 @@ cmake_minimum_required (VERSION 3.11) # Pick the C++ standard to compile with. # Abseil currently supports C++11, C++14, and C++17. -set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD 11 CACHE STRING "C++ standard used to compile this project") set(CMAKE_CXX_STANDARD_REQUIRED ON) project (libphonenumber) @@ -203,6 +203,8 @@ add_custom_command ( ) if (${BUILD_GEOCODER} STREQUAL "ON") + find_package(absl) + # Geocoding data cpp file generation set (TOOLS_DIR "${CMAKE_CURRENT_BINARY_DIR}/tools") add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../tools/cpp" "${TOOLS_DIR}") diff --git a/tools/cpp/CMakeLists.txt b/tools/cpp/CMakeLists.txt index b09416569..a12a9af3b 100644 --- a/tools/cpp/CMakeLists.txt +++ b/tools/cpp/CMakeLists.txt @@ -28,27 +28,29 @@ project (generate_geocoding_data) include (gtest.cmake) include (FetchContent) -# Downloading the abseil sources. -FetchContent_Declare( - abseil-cpp - GIT_REPOSITORY https://github.com/abseil/abseil-cpp.git - GIT_TAG origin/master -) - -# Building the abseil binaries -FetchContent_GetProperties(abseil-cpp) -if (NOT abseil-cpp_POPULATED) - FetchContent_Populate(abseil-cpp) -endif () - -if (NOT abseil-cpp_POPULATED) - message (FATAL_ERROR "Could not build abseil-cpp binaries.") -endif () - -# Safeguarding against any potential link errors as mentioned in -# https://github.com/abseil/abseil-cpp/issues/225 -set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) -add_subdirectory(${abseil-cpp_SOURCE_DIR} ${abseil-cpp_BINARY_DIR}) +if(NOT absl_FOUND) + # Downloading the abseil sources. + FetchContent_Declare( + abseil-cpp + GIT_REPOSITORY https://github.com/abseil/abseil-cpp.git + GIT_TAG origin/master + ) + + # Building the abseil binaries + FetchContent_GetProperties(abseil-cpp) + if (NOT abseil-cpp_POPULATED) + FetchContent_Populate(abseil-cpp) + endif () + + if (NOT abseil-cpp_POPULATED) + message (FATAL_ERROR "Could not build abseil-cpp binaries.") + endif () + + # Safeguarding against any potential link errors as mentioned in + # https://github.com/abseil/abseil-cpp/issues/225 + set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) + add_subdirectory(${abseil-cpp_SOURCE_DIR} ${abseil-cpp_BINARY_DIR}) +endif() find_or_build_gtest () set (