• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2012 The Libphonenumber Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15# Author: Patrick Mezard
16
17cmake_minimum_required (VERSION 3.11)
18
19# Pick the C++ standard to compile with.
20# Abseil currently supports C++11, C++14, and C++17.
21set(CMAKE_CXX_STANDARD 11)
22set(CMAKE_CXX_STANDARD_REQUIRED ON)
23
24project (generate_geocoding_data)
25
26# Helper functions dealing with finding libraries and programs this library
27# depends on.
28include (gtest.cmake)
29include (FetchContent)
30
31# Downloading the abseil sources.
32FetchContent_Declare(
33    abseil-cpp
34    GIT_REPOSITORY  https://github.com/abseil/abseil-cpp.git
35    GIT_TAG         20211102.0
36)
37
38# Building the abseil binaries
39FetchContent_GetProperties(abseil-cpp)
40if (NOT abseil-cpp_POPULATED)
41    FetchContent_Populate(abseil-cpp)
42endif ()
43
44if (NOT abseil-cpp_POPULATED)
45   message (FATAL_ERROR "Could not build abseil-cpp binaries.")
46endif ()
47
48# Safeguarding against any potential link errors as mentioned in
49# https://github.com/abseil/abseil-cpp/issues/225
50set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
51add_subdirectory(${abseil-cpp_SOURCE_DIR} ${abseil-cpp_BINARY_DIR})
52
53find_or_build_gtest ()
54set (
55  SOURCES
56  "src/cpp-build/generate_geocoding_data.cc"
57  "src/cpp-build/generate_geocoding_data_main.cc"
58)
59
60if (NOT WIN32)
61  add_definitions ("-Wall -Werror")
62endif ()
63
64include_directories ("src")
65
66add_executable (generate_geocoding_data ${SOURCES})
67target_link_libraries (generate_geocoding_data absl::strings absl::btree absl::node_hash_set)
68
69set (TEST_SOURCES
70  "src/cpp-build/generate_geocoding_data.cc"
71  "test/cpp-build/generate_geocoding_data_test.cc"
72  "test/cpp-build/run_tests.cc"
73)
74
75set (TEST_LIBS ${GTEST_LIB})
76
77if (NOT WIN32)
78  list (APPEND TEST_LIBS pthread)
79endif ()
80
81# Build the testing binary.
82include_directories ("test")
83add_executable (generate_geocoding_data_test ${TEST_SOURCES})
84target_link_libraries (generate_geocoding_data_test absl::btree ${TEST_LIBS} absl::node_hash_set)
85