diff --git a/ament_cmake_core/cmake/symlink_install/ament_cmake_symlink_install.cmake.in b/ament_cmake_core/cmake/symlink_install/ament_cmake_symlink_install.cmake.in index 510f190c..e18c49fe 100644 --- a/ament_cmake_core/cmake/symlink_install/ament_cmake_symlink_install.cmake.in +++ b/ament_cmake_core/cmake/symlink_install/ament_cmake_symlink_install.cmake.in @@ -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}") @@ -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}") + 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() diff --git a/ament_cmake_core/cmake/symlink_install/ament_cmake_symlink_install_targets.cmake b/ament_cmake_core/cmake/symlink_install/ament_cmake_symlink_install_targets.cmake index ec186290..2305f472 100644 --- a/ament_cmake_core/cmake/symlink_install/ament_cmake_symlink_install_targets.cmake +++ b/ament_cmake_core/cmake/symlink_install/ament_cmake_symlink_install_targets.cmake @@ -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 - # $ - get_property(location TARGET ${target} PROPERTY LOCATION) - list(APPEND target_files "${location}") + message("target: $") + list(APPEND target_files "$") endforeach() string(REPLACE ";" "\" \"" target_files_quoted