Fix BlueGene/Q build with recent CMake
authorMark Abraham <mark.j.abraham@gmail.com>
Mon, 5 Jan 2015 08:24:06 +0000 (08:24 +0000)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Fri, 16 Jan 2015 18:45:42 +0000 (19:45 +0100)
Works around broken FindCUDA.cmake in CMake 3.0 and 3.1, when cross
compiling, when the (optional) CMAKE_SYSTEM_PROCESSOR is not set.

Change-Id: I130ac95a84d4a67a7dbf6164ea93c37cda61066a

cmake/gmxManageGPU.cmake

index 69cbd5916d925fd1ec05b509d3bac4a1819ae34e..797f51cfbc479e098bb601fd5795141c8b77f1cf 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
+# Copyright (c) 2012,2013,2014,2015, by the GROMACS development team, led by
 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
 # and including many others, as listed in the AUTHORS file in the
 # top-level source directory and at http://www.gromacs.org.
@@ -57,8 +57,19 @@ if ((GMX_GPU OR GMX_GPU_AUTO) AND NOT GMX_GPU_DETECTION_DONE)
     gmx_detect_gpu()
 endif()
 
+# CMake 3.0-3.1 has a bug in the following case, which breaks
+# configuration on at least BlueGene/Q. A patch for that bug has been
+# accepted for upcoming CMake 3.2.
+if ((NOT CMAKE_VERSION VERSION_LESS "3.0.0") AND
+    (CMAKE_VERSION VERSION_LESS "3.2.0") AND
+        (CMAKE_CROSSCOMPILING AND NOT CMAKE_SYSTEM_PROCESSOR))
+    message(STATUS "Cannot search for CUDA because the CMake find package has a bug. Set a valid CMAKE_SYSTEM_PROCESSOR if you need to detect CUDA")
+else()
+    set(CAN_RUN_CUDA_FIND_PACKAGE 1)
+endif()
+
 # We need to call find_package even when we've already done the detection/setup
-if(GMX_GPU OR GMX_GPU_AUTO)
+if(GMX_GPU OR GMX_GPU_AUTO AND CAN_RUN_CUDA_FIND_PACKAGE)
     if(NOT GMX_GPU AND NOT GMX_DETECT_GPU_AVAILABLE)
         # Stay quiet when detection has occured and found no GPU.
         # Noise is acceptable when there is a GPU or the user required one.