MantisBT - CMake
View Issue Details
0015919CMakeCMakepublic2016-01-14 10:112016-06-10 14:21
qiv 
 
normalminoralways
closedfixed 
PCUbuntu15.04
CMake 3.0.2 
CMake 3.5CMake 3.5 
0015919: Building CUDA files fails when source path contains parenthesis
When working in a source path containing "()" I get the following error upon building CUDA files:

15:13 sandbox$ make
[ 6%] Building NVCC (Device) object CMakeFiles/githash.dir//./githash_generated_float3.cu.o
/bin/sh: 1: Syntax error: "(" unexpected
CMakeFiles/githash.dir/build.make:167: recipe for target 'CMakeFiles/githash.dir/./githash_generated_float3.cu.o' failed
make[2]: *** [CMakeFiles/githash.dir/./githash_generated_float3.cu.o] Error 2
CMakeFiles/Makefile2:60: recipe for target 'CMakeFiles/githash.dir/all' failed
make[1]: *** [CMakeFiles/githash.dir/all] Error 2
Makefile:76: recipe for target 'all' failed
make: *** [all] Error 2


The following fix provided by ngladitz in #cmake solves the issue on my machine:

diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake
index ada5b8a..fe2647a 100644
--- a/Modules/FindCUDA.cmake
+++ b/Modules/FindCUDA.cmake
@@ -1474,6 +1474,7 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files)
           -P "${custom_target_script}"
         WORKING_DIRECTORY "${cuda_compile_intermediate_directory}"
         COMMENT "${cuda_build_comment_string}"
+ VERBATIM
         )
 
       # Make sure the build system knows the file is generated.
16:06 sandbox$ cat CMakeLists.txt
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(githash)

FIND_PACKAGE(CUDA REQUIRED)
# FIND_PACKAGE(MPI REQUIRED)

INCLUDE(FindCUDA)

# INCLUDE_DIRECTORIES(/usr/local/cuda/include ${MPI_INCLUDE_PATH})

FILE(GLOB SOURCES "*.cu" "*.cpp" "*.c" "*.h")
CUDA_ADD_EXECUTABLE(githash ${SOURCES})

LIST(APPEND CMAKE_CXX_FLAGS "-std=c++0x -O3 -ffast-math -Wall")

LIST(APPEND CUDA_NVCC_FLAGS --compiler-options -fno-strict-aliasing -lineinfo -use_fast_math -Xptxas -dlcm=cg)
# LIST(APPEND CUDA_NVCC_FLAGS -gencode arch=compute_20,code=sm_20)
LIST(APPEND CUDA_NVCC_FLAGS -gencode arch=compute_30,code=sm_30)
# LIST(APPEND CUDA_NVCC_FLAGS -gencode arch=compute_35,code=sm_35)

# TARGET_LINK_LIBRARIES(githash /usr/local/cuda/lib64/libcudart.so ${MPI_LIBRARIES})


15:13 sandbox$ cmake .
-- Configuring done
-- Generating done
-- Build files have been written to: /home/.../Dropbox (CRG)/.../sandbox
CMake, CUDA, FindCUDA
Issue History
2016-01-14 10:11qivNew Issue
2016-01-14 10:13qivTag Attached: CMake
2016-01-14 10:13qivTag Attached: CUDA
2016-01-14 10:13qivTag Attached: FindCUDA
2016-01-14 10:19qivNote Added: 0040234
2016-01-15 08:47Brad KingNote Added: 0040246
2016-01-15 10:11qivNote Added: 0040247
2016-01-19 10:44Brad KingStatusnew => resolved
2016-01-19 10:44Brad KingResolutionopen => fixed
2016-01-19 10:44Brad KingFixed in Version => CMake 3.5
2016-01-19 10:44Brad KingTarget Version => CMake 3.5
2016-02-17 15:29Brad KingNote Added: 0040501
2016-06-10 14:21Kitware RobotNote Added: 0041248
2016-06-10 14:21Kitware RobotStatusresolved => closed

Notes
(0040234)
qiv   
2016-01-14 10:19   
Sorry, I forgot to give credit to http://bikulov.org/blog/2013/12/24/example-of-cmake-file-for-cuda-plus-cpp-code/ [^] for the CMakeLists.txt!
(0040246)
Brad King   
2016-01-15 08:47   
Thanks. Please try this fix:

 FindCUDA: Support special characters in path
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6ccc3070 [^]
(0040247)
qiv   
2016-01-15 10:11   
Does work for me.

Actually the first VERBATIM is enough to get it running. However my file is not identically to the one in the fix, the line numbers differ and some neighbouring ones as well.
(0040501)
Brad King   
2016-02-17 15:29   
The change in 0015919:0040246 introduced a regression discussed here:

 FindCUDA.cmake regression in 3.5.0-rc2
 http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/15827 [^]

The fix for now is to revert use of VERBATIM with Visual Studio generators, but that will not affect the use case posted here.
(0041248)
Kitware Robot   
2016-06-10 14:21   
This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.