BundleUtilities: Framework codesign Resources/Info.plist & Current

We need to ensure copied framework has proper layout with Resources/Info.plist
present next to versioned binary and Current symlink in Versions:

https://developer.apple.com/library/mac/technotes/tn2206

https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/FrameworkAnatomy.html

If Resources/ is not present we may try to copy Contents/Info.plist if present
to embedded Resources/Info.plist. This is a case of Qt5 that has
obsolete/invalid framework layout (see QTBUG-38511).
This commit is contained in:
Adam Strzelecki 2014-09-04 15:01:17 +02:00 committed by Brad King
parent f7df82acaa
commit 83a06bb4ab
1 changed files with 21 additions and 2 deletions

View File

@ -650,11 +650,30 @@ function(copy_resolved_framework_into_bundle resolved_item resolved_embedded_ite
execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${resolved_item}" "${resolved_embedded_item}")
# Plus Resources, if they exist:
string(REGEX REPLACE "^(.*)/[^/]+/[^/]+/[^/]+$" "\\1/Resources" resolved_resources "${resolved_item}")
string(REGEX REPLACE "^(.*)/[^/]+/[^/]+/[^/]+$" "\\1/Resources" resolved_embedded_resources "${resolved_embedded_item}")
string(REGEX REPLACE "^(.*)/[^/]+$" "\\1/Resources" resolved_resources "${resolved_item}")
string(REGEX REPLACE "^(.*)/[^/]+$" "\\1/Resources" resolved_embedded_resources "${resolved_embedded_item}")
if(EXISTS "${resolved_resources}")
#message(STATUS "copying COMMAND ${CMAKE_COMMAND} -E copy_directory '${resolved_resources}' '${resolved_embedded_resources}'")
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory "${resolved_resources}" "${resolved_embedded_resources}")
else()
# Otherwise try at least copy Contents/Info.plist to Resources/Info.plist, if it exists:
string(REGEX REPLACE "^(.*)/[^/]+/[^/]+/[^/]+$" "\\1/Contents/Info.plist" resolved_info_plist "${resolved_item}")
string(REGEX REPLACE "^(.*)/[^/]+$" "\\1/Resources/Info.plist" resolved_embedded_info_plist "${resolved_embedded_item}")
if(EXISTS "${resolved_info_plist}")
#message(STATUS "copying COMMAND ${CMAKE_COMMAND} -E copy_directory '${resolved_info_plist}' '${resolved_embedded_info_plist}'")
execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${resolved_info_plist}" "${resolved_embedded_info_plist}")
endif()
endif()
# Check if framework is versioned and fix it layout
string(REGEX REPLACE "^.*/([^/]+)/[^/]+$" "\\1" resolved_embedded_version "${resolved_embedded_item}")
string(REGEX REPLACE "^(.*)/[^/]+/[^/]+$" "\\1" resolved_embedded_versions "${resolved_embedded_item}")
string(REGEX REPLACE "^.*/([^/]+)/[^/]+/[^/]+$" "\\1" resolved_embedded_versions_basename "${resolved_embedded_item}")
if(resolved_embedded_versions_basename STREQUAL "Versions")
# Ensure Current symlink points to the framework version
if(NOT EXISTS "${resolved_embedded_versions}/Current")
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${resolved_embedded_version}" "${resolved_embedded_versions}/Current")
endif()
endif()
endif()
if(UNIX AND NOT APPLE)