From d2580e08d9df42be774f7c838d4498895a225427 Mon Sep 17 00:00:00 2001 From: Mark Abraham Date: Mon, 5 Jan 2015 08:24:06 +0000 Subject: [PATCH] Fix BlueGene/Q build with recent CMake 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 | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/cmake/gmxManageGPU.cmake b/cmake/gmxManageGPU.cmake index 69cbd5916d..797f51cfbc 100644 --- a/cmake/gmxManageGPU.cmake +++ b/cmake/gmxManageGPU.cmake @@ -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. -- 2.22.0