Running fixup_bundle for a specific target (PACKAGE)

784 views Asked by At

I would like to incorporate external dlls when running CPACK without enumerating all of them (by explicitly calling INSTALL(FILE ...) )

Employing fixup_bundle it is possible to fixup all the executables in the install folder (CMAKE_INSTALL_PREFIX) by copying the required libraries.

INSTALL(CODE "
   include(BundleUtilities)
   fixup_bundle(\"${APPS}\"   \"\"   \"${DIRS}\")
   " DESTINATION bin COMPONENT Runtime)

This code is executed when building the INSTALL target and will handle only elements present inside the folder CMAKE_INSTALL_PREFIX.

What I would like to do instead is to run fixup_bundle during the building of the PACKAGE target which is added by CPACK. in this way the install script generated will also include externa libraries.

Did anyone managed to do this?

1

There are 1 answers

0
Pierluigi On

The best solution I found so far do not rely on fixup_bundle but on listing all files that have to be installed for the runtime configuration (e.g. all dlls).

Given a target you can recover the associated runtime file and add it to the INSTALL project:

#get dll location
get_target_property(BIN_F ${target} LOCATION_${Configuration}) 

#copy to the bin folder
install(FILES ${BIN_F} DESTINATION ${destinationFolder} 
                    CONFIGURATIONS ${Configuration} 
                         COMPONENT Runtime) 

You then can recurse over the target dependenices to perform the same two operations using

get_target_property(link_libs ${target} INTERFACE_LINK_LIBRARIES)