fix cmake re-running failure introduced by ef1127f
authorSzilard Pall <pszilard@cbr.su.se>
Thu, 29 Nov 2012 14:57:33 +0000 (15:57 +0100)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Thu, 29 Nov 2012 22:26:40 +0000 (23:26 +0100)
The find_package(CUDA) macro needs to be called even after we've done
the GPU detection/setup, otherwise functionality provided by this module
will not be available and CUDA compilation helper macros will not be
found.

Change-Id: I6320f20fc3189f5be57b7344ca8049ee418bc3fb

cmake/gmxManageGPU.cmake

index 168fe2897e2ae31f087b5f57db383dc7cff601d6..5db51b31b1fb143228bbebfb4cccaa3c84e0b9c9 100644 (file)
@@ -23,8 +23,18 @@ if (GMX_GPU OR GMX_GPU_AUTO AND NOT GMX_GPU_DETECTION_DONE)
     gmx_detect_gpu()
 endif()
 
+# We need to call find_package even when we've already done the detection/setup
+if(GMX_GPU OR GMX_GPU_AUTO)
+    # We support CUDA >=v3.2 on *nix, but <= v4.1 doesn't work with MSVC
+    if(MSVC)
+        find_package(CUDA 4.1)
+    else()
+        find_package(CUDA 3.2)
+    endif()
+endif()
+
 # Depending on the current vale of GMX_GPU and GMX_GPU_AUTO:
-# - OFF, FALSE: Will skip this detection.
+# - OFF, FALSE: Will skip this detection/setup.
 # - OFF, TRUE : Will keep GMX_GPU=OFF if no CUDA is detected, but will assemble
 #               a warning message which will be issued at the end of the
 #               configuration if GPU(s) were found in the build system.
@@ -32,13 +42,6 @@ endif()
 #               if it is not available.
 # - ON , TRUE : Can't happen (GMX_GPU=ON can only be user-set at this point)
 if(GMX_GPU OR GMX_GPU_AUTO AND NOT GMX_GPU_DETECTION_DONE)
-    # We support CUDA >=v3.2 on *nix, but <= v4.1 doesn't work with MSVC
-    if(MSVC)
-        find_package(CUDA 4.1)
-    else()
-        find_package(CUDA 3.2)
-    endif()
-
     if (EXISTS ${CUDA_TOOLKIT_ROOT_DIR})
         set(CUDA_FOUND TRUE CACHE INTERNAL "Whether the CUDA toolkit was found" FORCE)
     else()