diff --git a/cmake_support/CopyDependencies.cmake b/cmake_support/CopyDependencies.cmake index f742bc84b7757cbb684a09735475a01be6cc6986..a146c16e9b24a4bc3ea8260b472d7522c7672a9f 100644 --- a/cmake_support/CopyDependencies.cmake +++ b/cmake_support/CopyDependencies.cmake @@ -325,17 +325,21 @@ function(change_install_names_for_item keys_var key) # Each referenced item's key is "rkey" in the loop: get_filename_component(exepath ${${key}_RESOLVED_EMBEDDED_ITEM} PATH) resolve_item( ${${key}_RESOLVED_EMBEDDED_ITEM} ${pr} exepath resolved_pr) - get_item_key("${resolved_pr}" rkey) - list(FIND ${keys_var} ${rkey} r_found) - if(r_found EQUAL -1) - MESSAGE(FATAL_ERROR "Key: '${rkey}' not found in dependency list. Cannot change install name.") - endif(r_found EQUAL -1) - if(NOT ${${rkey}_SYSTEMFLAG}) - get_filename_component(ref_exepath ${${rkey}_RESOLVED_EMBEDDED_ITEM} PATH) - string(REPLACE ${CMAKE_INSTALL_PREFIX} "" ref_rel_path ${ref_exepath}) - set(diff_path @loader_path${inv_rel_path}${ref_rel_path}/) - set(changes ${changes} "-change" "${pr}" "${diff_path}${${rkey}_ITEM}") - endif(NOT ${${rkey}_SYSTEMFLAG}) + # If dependency already resolves to library within install directory we don't have to do anything. + if(NOT (${resolved_pr} MATCHES ${CMAKE_INSTALL_PREFIX}) AND EXISTS "${resolved_pr}" ) + get_item_key("${resolved_pr}" rkey) + list(FIND ${keys_var} ${rkey} r_found) + if(r_found EQUAL -1) + message("Error while trying to get dependencies for ${${key}_RESOLVED_EMBEDDED_ITEM}.") + MESSAGE(FATAL_ERROR "Key: '${rkey}' not found in dependency list. Cannot change install name.") + endif(r_found EQUAL -1) + if(NOT ${${rkey}_SYSTEMFLAG}) + get_filename_component(ref_exepath ${${rkey}_RESOLVED_EMBEDDED_ITEM} PATH) + string(REPLACE ${CMAKE_INSTALL_PREFIX} "" ref_rel_path ${ref_exepath}) + set(diff_path @loader_path${inv_rel_path}${ref_rel_path}/) + set(changes ${changes} "-change" "${pr}" "${diff_path}${${rkey}_ITEM}") + endif(NOT ${${rkey}_SYSTEMFLAG}) + endif(NOT (${resolved_pr} MATCHES ${CMAKE_INSTALL_PREFIX}) AND EXISTS "${resolved_pr}" ) endforeach(pr) execute_process(COMMAND chmod u+w "${${key}_RESOLVED_EMBEDDED_ITEM}")