file(GET_RUNTIME_DEPENDENCIES EXECUTABLES "${TARGET_FILE}" DIRECTORIES "${RUNTIME_DEPENDENCIES_DIRECTORIES}" # Exclude standard system libraries by pattern before resolution PRE_EXCLUDE_REGEXES "^libc\\.so" "^libc\\+\\+\\.so" "^libcxxrt\\.so" "^libgcc_s\\.so" "^libm\\.so" "^librt\\.so" "^libthr\\.so" "^libutil\\.so" # Exclude any libraries found in standard system locations after resolution POST_EXCLUDE_REGEXES "^(/lib/|/usr/lib/)" RESOLVED_DEPENDENCIES_VAR resolved_libs UNRESOLVED_DEPENDENCIES_VAR unresolved_libs ) # Your existing filter for Windows-specific noise list(FILTER unresolved_libs EXCLUDE REGEX "^api-ms-win") foreach(unresolved IN LISTS unresolved_libs) message(WARNING "The following dependency could not be resolved: ${unresolved}") endforeach() foreach(lib IN LISTS resolved_libs) file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" TYPE SHARED_LIBRARY FOLLOW_SYMLINK_CHAIN FILES "${lib}" ) endforeach()