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 <dmitrii.galantsev@amd.com>


[ROCm/amdsmi commit: 0c52236abd]
This commit is contained in:
Galantsev, Dmitrii
2022-12-12 14:07:44 -06:00
parent 90f19f35e7
commit 77223cb3db
@@ -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)