[CMake] Thoughts on infrastructure for fixup_bundle

Lee Butler iraytrace at gmail.com
Wed Sep 23 12:03:38 EDT 2015


I've started using fixup_bundle().  One of the things that occurs to me 
is that much of the information that needs to go into fixup_bundle() 
arguments (executables and library directories) can be gleaned from 
arguments to add_executable() and target_link_libraries().

It might be nice to extend these two standard functions to create 
variables that could be used with fixup_bundle.  I could see writing 
macros or functions to wrap this up for my projects, but I think it 
might belong in the "standard" versions of these.
Perhaps this already exists and I have simply not seen it?

I'd like to get to a world where we could do something like:

# tell CMake to remember the executable names and libraries for each
set(CMAKE_BUILD_FIXUP_ARGS ON)

add_executable(execName ... BUNDLEME)
target_link_libraries(execName lib1 lib2 ...)
install(TARGETS execName ... )

add_executable(progName ... BUNDLEME)
target_link_libraries(progName lib1 lib18 ...)
install(TARGETS execName ...)

fixup_bundle(${CMAKE_INSTALL_TARGETS}
             ""
             ${CMAKE_execName_LIBPLACES} ${CMAKE_progName_LIBPLACES})

I'm speculating that it is target_link_libraries that I would extend 
with the capability to generate the lists of library locations (some 
code and conventions required for DLL platforms).  I could see some 
people wanting to avoid bundling executables they do not want to 
install, so a flag for add_executable to indicate whether to bundle 
seems like it would work.

In any case, this would allow you to do a fixup_bundle() as a POST_BUILD 
stage so that things could be run from the build directory.  This is 
nice for testing prior to doing an install.

Thoughts?


More information about the CMake mailing list