Skip to content

Commit

Permalink
Create symlinks to specific files instead of directory (#93)
Browse files Browse the repository at this point in the history
* Create symlinks to specific files instead of dir

* correct CMake foreach syntax

* Ensure link location exists

* rearrange to create links more directly

* only create link if file doesn't already exist

* Correct CMake file symlinks

* Tidy formatting

Change-Id: Idc9ea15bad45f15567b56c4737f83c1b9aa5016a
  • Loading branch information
lawruble13 authored and amd-aakash committed May 20, 2022
1 parent a52cb6f commit 5022bb7
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions share/rocm/cmake/ROCMInstallTargets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,12 @@ function(rocm_install_targets)
file(RELATIVE_PATH LINK_PATH
\${LINK_DIR}/${ROCM_INSTALL_LIBDIR}
\${SRC_DIR}/${ROCM_INSTALL_LIBDIR})
execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink
\${LINK_PATH}/$<TARGET_LINKER_FILE_NAME:${TARGET}>
\${LINK_DIR}/${ROCM_INSTALL_LIBDIR}/$<TARGET_LINKER_FILE_NAME:${TARGET}>
)
if(NOT EXISTS \${LINK_DIR}/${ROCM_INSTALL_LIBDIR}/$<TARGET_LINKER_FILE_NAME:${TARGET}>)
execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink
\${LINK_PATH}/$<TARGET_LINKER_FILE_NAME:${TARGET}>
\${LINK_DIR}/${ROCM_INSTALL_LIBDIR}/$<TARGET_LINKER_FILE_NAME:${TARGET}>
)
endif()
")

rocm_install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_symlink.cmake")
Expand Down Expand Up @@ -329,21 +331,28 @@ function(rocm_export_targets)

if(ROCM_SYMLINK_LIBS AND NOT WIN32)
string(TOLOWER "${PROJECT_NAME}" LINK_SUBDIR)

file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/cmake_symlink.cmake"
CONTENT "
set(SRC_DIR \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX})
set(LINK_DIR \${SRC_DIR}/${LINK_SUBDIR})
if(NOT EXISTS \${LINK_DIR}/${ROCM_INSTALL_LIBDIR}/cmake)
file(MAKE_DIRECTORY \${LINK_DIR}/${ROCM_INSTALL_LIBDIR}/cmake)
set(SRC_DIR \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CONFIG_PACKAGE_INSTALL_DIR})
set(LINK_DIR \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${LINK_SUBDIR}/${ROCM_INSTALL_LIBDIR}/cmake)
if(NOT EXISTS \${LINK_DIR})
file(MAKE_DIRECTORY \${LINK_DIR})
endif()
file(RELATIVE_PATH LINK_PATH
\${LINK_DIR}/${ROCM_INSTALL_LIBDIR}/cmake
\${SRC_DIR}/${CONFIG_PACKAGE_INSTALL_DIR}
)
execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink
\${LINK_PATH}
\${LINK_DIR}/${CONFIG_PACKAGE_INSTALL_DIR}
file(GLOB TARGET_FILES
LIST_DIRECTORIES false
RELATIVE \${SRC_DIR}
\${SRC_DIR}/${TARGET_FILE}*.cmake
)
foreach(filename ${CONFIG_NAME}.cmake ${CONFIG_NAME}-version.cmake \${TARGET_FILES})
file(RELATIVE_PATH LINK_PATH \${LINK_DIR} \${SRC_DIR}/\${filename})
if(NOT EXISTS \${LINK_DIR}/\${filename})
execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink
\${LINK_PATH}
\${LINK_DIR}/\${filename}
)
endif()
endforeach()
")
rocm_install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/cmake_symlink.cmake")
endif()
Expand Down

0 comments on commit 5022bb7

Please sign in to comment.