Genex: Clarify TARGET_RUNTIME_DLLS behavior on imported targets
TARGET_RUNTIME_DLLS computes to an empty string in add_custom_command:
cmake_minimum_required(VERSION 3.21)
project(test)
find_package(CUDAToolkit REQUIRED)
add_executable(exe test.cpp)
target_link_libraries(exe PRIVATE CUDA::cudart CUDA::cublas)
add_custom_command(TARGET exe POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:exe> $<TARGET_FILE_DIR:exe>
COMMAND_EXPAND_LISTS
)
MSVC 20.19 output:
Build started...
1>------ Build started: Project: ZERO_CHECK, Configuration: Debug x64 ------
1>Checking Build System
2>------ Build started: Project: exe, Configuration: Debug x64 ------
2>Building Custom Rule C:/Work/temp/RuntimeDlls/CMakeLists.txt
2>test.cpp
2>exe.vcxproj -> C:\Work\temp\RuntimeDlls_build\Debug\exe.exe
2>EXEC : CMake error : cmake version 3.21.4
2>Usage: C:\Program Files\CMake\bin\cmake.exe -E <command> [arguments...]
2>Available commands:
2> capabilities - Report capabilities built into cmake in JSON format
2> cat <files>... - concat the files and print them to the standard output
2> chdir dir cmd [args...] - run command in a given directory
2> compare_files [--ignore-eol] file1 file2
2> - check if file1 is same as file2
2> copy <file>... destination - copy files to destination (either file or directory)
2> copy_directory <dir>... destination - copy content of <dir>... directories to 'destination' directory
2> copy_if_different <file>... destination - copy files if it has changed
2> echo [<string>...] - displays arguments as text
Edited by Brad King