Skip to content

Commit 2dcb468

Browse files
committed
Use CMake 3.11 feature FetchContent for googletest
Uses the FetchContent feature to pull in the googletest sources instead of the old work around that was recommended before. Also update the googletest version to commit 2172c08.
1 parent b219873 commit 2dcb468

File tree

3 files changed

+23
-54
lines changed

3 files changed

+23
-54
lines changed

CMakeLists.txt

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ cmake_minimum_required (VERSION 3.11)
22

33
project(PerfUtils VERSION 0.1.0 LANGUAGES CXX C)
44

5+
################################################################################
6+
## Dependencies ################################################################
7+
################################################################################
8+
9+
find_package(Git REQUIRED) # needed to download google-test
10+
511
################################################################################
612
## Target Definiton ############################################################
713
################################################################################
@@ -92,7 +98,23 @@ install(
9298
################################################################################
9399
## Tests #######################################################################
94100
################################################################################
95-
include(cmake/googletest/googletest-config.cmake)
101+
include(FetchContent)
102+
FetchContent_Declare(
103+
googletest
104+
GIT_REPOSITORY https://github.com/google/googletest.git
105+
GIT_TAG 2172c08c9241ab0cc8857980bbe925fe1a55cf3c
106+
)
107+
108+
FetchContent_GetProperties(googletest)
109+
if(NOT googletest_POPULATED)
110+
FetchContent_Populate(googletest)
111+
add_subdirectory(
112+
${googletest_SOURCE_DIR}
113+
${googletest_BINARY_DIR}
114+
EXCLUDE_FROM_ALL
115+
)
116+
endif()
117+
96118
include(GoogleTest)
97119

98120
# Enables the add_test macro, which adds the test to the list to run.

cmake/googletest/CMakeLists.txt.in

Lines changed: 0 additions & 15 deletions
This file was deleted.

cmake/googletest/googletest-config.cmake

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)