View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0012099CMakeCMakepublic2011-04-17 10:072012-05-09 15:26
ReporterOfri Sadowsky 
Assigned ToJames Bigler 
PriorityhighSeveritymajorReproducibilityhave not tried
StatusclosedResolutionfixed 
PlatformOSWindows 7 x64OS Version
Product VersionCMake 2.8.4 
Target VersionCMake 2.8.7Fixed in VersionCMake 2.8.7 
Summary0012099: Unable to quote cmd line args to be passed to nvcc
DescriptionI am trying to build a CUDA project with Visual Studio 2010 and CMake.

I know that this is a sensitive issue.

Basically, I get a compilation error when nvcc tries to parse a stddef.h file, and runs into the use of an undefined macro named "nullptr".

A colleague of mine had patched my VS2010/CUDA setup so that with an ordinary VS project I can properly compile CUDA source files into .obj. One of the steps involved changing the VS rules so that the command line includes the following text:

  -Xcompiler "/Dnullptr=0 /Dnullptr_t=__nullptr_t /D__nullptr=((void*)0)"

The quotation marks are essential, because otherwise the parentheses around the (void *) are parsed incorrectly. As you can see, the missing macros are defined, so that the original problem is bypassed.

However hard I tried, I could not produce the proper quotation marks to be passed as nvcc command line arguments. It came to a point that when I take the command line produced within the CMake-generated VS project (using Verbose mode), and simply add the above options, my source file get compiled. But I can't get CMake to produce the same outcome.

Example: Use the OPTIONS flag on the cuda_add_library. By default, this simply separates the -Xcompiler from the rest of the stuff, and creates an invalid command line, where "Xcompiler" becomes one of the options for Xcompiler. If I remove the "-Xcompiler" then I can't get the quotation right around the options, and then the parentheses scramle things up.

It looks as though something is wrong in the way that the OPTIONS are parsed. I can't pinpoint the issue, and I can't get around it.
Steps To ReproduceYou can use an empty .cu file.

project(Test_CMake)

find_package(CUDA)

if(NOT CUDA_FOUND)
    message(SEND_ERROR "CUDA package not found!")
endif()

cuda_add_library(Test_CMake emptyfile.cu)


Try the various options.
TagsNo tags attached.
Attached Files

 Relationships
duplicate of 0011726closedJames Bigler Quotes in add_definitions causes bad command generation 

  Notes
(0026205)
Ofri Sadowsky (reporter)
2011-04-17 13:20

I continued to check on this issue, and I think I found out why the wrong quotation marks. In file run_nvcc.cmake, line 72:

  set(CUDA_NVCC_FLAGS "@CUDA_NVCC_FLAGS@;;@CUDA_WRAP_OPTION_NVCC_FLAGS@")

Notice the quotation marks wrapping around two variables. If any of the variables contains quotes of its own, it's screwed.

Two possible ways to address this:
1) Add "ESCAPE_QUOTES" in FindCUDA.cmake, line 1031
2) Remove teh quotes from run_nvcc.cmake.
(0026221)
James Bigler (developer)
2011-04-18 15:47

I marked this as a duplicate of 0011726, which deals with the same quote problem. Hopefully I'll get to this soon and fix all of these.
(0027981)
James Bigler (developer)
2011-12-14 22:58

This should be fixed in the 2.8.7 RC. Please try it and make sure it works for you.
(0029443)
David Cole (manager)
2012-05-09 15:26

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2011-04-17 10:07 Ofri Sadowsky New Issue
2011-04-17 13:20 Ofri Sadowsky Note Added: 0026205
2011-04-18 12:17 Brad King Assigned To => James Bigler
2011-04-18 12:17 Brad King Status new => assigned
2011-04-18 15:46 James Bigler Relationship added duplicate of 0011726
2011-04-18 15:47 James Bigler Note Added: 0026221
2011-12-14 22:58 James Bigler Note Added: 0027981
2011-12-14 22:58 James Bigler Status assigned => resolved
2011-12-14 22:58 James Bigler Fixed in Version => CMake 2.8.7
2011-12-14 22:58 James Bigler Resolution open => fixed
2011-12-16 17:15 David Cole Target Version => CMake 2.8.7
2012-05-09 15:26 David Cole Note Added: 0029443
2012-05-09 15:26 David Cole Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team