install(TARGETS RUNTIME_DEPENDENCIES) on macOS triggers unnecessary "no FRAMEWORK DESTINATION" error
In the latest versions of CMake 3.27 and macOS 13.4.1, when collecting build artifacts for packaging, adding RUNTIME_DEPENDENCIES
to install(TARGETS ...)
causes CMake to produce a meaningless no FRAMEWORK DESTINATION
error when there are no framework dependencies.
CMake Error at CMakeLists.txt:15 (install):
install TARGETS RUNTIME_DEPENDENCIES given no FRAMEWORK DESTINATION
For example, in a project that builds a TrivialTest
executable and libFoo.dylib
shared library, with CMake files:
# /CMakeLists.txt
cmake_minimum_required(VERSION 3.27)
project(
TrivialTest
VERSION 1.0
LANGUAGES CXX
)
add_subdirectory(Foo EXCLUDE_FROM_ALL)
add_executable(TrivialTest main.cpp)
target_link_libraries(TrivialTest
Foo
)
install(TARGETS
TrivialTest
RUNTIME_DEPENDENCIES
RUNTIME
)
install(FILES
$<TARGET_RUNTIME_DLLS:Foo>
TYPE BIN
)
# /Foo/CMakeLists.txt
project(CXX)
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
add_library(Foo foo.cpp foo.h)
target_include_directories(Foo PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
(Note that in the above example, CMake still fails to copy libFoo.dylib
to the deployment folder, for some reason.)