From 133820ef4d48180e3f5ade215a613185f3c633da Mon Sep 17 00:00:00 2001 From: Cory Bloor Date: Mon, 12 Feb 2024 13:13:22 -0700 Subject: [PATCH 1/6] Update version number and changelog for ROCm 6.1 (#169) --- CHANGELOG.md | 14 ++++++++++++++ CMakeLists.txt | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bda5f369..bbf7ee87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Change Log for rocm-cmake +## [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. diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ac51890..f53cb17a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 From f0d3cd7ce6a70f7d4cd0ccc5f48ad49c3911cff1 Mon Sep 17 00:00:00 2001 From: Joseph Macaranas <145489236+amd-jmacaran@users.noreply.github.com> Date: Thu, 2 May 2024 15:04:34 -0400 Subject: [PATCH 2/6] Add support for external CI builds using Azure Pipelines (#186) * Add support for external CI builds using Azure Pipelines * Change token name to match IT-created token --- .azuredevops/rocm-ci.yml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .azuredevops/rocm-ci.yml diff --git a/.azuredevops/rocm-ci.yml b/.azuredevops/rocm-ci.yml new file mode 100644 index 00000000..096c97c3 --- /dev/null +++ b/.azuredevops/rocm-ci.yml @@ -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 From 094c18c7d23546eee684564df10fa0088af4a69c Mon Sep 17 00:00:00 2001 From: Lauren Wrubleski Date: Fri, 10 May 2024 11:36:53 -0600 Subject: [PATCH 3/6] Packaging for static components (#182) * Initial changes for static packaging * Changelog update * Correct tests for new behaviour * Add missing parameter * Remove devel dependency on runtime for static builds --- CHANGELOG.md | 5 + .../cmake/ROCMCreatePackage.cmake | 125 +++++++++++------- test/pass/rocm-package-setup-component.cmake | 13 +- test/test.cmake | 6 + 4 files changed, 97 insertions(+), 52 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bbf7ee87..87354422 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # 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__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 diff --git a/share/rocmcmakebuildtools/cmake/ROCMCreatePackage.cmake b/share/rocmcmakebuildtools/cmake/ROCMCreatePackage.cmake index 746982d0..c55968d2 100755 --- a/share/rocmcmakebuildtools/cmake/ROCMCreatePackage.cmake +++ b/share/rocmcmakebuildtools/cmake/ROCMCreatePackage.cmake @@ -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}) @@ -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) rocm_join_if_set(", " CPACK_DEBIAN_DEVEL_PACKAGE_PROVIDES CPACK_DEBIAN_PACKAGE_PROVIDES @@ -411,7 +411,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.") @@ -449,7 +449,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} @@ -464,24 +464,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() @@ -497,26 +547,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 "" "${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 "" "${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 "" "${CPACK_PACKAGE_NAME}" + CPACK_DEBIAN_${COMPONENT_UC}_PACKAGE_NAME "${CPACK_DEBIAN_${COMPONENT_UC}_PACKAGE_NAME}") + string(REGEX REPLACE "" "${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) @@ -540,21 +576,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 "") endif() - endif() - if(NOT DEFINED PARSE_LIBRARY_NAME) - set(PARSE_LIBRARY_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}") diff --git a/test/pass/rocm-package-setup-component.cmake b/test/pass/rocm-package-setup-component.cmake index 546e5810..b8ed8cd8 100644 --- a/test/pass/rocm-package-setup-component.cmake +++ b/test/pass/rocm-package-setup-component.cmake @@ -1,3 +1,5 @@ +cmake_minimum_required(VERSION 3.10) + use_rocm_cmake() include(ROCMCreatePackage) include(ROCMClients) @@ -8,8 +10,8 @@ set(BUILD_SHARED_LIBS ON) rocm_package_setup_component(comp-a) test_expect_eq("${ROCM_PACKAGE_COMPONENTS}" "comp-a") -test_expect_eq("${CPACK_DEBIAN_COMP-A_PACKAGE_NAME}" "-comp-a") -test_expect_eq("${CPACK_RPM_COMP-A_PACKAGE_NAME}" "-comp-a") +test_expect_undef(CPACK_DEBIAN_COMP-A_PACKAGE_NAME) +test_expect_undef(CPACK_RPM_COMP-A_PACKAGE_NAME) rocm_package_setup_component( comp-b @@ -30,6 +32,7 @@ rocm_package_setup_component( RPM "baz = 3.0" COMPONENT comp-a comp-b LIBRARY_NAME packaging + PACKAGE_NAME comp-c ) test_expect_eq("${ROCM_PACKAGE_COMPONENTS}" "comp-a;comp-b;comp-c") @@ -44,8 +47,8 @@ rocm_package_setup_client_component( DEPENDS COMPONENT comp-c ) test_expect_eq("${ROCM_PACKAGE_COMPONENTS}" "comp-a;comp-b;comp-c;client-a") -test_expect_eq("${CPACK_DEBIAN_CLIENT-A_PACKAGE_NAME}" "-client-a") -test_expect_eq("${CPACK_RPM_CLIENT-A_PACKAGE_NAME}" "-client-a") +test_expect_undef(CPACK_DEBIAN_CLIENT-A_PACKAGE_NAME) +test_expect_undef(CPACK_RPM_CLIENT-A_PACKAGE_NAME) test_expect_eq("${CPACK_DEBIAN_CLIENT-A_PACKAGE_DEPENDS}" "") test_expect_eq("${CPACK_RPM_CLIENT-A_PACKAGE_REQUIRES}" "") test_expect_eq("${ROCM_PACKAGE_COMPONENT_DEPENDENCIES}" @@ -54,7 +57,7 @@ test_expect_eq("${ROCM_PACKAGE_COMPONENT_DEPENDENCIES}" set(CPACK_PACKAGE_NAME "packtest") set(CPACK_PACKAGE_VERSION 1.0.0) -rocm_set_comp_cpackvar(FALSE "${ROCM_PACKAGE_COMPONENTS};clients") +rocm_set_comp_cpackvar(FALSE "" "${ROCM_PACKAGE_COMPONENTS};clients") test_expect_eq("${CPACK_COMPONENTS_ALL}" "runtime;comp-a;comp-b;comp-c;client-a;clients") test_expect_eq("${CPACK_DEBIAN_RUNTIME_PACKAGE_NAME}" "packtest") diff --git a/test/test.cmake b/test/test.cmake index 42430d26..3200c0c9 100755 --- a/test/test.cmake +++ b/test/test.cmake @@ -49,6 +49,12 @@ macro(test_expect_eq X Y) endif() endmacro() +macro(test_expect_undef X) + if(DEFINED "${X}") + message(FATAL_ERROR "EXPECT FAILURE: ${X} IS DEFINED ${ARGN}") + endif() +endmacro() + macro(test_expect_matches X Y) if("${X}" STREQUAL "" OR NOT "${X}" MATCHES "${Y}") message(FATAL_ERROR "EXPECT FAILURE: ${X} NOT MATCHES ${Y} ${ARGN}") From 4d1eafba806d8c3059479b57f868d6f2fc801bcd Mon Sep 17 00:00:00 2001 From: Lauren Wrubleski Date: Fri, 10 May 2024 11:37:17 -0600 Subject: [PATCH 4/6] install executables to bin/asan for ASAN builds (#178) --- share/rocmcmakebuildtools/cmake/ROCMInstallTargets.cmake | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/share/rocmcmakebuildtools/cmake/ROCMInstallTargets.cmake b/share/rocmcmakebuildtools/cmake/ROCMInstallTargets.cmake index f21fc223..463c482c 100644 --- a/share/rocmcmakebuildtools/cmake/ROCMInstallTargets.cmake +++ b/share/rocmcmakebuildtools/cmake/ROCMInstallTargets.cmake @@ -137,7 +137,7 @@ function(rocm_install_targets) set(LIB_INSTALL_DIR ${PARSE_PREFIX}/${ROCM_INSTALL_LIBDIR}) set(INCLUDE_INSTALL_DIR ${PARSE_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}) elseif(ENABLE_ASAN_PACKAGING) - set(BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR}) + set(BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR}/asan) set(LIB_INSTALL_DIR ${ROCM_INSTALL_LIBDIR}/asan) set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}) else() @@ -185,9 +185,6 @@ function(rocm_install_targets) set(export_arg EXPORT ${EXPORT_FILE}) if(T_TYPE STREQUAL "EXECUTABLE") unset(export_arg) - if(ENABLE_ASAN_PACKAGING) - continue() - endif() endif() install( TARGETS ${TARGET} From f63ec229adca51a5d07fda47d53bafc1154f9aab Mon Sep 17 00:00:00 2001 From: Paul Fultz II Date: Tue, 21 May 2024 17:01:08 -0500 Subject: [PATCH 5/6] Pin doxygen version (#192) --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6a4787ab..43890cec 100755 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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" From a83c5075d85f1fd28d657a9277eb21c834d76f3f Mon Sep 17 00:00:00 2001 From: Ahsan Saghir <142340507+ahsan-ca@users.noreply.github.com> Date: Wed, 22 May 2024 08:53:19 -0400 Subject: [PATCH 6/6] Add flag to move libraries under project name (#188) Co-authored-by: Paul Fultz II --- .../cmake/ROCMInstallTargets.cmake | 59 +++++++++++++++---- test/libprivate/CMakeLists.txt | 51 ++++++++++++++++ test/libprivate/LICENSE | 3 + test/libprivate/importtarget.cmake | 3 + test/libprivate/include/simpleprivate.h | 12 ++++ test/libprivate/main.cpp | 6 ++ test/libprivate/simpleprivate.cpp | 7 +++ test/pass/libprivate.cmake | 11 ++++ 8 files changed, 141 insertions(+), 11 deletions(-) create mode 100644 test/libprivate/CMakeLists.txt create mode 100644 test/libprivate/LICENSE create mode 100644 test/libprivate/importtarget.cmake create mode 100644 test/libprivate/include/simpleprivate.h create mode 100644 test/libprivate/main.cpp create mode 100644 test/libprivate/simpleprivate.cpp create mode 100644 test/pass/libprivate.cmake diff --git a/share/rocmcmakebuildtools/cmake/ROCMInstallTargets.cmake b/share/rocmcmakebuildtools/cmake/ROCMInstallTargets.cmake index 463c482c..2d406866 100644 --- a/share/rocmcmakebuildtools/cmake/ROCMInstallTargets.cmake +++ b/share/rocmcmakebuildtools/cmake/ROCMInstallTargets.cmake @@ -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) @@ -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}/asan) - 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}) @@ -182,8 +200,24 @@ 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") + 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( @@ -216,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 diff --git a/test/libprivate/CMakeLists.txt b/test/libprivate/CMakeLists.txt new file mode 100644 index 00000000..42d68594 --- /dev/null +++ b/test/libprivate/CMakeLists.txt @@ -0,0 +1,51 @@ +################################################################################ +# Copyright (C) 2024 Advanced Micro Devices, Inc. +################################################################################ + + +cmake_minimum_required (VERSION 3.5) +project(libprivate CXX) + +find_package(ROCmCMakeBuildTools) + +include(ROCMInstallTargets) +include(ROCMPackageConfigHelpers) +include(ROCMSetupVersion) +include(ROCMInstallSymlinks) +include(ROCMCreatePackage) + +rocm_setup_version(VERSION 1.0.0) + +if(ROCM_PREFIX) +rocm_create_package( + NAME simple-private + PREFIX ${ROCM_PREFIX} + MAINTAINER "Amd amd@amd.com" + PTH + LDCONFIG) +else() +rocm_create_package( + NAME simple-private + MAINTAINER "Amd amd@amd.com" + PTH + LDCONFIG) +endif() + +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) + +add_library(simple_private simpleprivate.cpp) +#rocm_set_soversion(simple-private 1.1.2) + +add_executable(simple_private_main main.cpp) +target_link_libraries(simple_private_main simple_private) + +if(ROCM_PREFIX) + rocm_install_targets(PRIVATE TARGETS simple_private simple_private_main INCLUDE include PREFIX ${ROCM_PREFIX}) + rocm_export_targets(TARGETS simple_private INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/importtarget.cmake PREFIX ${ROCM_PREFIX}) + rocm_install_symlink_subdir(${ROCM_PREFIX}) +else() + rocm_install_targets(PRIVATE TARGETS simple_private simple_private_main INCLUDE include) + rocm_export_targets(TARGETS simple_private INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/importtarget.cmake) +endif() diff --git a/test/libprivate/LICENSE b/test/libprivate/LICENSE new file mode 100644 index 00000000..6d0ea731 --- /dev/null +++ b/test/libprivate/LICENSE @@ -0,0 +1,3 @@ +This is a placeholder license file for the purposes of testing, and is not the license for this repository or the files +contained in this directory. The license for rocm-cmake (including all files in this directory) can be located at +"https://github.com/RadeonOpenCompute/rocm-cmake/blob/master/LICENSE". \ No newline at end of file diff --git a/test/libprivate/importtarget.cmake b/test/libprivate/importtarget.cmake new file mode 100644 index 00000000..76a90f8b --- /dev/null +++ b/test/libprivate/importtarget.cmake @@ -0,0 +1,3 @@ +# ###################################################################################################################### +# Copyright (C) 2024 Advanced Micro Devices, Inc. +# ###################################################################################################################### diff --git a/test/libprivate/include/simpleprivate.h b/test/libprivate/include/simpleprivate.h new file mode 100644 index 00000000..520359d5 --- /dev/null +++ b/test/libprivate/include/simpleprivate.h @@ -0,0 +1,12 @@ +/******************************************************************************* + * Copyright (C) 2024 Advanced Micro Devices, Inc. + ******************************************************************************/ + + +#ifndef GUARD_SIMPLE_PRIVATE_H +#define GUARD_SIMPLE_PRIVATE_H + +void simple_private(); + + +#endif diff --git a/test/libprivate/main.cpp b/test/libprivate/main.cpp new file mode 100644 index 00000000..f8b9e7d7 --- /dev/null +++ b/test/libprivate/main.cpp @@ -0,0 +1,6 @@ + +void simple_private(); + +int main() { + simple_private(); +} diff --git a/test/libprivate/simpleprivate.cpp b/test/libprivate/simpleprivate.cpp new file mode 100644 index 00000000..33f0f31e --- /dev/null +++ b/test/libprivate/simpleprivate.cpp @@ -0,0 +1,7 @@ +/******************************************************************************* + * Copyright (C) 2024 Advanced Micro Devices, Inc. + ******************************************************************************/ + + +void simple_private() +{} diff --git a/test/pass/libprivate.cmake b/test/pass/libprivate.cmake new file mode 100644 index 00000000..e2992175 --- /dev/null +++ b/test/pass/libprivate.cmake @@ -0,0 +1,11 @@ +# ###################################################################################################################### +# Copyright (C) 2024 Advanced Micro Devices, Inc. +# ###################################################################################################################### + +install_dir( + ${TEST_DIR}/libprivate + CMAKE_ARGS -DROCM_SYMLINK_LIBS=OFF -DROCM_PREFIX=rocm + TARGETS package) +test_expect_file(${PREFIX}/lib/libprivate/include/simpleprivate.h) +test_expect_file(${PREFIX}/lib/libprivate/lib/libsimple_private.a) +install_dir(${TEST_DIR}/libprivate)