Commit Graph

32 Commits

Author SHA1 Message Date
Clinton Stimpson 3906ca5af4 BundleUtilities: Fix regression handling frameworks
Fix logic error introduced in commit e422f738 (BundleUtilities: Fix
treatment of .dylib inside .framework folders, 2016-02-11).
2016-03-07 09:30:18 -05:00
Christian Askeland e422f738e4 BundleUtilities: Fix treatment of .dylib inside .framework folders
The specific cause is when e.g.

    /Library/Frameworks/GStreamer.framework/Versions/1.0/lib/libgio-2.0.0.dylib

is detected by fixup_bundle.  set_bundle_key_values() interprets this as
a framework, thus doing a string replace that creates an embedded_item
that is equal to the original path, i.e. it is not embedded.
2016-02-11 08:49:06 -05:00
Emilie Harquel a479d7a0ae BundleUtilities: Fix handling of multiple RPATHs from OS X otool
The `otool` command may return multiple RPATH entires, so call
`gp_append_unique` for each one.  Otherwise we may try to ask
`install_name_tool` to deal with the same entry twice.
2015-12-17 10:56:27 -05:00
Daniele E. Domenichelli a7631fc4e0 Modules: Check for ARGC before using ARGV#
ARGV# could be defined from a parent scope.
2015-02-27 10:59:23 -05:00
Ruslan Baratov a27c13f4ca BundleUtilities: Teach fixup_bundle to check install_name_tool result
Fail explicitly if install_name_tool fails to make an update we need.
2015-02-10 11:00:27 -05:00
Adam Strzelecki 41564ff289 BundleUtilities: Ensure framework symlinks and Info.plist exist
This restores Qt SDK 4.8 and OS X >= 10.6.5 codesign compatibility
improving embedding frameworks using correct bundle layout described at:

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

1. If Versions/VERSION/Resources/Info.plist is missing, well known
   incorrect locations are checked for Info.plist and Info.plist is
   copied from there, otherwise codesign will fail.

2. Root framework symlinks to binary and Resources are restored to
   point inside Versions/Current, otherwise Qt 4.8 looking for
   Resources/ in framework root will fail.
2014-10-21 11:42:30 -04:00
Adam Strzelecki 83a06bb4ab 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).
2014-10-10 10:17:04 -04:00
Adam Strzelecki f7df82acaa BundleUtilities: Resolve & replace @rpath placeholders
This is done by gathering LC_RPATH commands for main bundle executable and
using it for @rpath lookup in dependent frameworks.

All functions that need to carry rpaths to now take optional <rpaths> argument.

This enabled apps using @rpath to be bundled correctly, which will be necessary
for upcoming Qt 5.4 that will use @rpath for all frameworks.

Check that install_name_tool has -delete_rpath before using it.
Otherwise it will fail with Xcode 3.x on 10.5 which has no -delete_rpath
option for install_name_tool command, that was first introduced in 10.6
SDK, even that 10.5 supports LC_RPATH and @rpath.
2014-10-10 10:16:24 -04:00
Adam Strzelecki 6c31379741 BundleUtilities: Use find on UNIX for fast executable lookup
It makes whole executable process quicker on UNIX, especially for large bundles
containing many files, since using find narrows results to only files having
executable flags then all further tests follow.

Since find ... -perm +0111 is not clearly POSIX compliant and some Linux
versions refuse it, it is better to use longer but portable:

   find ... -perm \( -perm -0100 -o -perm -0010 -o -perm -0001 \)
2014-10-10 10:15:56 -04:00
Tim Blechmann 810f5ccefc BundleUtilities: Allow Info.plist files which use CR line endings
Convert \r to our internal end-of-line character just as we do \n.

Signed-off-by: Tim Blechmann <tim@klingt.org>
2014-08-07 14:00:01 -04:00
Rolf Eike Beer b0b4b4602f Remove .* expressions from beginning and end of MATCHES regexs
All these expressions work the same:
  "foo"
  ".*foo.*"
  "^.*foo.*$"

This assumes that the "Intel*" expressions were meant to be "Intel.*".
2014-04-14 18:17:11 +02:00
Rolf Eike Beer 5bd48ac534 Replace string(REGEX REPLACE) with string(REPLACE) where possible
The simple replacement is much faster.
2014-04-14 18:17:05 +02:00
Kitware Robot f051814ed0 Convert builtin help to reStructuredText source files
Run the convert-help.bash script to convert documentation:

 ./convert-help.bash "/path/to/CMake-build/bin"

Then remove it.
2013-10-15 14:12:03 -04:00
David Cole 89256e03cf BundleUtilities: Use a more inclusive REGEX for frameworks (#13600)
Some frameworks might be built with the library right at the root
of the framework rather than down in a versioned sub-folder with
a symlink at the root.

Make one of the slashes in the REGEX optional so BundleUtilities
can still properly work with such frameworks ... even if they are
weird. ;-)

Thanks to Tobias Hieta for the bug report and for trying out the fix
before I pushed this commit.
2012-10-23 18:10:28 -04:00
Kitware Robot 9db3116226 Remove CMake-language block-end command arguments
Ancient versions of CMake required else(), endif(), and similar block
termination commands to have arguments matching the command starting the
block.  This is no longer the preferred style.

Run the following shell code:

for c in else endif endforeach endfunction endmacro endwhile; do
    echo 's/\b'"$c"'\(\s*\)(.\+)/'"$c"'\1()/'
done >convert.sed &&
git ls-files -z -- bootstrap '*.cmake' '*.cmake.in' '*CMakeLists.txt' |
egrep -z -v '^(Utilities/cm|Source/kwsys/)' |
egrep -z -v 'Tests/CMakeTests/While-Endwhile-' |
xargs -0 sed -i -f convert.sed &&
rm convert.sed
2012-08-13 14:19:16 -04:00
Brad King 40792a1a15 Merge topic 'fix-12034-fixup-bundle-with-non-dotapp-exe'
51e16c0 BundleUtilities: Avoid test on Watcom dashboards (#12034)
41f962a Revert "BundleUtilities: Run test on Windows if either MSVC or dumpbin was found."
e17135e BundleUtilities: Add rpath to loadable modules in test.
8064044 BundleUtilities: Print reason for not loading module.so
f3de459 BundleUtilities: Run test on Windows if either MSVC or dumpbin was found.
900bf98 BundleUtilities: Disable running test on Windows unless using MSVC.
fa4dc08 BundleUtilities: Fix issues with custom target DEPENDS in test (#12034)
e40b79e BundleUtilities: Fix test when using xcode (#12034)
b68d3dc BundleUtilities: Fix regex to extract dependents from ldd (#12034)
7ac7b43 BundleUtilities: Work w/ non .app exes on Mac (#12034)
2011-06-07 14:06:09 -04:00
David Cole 8f0667c113 BundleUtilities: Avoid a cryptic and unhelpful error message
When the path to "resolved_embedded_item" was shorter than
the path to the bundle being fixed up, fixup_bundle would
fail with a cmake error like:

  "string end index: 110 is out of range 0 - 85"

Detect when the path of resolved_embedded_item is too short
to be embedded in the bundle, and report the proper error
message, so the poor developer reading it has a snowball's
chance of actually fixing the issue.
2011-06-02 11:55:09 -04:00
Clinton Stimpson 7ac7b437b8 BundleUtilities: Work w/ non .app exes on Mac (#12034)
Also add a test of BundleUtilities including an exe,
some shared libs, a plugin, and a framework-style lib.

This test presently runs (and this functionality works)
on Linux, Mac and Windows.

For now, the framework-style lib is built as a plain old
shared lib because there is another yet-unresolved issue
with local frameworks without rpaths on the Mac.
2011-05-27 16:11:43 -04:00
David Cole c2895f48a4 BundleUtilities: error if fixup_bundle_item called on non-embedded item
Also, improve the documentation of the fixup_bundle and fixup_bundle_item
functions to clarify that plugin type "libs" need to be copied into
the bundle *before* calling fixup_bundle.

Commit e93a4b4d34 changed the way that
the libs parameter to fixup_bundle is interpreted. Before the commit,
the libs were copied into the bundle first and then fixed up. After
the commit, the copy was skipped, assuming the libs were in the bundle
in the first place, and then the fixups occurred as before.

However, before the commit, it was possible to name a lib from outside
the bundle, and have it copied in and then fixed up. Its resolved
embedded name was always inside the bundle before. After, its resolved
embedded name was just the same as its resolved name, which is in its
original location, and not necessarily inside the bundle.

This manifested itself as a problem with the ParaView call to
fixup_bundle and its many plugins. Previously, ParaView had simply
passed in the list of plugin file names as they existed in the build
tree, and left the copying into the bundle up to the fixup_bundle
function. When built with CMake 2.8.3 (the first version to contain
the above named commit) the fixup_bundle call would inadventently
fixup libraries in the build tree, not libraries that were in the
bundle. Furthermore, the plugins would not be in the final bundle.

This points out the fact that the fix for the bugs made by the above
commit was a backwards-incompatible change in behavior.

This commit makes it an error to try to fixup an item that is not
already inside the bundle to make the change in behavior apparent
to folks who were depending on the prior copy-in behavior: now,
they should get an error, and hopefully, reading the new and
improved documentation, should be able to resolve it in their
projects by adding code to install or copy in such libraries prior
to calling fixup_bundle.

Whew.
2010-12-06 16:35:59 -05:00
Clinton Stimpson 28c1be7a50 BundleUtilities: only do rpath strip on copied prerequisites. 2010-11-23 14:29:46 -07:00
Brad King 18c71e3c79 Merge topic 'fix-10417'
e93a4b4 Avoid adding self as prerequisite. (#10417)
2010-09-08 11:08:22 -04:00
Mike McQuaid 88fed668b1 Make bundle items writable before fixup (#9284)
This ensures that any bundle items are made user writable before
any attempt is made to alter them using install_name_tool. This is
because MacPorts/Fink/Homebrew don't install libraries as writable.
This fix is needed to allow fixup_bundle_item to work correctly
when ingesting libraries installed by these package managers.
2010-09-07 22:49:32 -04:00
David Cole e93a4b4d34 Avoid adding self as prerequisite. (#10417)
Thanks to Clinton Stimpson for the patch.
2010-09-07 21:29:43 -04:00
David Cole 90add6b504 Refine formatting for cmake --help-module output.
Also refer to self as module, not script.
2010-08-25 14:58:31 -04:00
David Cole af0c719b9a Merge branch 'patches/docBundleUtilities'
of http://github.com/themiwi/CMake
into fix-10747

Conflicts:
	Modules/BundleUtilities.cmake

There was one newly added function in BundleUtilities.cmake
which also needed the same "documentation at top" treatment.
2010-08-25 14:54:14 -04:00
Todd Gamblin 2cde67a781 Modules: Fix spelling 'To distributed' -> 'To distribute' 2010-08-09 08:48:31 -04:00
David Cole 979972f988 Copy Resources in Frameworks during fixup_bundle (#10020)
By default, if an embedded item is a framework, copy its
main dylib file explicitly, and then also its Resources
if it has any.

Inspect a variable, BU_COPY_FULL_FRAMEWORK_CONTENTS, and
if it's ON, copy the entire framework into the bundle.
2010-07-27 12:25:11 -04:00
Michael Wild f811470a96 Improve documentation of BundleUtilities.cmake
Put the function documentation into the header-comment, improve
formatting and list the user-relevant functions first.

Signed-off-by: Michael Wild <themiwi@users.sourceforge.net>
2010-05-23 14:38:20 +02:00
David Cole 23dbb3b803 Fix issue #9412 - remove RPATH from files copied by BundleUtilities.cmake on Linux. Thanks to Clinton Stimpson for the patch. 2009-09-28 17:43:52 -04:00
Brad King 3a666595c9 Convert CMake non-find modules to BSD License
This adds copyright/license notification blocks CMake's non-find
modules.  Most of the modules had no notices at all.  Some had notices
referring to the BSD license already.  This commit normalizes existing
notices and adds missing notices.
2009-09-28 11:46:51 -04:00
David Cole fe0b121da9 Overhaul GetPrerequisites and BundleUtilities: make fixup_bundle do something useful on Windows and Linux.
Formerly, fixup_bundle was useful only on the Mac for making standalone bundle applications that could be drag-n-drop moved to anyplace in the file system. fixup_bundle is not just for the Mac any more. It will now analyze executable files on Windows and Linux, too, and copy necessary non-system dlls to the same folder that the executable is in. This should work with dlls that you build as part of your build and also with 3rd-party dlls as long as you give fixup_bundle the right list of directories to search for those dlls. Many thanks to Clinton Stimpson for his help in ironing out the details involved in making this work.
2009-08-05 14:59:14 -04:00
David Cole 6f8bdd276c ENH: Add BundleUtilities.cmake and supporting changes to GetPrerequisites.cmake. Function copy_and_fixup_bundle in BundleUtilities helps to make standalone bundle applications on the Mac by pulling in prerequisite non-system libraries and frameworks as needed. Uses otool and install_name_tool to do analysis and fixups. Project-specific hooks for deciding where to embed libraries and for resolving item names into full path file names are also provided. 2008-09-06 12:20:07 -04:00