<div dir="auto">Just going to jump in here and show how we did it (on the bus with just my phone so will be a bit terse):<div dir="auto"><br></div><div dir="auto">packaging/InstallWindowsDeps.cmake:</div><div dir="auto"><br></div><div dir="auto"><pre style="word-wrap:break-word;white-space:pre-wrap">include(BundleUtilities)

# Dependant executables/libraries
set(INSIGHT_ARTIFACTS
    "${CMAKE_INSTALL_PREFIX}/orexplore-insight.exe"
    "${CMAKE_INSTALL_PREFIX}/insightmodel.dll"
    "${CMAKE_INSTALL_PREFIX}/insightview.dll"
)

# Install the HDF5 Blosc compression plugin
find_path(H5ZBLOSC_DLL_PATH NAMES H5Zblosc.dll)
file(INSTALL
    DESTINATION "${CMAKE_INSTALL_PREFIX}"
    TYPE SHARED_LIBRARY
    OPTIONAL
    FILES "${H5ZBLOSC_DLL_PATH}/H5Zblosc.dll")

# Install fontconfig configuration
#
# Note: This assumes the layout used by [1], where the fonts
#       directory is two levels up from the bin/x64 directory
#       where the DLL is.
#
# [1] <a href="https://github.com/ShiftMediaProject/fontconfig">https://github.com/ShiftMediaProject/fontconfig</a>
find_path(FONTCONFIG_DLL_PATH NAMES fontconfig.dll)
set(FONTCONFIG_FONTS_DIR "${FONTCONFIG_DLL_PATH}/../../fonts")
file(INSTALL "${FONTCONFIG_FONTS_DIR}" DESTINATION "${CMAKE_INSTALL_PREFIX}")

# Run windeployqt to install Qt libraries, plugins et.c.
execute_process(COMMAND windeployqt --no-translations --no-compiler-runtime --no-opengl-sw ${INSIGHT_ARTIFACTS})

# Run fixup_bundle(..) to bring in everything else.
fixup_bundle(
    "${CMAKE_INSTALL_PREFIX}/orexplore-insight.exe"
    "${CMAKE_INSTALL_PREFIX}/H5Zblosc.dll"
    ""
)

set(CODE_SIGNING_COMMAND "@INSIGHT_CODE_SIGNING_COMMAND@")

if(NOT "${CODE_SIGNING_COMMAND}" STREQUAL "")
    # Sign all executables/libraries
    file(GLOB_RECURSE FILES_TO_SIGN
        "${CMAKE_INSTALL_PREFIX}/*.exe"
        "${CMAKE_INSTALL_PREFIX}/*.dll"
    )

    separate_arguments(CODE_SIGNING_COMMAND WINDOWS_COMMAND "${CODE_SIGNING_COMMAND}")

    foreach(FILE_TO_SIGN ${FILES_TO_SIGN})
        execute_process(COMMAND ${CODE_SIGNING_COMMAND} "${FILE_TO_SIGN}")
    endforeach()
endif()</pre><pre style="word-wrap:break-word;white-space:pre-wrap"><br></pre><pre style="word-wrap:break-word;white-space:pre-wrap">packaging/Installmacosdeps.cmake:</pre><pre style="word-wrap:break-word;white-space:pre-wrap"><br></pre><pre style="word-wrap:break-word;white-space:pre-wrap">include(BundleUtilities)

# Install the HDF5 Blosc compression plugin
find_path(H5ZBLOSC_DYLIB_PATH NAMES libH5Zblosc.dylib)
file(INSTALL
    DESTINATION "${CMAKE_INSTALL_PREFIX}/@INSIGHT_MACOSX_BUNDLE_BUNDLE_NAME@.app/Contents/MacOS"
    TYPE SHARED_LIBRARY
    OPTIONAL
    FILES "${H5ZBLOSC_DYLIB_PATH}/libH5Zblosc.dylib")

# We use PATH as the list of extra search dirs for macdeployqt/fixup_bundle
string(REPLACE ":" ";" INSIGHT_LIBRARY_SEARCH_DIRS "$ENV{PATH}")

# Run macdeployqt to install Qt libraries, plugins et.c.
string(REGEX REPLACE "([^;]+)" "-libpath=\\1" _macdeployqt_flags "${INSIGHT_LIBRARY_SEARCH_DIRS}")
execute_process(COMMAND macdeployqt ${CMAKE_INSTALL_PREFIX}/@INSIGHT_MACOSX_BUNDLE_BUNDLE_NAME@.app ${_macdeployqt_flags} -verbose=3)

# Gather list of Qt plugins
file(GLOB_RECURSE _qtplugins "${CMAKE_INSTALL_PREFIX}/@INSIGHT_MACOSX_BUNDLE_BUNDLE_NAME@.app/Contents/PlugIns/*.dylib")

# Run fixup_bundle(..)
fixup_bundle(
    "${CMAKE_INSTALL_PREFIX}/@INSIGHT_MACOSX_BUNDLE_BUNDLE_NAME@.app"
    "${_qtplugins};${CMAKE_INSTALL_PREFIX}/@INSIGHT_MACOSX_BUNDLE_BUNDLE_NAME@.app/Contents/MacOS/libH5Zblosc.dylib"
    "${INSIGHT_LIBRARY_SEARCH_DIRS}"
)

# Despite what the documentation for macdeployqt says, it _does_ install
# non-Qt dependencies. It installs plain dylibs into Contents/Frameworks.
# This is a problem, because fixup_bundle(..), which we used above, will
# install the same libraries, but into Contents/MacOS. We thus remove the
# dylibs installed by macdeployqt, to avoid duplication.
file(GLOB _macdeployqt_dylibs "${CMAKE_INSTALL_PREFIX}/@INSIGHT_MACOSX_BUNDLE_BUNDLE_NAME@.app/Contents/Frameworks/*.dylib")
file(REMOVE ${_macdeployqt_dylibs})

set(CODE_SIGNING_COMMAND "@INSIGHT_CODE_SIGNING_COMMAND@")

if(NOT "${CODE_SIGNING_COMMAND}" STREQUAL "")
    separate_arguments(CODE_SIGNING_COMMAND UNIX_COMMAND "${CODE_SIGNING_COMMAND}")

    # Sign the entire application bundle.
    #
    # Note that we assume here that the code signing command in
    # ${CODE_SIGNING_COMMAND} is capable of recursive signing of
    # an macOS application bundle (e.g. `codesign --deep ..`).
    execute_process(COMMAND ${CODE_SIGNING_COMMAND} "${CMAKE_INSTALL_PREFIX}/@INSIGHT_MACOSX_BUNDLE_BUNDLE_NAME@.app")
endif()</pre><pre style="word-wrap:break-word;white-space:pre-wrap"><br></pre><pre style="word-wrap:break-word;white-space:pre-wrap">And then:</pre><pre style="word-wrap:break-word;white-space:pre-wrap"><br></pre><pre style="word-wrap:break-word;white-space:pre-wrap">configure_file(<a href="http://CPackOptions.cmake.in">CPackOptions.cmake.in</a> "${INSIGHT_CPACK_PROJECT_CONFIG_FILE}" @ONLY)

if(WIN32)
    configure_file(<a href="http://InstallWindowsDeps.cmake.in">InstallWindowsDeps.cmake.in</a>
        "${CMAKE_CURRENT_BINARY_DIR}/InstallWindowsDeps.cmake" @ONLY)
    install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/InstallWindowsDeps.cmake")
    set(CPACK_GENERATOR "ZIP;WIX")
elseif(APPLE)
    configure_file(<a href="http://InstallMacOSDeps.cmake.in">InstallMacOSDeps.cmake.in</a>
        "${CMAKE_CURRENT_BINARY_DIR}/InstallMacOSDeps.cmake" @ONLY)
    install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/InstallMacOSDeps.cmake")
    set(CPACK_GENERATOR "DragNDrop")
else()
    set(CPACK_GENERATOR "TGZ")
endif()

# General CPack options
set(CPACK_PACKAGE_NAME "${INSIGHT_CPACK_PACKAGE_NAME}")
set(CPACK_PACKAGE_VENDOR "${INSIGHT_CPACK_PACKAGE_VENDOR}")
set(CPACK_PACKAGE_VERSION_MAJOR "${INSIGHT_CPACK_PACKAGE_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${INSIGHT_CPACK_PACKAGE_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${INSIGHT_CPACK_PACKAGE_VERSION_PATCH}")
set(CPACK_PACKAGE_VERSION "${INSIGHT_CPACK_PACKAGE_VERSION}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${INSIGHT_CPACK_PACKAGE_INSTALL_DIRECTORY}")
set(CPACK_PACKAGE_EXECUTABLES "${INSIGHT_CPACK_PACKAGE_EXECUTABLES}")
set(CPACK_CREATE_DESKTOP_LINKS "${INSIGHT_CPACK_CREATE_DESKTOP_LINKS}")
set(CPACK_WIX_UPGRADE_GUID "${INSIGHT_CPACK_WIX_UPGRADE_GUID}")
set(CPACK_WIX_UI_BANNER "${INSIGHT_CPACK_WIX_UI_BANNER}")
set(CPACK_WIX_UI_DIALOG "${INSIGHT_CPACK_WIX_UI_DIALOG}")
set(CPACK_WIX_LICENSE_RTF "${INSIGHT_CPACK_WIX_LICENSE_RTF}")
set(CPACK_WIX_PRODUCT_ICON "${INSIGHT_CPACK_WIX_PRODUCT_ICON}")
set(CPACK_WIX_PATCH_FILE "${INSIGHT_CPACK_WIX_PATCH_FILE}")
set(CPACK_DMG_BACKGROUND_IMAGE "${INSIGHT_CPACK_DMG_BACKGROUND_IMAGE}")
set(CPACK_DMG_DS_STORE_SETUP_SCRIPT "${INSIGHT_CPACK_DMG_DS_STORE_SETUP_SCRIPT}")
set(CPACK_PROJECT_CONFIG_FILE "${INSIGHT_CPACK_PROJECT_CONFIG_FILE}")

include(CPack)</pre><pre style="word-wrap:break-word;white-space:pre-wrap"><br></pre><pre style="word-wrap:break-word;white-space:pre-wrap">Sorry for giving you the full paste, but as you can see we're using the install(SCRIPT) approach. The scrips are generated using configure_file so we can use generator expressions.</pre><pre style="word-wrap:break-word;white-space:pre-wrap"><br></pre><pre style="word-wrap:break-word;white-space:pre-wrap">Might not be the prettiest but has worked for us.</pre><pre style="word-wrap:break-word;white-space:pre-wrap"><br></pre><pre style="word-wrap:break-word;white-space:pre-wrap">PS sorry for the formatting DS</pre><pre style="word-wrap:break-word;white-space:pre-wrap">Cheers,</pre><pre style="word-wrap:break-word;white-space:pre-wrap">Elvis </pre></div></div><br><div class="gmail_quote"><div dir="ltr">Den tis 23 okt. 2018 07:43Eric Noulard <<a href="mailto:eric.noulard@gmail.com">eric.noulard@gmail.com</a>> skrev:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div dir="ltr">Le lun. 22 oct. 2018 à 23:05, Craig Scott <<a href="mailto:craig.scott@crascit.com" target="_blank" rel="noreferrer">craig.scott@crascit.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div><br></div><div>Yes I agree that having build rpath is useful.</div><div>I am not aware of any mechanism that enable calling some tool during CPack's install step.</div><div>Moreover I don't use MacOS at all so I don't have any experience with PackageMaker.</div><div><br></div><div>May be some Mac user may shed some more light on this.</div></div></div></blockquote><div><br></div><div>You should be able to do this using install(SCRIPT) or install(CODE), invoking the code signing through execute_process() as part of that script/code.</div></div></div></blockquote><div><br></div><div>I wasn't sure of that. </div><div><br></div><div>So just to be clear  do we know for sure that install(SCRIPT) install(CODE) will run after the CMake builtin-generated install scripts?</div><div>The builtin generated install script for target includes stripping, so for signing to work as expect we should be sure of the execution order?</div><div>Or may be you suggest not to install(TARGET) for the concerned target and write install(SCRIPT) replacement for those?<br></div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div>Taking a step back though, I don't know what your package contains, but if you're creating an app bundle, then you don't need CPack at all. An app bundle is already self contained and you should be able to get it to build with install RPATH, at which point it should find everything it needs. An advantage of building with install RPATH is that you can also make use of the XCODE_ATTRIBUTE target property support to set up the code signing and have Xcode/xcodebuild drive the whole code signing process for you. It's likely to be easier that way and is more compatible with tools like <a href="https://fastlane.tools" target="_blank" rel="noreferrer">Fastlane</a>, if you end up heading in that direction. But if you have embedded frameworks, then yeah, you probably end up having to do things manually yourself (CMake doesn't yet handle those well and has no direct support for it).</div></div><div><br></div>-- <br><div dir="ltr" class="m_-8401684431592393629m_5766365985255384731gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr">Craig Scott<br><div>Melbourne, Australia</div><div><a href="https://crascit.com" target="_blank" rel="noreferrer">https://crascit.com</a><br></div><div><br></div><div>New book released: <a href="https://crascit.com/professional-cmake/" target="_blank" rel="noreferrer">Professional CMake: A Practical Guide</a><br></div></div></div></div></div></div></div></div>
</blockquote></div><div><br></div>-- <br><div dir="ltr" class="m_-8401684431592393629gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Eric<br></div></div></div></div></div></div>
-- <br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://cmake.org/mailman/listinfo/cmake" rel="noreferrer noreferrer" target="_blank">https://cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div>