I'm using add_custom_command()
in CMakeLists.txt
in a project of mine. I seem to have worked it out nicely for building on Linux, but for when I try and build on Windows, something strange happens.
Here's a snippet from a subdirectory's CMakeLists.txt
in my project:
add_executable(vectorAddMMAP modified_cuda_samples/vectorAddMMAP/vectorAddMMAP.cpp)
add_custom_command(
OUTPUT vectorAddMMAP_kernel.fatbin
COMMAND ${CMAKE_CUDA_COMPILER}
-fatbin ${CCBIN_ARGUMENT}
--generate-code arch=compute_${CMAKE_CUDA_ARCHITECTURES},code=sm_${CMAKE_CUDA_ARCHITECTURES}
-o ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/vectorAddMMAP_kernel.fatbin
${CMAKE_CURRENT_SOURCE_DIR}/modified_cuda_samples/vectorAddMMAP/vectorAdd_kernel.cu
MAIN_DEPENDENCY modified_cuda_samples/vectorAddMMAP/vectorAdd_kernel.cu
... and this is the output I get on a Windows release from 2019, with MS Visual Studio 16 2019. (lines broken for readability)
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(241,5):
warning MSB8065: Custom build for item "..\..\examples\modified_cuda_samples\vectorAddMMAP\vectorAdd_kernel.cu" succeeded,
but specified output "d:\a\cuda-api-wrappers\cuda-api-wrappers\build\examples\vectoraddmmap_kernel.fatbin" has not been
created. This may cause incremental build to work incorrectly.
[D:\a\cuda-api-wrappers\cuda-api-wrappers\build\examples\do_build_vectorAddMMAP_kernel.vcxproj]
I don't understand how this can be possible. The custom command creates ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/vectorAddMMAP_kernel.fatbin
. And add_custom_command
's implied directory for relative path is ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
, right? So how can the file be missing if the compilation succeeded?