From 3f22de31caecb1fb4eacc7fa02500e568de8c0e3 Mon Sep 17 00:00:00 2001 From: Dirk Thomas Date: Fri, 20 Mar 2015 17:10:34 -0700 Subject: [PATCH 1/3] add support for symlinked install on windows --- .../ament_cmake_symlink_install.cmake.in | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) 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..afbd3e71 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 @@ -268,11 +268,19 @@ function(_ament_cmake_symlink_create_symlink absolute_file symlink) file(REMOVE "${symlink}") endif() - execute_process( - COMMAND "@CMAKE_COMMAND@" "-E" "create_symlink" - "${absolute_file}" - "${symlink}" - ) + if(NOT WIN32) + execute_process( + COMMAND "@CMAKE_COMMAND@" "-E" "create_symlink" + "${absolute_file}" + "${symlink}" + ) + else() + execute_process( + COMMAND "mklink" + "${symlink}" + "${absolute_file}" + ) + endif() # 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) From 5b0ee58f19f94651211e56eaa3218b38b45d5509 Mon Sep 17 00:00:00 2001 From: William Woodall Date: Fri, 27 Mar 2015 13:54:23 -0700 Subject: [PATCH 2/3] fixup symlink on Windows The IS_SYMLINK check in CMake doesn't appear to work on Windows, so I've disable the shortcut check on Windows. Also, I've changed the error checking on Windows and changed the way mklink is executed, instead executing it with cmd /C. --- .../ament_cmake_symlink_install.cmake.in | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) 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 afbd3e71..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}") @@ -274,18 +274,25 @@ function(_ament_cmake_symlink_create_symlink absolute_file 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 "mklink" + COMMAND "cmd" "/C" "mklink" "${symlink}" "${absolute_file}" + RESULT_VARIABLE ret ) - endif() - # 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 ret EQUAL 0) + message(FATAL_ERROR + "Could not create symlink '${symlink}' pointing to '${absolute_file}': ${ret}") + endif() endif() endfunction() From 122367b811911ec4799002edb52ed9d1bbb3ae5d Mon Sep 17 00:00:00 2001 From: William Woodall Date: Fri, 27 Mar 2015 14:09:48 -0700 Subject: [PATCH 3/3] [wip] use generator expressions with linking This still doesn't work because the generator expressions are not expanded in time to be used by execute_process. We might try using add_custom_command instead which supposedly works with generator expressions. --- .../ament_cmake_symlink_install_targets.cmake | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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