[cmake-developers] Patch: FindCUDA.cmake -Wall Warnings

Michael Tanner michael.tanner at new.ox.ac.uk
Sat Mar 28 21:34:55 EDT 2015


When 'Wall' flag is set, FindCUDA.cmake generates literally thousands of
warnings from NVIDIA¹s header files (primarily -Wunused-function
warnings).  This patch (below email signature) removes those warnings by
using the
CMAKE_INCLUDE_SYSTEM_FLAG_C flag to treat NVIDIA’s include files as system
headers.
--
Michael Tanner


From 725d0d7d078bf6a150560a5aa4e1d11fe6691ec9 Mon Sep 17 00:00:00 2001
From: Michael Tanner <mtanner at robots.ox.ac.uk>
Date: Sun, 29 Mar 2015 00:55:34 +0000
Subject: [PATCH] Fixes FindCUDA.cmake to prevent system warnings

Previously, the NVIDIA header/implementaiton files would generate literally
thousands of warnings to comopile even the simpleste of CUDA projects with
"-Wall".
---
Modules/FindCUDA.cmake | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake
index 81e1cad..c79ff35 100644
--- a/Modules/FindCUDA.cmake
+++ b/Modules/FindCUDA.cmake
@@ -1097,7 +1097,8 @@ macro(CUDA_WRAP_SRCS cuda_target format
generated_files)
   endif()

   # Initialize our list of includes with the user ones followed by the
CUDA system ones.
-  set(CUDA_NVCC_INCLUDE_ARGS ${CUDA_NVCC_INCLUDE_ARGS_USER}
"-I${CUDA_INCLUDE_DIRS}")
+  string(STRIP ${CMAKE_INCLUDE_SYSTEM_FLAG_C}
CMAKE_INCLUDE_SYSTEM_FLAG_C_STRIPPED)
+  set(CUDA_NVCC_INCLUDE_ARGS ${CUDA_NVCC_INCLUDE_ARGS_USER}
${CMAKE_INCLUDE_SYSTEM_FLAG_C_STRIPPED} ${CUDA_INCLUDE_DIRS})
   # Get the include directories for this directory and use them for our
nvcc command.
   # Remove duplicate entries which may be present since
include_directories
   # in CMake >= 2.8.8 does not remove them.
--
2.1.0






More information about the cmake-developers mailing list