Add cmake target for rocm_smi

rocm_smi will provide cmake files exporting the INCLUDE/LIBRARY targets.

Change-Id: I1943a3142bdc0abd8f03ff62e12e947aac835401
Esse commit está contido em:
Bill(Shuzhou) Liu
2021-08-30 11:08:33 -04:00
commit de Shuzhou Liu
commit 088fe48d12
5 arquivos alterados com 82 adições e 0 exclusões
+35
Ver Arquivo
@@ -137,6 +137,41 @@ set(CMN_INC_LIST ${CMN_INC_LIST} "${SHR_MUTEX_DIR}/shared_mutex.h")
add_subdirectory("rocm_smi")
add_subdirectory("oam")
# Create cmake target
# Add all targets to the build-tree export set
export(TARGETS ${ROCM_SMI_TARGET} ${OAM_TARGET}
FILE "${PROJECT_BINARY_DIR}/rcom_smi_target.cmake")
# Export the package for use from the build-tree
# (this registers the build-tree with a global CMake-registry)
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)
###########################
# Packaging directives
###########################
+8
Ver Arquivo
@@ -91,8 +91,16 @@ if ("${CMAKE_BUILD_TYPE}" STREQUAL Release)
endif()
endif ()
# use the target_include_directories() command to specify the include directories for the target
target_include_directories(${OAM_TARGET}
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:{OAM_NAME}/include>")
## Add the install directives for the runtime library.
install(TARGETS ${OAM_TARGET}
EXPORT rocm_smiTargets
LIBRARY DESTINATION ${OAM_NAME}/lib
ARCHIVE DESTINATION ${OAM_NAME}/lib
COMPONENT ${OAM_COMPONENT})
+12
Ver Arquivo
@@ -0,0 +1,12 @@
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()
+18
Ver Arquivo
@@ -0,0 +1,18 @@
# - Config file for the rocm_smi package
# It defines the following variables
# ROCM_SMI_INCLUDE_DIRS - include directories for rocm_smi
# ROCM_SMI_LIBRARIES - libraries to link against
# Compute paths
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@")
# Our library dependencies (contains definitions for IMPORTED targets)
if(NOT TARGET rocm_smi AND NOT rocm_smi_BINARY_DIR)
include("${ROCM_SMI_CMAKE_DIR}/rocm_smiTargets.cmake")
endif()
# These are IMPORTED targets created by RocmSmiTargets.cmake
set(ROCM_SMI_LIBRARIES "@CONF_LIBS@")
+9
Ver Arquivo
@@ -80,6 +80,14 @@ target_link_libraries(${ROCM_SMI_TARGET} pthread rt)
target_include_directories(${ROCM_SMI_TARGET} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR} ${COMMON_PROJ_ROOT}/common/shared_mutex)
# use the target_include_directories() command to specify the include directories for the target
target_include_directories(${ROCM_SMI_TARGET}
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${ROCM_SMI}/include>"
)
## Set the VERSION and SOVERSION values
set_property(TARGET ${ROCM_SMI_TARGET} PROPERTY
SOVERSION "${VERSION_MAJOR}")
@@ -113,6 +121,7 @@ if(${BUILD_SHARED_LIBS})
endif()
## Add the install directives for the runtime library.
install(TARGETS ${ROCM_SMI_TARGET}
EXPORT rocm_smiTargets
LIBRARY DESTINATION ${ROCM_SMI}/lib
ARCHIVE DESTINATION ${ROCM_SMI}/lib
COMPONENT ${ROCM_SMI_COMPONENT})