Skip to content

Commit

Permalink
Merge branch 'develop' into devel-provides-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lawruble13 authored May 23, 2024
2 parents 17d3d72 + a83c507 commit 235ee6d
Show file tree
Hide file tree
Showing 15 changed files with 293 additions and 67 deletions.
38 changes: 38 additions & 0 deletions .azuredevops/rocm-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
resources:
repositories:
- repository: pipelines_repo
type: github
endpoint: ROCm
name: ROCm/ROCm

variables:
- group: common
- template: /.azuredevops/variables-global.yml@pipelines_repo

trigger:
batch: true
branches:
include:
- develop
paths:
exclude:
- .github
- '.*.y*ml'
- '*.md'
- LICENSE

pr:
autoCancel: true
branches:
include:
- develop
paths:
exclude:
- .github
- '.*.y*ml'
- '*.md'
- LICENSE
drafts: false

jobs:
- template: ${{ variables.CI_COMPONENT_PATH }}/rocm-cmake.yml@pipelines_repo
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ jobs:
python -m pip install -r test/docsphinx/docs/.sphinx/requirements.txt
- name: Install Doxygen
uses: ssciwr/doxygen-install@v1
with:
version: "1.10.0"
- name: Run tests
run: |
git config --global user.email "you@example.com"
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Change Log for rocm-cmake

## [(Unreleased) rocm-cmake 0.13.0 for ROCm 6.2.0]
### Changed
- ROCmCreatePackage: Accepts a suffix parameter, automatically generating it for static or ASAN builds.
- Package names will no longer be pulled from `CPACK_<GEN>_PACKAGE_NAME`
- Runtime packages will no longer be generated for static builds
## [rocm-cmake 0.12.0 for ROCm 6.1.0]
### Added
- ROCMTest: Add rpath to installed tests
- AOCMCreatePackage: Allow additional provides on header-only packages
- ROCMSphinxDoc: Allow separate source and config directories
### Changed
- Renamed CMake package to ROCmCMakeBuildTools. A wrapper has been provided
to ensure that `find_package(ROCM)` continues to work, but it is recommended
that developers switch to `find_package(ROCmCMakeBuildTools)`
- ROCMInstallTargets: Stopped installing executables in ASAN builds
### Fixed
- ROCMClangTidy: Fixed invalid list index in clang tidy
- Fixed test failures when `ROCM_CMAKE_GENERATOR` is an empty string

## [rocm-cmake 0.11.0 for ROCm 6.0.0]
### Changed
- ROCMSphinxDoc: Improved validation, documentation and rocm-docs-core integration.
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/share/rocmcmakebuildtool
include(ROCMCreatePackage)
include(ROCMSetupVersion)

rocm_setup_version(VERSION 0.11.0)
rocm_setup_version(VERSION 0.12.0)

include(CMakePackageConfigHelpers)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/ROCmCMakeBuildToolsConfigVersion.cmake
Expand Down
125 changes: 78 additions & 47 deletions share/rocmcmakebuildtools/cmake/ROCMCreatePackage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ endmacro()

macro(rocm_create_package)
set(options LDCONFIG PTH HEADER_ONLY)
set(oneValueArgs NAME DESCRIPTION SECTION MAINTAINER LDCONFIG_DIR PREFIX)
set(oneValueArgs NAME DESCRIPTION SECTION MAINTAINER LDCONFIG_DIR PREFIX SUFFIX)
set(multiValueArgs DEPENDS COMPONENTS)

cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
Expand Down Expand Up @@ -324,18 +324,18 @@ macro(rocm_create_package)
endif()

if (ROCM_USE_DEV_COMPONENT)
rocm_compute_component_package_name(devel "${CPACK_PACKAGE_NAME}" "${PARSE_SUFFIX}" "${PARSE_HEADER_ONLY}")
list(APPEND PARSE_COMPONENTS devel)
set(CPACK_DEBIAN_DEVEL_PACKAGE_NAME "${CPACK_PACKAGE_NAME}-dev")
rocm_join_if_set(", " CPACK_DEBIAN_RUNTIME_PACKAGE_RECOMMENDS
"${CPACK_PACKAGE_NAME}-dev (>=${CPACK_PACKAGE_VERSION})")
"${CPACK_DEBIAN_DEVEL_PACKAGE_NAME} (>=${CPACK_PACKAGE_VERSION})")

rocm_find_program_version(rpmbuild GREATER_EQUAL 4.12.0 QUIET)
if(rpmbuild_VERSION_OK)
rocm_join_if_set(", " CPACK_RPM_RUNTIME_PACKAGE_SUGGESTS
"${CPACK_PACKAGE_NAME}-devel >= ${CPACK_PACKAGE_VERSION}"
"${CPACK_RPM_DEVEL_PACKAGE_NAME} >= ${CPACK_PACKAGE_VERSION}"
)
endif()
if(PARSE_HEADER_ONLY)
if(PARSE_HEADER_ONLY OR NOT BUILD_SHARED_LIBS)
if(DEFINED CPACK_DEBIAN_DEVEL_PACKAGE_PROVIDES)
rocm_join_if_set(", "
CPACK_DEBIAN_DEVEL_PACKAGE_PROVIDES
Expand Down Expand Up @@ -426,7 +426,7 @@ macro(rocm_create_package)
endif()
rocm_setup_license(${PARSE_HEADER_ONLY})
if(PARSE_COMPONENTS)
rocm_set_comp_cpackvar(PARSE_HEADER_ONLY "${PARSE_COMPONENTS}")
rocm_set_comp_cpackvar(PARSE_HEADER_ONLY "${PARSE_SUFFIX}" "${PARSE_COMPONENTS}")
endif()
include(CPack)
set(ROCM_PACKAGE_CREATED TRUE CACHE INTERNAL "Track whether rocm_create_package has been called.")
Expand Down Expand Up @@ -464,7 +464,7 @@ macro(rocm_setup_license HEADER_ONLY)
FILES ${CPACK_RESOURCE_FILE_LICENSE}
DESTINATION share/doc/${_rocm_cpack_package_name}-asan
)
elseif(ROCM_USE_DEV_COMPONENT AND ${HEADER_ONLY})
elseif((ROCM_USE_DEV_COMPONENT AND ${HEADER_ONLY}) OR NOT BUILD_SHARED_LIBS)
install(
FILES ${CPACK_RESOURCE_FILE_LICENSE}
DESTINATION share/doc/${_rocm_cpack_package_name}
Expand All @@ -479,24 +479,74 @@ macro(rocm_setup_license HEADER_ONLY)
endif()
endmacro()

macro(rocm_set_comp_cpackvar HEADER_ONLY components)
macro(rocm_compute_component_package_name COMPONENT_NAME BASE_NAME NAME_SUFFIX HEADER_ONLY)
# both the fully upper and lowercased names of the components will be needed
string(TOLOWER ${COMPONENT_NAME} _component_name_lower)
string(TOUPPER ${COMPONENT_NAME} _component_name_upper)

# determine the package name suffix due to specific build conditions
if(${NAME_SUFFIX})
string(TOLOWER ${NAME_SUFFIX} _component_suffix)
else()
if(ENABLE_ASAN_PACKAGING)
set(_component_suffix asan)
elseif(NOT ${HEADER_ONLY} AND NOT ${BUILD_SHARED_LIBS})
set(_component_suffix static)
endif()
endif()
if(_component_suffix)
set(_component_suffix "-${_component_suffix}")
endif()

# determine the package name component
if(_component_name_lower STREQUAL "runtime")
set(_rpm_component_partial "")
set(_deb_component_partial "")
elseif(_component_name_lower STREQUAL "devel")
set(_rpm_component_partial "-devel")
set(_deb_component_partial "-dev")
else()
set(_rpm_component_partial "-${_component_name_lower}")
set(_deb_component_partial "-${_component_name_lower}")
endif()

# set the package names
if(NOT DEFINED CPACK_RPM_${_component_name_upper}_PACKAGE_NAME
OR CPACK_RPM_${_component_name_upper}_PACKAGE_NAME STREQUAL ""
)
set(CPACK_RPM_${_component_name_upper}_PACKAGE_NAME
"${BASE_NAME}${_rpm_component_partial}${_component_suffix}")
endif()
if(NOT DEFINED CPACK_DEBIAN_${_component_name_upper}_PACKAGE_NAME
OR CPACK_DEBIAN_${_component_name_upper}_PACKAGE_NAME STREQUAL ""
)
set(CPACK_DEBIAN_${_component_name_upper}_PACKAGE_NAME
"${BASE_NAME}${_deb_component_partial}${_component_suffix}")
endif()

# clean up temporary variables
unset(_deb_component_partial)
unset(_rpm_component_partial)
unset(_component_suffix)
unset(_component_name_upper)
unset(_component_name_lower)
endmacro(rocm_compute_component_package_name)

macro(rocm_set_comp_cpackvar HEADER_ONLY NAME_SUFFIX components)
# Setting component specific variables
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)

if(NOT ROCM_USE_DEV_COMPONENT OR NOT ${HEADER_ONLY})
set(CPACK_RPM_MAIN_COMPONENT "runtime")
rocm_compute_component_package_name("runtime" "${CPACK_PACKAGE_NAME}" "${NAME_SUFFIX}" ${HEADER_ONLY})
if (NOT ENABLE_ASAN_PACKAGING)
set(CPACK_RPM_RUNTIME_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
list(APPEND CPACK_COMPONENTS_ALL runtime)
set(CPACK_DEBIAN_RUNTIME_FILE_NAME
"${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}-${DEBIAN_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb")
set(CPACK_DEBIAN_RUNTIME_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
else()
set(CPACK_PACKAGE_NAME "${CPACK_PACKAGE_NAME}-asan")
set(CPACK_RPM_RUNTIME_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
set(CPACK_RPM_RUNTIME_FILE_NAME "RPM-DEFAULT")
set(CPACK_DEBIAN_RUNTIME_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
set(CPACK_DEBIAN_RUNTIME_FILE_NAME "DEB-DEFAULT")
endif()
if (NOT ${HEADER_ONLY} AND BUILD_SHARED_LIBS)
set(CPACK_RPM_MAIN_COMPONENT "runtime")
list(APPEND CPACK_COMPONENTS_ALL runtime)
endif()
endif()
Expand All @@ -512,26 +562,12 @@ macro(rocm_set_comp_cpackvar HEADER_ONLY components)
string(TOUPPER "${COMPONENT}" COMPONENT_UC)
set(CPACK_RPM_${COMPONENT_UC}_FILE_NAME "RPM-DEFAULT")
set(CPACK_DEBIAN_${COMPONENT_UC}_FILE_NAME "DEB-DEFAULT")
if(NOT DEFINED CPACK_DEBIAN_${COMPONENT_UC}_PACKAGE_NAME
OR CPACK_DEBIAN_${COMPONENT_UC}_PACKAGE_NAME STREQUAL "")
if(NOT DEFINED CPACK_DEBIAN_PACKAGE_NAME OR CPACK_DEBIAN_PACKAGE_NAME STREQUAL "")
set(CPACK_DEBIAN_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
endif()
string(TOLOWER "${CPACK_DEBIAN_PACKAGE_NAME}-${COMPONENT}" CPACK_DEBIAN_${COMPONENT_UC}_PACKAGE_NAME)
else()
string(REGEX REPLACE "<PACKAGE_NAME>" "${CPACK_PACKAGE_NAME}"
CPACK_DEBIAN_${COMPONENT_UC}_PACKAGE_NAME "${CPACK_DEBIAN_${COMPONENT_UC}_PACKAGE_NAME}")
endif()
if(NOT DEFINED CPACK_RPM_${COMPONENT_UC}_PACKAGE_NAME
OR CPACK_RPM_${COMPONENT_UC}_PACKAGE_NAME STREQUAL "")
if(NOT DEFINED CPACK_RPM_PACKAGE_NAME OR CPACK_RPM_PACKAGE_NAME STREQUAL "")
set(CPACK_RPM_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
endif()
string(TOLOWER "${CPACK_RPM_PACKAGE_NAME}-${COMPONENT}" CPACK_RPM_${COMPONENT_UC}_PACKAGE_NAME)
else()
string(REGEX REPLACE "<PACKAGE_NAME>" "${CPACK_PACKAGE_NAME}"
CPACK_RPM_${COMPONENT_UC}_PACKAGE_NAME "${CPACK_RPM_${COMPONENT_UC}_PACKAGE_NAME}")
endif()
rocm_compute_component_package_name("${COMPONENT}" "${CPACK_PACKAGE_NAME}" "${NAME_SUFFIX}" "${HEADER_ONLY}")

string(REGEX REPLACE "<PACKAGE_NAME>" "${CPACK_PACKAGE_NAME}"
CPACK_DEBIAN_${COMPONENT_UC}_PACKAGE_NAME "${CPACK_DEBIAN_${COMPONENT_UC}_PACKAGE_NAME}")
string(REGEX REPLACE "<PACKAGE_NAME>" "${CPACK_PACKAGE_NAME}"
CPACK_RPM_${COMPONENT_UC}_PACKAGE_NAME "${CPACK_RPM_${COMPONENT_UC}_PACKAGE_NAME}")
endforeach()
if(ROCM_PACKAGE_COMPONENT_DEPENDENCIES)
foreach(COMP_DEP IN LISTS ROCM_PACKAGE_COMPONENT_DEPENDENCIES)
Expand All @@ -555,21 +591,16 @@ macro(rocm_package_setup_component COMPONENT_NAME)

list(APPEND ROCM_PACKAGE_COMPONENTS ${COMPONENT_NAME})

if(NOT DEFINED PARSE_PACKAGE_NAME)
string(TOLOWER "${COMPONENT_NAME}" PARSE_PACKAGE_NAME)
if(NOT BUILD_SHARED_LIBS)
set(PARSE_PACKAGE_NAME "${PARSE_PACKAGE_NAME}-static")
if(DEFINED PARSE_PACKAGE_NAME)
if(NOT DEFINED PARSE_LIBRARY_NAME)
set(PARSE_LIBRARY_NAME "<PACKAGE_NAME>")
endif()
endif()

if(NOT DEFINED PARSE_LIBRARY_NAME)
set(PARSE_LIBRARY_NAME "<PACKAGE_NAME>")
endif()

string(TOUPPER "${COMPONENT_NAME}" COMPONENT_GNAME)
string(TOUPPER "${COMPONENT_NAME}" COMPONENT_GNAME)

set(CPACK_DEBIAN_${COMPONENT_GNAME}_PACKAGE_NAME "${PARSE_LIBRARY_NAME}-${PARSE_PACKAGE_NAME}")
set(CPACK_RPM_${COMPONENT_GNAME}_PACKAGE_NAME "${PARSE_LIBRARY_NAME}-${PARSE_PACKAGE_NAME}")
set(CPACK_DEBIAN_${COMPONENT_GNAME}_PACKAGE_NAME "${PARSE_LIBRARY_NAME}-${PARSE_PACKAGE_NAME}")
set(CPACK_RPM_${COMPONENT_GNAME}_PACKAGE_NAME "${PARSE_LIBRARY_NAME}-${PARSE_PACKAGE_NAME}")
endif()

if(DEFINED PARSE_PARENT)
list(APPEND ROCM_PACKAGE_COMPONENT_DEPENDENCIES "${PARSE_PARENT}->${COMPONENT_NAME}")
Expand Down
62 changes: 48 additions & 14 deletions share/rocmcmakebuildtools/cmake/ROCMInstallTargets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ endfunction()
option(ROCM_SYMLINK_LIBS "Create backwards compatibility symlink for library files." ON)

function(rocm_install_targets)
set(options)
set(options PRIVATE)
set(oneValueArgs PREFIX EXPORT COMPONENT)
set(multiValueArgs TARGETS INCLUDE)

Expand All @@ -133,17 +133,35 @@ function(rocm_install_targets)

if(PARSE_PREFIX)
set(PREFIX_DIR ${PARSE_PREFIX})
set(BIN_INSTALL_DIR ${PARSE_PREFIX}/${CMAKE_INSTALL_BINDIR})
set(LIB_INSTALL_DIR ${PARSE_PREFIX}/${ROCM_INSTALL_LIBDIR})
set(INCLUDE_INSTALL_DIR ${PARSE_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR})
if(PARSE_PRIVATE)
set(BIN_INSTALL_DIR ${PARSE_PREFIX}/${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME})
set(LIB_INSTALL_DIR ${PARSE_PREFIX}/${ROCM_INSTALL_LIBDIR}/${PROJECT_NAME}/lib)
set(INCLUDE_INSTALL_DIR ${PARSE_PREFIX}/${ROCM_INSTALL_LIBDIR}/${PROJECT_NAME}/include)
else()
set(BIN_INSTALL_DIR ${PARSE_PREFIX}/${CMAKE_INSTALL_BINDIR})
set(LIB_INSTALL_DIR ${PARSE_PREFIX}/${ROCM_INSTALL_LIBDIR})
set(INCLUDE_INSTALL_DIR ${PARSE_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR})
endif()
elseif(ENABLE_ASAN_PACKAGING)
set(BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR})
set(LIB_INSTALL_DIR ${ROCM_INSTALL_LIBDIR}/asan)
set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR})
if(PARSE_PRIVATE)
set(BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR}/asan/${PROJECT_NAME})
set(LIB_INSTALL_DIR ${ROCM_INSTALL_LIBDIR}/asan/${PROJECT_NAME}/lib)
set(INCLUDE_INSTALL_DIR ${ROCM_INSTALL_LIBDIR}/asan/${PROJECT_NAME}/include)
else()
set(BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR}/asan)
set(LIB_INSTALL_DIR ${ROCM_INSTALL_LIBDIR}/asan)
set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR})
endif()
else()
set(BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR})
set(LIB_INSTALL_DIR ${ROCM_INSTALL_LIBDIR})
set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR})
if(PARSE_PRIVATE)
set(BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME})
set(LIB_INSTALL_DIR ${ROCM_INSTALL_LIBDIR}/${PROJECT_NAME}/lib)
set(INCLUDE_INSTALL_DIR ${ROCM_INSTALL_LIBDIR}/${PROJECT_NAME}/include)
else()
set(BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR})
set(LIB_INSTALL_DIR ${ROCM_INSTALL_LIBDIR})
set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR})
endif()
endif()

foreach(TARGET ${PARSE_TARGETS})
Expand Down Expand Up @@ -182,12 +200,25 @@ function(rocm_install_targets)

foreach(TARGET IN LISTS PARSE_TARGETS)
get_target_property(T_TYPE ${TARGET} TYPE)
if(NOT PARSE_PRIVATE AND NOT T_TYPE STREQUAL "INTERFACE_LIBRARY")
# TODO: Create a function to set INSTALL_RPATH
if(POLICY CMP0095)
set_property(TARGET ${TARGET} APPEND PROPERTY INSTALL_RPATH "${ORIGIN}/${PROJECT_NAME}/lib")
else()
set_property(TARGET ${TARGET} APPEND PROPERTY INSTALL_RPATH "\\\${ORIGIN}/${PROJECT_NAME}/lib")
endif()
endif()
set(export_arg EXPORT ${EXPORT_FILE})
if(T_TYPE STREQUAL "EXECUTABLE")
unset(export_arg)
if(ENABLE_ASAN_PACKAGING)
continue()
if(PARSE_PRIVATE)
if(POLICY CMP0095)
set_property(TARGET ${TARGET} APPEND PROPERTY INSTALL_RPATH "${ORIGIN}/../lib/${PROJECT_NAME}/lib")
else()
set_property(TARGET ${TARGET} APPEND PROPERTY
INSTALL_RPATH "\\\${ORIGIN}/../lib/${PROJECT_NAME}/lib")
endif()
endif()
unset(export_arg)
endif()
install(
TARGETS ${TARGET}
Expand Down Expand Up @@ -219,7 +250,10 @@ function(rocm_install_targets)
NAMELINK_ONLY
)
endif()
if(ROCM_SYMLINK_LIBS AND NOT WIN32 AND T_TYPE MATCHES ".*_LIBRARY"
if(ROCM_SYMLINK_LIBS AND PARSE_PRIVATE)
message(WARNING "ROCM_SYMLINK_LIBS is not supported with PRIVATE.")
endif()
if(ROCM_SYMLINK_LIBS AND NOT PARSE_PRIVATE AND NOT WIN32 AND T_TYPE MATCHES ".*_LIBRARY"
AND NOT T_TYPE STREQUAL "INTERFACE_LIBRARY")
string(TOLOWER "${PROJECT_NAME}" LINK_SUBDIR)
file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_symlink.cmake
Expand Down
Loading

0 comments on commit 235ee6d

Please sign in to comment.