From adaf3c99664b596967446bbe41bcf656b2bc82a2 Mon Sep 17 00:00:00 2001 From: "Galantsev, Dmitrii" Date: Wed, 29 Oct 2025 18:19:13 -0500 Subject: [PATCH] Use system gtest instead of building from source Signed-off-by: Galantsev, Dmitrii [ROCm/amdsmi commit: a375479386032721160a2b1aa1534edddc20f182] --- projects/amdsmi/README.md | 4 ++++ .../amdsmi/tests/amd_smi_test/CMakeLists.txt | 17 +++-------------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/projects/amdsmi/README.md b/projects/amdsmi/README.md index 098c44c13e..da331bdbcd 100644 --- a/projects/amdsmi/README.md +++ b/projects/amdsmi/README.md @@ -130,6 +130,10 @@ during development; earlier versions are not guaranteed to work. * libdrm-dev (for Ubuntu and Debian) * libdrm-devel (for RPM-based distributions) +To build the tests, the following additional dependency is required: + +* Google Test (libgtest-dev for Ubuntu/Debian, gtest-devel for RPM-based distributions) + In order to build the AMD SMI Python package, the following components are required: * Python (3.6.8 or later) diff --git a/projects/amdsmi/tests/amd_smi_test/CMakeLists.txt b/projects/amdsmi/tests/amd_smi_test/CMakeLists.txt index a8c9d224d4..12f72be131 100644 --- a/projects/amdsmi/tests/amd_smi_test/CMakeLists.txt +++ b/projects/amdsmi/tests/amd_smi_test/CMakeLists.txt @@ -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})