[cmake-developers] [CMake 0012099]: Unable to quote cmd line args to be passed to nvcc

Mantis Bug Tracker mantis at public.kitware.com
Sun Apr 17 10:07:46 EDT 2011


The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=12099 
====================================================================== 
Reported By:                Ofri Sadowsky
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   12099
Category:                   CMake
Reproducibility:            have not tried
Severity:                   major
Priority:                   high
Status:                     new
====================================================================== 
Date Submitted:             2011-04-17 10:07 EDT
Last Modified:              2011-04-17 10:07 EDT
====================================================================== 
Summary:                    Unable to quote cmd line args to be passed to nvcc
Description: 
I 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 Reproduce: 
You 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.
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2011-04-17 10:07 Ofri Sadowsky  New Issue                                    
======================================================================




More information about the cmake-developers mailing list