Hi,

The FindCUDA.cmake module since v3.0 has had a bug because it assumes that
when cross compiling that CMAKE_SYSTEM_PROCESSOR will be defined. That
definition is documented as optional at
http://www.vtk.org/Wiki/CMake_Cross_Compiling, and the module can't work if
it happens to be undefined. Attached patch
wraps the uses of CMAKE_SYSTEM_PROCESSOR in quotes so that interpolation
will lead to the intended behaviour in all cases.

I haven't filed a bug report, per
http://www.cmake.org/Wiki/CMake_FAQ#I_found_a_Bug.21_What_should_I_do.3F

Thanks,

Mark
From ff32fca999767e57b48ec68c30b093207c560a2f Mon Sep 17 00:00:00 2001
From: Mark Abraham <mark.j.abra...@gmail.com>
Date: Sun, 4 Jan 2015 14:37:51 +0100
Subject: [PATCH] Fix FindCUDA.cmake assumption about cross-compiling

CMAKE_SYSTEM_PROCESSOR is not guaranteed to be defined (per
http://www.vtk.org/Wiki/CMake_Cross_Compiling), and when cross
compiling where it happens to be undefined, this module was broken.
---
 Modules/FindCUDA.cmake | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake
index 29bb875..55b868e 100644
--- a/Modules/FindCUDA.cmake
+++ b/Modules/FindCUDA.cmake
@@ -613,7 +613,7 @@ endif()
 set(CUDA_VERSION_STRING "${CUDA_VERSION}")
 
 # Support for arm cross compilation with CUDA 5.5
-if(CUDA_VERSION VERSION_GREATER "5.0" AND CMAKE_CROSSCOMPILING AND ${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm" AND EXISTS "${CUDA_TOOLKIT_ROOT_DIR}/targets/armv7-linux-gnueabihf")
+if(CUDA_VERSION VERSION_GREATER "5.0" AND CMAKE_CROSSCOMPILING AND "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm" AND EXISTS "${CUDA_TOOLKIT_ROOT_DIR}/targets/armv7-linux-gnueabihf")
   set(CUDA_TOOLKIT_TARGET_DIR "${CUDA_TOOLKIT_ROOT_DIR}/targets/armv7-linux-gnueabihf" CACHE PATH "Toolkit target location.")
 else()
   set(CUDA_TOOLKIT_TARGET_DIR "${CUDA_TOOLKIT_ROOT_DIR}" CACHE PATH "Toolkit target location.")
@@ -621,7 +621,7 @@ endif()
 mark_as_advanced(CUDA_TOOLKIT_TARGET_DIR)
 
 # Target CPU architecture
-if(CUDA_VERSION VERSION_GREATER "5.0" AND CMAKE_CROSSCOMPILING AND ${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
+if(CUDA_VERSION VERSION_GREATER "5.0" AND CMAKE_CROSSCOMPILING AND "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm")
   set(_cuda_target_cpu_arch_initial "ARM")
 else()
   set(_cuda_target_cpu_arch_initial "")
-- 
2.2.1

-- 

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

Reply via email to