Reputation: 1203
I want to install all dependent libraries.
To do that I do
install(FILES "path/external.dll" DESTINATION lib)
However, I have already configured the path(and the lib) with target_link_libraries
:
target_link_libraries(${PROJECT_NAME} PUBLIC "path/external.dll")
So, I think that I might not need again telling install FILES
I would be able to do this with install TARGETS
, would not I?
However,
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin LIBRARY DESTINATION lib)
does not install dependent libraries.
How could I do that without repeating it?
Upvotes: 3
Views: 5396
Reputation: 19916
CMake 3.21 added an argument to install(TARGETS)
for this: RUNTIME_DEPENDENCIES
. Try this:
include(GNUInstallDirs)
install(
TARGETS my_target
RUNTIME_DEPENDENCIES
[DIRECTORIES ...]
)
Where DIRECTORIES
marks the beginning of an optional list of search paths. Also note that including GNUInstallDirs sets up the default destinations correctly.
See the docs: https://cmake.org/cmake/help/latest/command/install.html#targets
Upvotes: 1