commit:     bba5c918ff7ee2e10af6e2ae7b6714c43e15a531
Author:     Sv. Lockal <lockalsash <AT> gmail <DOT> com>
AuthorDate: Tue Oct 21 18:21:31 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Oct 21 18:47:38 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=bba5c918

dev-util/amdsmi: new package, add 7.0.2

This package includes amd-smi cli tool, libraries and python bindings
and serves as a replacement to dev-util/rocm-smi, as it reaches
"maintenance mode" (only critical bug fixes will be applied) and new
features and hardware are added only to the new amd-smi tool.

Bug: https://bugs.gentoo.org/964799
Signed-off-by: Sv. Lockal <lockalsash <AT> gmail.com>
Part-of: https://github.com/gentoo/gentoo/pull/44165
Closes: https://github.com/gentoo/gentoo/pull/44165
Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-util/amdsmi/Manifest                           |   2 +
 dev-util/amdsmi/amdsmi-7.0.2.ebuild                | 121 ++++++++++++++
 .../amdsmi/files/amdsmi-7.0.2-fix-includes.patch   |  43 +++++
 .../amdsmi/files/amdsmi-7.0.2-fix-soversion.patch  | 184 +++++++++++++++++++++
 dev-util/amdsmi/files/amdsmi-7.0.2-no-git.patch    |  21 +++
 .../amdsmi/files/amdsmi-7.0.2-unbundle-gtest.patch |  47 ++++++
 dev-util/amdsmi/metadata.xml                       |  15 ++
 7 files changed, 433 insertions(+)

diff --git a/dev-util/amdsmi/Manifest b/dev-util/amdsmi/Manifest
new file mode 100644
index 000000000000..5cd1cc948dc5
--- /dev/null
+++ b/dev-util/amdsmi/Manifest
@@ -0,0 +1,2 @@
+DIST amdsmi-7.0.2.tar.gz 910310 BLAKE2B 
ea375b20019e7fdefc0c0f38444e52c0b56e8ef8a83897ce1a6c52f407521592862ca743110059b3a32043305fcde006885cb25d1a13124c41a4c5222c7e44df
 SHA512 
4e57c53edb7dbb1337468c80071bc13439bf6257360f5b91fbec3d383bf55f22ce0327544c2a94b3a630de94906d8ed9e1f92177914fc6096eb22f55c773d4ff
+DIST esmi_pkg_ver-4.2.tar.gz 463866 BLAKE2B 
4d78fe94351623dad5a187133ad8d1be456c2477b69c0b6dc15b2d239b494c9f4011fe558e36a07f7b03b67daccf8bf03b92ea3502dc31ddc965fa9e28b3b49e
 SHA512 
8a86eb84f86cada75232a800ce81f151bfe4b77f119a1a19189abddf8473e7b7f860594a206303277f708497e86db34af519e061e5ff3bb9d860b943c5781b09

diff --git a/dev-util/amdsmi/amdsmi-7.0.2.ebuild 
b/dev-util/amdsmi/amdsmi-7.0.2.ebuild
new file mode 100644
index 000000000000..a748666b9982
--- /dev/null
+++ b/dev-util/amdsmi/amdsmi-7.0.2.ebuild
@@ -0,0 +1,121 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+PYTHON_COMPAT=( python3_{10..14} )
+ROCM_SKIP_GLOBALS=1
+inherit cmake linux-info python-r1 rocm
+
+ESMI_PN=esmi_pkg_ver
+ESMI_PV=4.2
+
+DESCRIPTION="AMD System Management Interface for managing and monitoring GPUs"
+HOMEPAGE="
+       https://github.com/ROCm/amdsmi
+       https://rocm.docs.amd.com/projects/amdsmi/en/latest/
+"
+SRC_URI="
+       https://github.com/ROCm/amdsmi/archive/refs/tags/rocm-${PV}.tar.gz -> 
${P}.tar.gz
+       
https://github.com/amd/esmi_ib_library/archive/refs/tags/${ESMI_PN}-${ESMI_PV}.tar.gz
+"
+S="${WORKDIR}/amdsmi-rocm-${PV}"
+ESMI_S="${WORKDIR}/esmi_ib_library-${ESMI_PN}-${ESMI_PV}"
+
+LICENSE="MIT"
+SLOT="0/$(ver_cut 1-2)"
+KEYWORDS="~amd64"
+
+IUSE="test"
+RESTRICT="!test? ( test )"
+
+REQUIRED_USE="${PYTHON_REQUIRED_USE}"
+
+DEPEND="
+       ${PYTHON_DEPS}
+       test? ( dev-cpp/gtest )
+"
+RDEPEND="
+       ${PYTHON_DEPS}
+       dev-libs/rocm-core:${SLOT}
+"
+
+PATCHES=(
+       "${FILESDIR}"/${PN}-7.0.2-no-git.patch
+       "${FILESDIR}"/${PN}-7.0.2-fix-includes.patch
+       "${FILESDIR}"/${PN}-7.0.2-unbundle-gtest.patch
+       "${FILESDIR}"/${PN}-7.0.2-fix-soversion.patch
+)
+
+CONFIG_CHECK="~HSA_AMD ~DRM_AMDGPU"
+
+src_prepare() {
+       ln -s "${ESMI_S}" esmi_ib_library || die
+
+       # git does not work for tar.gz releases
+       # sed -e 's/find_program[[:space:]]*(GIT NAMES git)/find_package(Git)/' 
\
+       #       -e 's/\<GIT\>/GIT_EXECUTABLE/g' \
+       #       -i CMakeLists.txt \
+       #       -i "${ESMI_S}"/CMakeLists.txt \
+       #       -i rocm_smi/CMakeLists.txt || die
+
+       # sed -e '/find_program[[:space:]]*(get_commits/d' \
+       #       -i cmake_modules/utils.cmake 
"${ESMI_S}"/cmake_modules/utils.cmake || die
+
+       # Compatibility with CMake < 3.10 will be removed
+       sed -e "/cmake_minimum_required/ s/3\.5\.0/3.10/" \
+               -i goamdsmi_shim/CMakeLists.txt "${ESMI_S}"/CMakeLists.txt || 
die
+
+       sed -e "s/-Wall -Wextra//" \
+               -i CMakeLists.txt "${ESMI_S}"/CMakeLists.txt 
goamdsmi_shim/CMakeLists.txt || die
+
+       # Reset custom installation path
+       sed -e "/generic_add_rocm/d" -i CMakeLists.txt || die
+
+       # Remove /usr/lib to fix multilib
+       sed -e '/target_link_libraries.*\/lib/d' -i 
goamdsmi_shim/CMakeLists.txt || die
+
+       # Install docs to correct place
+       sed -e "s:doc/\${CPACK_PACKAGE_NAME}:doc/${P}:" -i CMakeLists.txt || die
+
+       # Do not install /usr/share/doc/${P}-asan
+       sed -e "s/COMPONENT asan/COMPONENT asan EXCLUDE_FROM_ALL/" -i 
CMakeLists.txt || die
+
+       cmake_src_prepare
+}
+
+src_configure() {
+       python_setup
+
+       local mycmakeargs=(
+               -DBUILD_TESTS=$(usex test)
+               -DUSE_SYSTEM_GTEST=ON
+               -Wno-dev
+       )
+       cmake_src_configure
+}
+
+src_install() {
+       cmake_src_install
+
+       # Wrong places
+       rm "${ED}"/usr/share/amd_smi/amdsmi/{libamd_smi.so,LICENSE,README.md} 
|| die
+
+       python_fix_shebang "${ED}"/usr/libexec/amdsmi_cli
+       python_domodule "${ED}"/usr/libexec/amdsmi_cli
+       python_domodule "${ED}"/usr/share/amd_smi/amdsmi
+
+       fperms a+x "/usr/lib/${EPYTHON}/site-packages/amdsmi_cli/amdsmi_cli.py"
+       dosym -r "/usr/lib/${EPYTHON}/site-packages/amdsmi_cli/amdsmi_cli.py" 
/usr/bin/amd-smi
+
+       rm -rf "${ED}"/usr/share/amd_smi "${ED}"/usr/libexec/amdsmi_cli || die
+}
+
+src_test() {
+       # GPU access in amdsmitstReadOnly.TestSysInfoRead and 
amdsmitstReadOnly.TestIdInfoRead
+       addwrite /dev/dri/renderD128
+
+       # Few tests fail on ASUS GZ302E: no metrics from kernel?
+       
GTEST_FILTER="-amdsmitstReadOnly.TempRead:amdsmitstReadOnly.TestFrequenciesRead"
 \
+       "${BUILD_DIR}/tests/amd_smi_test/amdsmitst" || die "Test failed"
+}

diff --git a/dev-util/amdsmi/files/amdsmi-7.0.2-fix-includes.patch 
b/dev-util/amdsmi/files/amdsmi-7.0.2-fix-includes.patch
new file mode 100644
index 000000000000..be26f889ea30
--- /dev/null
+++ b/dev-util/amdsmi/files/amdsmi-7.0.2-fix-includes.patch
@@ -0,0 +1,43 @@
+Fix missing includes for >=libstdc++-15.
+Upstream bug: https://github.com/ROCm/amdsmi/issues/123
+Upstream bug: https://github.com/ROCm/amdsmi/issues/124
+--- a/rocm_smi/include/rocm_smi/rocm_smi_common.h
++++ b/rocm_smi/include/rocm_smi/rocm_smi_common.h
+@@ -23,6 +23,7 @@
+ #ifndef INCLUDE_ROCM_SMI_ROCM_SMI_COMMON_H_
+ #define INCLUDE_ROCM_SMI_ROCM_SMI_COMMON_H_
+ 
++#include <cstdint>
+ #include <memory>
+ #include <map>
+ #include <vector>
+--- a/tests/amd_smi_test/functional/frequencies_read.cc
++++ b/tests/amd_smi_test/functional/frequencies_read.cc
+@@ -21,6 +21,7 @@
+  */
+ 
+ #include <cstdint>
++#include <iomanip>
+ #include <iostream>
+ #include <string>
+ 
+--- a/tests/amd_smi_test/functional/hw_topology_read.cc
++++ b/tests/amd_smi_test/functional/hw_topology_read.cc
+@@ -24,6 +24,7 @@
+ #include <stdint.h>
+ #include <stddef.h>
+ 
++#include <iomanip>
+ #include <iostream>
+ #include <string>
+ #include <vector>
+--- a/tests/amd_smi_test/functional/sys_info_read.cc
++++ b/tests/amd_smi_test/functional/sys_info_read.cc
+@@ -24,6 +24,7 @@
+ #include <stddef.h>
+ #include <gtest/gtest.h>
+ 
++#include <iomanip>
+ #include <iostream>
+ #include <string>
+ #include <limits>

diff --git a/dev-util/amdsmi/files/amdsmi-7.0.2-fix-soversion.patch 
b/dev-util/amdsmi/files/amdsmi-7.0.2-fix-soversion.patch
new file mode 100644
index 000000000000..ab8a57313f33
--- /dev/null
+++ b/dev-util/amdsmi/files/amdsmi-7.0.2-fix-soversion.patch
@@ -0,0 +1,184 @@
+Set the SOVERSION in CMake from MAJOR/MINOR/RELEASE variables instead of git 
info
+Backports:
+* 
https://github.com/ROCm/amdsmi/commit/ccfdb65b6ff873d74c610cc48b3b398002a16757
+* 
https://github.com/ROCm/amdsmi/commit/925014ddafb3d6c18686613afd7ac817b548f1e6
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -43,6 +43,11 @@ find_program(GIT NAMES git)
+ 
+ ## Setup the package version based on git tags.
+ set(PKG_VERSION_GIT_TAG_PREFIX "amdsmi_pkg_ver")
++get_version_from_file("include/amd_smi/amdsmi.h" "MAJOR")
++get_version_from_file("include/amd_smi/amdsmi.h" "MINOR")
++get_version_from_file("include/amd_smi/amdsmi.h" "RELEASE")
++set(DEFAULT_VERSION "${MAJOR}.${MINOR}.${RELEASE}")
++get_package_version_number(${DEFAULT_VERSION} ${PKG_VERSION_GIT_TAG_PREFIX} 
GIT)
+ get_package_version_number("26.0.2" ${PKG_VERSION_GIT_TAG_PREFIX} GIT)
+ message("Package version: ${PKG_VERSION_STR}")
+ set(${AMD_SMI_LIBS_TARGET}_VERSION_MAJOR "${CPACK_PACKAGE_VERSION_MAJOR}")
+@@ -54,6 +59,11 @@ set(${AMD_SMI_LIBS_TARGET}_VERSION_STRING
+     
"${${AMD_SMI_LIBS_TARGET}_VERSION_MAJOR}.${${AMD_SMI_LIBS_TARGET}_VERSION_MINOR}.${${AMD_SMI_LIBS_TARGET}_VERSION_PATCH}+${${AMD_SMI_LIBS_TARGET}_VERSION_HASH}"
+ )
+ 
++set(DEFAULT_VERSION 
"${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
++update_version_in_file("include/amd_smi/amdsmi.h" ${DEFAULT_VERSION} "#define 
AMDSMI_LIB_VERSION_" " *" " ")
++update_version_in_file("rust-interface/src/amdsmi_wrapper.rs" 
${DEFAULT_VERSION} "AMDSMI_LIB_VERSION_" " *: *u32 *= *"
++                       ": u32 = ")
++
+ # Make proper version for appending
+ # Default Value is 99999
+ set(ROCM_VERSION_FOR_PACKAGE "99999")
+--- a/cmake_modules/utils.cmake
++++ b/cmake_modules/utils.cmake
+@@ -56,30 +56,87 @@ function(parse_version VERSION_STRING)
+ 
+ endfunction()
+ 
++function(get_version_from_file REL_FILE_PATH ITEM)
++    set(FILE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${REL_FILE_PATH}")
++    set(OUTPUT_ITEM "0")
++
++    if(EXISTS "${FILE_PATH}")
++        file(READ ${FILE_PATH} file_contents)
++        string(REGEX MATCHALL "AMDSMI_LIB_VERSION_${ITEM} *[0-9]+" OUTPUT_STR 
"${file_contents}")
++        list(LENGTH OUTPUT_STR OUTPUT_STR_LENGTH)
++        if(${OUTPUT_STR_LENGTH} GREATER 0)
++            string(REGEX MATCH "[0-9]+" OUTPUT_ITEM "${OUTPUT_STR}")
++        endif()
++    endif()
++
++    set(${ITEM} "${OUTPUT_ITEM}" PARENT_SCOPE)
++endfunction()
++
++# Parses file for a pattern and replaces the value
++# associated with that pattern with a specified value
++# Replaces VERSION(MAJOR.MINOR.RELEASE) with updated values
++function(update_version_in_file REL_FILE_PATH DEFAULT_VERSION PAT1 PAT2 PAT3)
++    get_version_from_file(${REL_FILE_PATH} "MAJOR")
++    get_version_from_file(${REL_FILE_PATH} "MINOR")
++    get_version_from_file(${REL_FILE_PATH} "RELEASE")
++    set(FILE_VERSION "${MAJOR}.${MINOR}.${RELEASE}")
++
++    if(DEFAULT_VERSION VERSION_GREATER FILE_VERSION)
++        set(FILE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${REL_FILE_PATH}")
++        if(EXISTS "${FILE_PATH}")
++            parse_version(${DEFAULT_VERSION})
++            file(READ ${FILE_PATH} file_contents_new)
++
++            string(REGEX REPLACE "${PAT1}MAJOR${PAT2} *[0-9]*" 
"${PAT1}MAJOR${PAT3}${VERSION_MAJOR}" file_contents
++                                 "${file_contents_new}")
++            string(REGEX REPLACE "${PAT1}MINOR${PAT2} *[0-9]*" 
"${PAT1}MINOR${PAT3}${VERSION_MINOR}" file_contents_new
++                                 "${file_contents}")
++            string(REGEX REPLACE "${PAT1}RELEASE${PAT2} *[0-9]*" 
"${PAT1}RELEASE${PAT3}${VERSION_PATCH}" file_contents
++                                 "${file_contents_new}")
++
++            file(WRITE ${FILE_PATH} "${file_contents}")
++        endif()
++        set(VERSION_STRING "${DEFAULT_VERSION}" PARENT_SCOPE)
++    else()
++        set(VERSION_STRING "${FILE_VERSION}" PARENT_SCOPE)
++    endif()
++endfunction()
++
+ ## Gets the current version of the repository
+ ## using versioning tags and git describe.
+ ## Passes back a packaging version string
+ ## and a library version string.
+ function(get_version_from_tag DEFAULT_VERSION_STRING VERSION_PREFIX GIT)
+     parse_version(${DEFAULT_VERSION_STRING})
++    set(DEFAULT_VERSION_MAJOR "${VERSION_MAJOR}")
++    set(DEFAULT_VERSION_MINOR "${VERSION_MINOR}")
++    set(DEFAULT_VERSION_PATCH "${VERSION_PATCH}")
+ 
+     if(GIT)
+         execute_process(
+-            COMMAND git describe --tags --dirty --long --match 
${VERSION_PREFIX}-[0-9.]*
++            COMMAND git tag --list --sort=-version:refname 
"${VERSION_PREFIX}*"
++            COMMAND head -n 1
+             WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+             OUTPUT_VARIABLE GIT_TAG_STRING
+-            OUTPUT_STRIP_TRAILING_WHITESPACE
+-            RESULT_VARIABLE RESULT)
+-        if(${RESULT} EQUAL 0)
++            OUTPUT_STRIP_TRAILING_WHITESPACE RESULTS_VARIABLE RESULTS)
++        if(GIT_TAG_STRING)
++
+             parse_version(${GIT_TAG_STRING})
+         endif()
+ 
+     endif()
+ 
+-    set(VERSION_STRING "${VERSION_STRING}" PARENT_SCOPE)
+-    set(VERSION_MAJOR "${VERSION_MAJOR}" PARENT_SCOPE)
+-    set(VERSION_MINOR "${VERSION_MINOR}" PARENT_SCOPE)
+-    set(VERSION_PATCH "${VERSION_PATCH}" PARENT_SCOPE)
++    if(VERSION_STRING VERSION_GREATER DEFAULT_VERSION_STRING)
++        set(VERSION_STRING "${VERSION_STRING}" PARENT_SCOPE)
++        set(VERSION_MAJOR "${VERSION_MAJOR}" PARENT_SCOPE)
++        set(VERSION_MINOR "${VERSION_MINOR}" PARENT_SCOPE)
++        set(VERSION_PATCH "${VERSION_PATCH}" PARENT_SCOPE)
++    else()
++        set(VERSION_STRING "${DEFAULT_VERSION_STRING}" PARENT_SCOPE)
++        set(VERSION_MAJOR "${DEFAULT_VERSION_MAJOR}" PARENT_SCOPE)
++        set(VERSION_MINOR "${DEFAULT_VERSION_MINOR}" PARENT_SCOPE)
++        set(VERSION_PATCH "${DEFAULT_VERSION_PATCH}" PARENT_SCOPE)
++    endif()
+ endfunction()
+ 
+ function(num_change_since_prev_pkg VERSION_PREFIX)
+@@ -106,6 +163,7 @@ function(num_change_since_prev_pkg VERSION_PREFIX)
+ endfunction()
+ 
+ function(get_package_version_number DEFAULT_VERSION_STRING VERSION_PREFIX GIT)
++    parse_version(${DEFAULT_VERSION_STRING})
+     get_version_from_tag(${DEFAULT_VERSION_STRING} ${VERSION_PREFIX} GIT)
+     num_change_since_prev_pkg(${VERSION_PREFIX})
+     set(PKG_VERSION_STR "${VERSION_STRING}.${NUM_COMMITS}")
+--- a/src/CMakeLists.txt
++++ b/src/CMakeLists.txt
+@@ -59,27 +59,9 @@ endif()
+ # VERSION_* variables should be set by get_version_from_tag
+ message("Package version: ${PKG_VERSION_STR}")
+ 
+-# Debian package specific variables
+-# Set a default value for the package version
+-get_version_from_tag("${${AMD_SMI_LIBS_TARGET}_VERSION_MAJOR}.${${AMD_SMI_LIBS_TARGET}_VERSION_MINOR}.0.0"
+-                     ${SO_VERSION_GIT_TAG_PREFIX} GIT)
+-
+-# VERSION_* variables should be set by get_version_from_tag
+-if(${ROCM_PATCH_VERSION})
+-    set(VERSION_PATCH ${ROCM_PATCH_VERSION})
+-    set(SO_VERSION_STRING 
"${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
+-else()
+-    set(SO_VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}")
+-endif()
+-set(${AMD_SMI}_VERSION_MAJOR "${VERSION_MAJOR}")
+-set(${AMD_SMI}_VERSION_MINOR "${VERSION_MINOR}")
+-set(${AMD_SMI}_VERSION_PATCH "0")
+-set(${AMD_SMI}_VERSION_BUILD "0")
++set(SO_VERSION_STRING "${MAJOR}.${MINOR}.${RELEASE}")
+ message("SOVERSION: ${SO_VERSION_STRING}")
+ 
+-# Create a configure file to get version info from within library
+-configure_file("amd_smiConfig.in" 
"${PROJECT_SOURCE_DIR}/include/amd_smi/amd_smiConfig.h")
+-
+ add_library(${AMD_SMI} ${SRC_LIST} ${INC_LIST})
+ target_link_libraries(${AMD_SMI} pthread rt dl ${DRM_LIBRARIES} 
${AMDGPU_DRM_LIBRARIES})
+ target_include_directories(${AMD_SMI} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} 
${PROJECT_SOURCE_DIR}/rocm_smi/include
+@@ -90,7 +72,7 @@ target_include_directories(${AMD_SMI} PUBLIC 
"$<BUILD_INTERFACE:${CMAKE_CURRENT_
+                                              
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
+ 
+ ## Set the VERSION and SOVERSION values
+-set_property(TARGET ${AMD_SMI} PROPERTY SOVERSION "${VERSION_MAJOR}")
++set_property(TARGET ${AMD_SMI} PROPERTY SOVERSION "${MAJOR}")
+ set_property(TARGET ${AMD_SMI} PROPERTY VERSION "${SO_VERSION_STRING}")
+ 
+ ## If the library is a release, strip the target library
+@@ -115,6 +97,6 @@ install(
+     DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/amd_smi
+     COMPONENT dev)
+ install(
+-    FILES ${PROJECT_SOURCE_DIR}/include/amd_smi/amd_smiConfig.h
++    FILES ${PROJECT_SOURCE_DIR}/rocm_smi/include/rocm_smi/kfd_ioctl.h
+     DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/amd_smi
+     COMPONENT dev)

diff --git a/dev-util/amdsmi/files/amdsmi-7.0.2-no-git.patch 
b/dev-util/amdsmi/files/amdsmi-7.0.2-no-git.patch
new file mode 100644
index 000000000000..989270521621
--- /dev/null
+++ b/dev-util/amdsmi/files/amdsmi-7.0.2-no-git.patch
@@ -0,0 +1,21 @@
+Should not check and update esmi_ib_library in network isolation
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -39,7 +39,7 @@ find_package(PkgConfig)
+ generic_add_rocm()
+ 
+ # provide git to utilities
+-find_program(GIT NAMES git)
++# find_program(GIT NAMES git)
+ 
+ ## Setup the package version based on git tags.
+ set(PKG_VERSION_GIT_TAG_PREFIX "amdsmi_pkg_ver")
+@@ -126,7 +126,7 @@ if(ENABLE_ESMI_LIB)
+         message(STATUS "Adding esmi_ib_library...")
+         execute_process(COMMAND git clone --depth=1 -b ${current_esmi_tag} 
https://github.com/amd/esmi_ib_library.git
+                                 ${PROJECT_SOURCE_DIR}/esmi_ib_library)
+-    else()
++    elseif(FALSE)
+         message(STATUS "esmi_ib_library already installed, checking 
version...")
+ 
+         # Grab latest commit and get the tag

diff --git a/dev-util/amdsmi/files/amdsmi-7.0.2-unbundle-gtest.patch 
b/dev-util/amdsmi/files/amdsmi-7.0.2-unbundle-gtest.patch
new file mode 100644
index 000000000000..a656a3ee896f
--- /dev/null
+++ b/dev-util/amdsmi/files/amdsmi-7.0.2-unbundle-gtest.patch
@@ -0,0 +1,47 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -86,6 +86,7 @@ option(BUILD_TESTS "Build test suite" OFF)
+ option(ENABLE_ASAN_PACKAGING "" OFF)
+ option(ENABLE_ESMI_LIB "Build ESMI Library" ON)
+ option(BUILD_EXAMPLES "Build examples" OFF)
++option(USE_SYSTEM_GTEST "Use system-installed googletest instead of fetching 
it" OFF)
+ 
+ include(CMakeDependentOption)
+ # these options don't work without BUILD_SHARED_LIBS
+--- a/tests/amd_smi_test/CMakeLists.txt
++++ b/tests/amd_smi_test/CMakeLists.txt
+@@ -6,10 +6,14 @@ 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)
++if(USE_SYSTEM_GTEST)
++    find_package(GTest 1.14.0 REQUIRED)
++else()
++    # 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)
++endif()
+ 
+ enable_testing()
+ 
+@@ -63,8 +67,10 @@ install(
+     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})
++if(NOT USE_SYSTEM_GTEST)
++    # Install googletest libraries with tests
++    install(
++        TARGETS gtest gtest_main
++        DESTINATION ${SHARE_INSTALL_PREFIX}/tests
++        COMPONENT ${TESTS_COMPONENT})
++endif()

diff --git a/dev-util/amdsmi/metadata.xml b/dev-util/amdsmi/metadata.xml
new file mode 100644
index 000000000000..9d2042a10cc9
--- /dev/null
+++ b/dev-util/amdsmi/metadata.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd";>
+<pkgmetadata>
+    <maintainer type="person">
+        <email>[email protected]</email>
+        <name>Sv. Lockal</name>
+    </maintainer>
+    <maintainer type="project" proxied="proxy">
+        <email>[email protected]</email>
+        <name>Proxy Maintainers</name>
+    </maintainer>
+    <upstream>
+        <remote-id type="github">ROCm/amdsmi</remote-id>
+    </upstream>
+</pkgmetadata>

Reply via email to