From beaffa2c84efc2d5a4f5340dd2f3d7ab6a04212f Mon Sep 17 00:00:00 2001 From: "Galantsev, Dmitrii" Date: Tue, 19 Aug 2025 11:39:39 -0500 Subject: [PATCH] [SWDEV-545751] CMAKE - Enable fPIC (#629) Change-Id: Iaade10e70b3a39d6bca23ae98f9f501339ffd76d Signed-off-by: Galantsev, Dmitrii [ROCm/amdsmi commit: cd33b75540a3f077751ef81d05794bb863c673a0] --- projects/amdsmi/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/projects/amdsmi/CMakeLists.txt b/projects/amdsmi/CMakeLists.txt index c4d22fecc6..8a99a2ee6a 100644 --- a/projects/amdsmi/CMakeLists.txt +++ b/projects/amdsmi/CMakeLists.txt @@ -97,6 +97,10 @@ option(ENABLE_ASAN_PACKAGING "" OFF) option(ENABLE_ESMI_LIB "Build ESMI Library" ON) option(BUILD_EXAMPLES "Build examples" OFF) +# If amdsmi is built as a static library, it should support being embedded in other programs. The setting below essentially enables the -fPIC flag. +set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "Enable position independent code for all targets") +mark_as_advanced(CMAKE_POSITION_INDEPENDENT_CODE) + include(CMakeDependentOption) # these options don't work without BUILD_SHARED_LIBS cmake_dependent_option(BUILD_WRAPPER "Rebuild AMDSMI-wrapper" OFF "BUILD_SHARED_LIBS" OFF)