[cmake-developers] [CMake 0015240]: When compiling CUDA *.cu code, NVCC uses CXX_FLAGS when it should be using C_FLAGS

Mantis Bug Tracker mantis at public.kitware.com
Tue Nov 11 10:04:23 EST 2014


The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=15240 
====================================================================== 
Reported By:                jeremyherbert
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   15240
Category:                   CMake
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2014-11-11 10:04 EST
Last Modified:              2014-11-11 10:04 EST
====================================================================== 
Summary:                    When compiling CUDA *.cu code, NVCC uses CXX_FLAGS
when it should be using C_FLAGS
Description: 
When compiling cu files with cmake, it applies CXX_FLAGS to C compilation. See
the attached main.cu and CMakeLists.txt for an example. This can lead to
unnecessary warnings and errors as seen below:

$ make
-- Configuring done
-- Generating done
-- Build files have been written to: /home/jeremy/optix/jaguar/tmp/build
[ 50%] Building NVCC (Device) object
CMakeFiles/a_test.dir/a_test_generated_main.cu.o
cc1: warning: command line option ‘-std=c++11’ is valid for C++/ObjC++ but
not for C [enabled by default]
cc1: warning: command line option ‘-std=c++11’ is valid for C++/ObjC++ but
not for C [enabled by default]
[100%] Building NVCC intermediate link file
CMakeFiles/a_test.dir/a_test_intermediate_link.o
Linking CXX executable a_test
[100%] Built target a_test
$

if you use the -v option of nvcc, you can see that cmake is indeed applying the
wrong arguments to "gcc -x c":

...
#$ "/usr/bin"/gcc-4.8 -D__CUDA_ARCH__=200 -E -x c     
-DCUDA_DOUBLE_MATH_FUNCTIONS  -D__CUDACC__ -D__NVCC__ -D__CUDACC_RDC__
-D__CUDANVVM__  -std=c++11 -g -fPIC -g -fexceptions -fPIC -D__CUDA_PREC_DIV
-D__CUDA_PREC_SQRT -I"/usr/local/cuda-6.5/include"
-I"/usr/local/cuda-6.5/targets/x86_64-linux/include"
-I"/usr/local/cuda-6.5/include"
"-I/usr/local/cuda-6.5/bin/../targets/x86_64-linux/include"   -m64 -g -gdwarf-2
-o "/tmp/tmpxft_00003aee_00000000-7_main.cpp2.i"
"/tmp/tmpxft_00003aee_00000000-3_main.cudafe1.gpu"
cc1: warning: command line option ‘-std=c++11’ is valid for C++/ObjC++ but
not for C [enabled by default]
...

Steps to Reproduce: 
cmake the attached files.

Additional Information: 
see
http://stackoverflow.com/questions/26867352/cant-get-rid-of-warning-command-line-option-std-c11-using-nvcc-cuda-cma/26867522#26867522
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2014-11-11 10:04 jeremyherbert  New Issue                                    
2014-11-11 10:04 jeremyherbert  File Added: example.zip                      
======================================================================



More information about the cmake-developers mailing list