Canonicalize the input paths so we treat them both consistently,
in particular when comparing them via string operations. This
is needed for calls like
fixup_bundle("${CMAKE_INSTALL_PREFIX}/../test" ...)
Suggested-by: Benjamin Ballet <bballet@ivsweb.com>
As dumpbin.exe is no longer reliable for gcc libraries on MinGW because
it crashes on many common libraries like libgcc_s and libgfortran it is
now necessary too resort to using objdump for DLL dependency walking.
Using objdump has a secondary problem in that it generates a lot of
output for large libraries and causes fixup_bundle() to take many
minutes to process what took fractions of a second with
"dumpbin.exe /dependents".
Add a 'grep' pre-filter in the execute_process() command pipeline to
reduce this output to a minimum for a several orders of magnitude speed
up. If grep is not available just use the full output.
As there does not seem to be a reliable way of detecting MinGW, callers
of fixup_bundle() may have to set the variable gp_tool to "objdump" if
dumpbin.exe is installed on the build machine to stop it using the
broken MS dumpbin.exe for library dependency walking.
These all test the same variable for different values, so only one of them can
ever be true. This also allows to completely remove one variable that only
flagged if one of the conditions matched.
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.
The VS IDE sets the environment variable VS_UNICODE_OUTPUT when
executing build rules in order to tell MS tools to report output through
a back door instead of through stdout/stderr. Unset this variable so
that CMake can capture or properly redirect all output from processes it
runs even when running inside a VS IDE build environment.
This generalizes the special cases fixed by commit 80d045b0 (When
GetPrerequisites.cmake runs dumpbin while running inside the VS IDE...,
2008-05-01) and commit 44aff73d (ExternalProject: Avoid bleed-through
output when logging, 2011-01-06), so drop special handling of
VS_UNICODE_OUTPUT in those instances.
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
Change to consider a library embedded if it is found in a subdirectory relative to the
using executable/library. Previous commit considered them local.
This case is encountered when @rpath is used with framework libraries, which are inside a directory tree.
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.
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.
Fix IF(WIN32) guards check for cygwin. Fix checking if the depenency is in a system location to use cygwin style paths on cygwin. Also change GetPrerequisites to switch gp_tool to tools that are very unlikely to be found, ie. dumpbin on Apple and otool on Windows/Unix.
Users PATH may contain elements that end with backslash. This will escape the semicolon when iterating resulting in mismatches.
Fix indentation.
Fix whitespace
IF(... MATCHES ...) used for comparing directories chokes especially in the case of C:\Program Files (x86)\<blah> because of regex pattern matching. Switched this to use STREQUAL in a loop instead.
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.
ldd can return "not found" and we need to handle it correctly.
In that case, we extract only the name of the library instead of trying for its full path.
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>
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.
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.