Skip to content

Commit 6b2f7a6

Browse files
committed
Extract googletest cmake into proper file
1 parent e128c30 commit 6b2f7a6

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

src/AddGoogleTest.cmake

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
cmake_minimum_required(VERSION 3.11.0)
2+
3+
include(FetchContent)
4+
FetchContent_Declare(
5+
googletest
6+
GIT_REPOSITORY https://github.com/google/googletest.git
7+
GIT_TAG release-1.8.0
8+
)
9+
FetchContent_MakeAvailable(googletest)
10+
FetchContent_GetProperties(googletest)
11+
if(NOT googletest_POPULATED)
12+
FetchContent_Populate(googletest)
13+
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR})
14+
endif()
15+

src/CMakeLists.txt

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,7 @@ cmake_minimum_required(VERSION 3.11.0)
33
set(CMAKE_CXX_STANDARD 17)
44
project(cpp11training)
55

6-
include(FetchContent)
7-
FetchContent_Declare(
8-
googletest
9-
GIT_REPOSITORY https://github.com/google/googletest.git
10-
GIT_TAG release-1.8.0
11-
)
12-
FetchContent_MakeAvailable(googletest)
13-
FetchContent_GetProperties(googletest)
14-
if(NOT googletest_POPULATED)
15-
FetchContent_Populate(googletest)
16-
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR})
17-
endif()
6+
include(AddGoogleTest.cmake)
187

198
project(cpp11training)
209
file (GLOB_RECURSE SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")

0 commit comments

Comments
 (0)