aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmake
diff options
context:
space:
mode:
authorGravatar Gil <mcg@google.com>2017-12-06 16:10:59 -0800
committerGravatar GitHub <noreply@github.com>2017-12-06 16:10:59 -0800
commit32bdc38400258b24edb37990cc8cba057a3297de (patch)
tree1bf6bfda76e3fd5d0119d63d4544e9d6710ce264 /cmake
parentcb5f3efd3ab53561afd7de625d16d014d14374dd (diff)
Rework the top-level cmake build to be a superproject (#538)
All projects are now ExternalProjects This makes it much easier to build them all in a single pass.
Diffstat (limited to 'cmake')
-rw-r--r--cmake/external/firestore.cmake40
-rw-r--r--cmake/external/googletest.cmake40
-rw-r--r--cmake/utils.cmake4
3 files changed, 51 insertions, 33 deletions
diff --git a/cmake/external/firestore.cmake b/cmake/external/firestore.cmake
new file mode 100644
index 0000000..5316873
--- /dev/null
+++ b/cmake/external/firestore.cmake
@@ -0,0 +1,40 @@
+# Copyright 2017 Google
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+include(ExternalProject)
+
+set(source_dir ${PROJECT_SOURCE_DIR}/Firestore)
+set(binary_dir ${PROJECT_BINARY_DIR}/Firestore)
+
+ExternalProject_Add(
+ Firestore
+ DEPENDS googletest
+
+ # Lay the binary directory out as if this were a subproject. This makes it
+ # possible to build and test in it directly.
+ PREFIX ${binary_dir}
+ SOURCE_DIR ${source_dir}
+ BINARY_DIR ${binary_dir}
+ BUILD_ALWAYS ON
+
+ # Even though this isn't installed, set up the INSTALL_DIR so that
+ # find_package can find dependencies built from source.
+ INSTALL_DIR ${FIREBASE_INSTALL_DIR}
+ INSTALL_COMMAND ""
+ TEST_BEFORE_INSTALL ON
+
+ CMAKE_ARGS
+ -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
+ -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
+)
diff --git a/cmake/external/googletest.cmake b/cmake/external/googletest.cmake
index 66b2689..a956e9f 100644
--- a/cmake/external/googletest.cmake
+++ b/cmake/external/googletest.cmake
@@ -13,42 +13,22 @@
# limitations under the License.
include(ExternalProject)
+
ExternalProject_Add(
- googletest_external
- PREFIX googletest
+ googletest
+
URL "https://github.com/google/googletest/archive/release-1.8.0.tar.gz"
URL_HASH "SHA256=58a6f4277ca2bc8565222b3bbd58a177609e9c488e8a72649359ba51450db7d8"
- CMAKE_ARGS
- -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
- -DBUILD_GMOCK:BOOL=OFF
- -DBUILD_GTEST:BOOL=ON
+ PREFIX ${PROJECT_BINARY_DIR}/third_party/googletest
- # Cut down on scary log output
- LOG_DOWNLOAD ON
- LOG_CONFIGURE ON
+ DOWNLOAD_DIR ${FIREBASE_DOWNLOAD_DIR}
+ INSTALL_DIR ${FIREBASE_INSTALL_DIR}
- INSTALL_COMMAND ""
- UPDATE_COMMAND ""
TEST_COMMAND ""
-)
-
-ExternalProject_Get_Property(googletest_external source_dir binary_dir)
-# CMake requires paths in include_directories to exist at configure time
-file(MAKE_DIRECTORY ${source_dir}/googletest/include)
-
-add_library(gtest STATIC IMPORTED GLBOAL)
-set_target_properties(
- gtest PROPERTIES
- INTERFACE_INCLUDE_DIRECTORIES ${source_dir}/googletest/include
- IMPORTED_LOCATION ${binary_dir}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest.a
-)
-add_dependencies(gtest googletest_external)
-
-add_library(gtest_main STATIC IMPORTED GLOBAL)
-set_target_properties(
- gtest_main PROPERTIES
- IMPORTED_LOCATION ${binary_dir}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main.a
+ CMAKE_ARGS
+ -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
+ -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
+ -DBUILD_SHARED_LIBS:BOOL=OFF
)
-add_dependencies(gtest_main googletest_external)
diff --git a/cmake/utils.cmake b/cmake/utils.cmake
index 40e2325..54044d6 100644
--- a/cmake/utils.cmake
+++ b/cmake/utils.cmake
@@ -23,7 +23,5 @@ function(cc_test name)
add_executable(${name} ${ARGN})
add_test(${name} ${name})
- target_link_libraries(${name} gtest gtest_main)
-
- add_dependencies(check ${name})
+ target_link_libraries(${name} GTest::GTest GTest::Main)
endfunction()