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 ====================================================================== -- 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
