blob: def6559c28c82168f87aa6680c220dca51e81511 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# gtest
find_package(Threads REQUIRED)
# Enable ExternalProject CMake module
INCLUDE(ExternalProject)
ExternalProject_Add(
gtest
URL https://github.com/google/googletest/archive/release-1.8.1.zip
SOURCE_DIR "${CMAKE_BINARY_DIR}/gtest-src"
BINARY_DIR "${CMAKE_BINARY_DIR}/gtest-build"
INSTALL_COMMAND ""
LOG_DOWNLOAD ON
LOG_CONFIGURE ON
LOG_BUILD ON
)
# Get GTest source and binary directories from CMake project
ExternalProject_Get_Property(gtest source_dir binary_dir)
# Create a libgtest target to be used as a dependency by test programs
ADD_LIBRARY(libgtest INTERFACE)
TARGET_INCLUDE_DIRECTORIES(libgtest
INTERFACE
${source_dir}/googletest/include
)
TARGET_LINK_LIBRARIES(libgtest
INTERFACE
${binary_dir}/googlemock/gtest/libgtest.a
${CMAKE_THREAD_LIBS_INIT}
)
# Create a libgmock target to be used as a dependency by test programs
ADD_LIBRARY(libgmock INTERFACE)
TARGET_INCLUDE_DIRECTORIES(libgmock
INTERFACE
${source_dir}/googlemock/include
)
TARGET_LINK_LIBRARIES(libgmock
INTERFACE
${binary_dir}/googlemock/libgmock.a
${CMAKE_THREAD_LIBS_INIT}
)
|