Use system gtest instead of building from source

Signed-off-by: Galantsev, Dmitrii <dmitrii.galantsev@amd.com>


[ROCm/amdsmi commit: a375479386]
This commit is contained in:
Galantsev, Dmitrii
2025-10-29 18:19:13 -05:00
committed by Arif, Maisam
parent 55f999f3ce
commit adaf3c9966
2 changed files with 7 additions and 14 deletions
@@ -1,15 +1,10 @@
# Required Defines first:
option(INSTALL_GTEST "Install GTest (only useful if GTest is not already installed)" OFF)
# Help tests find libraries at runtime
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)
# Use system-installed GTest
find_package(GTest REQUIRED)
enable_testing()
@@ -50,7 +45,7 @@ include_directories(${TEST} ${CMAKE_CURRENT_SOURCE_DIR}/.. ${ROCM_INC_DIR}/..)
# Build rules
add_executable(${TEST} ${tstSources} ${functionalSources})
target_link_libraries(${TEST} ${AMD_SMI} GTest::gtest_main c stdc++ pthread)
target_link_libraries(${TEST} ${AMD_SMI} GTest::gtest c stdc++ pthread)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9")
@@ -67,9 +62,3 @@ install(
FILES amdsmitst.exclude
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})