Skip to content

Simplify integration with googletest #672

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion Firestore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,23 @@ set(FIREBASE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX})
list(INSERT CMAKE_MODULE_PATH 0 ${FIREBASE_SOURCE_DIR}/cmake)
include(utils)

find_package(GTest REQUIRED)
# Include GoogleTest directly in the build.
set(gtest_dir ${FIREBASE_INSTALL_DIR}/external/googletest)
add_subdirectory(
${gtest_dir}/src/googletest
${gtest_dir}/src/googletest-build
EXCLUDE_FROM_ALL
)

# Set up aliases with the same names as available via FindGTest.
add_library(
GTest::GTest ALIAS gtest
)

add_library(
GTest::Main ALIAS gtest_main
)

find_package(LevelDB REQUIRED)
find_package(GRPC REQUIRED)

Expand Down
1 change: 0 additions & 1 deletion cmake/external/firestore.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ ExternalProject_Add(
CMAKE_ARGS
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX:PATH=${FIREBASE_INSTALL_DIR}
${GTEST_CMAKE_ARGS}

BUILD_ALWAYS ON

Expand Down
24 changes: 3 additions & 21 deletions cmake/external/googletest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,9 @@ ExternalProject_Add(

PREFIX ${PROJECT_BINARY_DIR}/external/googletest

CMAKE_ARGS
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DBUILD_SHARED_LIBS:BOOL=OFF

# Just download the sources without building.
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)

ExternalProject_Get_Property(
googletest
SOURCE_DIR BINARY_DIR
)

# Arguments to pass to another CMake invocation so that it can find googletest
# without installing it using the standard FindGTest module.
set(GTEST_INCLUDE_DIR ${SOURCE_DIR}/googletest/include)
set(GTEST_LIBRARY ${BINARY_DIR}/googlemock/gtest/libgtest.a)
set(GTEST_MAIN_LIBRARY ${BINARY_DIR}/googlemock/gtest/libgtest_main.a)
set(
GTEST_CMAKE_ARGS
-DGTEST_INCLUDE_DIR=${GTEST_INCLUDE_DIR}
-DGTEST_LIBRARY=${GTEST_LIBRARY}
-DGTEST_MAIN_LIBRARY=${GTEST_MAIN_LIBRARY}
)