From aac09912eccabf4c26ef1982ff1fc1a454a08a79 Mon Sep 17 00:00:00 2001 From: "Galantsev, Dmitrii" Date: Thu, 6 Nov 2025 01:23:19 -0600 Subject: [PATCH] Add downloaded gtest as fallback Signed-off-by: Galantsev, Dmitrii --- README.md | 4 ---- tests/amd_smi_test/CMakeLists.txt | 20 ++++++++++++++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index da331bdbcd..098c44c13e 100644 --- a/README.md +++ b/README.md @@ -130,10 +130,6 @@ 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/tests/amd_smi_test/CMakeLists.txt b/tests/amd_smi_test/CMakeLists.txt index 12f72be131..9463cf23fa 100644 --- a/tests/amd_smi_test/CMakeLists.txt +++ b/tests/amd_smi_test/CMakeLists.txt @@ -1,10 +1,26 @@ +option(INSTALL_GTEST "Install GTest" 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") -# Use system-installed GTest -find_package(GTest REQUIRED) +if(POLICY CMP0135) + cmake_policy(SET CMP0135 NEW) +endif() + +# Use system GTest if available, otherwise fetch and build +find_package(GTest) +if(NOT GTest_FOUND) + include(FetchContent) + FetchContent_Declare( + googletest + # Originally mirrored from: https://github.com/google/googletest/releases/download/v1.16.0/googletest-1.16.0.tar.gz + URL https://rocm-third-party-deps.s3.us-east-2.amazonaws.com/googletest-1.16.0.tar.gz + URL_HASH SHA256=78c676fc63881529bf97bf9d45948d905a66833fbfa5318ea2cd7478cb98f399 + ) + FetchContent_MakeAvailable(googletest) +endif() enable_testing()