blob: a656a3ee896f3d17b8bad40d720a9573f32973ee (
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
|
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -86,6 +86,7 @@ option(BUILD_TESTS "Build test suite" OFF)
option(ENABLE_ASAN_PACKAGING "" OFF)
option(ENABLE_ESMI_LIB "Build ESMI Library" ON)
option(BUILD_EXAMPLES "Build examples" OFF)
+option(USE_SYSTEM_GTEST "Use system-installed googletest instead of fetching it" OFF)
include(CMakeDependentOption)
# these options don't work without BUILD_SHARED_LIBS
--- a/tests/amd_smi_test/CMakeLists.txt
+++ b/tests/amd_smi_test/CMakeLists.txt
@@ -6,10 +6,14 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--enable-new-dtags")
set(CMAKE_INSTALL_RPATH "\$ORIGIN:\$ORIGIN/../../../lib"
CACHE STRING "RUNPATH for tests. Helps find libgtest.so and libamd_smi.so")
-# Download and compile googletest
-include(FetchContent)
-FetchContent_Declare(googletest GIT_REPOSITORY https://github.com/google/googletest.git GIT_TAG v1.14.0)
-FetchContent_MakeAvailable(googletest)
+if(USE_SYSTEM_GTEST)
+ find_package(GTest 1.14.0 REQUIRED)
+else()
+ # Download and compile googletest
+ include(FetchContent)
+ FetchContent_Declare(googletest GIT_REPOSITORY https://github.com/google/googletest.git GIT_TAG v1.14.0)
+ FetchContent_MakeAvailable(googletest)
+endif()
enable_testing()
@@ -63,8 +67,10 @@ install(
DESTINATION ${SHARE_INSTALL_PREFIX}/tests
COMPONENT ${TESTS_COMPONENT})
-# Install googletest libraries with tests
-install(
- TARGETS gtest gtest_main
- DESTINATION ${SHARE_INSTALL_PREFIX}/tests
- COMPONENT ${TESTS_COMPONENT})
+if(NOT USE_SYSTEM_GTEST)
+ # Install googletest libraries with tests
+ install(
+ TARGETS gtest gtest_main
+ DESTINATION ${SHARE_INSTALL_PREFIX}/tests
+ COMPONENT ${TESTS_COMPONENT})
+endif()
|