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

add support for symlinked install on windows #6

Open
wants to merge 3 commits into
base: rolling
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
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ endfunction()

function(_ament_cmake_symlink_create_symlink absolute_file symlink)
# avoid any work if correct symlink is already in place
if(EXISTS "${symlink}" AND IS_SYMLINK "${symlink}")
if(WIN32 AND EXISTS "${symlink}" AND IS_SYMLINK "${symlink}")
get_filename_component(destination "${symlink}" REALPATH)
if("${destination} " STREQUAL "${absolute_file} ")
message(STATUS "Up-to-date symlink: ${symlink}")
Expand All @@ -268,16 +268,31 @@ function(_ament_cmake_symlink_create_symlink absolute_file symlink)
file(REMOVE "${symlink}")
endif()

execute_process(
COMMAND "@CMAKE_COMMAND@" "-E" "create_symlink"
"${absolute_file}"
"${symlink}"
)
# the CMake command does not provide a return code so check manually
if(NOT EXISTS "${symlink}" OR NOT IS_SYMLINK "${symlink}")
get_filename_component(destination "${symlink}" REALPATH)
message(FATAL_ERROR
"Could not create symlink '${symlink}' pointing to '${absolute_file}'")
if(NOT WIN32)
execute_process(
COMMAND "@CMAKE_COMMAND@" "-E" "create_symlink"
"${absolute_file}"
"${symlink}"
)
# the CMake command does not provide a return code so check manually
if(NOT EXISTS "${symlink}" OR NOT IS_SYMLINK "${symlink}")
get_filename_component(destination "${symlink}" REALPATH)
message(FATAL_ERROR
"Could not create symlink '${symlink}' pointing to '${absolute_file}'")
endif()
else()
string(REPLACE "/" "\\" symlink "${symlink}")
string(REPLACE "/" "\\" absolute_file "${absolute_file}")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use file(TO_NATIVE_PATH for these kind of conversions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right, but those lines may not end up being needed. This pull request isn't really ready for review since it isn't working yet.

execute_process(
COMMAND "cmd" "/C" "mklink"
"${symlink}"
"${absolute_file}"
RESULT_VARIABLE ret
)
if(NOT ret EQUAL 0)
message(FATAL_ERROR
"Could not create symlink '${symlink}' pointing to '${absolute_file}': ${ret}")
endif()
endif()
endfunction()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,8 @@ function(ament_cmake_symlink_install_targets)
message(FATAL_ERROR "ament_cmake_symlink_install_targets() "
"'${target}' is an imported target")
endif()
# TODO consider using a generator expression instead
# $<TARGET_FILE:target>
get_property(location TARGET ${target} PROPERTY LOCATION)
list(APPEND target_files "${location}")
message("target: $<TARGET_FILE:${target}>")
list(APPEND target_files "$<TARGET_FILE:${target}>")
endforeach()

string(REPLACE ";" "\" \"" target_files_quoted
Expand Down