install(RUNTIME_DEPENDENCIES ...) excludes runtime dependency built in the same project
I am not sure if this is actually a bug or intended behavior. I apologize if I have missed something very trivial.
$ cat nehal/CMakeLists.txt
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
include_guard(GLOBAL)
project(blah)
add_library(blah SHARED
blah.cc)
add_executable(blah_exe
main.x.cpp)
target_link_libraries(blah_exe PRIVATE blah)
install(TARGETS blah_exe RUNTIME_DEPENDENCIES)
Consider the snippet above. It generates the following chunk of code in cmake_install.cmake
:
if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
file(GET_RUNTIME_DEPENDENCIES
RESOLVED_DEPENDENCIES_VAR _CMAKE_DEPS
EXECUTABLES
"/spare/scratch/nehal_1638811664/build/blah_exe"
POST_EXCLUDE_FILES_STRICT
"/spare/scratch/nehal_1638811664/build/libblah.so"
)
endif()
Why is libblah.so
explicitly excluded and that too with an undocumented option?
I went through a small discussion at https://discourse.cmake.org/t/control-what-is-installed-packaged/3778/5 and it talks about the avoidance of double installation. But I'm trying to not write multiple install rules in the first place
I'm hopeful what I want can be resolved using some regex as listed in https://cmake.org/cmake/help/latest/command/install.html#runtime-dependency-set, and an example would be nice