[CMake] Gathering up required shared libraries
Clinton Stimpson
clinton at elemtech.com
Tue Aug 2 18:10:33 EDT 2011
On Tuesday, August 02, 2011 03:38:01 pm Gregory Crosswhite wrote:
> On 8/2/11 1:09 PM, Clinton Stimpson wrote:
> > Ok, can you make an example that demonstrates the problem?
> >
> > I think this should work without overriding get_dotapp_dir() in
> > BundleUtilities.
>
> The example is attached to this e-mail. I don't actually use Boost in
> this example except as a means of pulling in a dependency on a
> non-system shared library, so if necessary replace all references to it
> in CMakeLists.txt with some other package on your system that will
> generate a dependency on a non-system shared library in order to see
> something akin to what I am seeing.
>
> My CMakeLists.txt file looks like this:
>
> ======== CMakeLists.txt ========
> cmake_minimum_required(VERSION 2.8.5)
>
> set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/bundle)
>
> find_package( Boost COMPONENTS thread REQUIRED )
> link_directories ( ${Boost_LIBRARY_DIRS} )
> include_directories ( ${Boost_INCLUDE_DIRS} )
>
> add_executable(hello hello)
> target_link_libraries(hello ${Boost_LIBRARIES})
> install (TARGETS hello RUNTIME DESTINATION bin)
>
> configure_file(
> ${CMAKE_SOURCE_DIR}/FixBundle.cmake.in
> ${CMAKE_BINARY_DIR}/FixBundle.cmake
You need an @ONLY for configure_file() so it doesn't substitute the ${} parts
also.
> ====== VERSION 2 ERROR MESSAGE ======
> -- Install configuration: ""
> -- Up-to-date:
> /Users/gcross/Documents/ThrowawayCode/cmake-issue-example/build/bundle/bin/
> hello -- fixup_bundle
> --
> app='/Users/gcross/Documents/ThrowawayCode/cmake-issue-example/build/bundle
> /bin/hello' -- libs=''
> -- dirs=''
> -- fixup_bundle: preparing...
> -- fixup_bundle: copying...
> -- 1/4: *NOT* copying
> '/Users/gcross/Documents/ThrowawayCode/cmake-issue-example/build/bundle/bin
> /hello' -- 2/4: copying '/opt/local/lib/libboost_thread-mt.dylib'
> Error copying file "/opt/local/lib/libboost_thread-mt.dylib" to
> "/libboost_thread-mt.dylib".
> -- fixup_bundle: fixing...
> -- 3/4: fixing up
> '/Users/gcross/Documents/ThrowawayCode/cmake-issue-example/build/bundle/bin
> /hello' -- 4/4: fixing up '/libboost_thread-mt.dylib'
>
> exe_dotapp_dir/='/Users/gcross/Documents/ThrowawayCode/cmake-issue-example/
> build/bundle/bin/' item_substring=''
> resolved_embedded_item='/libboost_thread-mt.dylib'
the "/libboost_thread-mt.dylib" comes from the missing @ONLY in configure_file()
Without that, it gave you
function(gp_item_default_embedded_path item default_embedded_path_var)
set( "@executable_path/../lib" PARENT_SCOPE)
endfunction(gp_item_default_embedded_path)
instead of
function(gp_item_default_embedded_path item default_embedded_path_var)
set(${default_embedded_path_var} "@executable_path/../lib" PARENT_SCOPE)
endfunction(gp_item_default_embedded_path)
>
> As you can see, neither version works. The first version doesn't work
> because fixup_bundle requires an executable file rather than a
> directory, and the second version doesn't work because it sets the
> bundle directory to bin/ *inside* of the installation prefix and so it
> doesn't see that the libraries are also inside the bundle.
You should either pass in the executable or a .app/ directory to fixup_bundle()
But after those fixes... there is another error that says:
"Install or copy the item into the bundle before calling fixup_bundle.
Or maybe there's a typo or incorrect path in one of the args to fixup_bundle?"
I thought that check applied only to parameters passed in the second argument
of fixup_bundle(), so that looks like a bug. That function is also only called
on Mac if that helps explain some behavior you are seeing.
If I comment out the FATAL_ERROR it issues, then it completes and gives a
working installation. Would you like to file a bug report for this?
--
Clinton Stimpson
Elemental Technologies, Inc
Computational Simulation Software, LLC
www.csimsoft.com
More information about the CMake
mailing list