From 164efd81af4ad45088238d19d8bdceaca0d6d882 Mon Sep 17 00:00:00 2001 From: "Galantsev, Dmitrii" Date: Fri, 22 Sep 2023 20:56:21 -0500 Subject: [PATCH] SWDEV-423672 - Always compile and install gtest This commit makes sure GTest is always compiled with rocm_smi_lib_tests. GTest installation was inconsistent outside of AMD CI environment. libgtest.so wouldn't get installed with rocm_smi_lib_tests if gtest existed on the build machine. Which is undesirable when packaging. Change-Id: I607df6c67c81480e3b6487b28f14924e8bf56ad4 Signed-off-by: Galantsev, Dmitrii [ROCm/rocm_smi_lib commit: 0c662611e9f593e248dcee864fe5d3ebad6c94a2] --- .../tests/rocm_smi_test/CMakeLists.txt | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/projects/rocm-smi-lib/tests/rocm_smi_test/CMakeLists.txt b/projects/rocm-smi-lib/tests/rocm_smi_test/CMakeLists.txt index b2347e0bff..efdbe96469 100755 --- a/projects/rocm-smi-lib/tests/rocm_smi_test/CMakeLists.txt +++ b/projects/rocm-smi-lib/tests/rocm_smi_test/CMakeLists.txt @@ -26,16 +26,19 @@ set(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(RSMITST "rsmitst") # Hack to find libraries after installation +# $ORIGIN is needed for libgtest.so # /opt/rocm/share/rocm-smi/rsmitst_tests/../../../ = /opt/rocm set(RSMITST_RPATH - "\$ORIGIN/../../../lib") + "\$ORIGIN/../../../lib" + "\$ORIGIN") # combine lists set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH} ${RSMITST_RPATH}) -# Try to find googletest -find_package(GTest 1.12.0) +# TODO: Try to find googletest +# DISABLED because we want to install gtest with rocm_smi_lib ourselves +#find_package(GTest 1.12.0) # GTest_FOUND is set to TRUE if ANY version is found # GTest_VERSION is set if 1.12.0 or newer version is found @@ -47,6 +50,9 @@ if(NOT GTest_FOUND STREQUAL "TRUE" OR NOT DEFINED GTest_VERSION) GIT_REPOSITORY https://github.com/google/googletest.git GIT_TAG release-1.12.0) FetchContent_MakeAvailable(googletest) + install(TARGETS gtest gtest_main + DESTINATION ${SHARE_INSTALL_PREFIX}/rsmitst_tests + COMPONENT ${TESTS_COMPONENT}) endif() # Other source directories @@ -64,13 +70,14 @@ target_include_directories(${RSMITST} PUBLIC ${SRC_DIR}/..) target_link_libraries( ${RSMITST} PUBLIC ${ROCM_SMI_TARGET} - PUBLIC GTest::gtest_main + PUBLIC gtest + PUBLIC gtest_main PUBLIC c PUBLIC stdc++ PUBLIC pthread PUBLIC dl) -install(TARGETS ${RSMITST} gtest gtest_main +install(TARGETS ${RSMITST} DESTINATION ${SHARE_INSTALL_PREFIX}/rsmitst_tests COMPONENT ${TESTS_COMPONENT})