1 cmake_minimum_required(VERSION 2.8.12)
3 project(googletest-download NONE)
5 # Enable ExternalProject CMake module
6 include(ExternalProject)
8 option(ALLOW_DOWNLOADING_GOOGLETEST "If googletest src tree is not found in location specified by GOOGLETEST_PATH, do fetch the archive from internet" OFF)
9 set(GOOGLETEST_PATH "/usr/src/googletest" CACHE PATH
10 "Path to the googletest root tree. Should contain googletest and googlemock subdirs. And CMakeLists.txt in root, and in both of these subdirs")
12 # Download and install GoogleTest
14 message(STATUS "Looking for Google Test sources")
15 message(STATUS "Looking for Google Test sources in ${GOOGLETEST_PATH}")
16 if(EXISTS "${GOOGLETEST_PATH}" AND IS_DIRECTORY "${GOOGLETEST_PATH}" AND EXISTS "${GOOGLETEST_PATH}/CMakeLists.txt" AND
17 EXISTS "${GOOGLETEST_PATH}/googletest" AND IS_DIRECTORY "${GOOGLETEST_PATH}/googletest" AND EXISTS "${GOOGLETEST_PATH}/googletest/CMakeLists.txt" AND
18 EXISTS "${GOOGLETEST_PATH}/googlemock" AND IS_DIRECTORY "${GOOGLETEST_PATH}/googlemock" AND EXISTS "${GOOGLETEST_PATH}/googlemock/CMakeLists.txt")
19 message(STATUS "Found Google Test in ${GOOGLETEST_PATH}")
23 PREFIX "${CMAKE_BINARY_DIR}"
24 DOWNLOAD_DIR "${CMAKE_BINARY_DIR}/download"
25 SOURCE_DIR "${GOOGLETEST_PATH}" # use existing src dir.
26 BINARY_DIR "${CMAKE_BINARY_DIR}/build"
33 if(NOT ALLOW_DOWNLOADING_GOOGLETEST)
34 message(SEND_ERROR "Did not find Google Test sources! Either pass correct path in GOOGLETEST_PATH, or enable BENCHMARK_DOWNLOAD_DEPENDENCIES, or disable BENCHMARK_USE_BUNDLED_GTEST, or disable BENCHMARK_ENABLE_GTEST_TESTS / BENCHMARK_ENABLE_TESTING.")
37 message(WARNING "Did not find Google Test sources! Fetching from web...")
40 GIT_REPOSITORY https://github.com/google/googletest.git
41 GIT_TAG "release-1.11.0"
42 PREFIX "${CMAKE_BINARY_DIR}"
43 STAMP_DIR "${CMAKE_BINARY_DIR}/stamp"
44 DOWNLOAD_DIR "${CMAKE_BINARY_DIR}/download"
45 SOURCE_DIR "${CMAKE_BINARY_DIR}/src"
46 BINARY_DIR "${CMAKE_BINARY_DIR}/build"
55 ExternalProject_Get_Property(googletest SOURCE_DIR BINARY_DIR)
56 file(WRITE googletest-paths.cmake
57 "set(GOOGLETEST_SOURCE_DIR \"${SOURCE_DIR}\")
58 set(GOOGLETEST_BINARY_DIR \"${BINARY_DIR}\")