[CMake] Mac Bundle installation with libraries

Clinton Stimpson clinton at elemtech.com
Fri Feb 26 15:12:06 EST 2010


Using BundleUtilities.cmake on each of the bundles should copy that library 
into each bundle.

Clint

On Friday 26 February 2010 11:02:12 am James Bigler wrote:
> I have a project that builds a group of mac bundles that depend on a
>  library I also compile.  I need to install the library within the bundle
>  to get it to be relocatable, but I have no way of doing this without
>  creating a circular dependency.
> 
> src/CMakeLists.txt:
> 
> add_subdirectory(mylib)
> add_subdirectory(mysamples)
> 
> src/mylib/CMakeLists.txt:
> 
> add_library(mylib mylib.cpp mylib.h)
> set_target_properties(mylib PROPERTIES VERSION "2.3.4" SOVERSION "1")
> install(TARGETS mylib RUNTIME DESTINATION bin LIBRARY DESTINATION lib
> ARCHIVE DESTINATION lib)
> 
> src/mysamples/CMakeLists.txt:
> 
> foreach(sample fun lessfun)
>   add_executable(${sample} ${sample}.cpp MACOSX_BUNDLE)
>   target_link_libraries(${sample} mylib)
> 
>   install(TARGETS ${sample} DESTINATION samples)
>   # I really want to install mylib in the bundle, but I don't have access
>  to the library target anymore.
>   install(TARGETS mylib DESTINATION samples/${sample}.app/Contents/MacOS)
> endforeach()
> 
> I really want to install my library within the bundle, but I don't have
> access to the library outside of the mylib subdirectory.  I can't create
> install targets in the mylib install directory, because I don't have the
> list of bundles to install it to until after I parse the mysamples
>  directory and it's too late.
> 
> I tried to use the LOCATION_${CMAKE_BUILD_CONFIG} variable, but because I'm
> using the VERSION and SOVERSION properties on my library I only get one of
> the symlinks and not all three (libmylib.dylib -> libmylib.2.3.4.dylib,
> libmylib.1.dylib -> libmylib.2.3.4.dylib, and libmylib.2.3.4.dylib).
> 
> Is there some way I can get mylib to also install with my executable
> bundles?
> 
> James
> 


More information about the CMake mailing list