diff --git a/projects/rocm-smi-lib/CMakeLists.txt b/projects/rocm-smi-lib/CMakeLists.txt index 81d72a6761..ffecf08b8f 100755 --- a/projects/rocm-smi-lib/CMakeLists.txt +++ b/projects/rocm-smi-lib/CMakeLists.txt @@ -145,6 +145,36 @@ set(CMN_INC_LIST ${CMN_INC_LIST} "${SHR_MUTEX_DIR}/shared_mutex.h") add_subdirectory("rocm_smi") add_subdirectory("oam") +#TODO: Should use GNUInstallDirs to match distro standards +#This need fix in subdirectory CMakefile as well +#include(GNUInstallDirs) +set(LIB_INSTALL_DIR "lib") +set(INCLUDE_INSTALL_DIR "include") +set(BIN_INSTALL_DIR "bin") + +include(CMakePackageConfigHelpers) + +configure_package_config_file( + rocm_smi-config.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/rocm_smi-config.cmake + INSTALL_DESTINATION ${LIB_INSTALL_DIR}/cmake/rocm_smi + PATH_VARS LIB_INSTALL_DIR INCLUDE_INSTALL_DIR BIN_INSTALL_DIR + ) + +write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/rocm_smi-config-version.cmake + VERSION "${AMD_SMI_LIBS_TARGET_VERSION_MAJOR}.${AMD_SMI_LIBS_TARGET_VERSION_MINOR}.${AMD_SMI_LIBS_TARGET_VERSION_PATCH}" + COMPATIBILITY SameMajorVersion + ) + +install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/rocm_smi-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/rocm_smi-config-version.cmake + DESTINATION + lib/cmake/${ROCM_SMI} + COMPONENT dev + ) + # Create cmake target # Add all targets to the build-tree export set export(TARGETS ${ROCM_SMI_TARGET} ${OAM_TARGET} @@ -155,28 +185,8 @@ export(TARGETS ${ROCM_SMI_TARGET} ${OAM_TARGET} export(PACKAGE rocm_smi) # Create the rocm_smiConfig.cmake and rocm_smiConfigVersion files # ... for the build tree -set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}") -set(CONF_LIB_DIR "${PROJECT_BINARY_DIR}") -set(CONF_LIBS "${ROCM_SMI_LIB_NAME}.so") -configure_file(rocm_smi-config.cmake.in - "${PROJECT_BINARY_DIR}/rocm_smi-config.cmake" @ONLY) -# ... for the install tree -set(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/rocm_smi/include") -set(CONF_LIB_DIR "${CMAKE_INSTALL_PREFIX}/rocm_smi/lib") -set(CONF_LIBS "${ROCM_SMI_LIB_NAME}.so") -configure_file(rocm_smi-config.cmake.in - "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/rocm_smi-config.cmake" @ONLY) -# ... for both -configure_file(rocm_smi-config-version.cmake.in - "${PROJECT_BINARY_DIR}/rocm_smi-config-version.cmake" @ONLY) -# Install the rocm_smi-config.cmake and rocm_smi-config-version.cmake -install(FILES - "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/rocm_smi-config.cmake" - "${PROJECT_BINARY_DIR}/rocm_smi-config-version.cmake" - DESTINATION "${ROCM_SMI}/lib/cmake" COMPONENT dev) -# Install the export set for use with the install-tree install(EXPORT rocm_smiTargets DESTINATION - "${ROCM_SMI}/lib/cmake" COMPONENT dev) + "lib/cmake/${ROCM_SMI}" COMPONENT dev) #License file set(CPACK_RPM_PACKAGE_LICENSE "NCSA") diff --git a/projects/rocm-smi-lib/rocm_smi-config-version.cmake.in b/projects/rocm-smi-lib/rocm_smi-config-version.cmake.in deleted file mode 100644 index 1f3dd0beb5..0000000000 --- a/projects/rocm-smi-lib/rocm_smi-config-version.cmake.in +++ /dev/null @@ -1,12 +0,0 @@ -set(PACKAGE_VERSION "@ROCM_SMI_VERSION@") - -# Check whether the requested PACKAGE_FIND_VERSION is compatible -if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") - set(PACKAGE_VERSION_COMPATIBLE FALSE) -else() - set(PACKAGE_VERSION_COMPATIBLE TRUE) - if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") - set(PACKAGE_VERSION_EXACT TRUE) - endif() -endif() - diff --git a/projects/rocm-smi-lib/rocm_smi-config.cmake.in b/projects/rocm-smi-lib/rocm_smi-config.cmake.in index 3ca1ed74cd..83a8871af4 100644 --- a/projects/rocm-smi-lib/rocm_smi-config.cmake.in +++ b/projects/rocm-smi-lib/rocm_smi-config.cmake.in @@ -4,9 +4,15 @@ # ROCM_SMI_LIBRARIES - libraries to link against # Compute paths +@PACKAGE_INIT@ get_filename_component(ROCM_SMI_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) -set(ROCM_SMI_INCLUDE_DIR "@CONF_INCLUDE_DIRS@") -set(ROCM_SMI_LIB_DIR "@CONF_LIB_DIR@") + +set_and_check( rocm_smi_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@" ) +set_and_check( ROCM_SMI_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@" ) +set_and_check( ROCM_SMI_INCLUDE_DIRS "@PACKAGE_INCLUDE_INSTALL_DIR@" ) +set_and_check( rocm_smi_LIB_DIR "@PACKAGE_LIB_INSTALL_DIR@" ) +set_and_check( ROCM_SMI_LIB_DIR "@PACKAGE_LIB_INSTALL_DIR@" ) +set_and_check( ROCM_SMI_LIB_DIRS "@PACKAGE_LIB_INSTALL_DIR@" ) # Our library dependencies (contains definitions for IMPORTED targets) if(NOT TARGET rocm_smi AND NOT rocm_smi_BINARY_DIR) @@ -14,5 +20,8 @@ if(NOT TARGET rocm_smi AND NOT rocm_smi_BINARY_DIR) endif() # These are IMPORTED targets created by RocmSmiTargets.cmake -set(ROCM_SMI_LIBRARIES "@CONF_LIBS@") +# TODO: Need to check if OAM libraries are needed here! +set(ROCM_SMI_LIBRARIES rocm_smi64) +set(ROCM_SMI_LIBRARY rocm_smi64) +check_required_components(rocm_smi)