I've attached two patches that fix bugs in the CUDA_COMPILE{,_PTX,_FATBIN,_CUBIN} macros from FindCUDA.cmake.
First bug (fixed by patch #1) Commit 7ded655 added generator expressions in CUDA_WRAP_SRCS to scrape include directories and compile definitions off of the target. This works great when the target name passed to CUDA_WRAP_SRCS is an actual target (like in cuda_add_library and cuda_add_executable). However, the CUDA_COMPILE* macros also use CUDA_WRAP_SRCS, and they pass in a hardcoded name that doesn't represent a real target. This breaks the generator expressions, causing CMake to abort during generation. I fixed this by teaching CUDA_WRAP_SRCS to check for "PHONY" in its argument list. When CUDA_WRAP_SRCS sees "PHONY", it queries the appropriate directory properties (INCLUDE_DIRECTORIES and COMPILE_DEFINITIONS) instead of using the generator expressions. I then modified cuda_compile_base (which is used internally by all the CUDA_COMPILE* macros) to pass PHONY to CUDA_WRAP_SRCS. Second bug (fixed by patch #2) In a couple spots, CUDA_WRAP_SRCS assumes that the passed-in target name is unique - for example, the name of the directory containing the intermediate output is built from the target name. However, the CUDA_COMPILE* macros always pass the same hardcoded target name. So, if you call the same macro twice in a directory, some of the generated files from the second call will silently overwrite those from the first call. I fixed this by adding a counter (_cuda_internal_phony_counter) as a directory property. The counter gets incremented every time cuda_compile_base is called, and the value of the counter is appended to the hardcoded target name that gets passed to CUDA_WRAP_SRCS. This ensures that each call to the macro has its own unique target name. Thanks! Stephen Sorley
0001-FindCUDA-Fix-for-broken-cuda_compile-commands.patch
Description: 0001-FindCUDA-Fix-for-broken-cuda_compile-commands.patch
0002-FindCUDA-Allow-cuda_compile-macros-to-be-called-more.patch
Description: 0002-FindCUDA-Allow-cuda_compile-macros-to-be-called-more.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