Skip to content

Commit 92c0417

Browse files
committed
Make achives have relative directories
1 parent 3672a39 commit 92c0417

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

share/rocmcmakebuildtools/cmake/ROCMCreatePackage.cmake

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,13 +289,6 @@ macro(rocm_create_package)
289289
if(${CPACK_SET_DESTDIR})
290290
set(CPACK_PACKAGING_INSTALL_PREFIX "")
291291
endif()
292-
else()
293-
# On Windows, CPACK_SET_DESTDIR is not supported, but we need to set
294-
# CPACK_PACKAGING_INSTALL_PREFIX to ensure consistent archive structure
295-
# between platforms for TGZ/ZIP generators.
296-
if(NOT DEFINED CPACK_PACKAGING_INSTALL_PREFIX)
297-
set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
298-
endif()
299292
endif()
300293

301294
rocm_get_patch_version(ROCM_VERSION_NUM)
@@ -439,6 +432,18 @@ macro(rocm_create_package)
439432
# Lintian Warning Fix: Enable post/pre scripts only if non empty
440433
rocm_check_and_configure_script_files("${PROJECT_BINARY_DIR}/debian/prerm" "${PROJECT_BINARY_DIR}/debian/postinst")
441434

435+
# Create a CPack project config file for generator-specific settings
436+
set(_cpack_project_config "${PROJECT_BINARY_DIR}/CPackProjectConfig.cmake")
437+
file(WRITE "${_cpack_project_config}" "
438+
# Generator-specific configuration for consistent archive paths
439+
if(CPACK_GENERATOR MATCHES \"TGZ|ZIP\")
440+
# Use relative paths for archive generators (consistent across platforms)
441+
set(CPACK_SET_DESTDIR OFF)
442+
set(CPACK_PACKAGING_INSTALL_PREFIX \"/\")
443+
endif()
444+
")
445+
set(CPACK_PROJECT_CONFIG_FILE "${_cpack_project_config}")
446+
442447
include(CPack)
443448
set(ROCM_PACKAGE_CREATED TRUE CACHE INTERNAL "Track whether rocm_create_package has been called.")
444449
endmacro()

test/pass/simple-test-package.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ file(GLOB TEST_PACKAGE ${BUILD_DIR}/*-tests.tar.gz)
77
list(LENGTH TEST_PACKAGE NTEST_PACKAGE)
88
test_expect_eq(${NTEST_PACKAGE} 1)
99
test_exec(COMMAND ${CMAKE_COMMAND} -E tar t ${TEST_PACKAGE})
10-
test_exec(COMMAND ${CMAKE_COMMAND} -E tar x ${TEST_PACKAGE} WORKING_DIRECTORY /)
10+
test_exec(COMMAND ${CMAKE_COMMAND} -E tar x ${TEST_PACKAGE} WORKING_DIRECTORY ${PREFIX})
1111
test_expect_file(${PREFIX}/libexec/installed-tests/simple/CTestTestfile.cmake)

0 commit comments

Comments
 (0)