FindCUDA.cmake from 3.5.0-rc2 is failing for me when creating solution files for Visual Studio on Windows (VS 2013 update 4, to be specific). The ninja generator on Windows is unaffected.
When I attempt to build a cuda target, the compile step for each .cu file fails with the following message: Building NVCC (Device) object utils/CMakeFiles/utils_cu.dir/Release/utils_cu_generated_cudaarray.cu.obj 3> cudaarray.cu 3> 3> '$' is not recognized as an internal or external command, 3> 3> operable program or batch file. 3> 3> CMake Error at utils_cu_generated_cudaarray.cu.obj.cmake:207 (message): 3> Error generating 3> C:/Users/sorlesl1/Desktop/testproj/build/utils/CMakeFiles/utils_cu.dir//Release/utils_cu_generated_cudaarray.cu.obj I've traced the problem to this commit<https://github.com/Kitware/CMake/commit/6ccc307053f03c4c48a2cb9d5795f91d341a5c39>, which added VERBATIM to the add_custom_command() call in CUDA_WRAP_SRCS. Adding the VERBATIM flag changes how the escaped double-quotes in the ccbin_flags variable are interpreted: Without verbatim, ${ccbin_flags} expands to the following in the generated VS project: -D "CCBIN:PATH=$(VCInstallDir)bin" With verbatim, the double quotes are escaped in the generated project, causing the error: -D \"CCBIN:PATH=$(VCInstallDir)bin\" If the escaped quotes are omitted entirely when ccbin_flags is set, the custom command still fails, this time due to VCInstallDir expanding at compile time to a path containing spaces. According to bug 15001<https://cmake.org/Bug/view.php?id=15001>, there isn't any way in CMake to correctly quote Visual Studio placeholder variables that expand to values containing spaces - you'll always get either no quotes, or escaped quotes. However, I was able to work around this problem by getting the compiler path directly from CMake instead of using the placeholder. Please see the attached patch (it's based on master) - with this patch, compiling CUDA code with Visual Studio works again. Thanks, Stephen Sorley
0001-Fixed-Visual-Studio-CUDA-compile-failure.patch
Description: 0001-Fixed-Visual-Studio-CUDA-compile-failure.patch
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers
