Skip to content

Commit

Permalink
[SUPERBUILD] fixes for FFTW3
Browse files Browse the repository at this point in the history
  • Loading branch information
KrisThielemans committed Jan 27, 2017
1 parent a667104 commit f180227
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 5 deletions.
114 changes: 114 additions & 0 deletions CMake/FindFFTW3.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# - Try to find FFTW3.
# Usage: find_package(FFTW3 [COMPONENTS [single double long-double threads]])
#
# Variables used by this module:
# FFTW3_ROOT_DIR - FFTW3 root directory
# Variables defined by this module:
# FFTW3_FOUND - system has FFTW3
# FFTW3_INCLUDE_DIR - the FFTW3 include directory (cached)
# FFTW3_INCLUDE_DIRS - the FFTW3 include directories
# (identical to FFTW3_INCLUDE_DIR)
# FFTW3[FL]?_LIBRARY - the FFTW3 library - double, single(F),
# long-double(L) precision (cached)
# FFTW3[FL]?_THREADS_LIBRARY - the threaded FFTW3 library - double, single(F),
# long-double(L) precision (cached)
# FFTW3_LIBRARIES - list of all FFTW3 libraries found

# Copyright (C) 2009-2010
# ASTRON (Netherlands Institute for Radio Astronomy)
# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
#
# This file is part of the LOFAR software suite.
# The LOFAR software suite is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# The LOFAR software suite is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>.
#
# $Id: FindFFTW3.cmake 15918 2010-06-25 11:12:42Z loose $

# Use double precision by default.
if(FFTW3_FIND_COMPONENTS MATCHES "^$")
set(_components double)
else()
set(_components ${FFTW3_FIND_COMPONENTS})
endif()

# Loop over each component.
set(_libraries)
foreach(_comp ${_components})
if(_comp STREQUAL "single")
list(APPEND _libraries fftw3f)
elseif(_comp STREQUAL "double")
list(APPEND _libraries fftw3)
elseif(_comp STREQUAL "long-double")
list(APPEND _libraries fftw3l)
elseif(_comp STREQUAL "threads")
set(_use_threads ON)
else()
message(FATAL_ERROR "FindFFTW3: unknown component `${_comp}' specified. "
"Valid components are `single', `double', `long-double', and `threads'.")
endif()
endforeach()

# If using threads, we need to link against threaded libraries as well.
if(_use_threads)
set(_thread_libs)
foreach(_lib ${_libraries})
list(APPEND _thread_libs ${_lib}_threads)
endforeach()
set(_libraries ${_thread_libs} ${_libraries})
endif()

# Keep a list of variable names that we need to pass on to
# find_package_handle_standard_args().
set(_check_list)

# Search for all requested libraries.
if (WIN32)

foreach(_lib ${_libraries})

string(TOUPPER ${_lib} _LIB)

find_library(${_LIB}_LIBRARY lib${_lib}-3
HINTS $ENV{FFTW3_ROOT_DIR} PATH_SUFFIXES lib)
mark_as_advanced(${_LIB}_LIBRARY)
list(APPEND FFTW3_LIBRARIES ${${_LIB}_LIBRARY})
list(APPEND _check_list ${_LIB}_LIBRARY)
endforeach()

message("FFTW3 WINDOWS libraries: " ${FFTW3_LIBRARIES})

else ()
foreach(_lib ${_libraries})

string(TOUPPER ${_lib} _LIB)

find_library(${_LIB}_LIBRARY ${_lib}
HINTS $ENV{FFTW3_ROOT_DIR} PATH_SUFFIXES lib)
mark_as_advanced(${_LIB}_LIBRARY)
list(APPEND FFTW3_LIBRARIES ${${_LIB}_LIBRARY})
list(APPEND _check_list ${_LIB}_LIBRARY)
endforeach()

message("FFTW3 UNIX libraries: " ${FFTW3_LIBRARIES})
endif ()

# Search for the header file.
find_path(FFTW3_INCLUDE_DIR fftw3.h
HINTS $ENV{FFTW3_ROOT_DIR} PATH_SUFFIXES include)
mark_as_advanced(FFTW3_INCLUDE_DIR)
list(APPEND _check_list FFTW3_INCLUDE_DIR)

# Handle the QUIETLY and REQUIRED arguments and set FFTW3_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FFTW3 DEFAULT_MSG ${_check_list})
4 changes: 2 additions & 2 deletions SuperBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ option(USE_SYSTEM_BOOST "Build using an external version of Boost" OFF)
option(USE_SYSTEM_STIR "Build using an external version of STIR" OFF)
option(USE_SYSTEM_HDF5 "Build using an external version of HDF5" OFF)
option(USE_SYSTEM_ISMRMRD "Build using an external version of ISMRMRD" OFF)
option(USE_SYSTEM_FFTW "Build using an external version of fftw" OFF)
option(USE_SYSTEM_FFTW3 "Build using an external version of fftw" OFF)
option(USE_SYSTEM_SIRF "Build using an external version of SIRF" OFF)


Expand All @@ -37,7 +37,7 @@ ExternalProject_Include_Dependencies(${proj} DEPENDS_VAR ${PRIMARY_PROJECT_NAME}
message(STATUS "")
message(STATUS "BOOST_ROOT = " ${BOOST_ROOT})
message(STATUS "ISMRMRD_ROOT = " ${ISMRMRD_ROOT})
message(STATUS "FFTW3_ROOT = " ${FFTW3_ROOT})
message(STATUS "FFTW3_ROOT_DIR = " ${FFTW3_ROOT_DIR})
message(STATUS "STIR_DIR = " ${STIR_DIR})
message(STATUS "HDF5_ROOT = " ${HDF5_ROOT})
message(STATUS "MATLAB_ROOT = " ${MATLAB_ROOT})
Expand Down
6 changes: 3 additions & 3 deletions SuperBuild/External_FFTW3.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#These need to be unique globally
set(externalProjName FFTW3)
set(proj FFTW3)

set(proj_COMPONENTS "COMPONENTS single")
# Set dependency list
set(${proj}_DEPENDENCIES "")

Expand Down Expand Up @@ -44,8 +44,8 @@ if(NOT ( DEFINED "USE_SYSTEM_${externalProjName}" AND "${USE_SYSTEM_${externalPr

else()
if(${USE_SYSTEM_${externalProjName}})
find_package(${proj} ${${externalProjName}_REQUIRED_VERSION} REQUIRED)
message("USING the system ${externalProjName}, set ${externalProjName}_DIR=${${externalProjName}_DIR}")
find_package(${proj} ${${externalProjName}_REQUIRED_VERSION} ${${externalProjName}_COMPONENTS} REQUIRED)
message(STATUS "USING the system ${externalProjName}, found FFTW3_INCLUDE_DIR=${FFTW3_INCLUDE_DIR}, FFTW3_LIBRARY=${FFTW3_LIBRARY}")
endif()
endif()

Expand Down

0 comments on commit f180227

Please sign in to comment.