From 9a6b102205045e457db24bd00777ef000c30e242 Mon Sep 17 00:00:00 2001 From: Clinton Stimpson Date: Mon, 21 Nov 2011 16:45:49 -0700 Subject: GetPrerequisites: Add support for @rpath on Mac OS X. Handle @rpath much like other Unixes, by doing a find_file with the given directories. Also, consider a library to be local if it is found in the same directory or a subdirectory relative to the user executable/library. Previously, it was local only if found in the same directory. This case is encountered when @rpath is used with framework libraries, which are inside a directory tree. --- Modules/GetPrerequisites.cmake | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake index 2efa079..fbbaf9c 100644 --- a/Modules/GetPrerequisites.cmake +++ b/Modules/GetPrerequisites.cmake @@ -304,6 +304,26 @@ function(gp_resolve_item context item exepath dirs resolved_item_var) endif(NOT resolved) if(NOT resolved) + if(item MATCHES "@rpath") + # + # @rpath references are relative to the paths built into the binaries with -rpath + # We handle this case like we do for other Unixes + # + string(REPLACE "@rpath/" "" norpath_item "${item}") + + set(ri "ri-NOTFOUND") + find_file(ri "${norpath_item}" ${exepath} ${dirs} NO_DEFAULT_PATH) + if(ri) + #message(STATUS "info: 'find_file' in exepath/dirs (${ri})") + set(resolved 1) + set(resolved_item "${ri}") + set(ri "ri-NOTFOUND") + endif(ri) + + endif(item MATCHES "@rpath") + endif(NOT resolved) + + if(NOT resolved) set(ri "ri-NOTFOUND") find_file(ri "${item}" ${exepath} ${dirs} NO_DEFAULT_PATH) find_file(ri "${item}" ${exepath} ${dirs} /usr/lib) @@ -458,9 +478,13 @@ function(gp_resolved_file_type original_file file exepath dirs type_var) if(NOT is_system) get_filename_component(original_path "${original_lower}" PATH) - get_filename_component(path "${lower}" PATH) - if("${original_path}" STREQUAL "${path}") - set(is_local 1) + string(LENGTH "${original_path}/" original_length) + string(LENGTH "${lower}" path_length) + if(${path_length} GREATER ${original_length}) + string(SUBSTRING "${lower}" 0 ${original_length} path) + if("${original_path}/" STREQUAL "${path}") + set(is_local 1) + endif() endif() endif() endif() -- cgit v0.12