blob: fa8d09aafe74b9f4abc329b6ca12ada49b192493 (
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
From 727e9b8312c7ae011b667152606afc0e04ea197a Mon Sep 17 00:00:00 2001
From: Jan Henke <Jan.Henke@taujhe.de>
Date: Sun, 14 Jun 2020 14:12:02 +0200
Subject: [PATCH] Use system gtest instead of downloading and building it
---
CMakeLists.txt | 1 -
tests/CMakeLists.txt | 30 ++++--------------------------
2 files changed, 4 insertions(+), 27 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 740cd31..f1bf7a2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,7 +3,6 @@ cmake_minimum_required(VERSION 3.1.3...3.16)
project(GSL VERSION 3.1.0 LANGUAGES CXX)
include(ExternalProject)
-find_package(Git)
# Use GNUInstallDirs to provide the right locations on all platforms
include(GNUInstallDirs)
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 2bd1bbe..c42afb7 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -5,32 +5,9 @@ project(GSLTests CXX)
# will make visual studio generated project group files
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
-configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt)
-execute_process(
- COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
- RESULT_VARIABLE result
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download
-)
-if(result)
- message(FATAL_ERROR "CMake step for googletest failed: ${result}")
-endif()
-
-execute_process(
- COMMAND ${CMAKE_COMMAND} --build .
- RESULT_VARIABLE result
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download
-)
-if(result)
- message(FATAL_ERROR "CMake step for googletest failed: ${result}")
-endif()
-
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
-add_subdirectory(
- ${CMAKE_CURRENT_BINARY_DIR}/googletest-src
- ${CMAKE_CURRENT_BINARY_DIR}/googletest-build
- EXCLUDE_FROM_ALL
-)
+find_package(GTest REQUIRED)
if (MSVC AND (GSL_CXX_STANDARD EQUAL 17))
set(GSL_CPLUSPLUS_OPT -Zc:__cplusplus -permissive-)
@@ -139,7 +116,7 @@ endif(MSVC)
# for tests to find the gtest header
target_include_directories(gsl_tests_config SYSTEM INTERFACE
- googletest/googletest/include
+ ${GTest_INCLUDE_DIRS}
)
set_property(TARGET PROPERTY FOLDER "GSL_tests")
@@ -149,7 +126,8 @@ function(add_gsl_test name)
target_link_libraries(${name}
GSL
gsl_tests_config
- gtest_main
+ GTest::GTest
+ GTest::Main
)
add_test(
${name}
--
2.26.2
|