diff --git a/projects/rocm-smi-lib/CMakeLists.txt b/projects/rocm-smi-lib/CMakeLists.txt index 8bdc698c70..b779d4ca60 100755 --- a/projects/rocm-smi-lib/CMakeLists.txt +++ b/projects/rocm-smi-lib/CMakeLists.txt @@ -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 ########################### diff --git a/projects/rocm-smi-lib/oam/CMakeLists.txt b/projects/rocm-smi-lib/oam/CMakeLists.txt index 3968823272..6373a84dda 100644 --- a/projects/rocm-smi-lib/oam/CMakeLists.txt +++ b/projects/rocm-smi-lib/oam/CMakeLists.txt @@ -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 + "$" + "$") + + ## 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}) diff --git a/projects/rocm-smi-lib/rocm_smi-config-version.cmake.in b/projects/rocm-smi-lib/rocm_smi-config-version.cmake.in new file mode 100644 index 0000000000..1f3dd0beb5 --- /dev/null +++ b/projects/rocm-smi-lib/rocm_smi-config-version.cmake.in @@ -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() + diff --git a/projects/rocm-smi-lib/rocm_smi-config.cmake.in b/projects/rocm-smi-lib/rocm_smi-config.cmake.in new file mode 100644 index 0000000000..3ca1ed74cd --- /dev/null +++ b/projects/rocm-smi-lib/rocm_smi-config.cmake.in @@ -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@") + diff --git a/projects/rocm-smi-lib/rocm_smi/CMakeLists.txt b/projects/rocm-smi-lib/rocm_smi/CMakeLists.txt index 90cad13cbe..dff27c9f42 100755 --- a/projects/rocm-smi-lib/rocm_smi/CMakeLists.txt +++ b/projects/rocm-smi-lib/rocm_smi/CMakeLists.txt @@ -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 + "$" + "$" +) + + ## 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})