From 77223cb3db759fea1b6ff9286173c1c9037bfd57 Mon Sep 17 00:00:00 2001 From: "Galantsev, Dmitrii" Date: Mon, 12 Dec 2022 14:07:44 -0600 Subject: [PATCH] CMAKE: Resolve lib dependencies for tests amdsmitst was failing and not finding libgtest and libamd_smi. This change resolves the issue by 1. Installing gtest into tests directory 2. Modifying RUNPATH variable to point to libamd_smi.so Change-Id: I126d01c88116d37c5f2b55b9ecb2c9f1313f26fe Signed-off-by: Galantsev, Dmitrii [ROCm/amdsmi commit: 0c52236abd4d99d9621400b9837bda1f20147260] --- projects/amdsmi/tests/amd_smi_test/CMakeLists.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/projects/amdsmi/tests/amd_smi_test/CMakeLists.txt b/projects/amdsmi/tests/amd_smi_test/CMakeLists.txt index 87766c521a..c5be99ae21 100644 --- a/projects/amdsmi/tests/amd_smi_test/CMakeLists.txt +++ b/projects/amdsmi/tests/amd_smi_test/CMakeLists.txt @@ -1,6 +1,12 @@ # 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 "-Wl,--enable-new-dtags") +set(CMAKE_INSTALL_RPATH + "\$ORIGIN:\$ORIGIN/../../../lib" + CACHE STRING "RUNPATH for tests. Helps find libgtest.so and libamd_smi.so") + # Try to find googletest find_package(GTest 1.11.0) @@ -58,7 +64,9 @@ add_executable(${TEST} ${tstSources} ${functionalSources}) target_link_libraries(${TEST} amd_smi c stdc++ pthread GTest::gtest_main) +# Install tests and gtest +# TODO: Remove GTest from here in the future and rely on INSTALL_GTEST? install( - TARGETS ${TEST} + TARGETS ${TEST} gtest gtest_main DESTINATION ${SHARE_INSTALL_PREFIX}/tests/amd_smi COMPONENT tests)