aboutsummaryrefslogtreecommitdiff
blob: e78ba0a2a15d548275f9f9fa0cd57e2fde5409bc (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
diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake
index ae2832b..c250eff 100644
--- a/cmake/dependencies.cmake
+++ b/cmake/dependencies.cmake
@@ -4,41 +4,10 @@ set(SCN_OPTIONAL_DEPENDENCIES "")
 
 if (SCN_TESTS)
     # GTest
-
-    FetchContent_Declare(
-            googletest
-            GIT_REPOSITORY https://github.com/google/googletest.git
-            GIT_TAG main
-            GIT_SHALLOW TRUE
-    )
-
-    # gtest CMake does some flag overriding we don't want, and it's also quite heavy
-    # Do it manually
-
-    set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
-
-    FetchContent_GetProperties(googletest)
-    if (NOT googletest)
-        FetchContent_Populate(googletest)
-    endif ()
-
-    find_package(Threads)
-
-    add_library(scn_gtest
-            "${googletest_SOURCE_DIR}/googletest/src/gtest-all.cc"
-            "${googletest_SOURCE_DIR}/googlemock/src/gmock-all.cc"
-    )
-    target_include_directories(scn_gtest SYSTEM
-            PUBLIC
-            "${googletest_SOURCE_DIR}/googletest/include"
-            "${googletest_SOURCE_DIR}/googlemock/include"
-            PRIVATE
-            "${googletest_SOURCE_DIR}/googletest"
-            "${googletest_SOURCE_DIR}/googlemock"
-    )
-    target_link_libraries(scn_gtest PRIVATE Threads::Threads)
-    target_compile_features(scn_gtest PUBLIC cxx_std_17)
-    target_compile_options(scn_gtest PRIVATE $<$<CXX_COMPILER_ID:GNU>: -Wno-psabi>)
+    find_package(GTest REQUIRED)
+    add_library(scn_gtest INTERFACE)
+    target_link_libraries(scn_gtest INTERFACE GTest::GTest)
+    target_compile_features(scn_gtest INTERFACE cxx_std_17)
 endif ()
 
 if (SCN_BENCHMARKS)
@@ -158,8 +127,3 @@ if (SCN_REGEX_BACKEND STREQUAL "re2")
     set(SCN_REGEX_BACKEND_TARGET re2::re2)
 endif ()
 
-# make available
-
-FetchContent_MakeAvailable(
-        ${SCN_OPTIONAL_DEPENDENCIES}
-)