Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port symlink_install fixes from ament_cmake to catkin #1199

Open
wants to merge 1 commit into
base: noetic-devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion cmake/symlink_install/catkin_symlink_install.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ function(catkin_symlink_install_targets)
"unused/unsupported arguments: ${ARG_UNPARSED_ARGUMENTS}")
endif()

list(REVERSE ARG_TARGET_FILES)
list(REMOVE_DUPLICATES ARG_TARGET_FILES)
list(REVERSE ARG_TARGET_FILES)

# iterate over target files
foreach(file ${ARG_TARGET_FILES})
if(NOT IS_ABSOLUTE "${file}")
Expand All @@ -239,7 +243,7 @@ function(catkin_symlink_install_targets)
get_filename_component(fileext "${file}" EXT)
if(fileext STREQUAL ".a" OR fileext STREQUAL ".lib")
set(destination "${ARG_ARCHIVE_DESTINATION}")
elseif(fileext STREQUAL ".dylib" OR fileext MATCHES "\\.so(\\.[0-9]+)?(\\.[0-9]+)?(\\.[0-9]+)?$")
elseif(fileext MATCHES "(\\.[0-9]+)?(\\.[0-9]+)?(\\.[0-9]+)?\\.dylib$" OR fileext MATCHES "\\.so(\\.[0-9]+)?(\\.[0-9]+)?(\\.[0-9]+)?$")
set(destination "${ARG_LIBRARY_DESTINATION}")
elseif(fileext STREQUAL "" OR fileext STREQUAL ".dll" OR fileext STREQUAL ".exe")
set(destination "${ARG_RUNTIME_DESTINATION}")
Expand Down
19 changes: 18 additions & 1 deletion cmake/symlink_install/catkin_symlink_install_files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set(__CATKIN_SYMLINK_INSTALL_FILES_INDEX "0"
CACHE INTERNAL "Index for unique symlink install files")

#
# Reimplement CMake install(FILES) command to use symlinks instead of copying
# resources.
Expand Down Expand Up @@ -42,8 +45,22 @@ function(catkin_symlink_install_files files_keyword)

if(index EQUAL -1)
string(REPLACE ";" "\" \"" argn_quoted "\"${ARGN}\"")

# generate unique files
set(generated_file_base
"${CMAKE_CURRENT_BINARY_DIR}/catkin_symlink_install_files_${__CATKIN_SYMLINK_INSTALL_FILES_INDEX}")
set(generated_file_generator_suffix "${generated_file_base}_$<CONFIG>.cmake")
set(generated_file_variable_suffix "${generated_file_base}_\${CMAKE_INSTALL_CONFIG_NAME}.cmake")
math(EXPR __CATKIN_SYMLINK_INSTALL_FILES_INDEX
"${__CATKIN_SYMLINK_INSTALL_FILES_INDEX} + 1")
set(__CATKIN_SYMLINK_INSTALL_FILES_INDEX "${__CATKIN_SYMLINK_INSTALL_FILES_INDEX}"
CACHE INTERNAL "Index for unique symlink install files")

file(GENERATE OUTPUT "${generated_file_generator_suffix}"
CONTENT
"catkin_symlink_install_files(CURRENT_SOURCE_DIR \"${CMAKE_CURRENT_SOURCE_DIR}\" FILES ${argn_quoted})\n")
catkin_symlink_install_append_install_code(
"catkin_symlink_install_files(CURRENT_SOURCE_DIR \"${CMAKE_CURRENT_SOURCE_DIR}\" FILES ${argn_quoted})"
"include(\"${generated_file_variable_suffix}\")"
COMMENTS "install(FILES ${argn_quoted})"
)
endif()
Expand Down
9 changes: 5 additions & 4 deletions cmake/symlink_install/catkin_symlink_install_targets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,12 @@ function(catkin_symlink_install_targets)
"'${target}' is an imported target")
endif()
list(APPEND target_files "$<TARGET_FILE:${target}>")
if(WIN32)
get_target_property(target_type "${target}" TYPE)
if("${target_type}" STREQUAL "SHARED_LIBRARY")
list(APPEND target_files "$<TARGET_LINKER_FILE:${target}>")
get_target_property(target_type "${target}" TYPE)
if("${target_type}" STREQUAL "SHARED_LIBRARY")
if(NOT WIN32)
list(APPEND target_files "$<TARGET_SONAME_FILE:${target}>")
endif()
list(APPEND target_files "$<TARGET_LINKER_FILE:${target}>")
endif()
endforeach()

Expand Down