Skip to content

Commit 97d23a4

Browse files
committed
Use CMake's FetchContent to add gtest dependency
1 parent 68f508c commit 97d23a4

File tree

6 files changed

+25
-224
lines changed

6 files changed

+25
-224
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ matrix:
5555

5656
script:
5757
- mkdir build && cd build
58-
- cmake ..
58+
- cmake ../cpp11training
5959
- make
6060
- ./cpp11training
6161
- cd ..

CMake/DownloadProject.CMakeLists.cmake.in

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

CMake/DownloadProject.cmake

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

CMake/SetupGoogletest.cmake

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

CMakeLists.txt

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

cpp11training/CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
cmake_minimum_required(VERSION 3.11.0)
2+
3+
set(CMAKE_CXX_STANDARD 17)
4+
project(cpp11training)
5+
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()
18+
19+
project(cpp11training)
20+
file (GLOB_RECURSE SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
21+
add_executable(cpp11training ${SOURCES})
22+
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
23+
target_link_libraries(cpp11training gtest gmock_main)
24+
# target_link_libraries(cpp11training PUBLIC GTest::main)

0 commit comments

Comments
 (0)