は比較的容易であることが判明:
set_target_properties(mylib PROPERTIES
# Build a framework on OSX.
FRAMEWORK TRUE
# Add a relative path for dependencies to the rpath of mylib (when installed).
INSTALL_RPATH "@loader_path"
# But also use the INSTALL_RPATH anyway in the build tree, before it is installed.
BUILD_WITH_INSTALL_RPATH TRUE
)
しかし、それはフレームワークに依存関係をコピーしません。私はそれを手動で行います:
# Copy libfoo into the bundle.
if (APPLE)
add_custom_command(TARGET mylib POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE:libfoo>" "$<TARGET_FILE_DIR:mylib>"
COMMENT "Bundling libfoo"
VERBATIM
)
endif()