Fix own-FFTW build
authorMark Abraham <mark.j.abraham@gmail.com>
Thu, 14 May 2015 09:29:27 +0000 (11:29 +0200)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Thu, 14 May 2015 22:01:46 +0000 (00:01 +0200)
Recent changes broke the expectation that the own-FFTW build attempts
to pretend to have run SIMD-support tests on the build that it has not
yet performed. This is all more complicated than it needs to be,
and will be refactored in master branch.

Fixes #1735

Change-Id: I9e5f296b199b6b5af685fa2ba87cc962a41a251f

cmake/gmxManageFFTLibraries.cmake
src/contrib/fftw/CMakeLists.txt

index bc66a18d92e91897f91b6811e18f150e05f24ae9..f8fcc47b16660e8e3ef380ae99211fcda1e11a63 100644 (file)
@@ -65,6 +65,12 @@ if(${GMX_FFT_LIBRARY} STREQUAL "FFTW3")
         set(FFTW fftwf)
     endif()
 
+    # Note that these calls are expected to function the same way,
+    # particularly with respect to setting CMake variables that
+    # record the presence of particular FFTW SIMD support.
+    # TODO There is no need for this requirement, all the remaining
+    # code here can be refactored to have just one check of
+    # GMX_BUILD_OWN_FFTW, which simplifies both code paths.
     if(GMX_BUILD_OWN_FFTW)
       add_subdirectory(src/contrib/fftw)
     else()
index c7d72989521fdc46130dbb3ae5e06bd1521b933f..2ad1501c685bbdcc71c10e9145d2be93ce39b0b7 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.
@@ -40,6 +40,9 @@
 # Input: FFTW variable contains the FFTW component to build,
 #        either fftw or fftwf for double or single precision
 
+string(TOUPPER "${FFTW}" UPPERFFTW)
+string(TOLOWER "${FFTW}" LOWERFFTW)
+
 set(GMX_BUILD_OWN_FFTW_OPTIMIZATION_CONFIGURATION "" CACHE INTERNAL "Optimization flags for FFTW compilation")
 if(${CMAKE_CURRENT_BINARY_DIR} MATCHES ".*[[:space:]].*")
     message(FATAL_ERROR "An internal limitation of FFTW means GROMACS cannot build FFTW in a directory with whitespace in its name. Either use a system FFTW, build it yourself, or build GROMACS in a different location.")
@@ -58,6 +61,9 @@ endif()
 # Testing shows FFTW configured with --enable-avx is never better than --enable-sse2, so we do the latter always.
 if(${GMX_SIMD} MATCHES "^(SSE|AVX)")
     set(GMX_BUILD_OWN_FFTW_OPTIMIZATION_CONFIGURATION --enable-sse2 CACHE INTERNAL "Optimization flags for FFTW compilation")
+    # Fake the result of the SIMD test, so the checks for x86 SIMD
+    # suport are silent
+    set(${UPPERFFTW}_HAVE_SSE2 TRUE PARENT_SCOPE)
 endif()
 
 # Allow cross-compiles
@@ -117,12 +123,11 @@ endif()
 
 ExternalProject_get_property(${EXTERNAL_FFTW_BUILD_TARGET} INSTALL_DIR)
 
-string(TOUPPER "${FFTW}" UPPERFFTW)
-string(TOLOWER "${FFTW}" LOWERFFTW)
 string(REGEX REPLACE "fftw" "fftw3" FFTW_LIBNAME ${LOWERFFTW})
 set(${UPPERFFTW}_LIBRARIES ${INSTALL_DIR}/lib/lib${FFTW_LIBNAME}${CMAKE_STATIC_LIBRARY_SUFFIX})
 set(${UPPERFFTW}_INCLUDE_DIRS ${INSTALL_DIR}/include PARENT_SCOPE)
 set(${UPPERFFTW}_FOUND TRUE PARENT_SCOPE)
+# TODO This is only true on x86, but does not actually cause a problem
 set(${UPPERFFTW}_HAVE_SIMD TRUE PARENT_SCOPE)
 
 add_library(gmxfftw STATIC IMPORTED GLOBAL)