Commit 31554d84 authored by Florent Pruvost's avatar Florent Pruvost

update FindFFTW to be found with pkg-config

parent 129cf214
......@@ -64,10 +64,10 @@
if (NOT FFTW_FOUND)
set(FFTW_DIR "" CACHE PATH "Installation directory of FFTW library given by user")
if (NOT FFTW_FIND_QUIETLY)
message(STATUS "A cache variable, namely FFTW_DIR, has been set to specify the install directory of FFTW")
endif()
set(FFTW_DIR "" CACHE PATH "Installation directory of FFTW library given by user")
if (NOT FFTW_FIND_QUIETLY)
message(STATUS "A cache variable, namely FFTW_DIR, has been set to specify the install directory of FFTW")
endif()
endif()
# Set the version to find
......@@ -80,223 +80,264 @@ set(FFTW_LOOK_FOR_FFTW_LONG OFF)
set(FFTW_LOOK_FOR_FFTW_QUAD OFF)
if( FFTW_FIND_COMPONENTS )
foreach( component ${FFTW_FIND_COMPONENTS} )
if (${component} STREQUAL "THREADS")
# means we look for the Threads version of FFTW
set(FFTW_LOOK_FOR_THREADS ON)
endif()
if (${component} STREQUAL "OMP")
# means we look for the OpenMP version of FFTW
set(FFTW_LOOK_FOR_OMP ON)
endif()
if (${component} STREQUAL "SIMPLE")
# means we look for FFTW simple precision (fftw3f)
set(FFTW_LOOK_FOR_FFTW_SIMPLE ON)
set(FFTW_LOOK_FOR_FFTW_DOUBLE OFF)
set(FFTW_LOOK_FOR_FFTW_LONG OFF)
set(FFTW_LOOK_FOR_FFTW_QUAD OFF)
endif()
if (${component} STREQUAL "DOUBLE")
# means we look for FFTW double precision (fftw3)
set(FFTW_LOOK_FOR_FFTW_SIMPLE OFF)
set(FFTW_LOOK_FOR_FFTW_DOUBLE ON)
set(FFTW_LOOK_FOR_FFTW_LONG OFF)
set(FFTW_LOOK_FOR_FFTW_QUAD OFF)
endif()
if (${component} STREQUAL "LONG")
# means we look for FFTW long double precision (fftw3l)
set(FFTW_LOOK_FOR_FFTW_SIMPLE OFF)
set(FFTW_LOOK_FOR_FFTW_DOUBLE OFF)
set(FFTW_LOOK_FOR_FFTW_LONG ON)
set(FFTW_LOOK_FOR_FFTW_QUAD OFF)
endif()
if (${component} STREQUAL "QUAD")
# means we look for FFTW quad precision (fftw3q)
set(FFTW_LOOK_FOR_FFTW_SIMPLE OFF)
set(FFTW_LOOK_FOR_FFTW_DOUBLE OFF)
set(FFTW_LOOK_FOR_FFTW_LONG OFF)
set(FFTW_LOOK_FOR_FFTW_QUAD ON)
endif()
if (${component} STREQUAL "MKL")
# means we look for the Intel MKL version of FFTW
set(FFTW_LOOK_FOR_MKL ON)
if (FFTW_LOOK_FOR_FFTW_LONG)
message(WARNING "Looking for FFTW -- long precision functions do not exist in MKL FFTW")
set(FFTW_LOOK_FOR_FFTW_LONG OFF)
endif()
if (FFTW_LOOK_FOR_FFTW_QUAD)
message(WARNING "Looking for FFTW -- quadruple functions do not exist in MKL FFTW")
set(FFTW_LOOK_FOR_FFTW_QUAD OFF)
endif()
endif()
endforeach()
foreach( component ${FFTW_FIND_COMPONENTS} )
if (${component} STREQUAL "THREADS")
# means we look for the Threads version of FFTW
set(FFTW_LOOK_FOR_THREADS ON)
endif()
if (${component} STREQUAL "OMP")
# means we look for the OpenMP version of FFTW
set(FFTW_LOOK_FOR_OMP ON)
endif()
if (${component} STREQUAL "SIMPLE")
# means we look for FFTW simple precision (fftw3f)
set(FFTW_LOOK_FOR_FFTW_SIMPLE ON)
set(FFTW_LOOK_FOR_FFTW_DOUBLE OFF)
set(FFTW_LOOK_FOR_FFTW_LONG OFF)
set(FFTW_LOOK_FOR_FFTW_QUAD OFF)
endif()
if (${component} STREQUAL "DOUBLE")
# means we look for FFTW double precision (fftw3)
set(FFTW_LOOK_FOR_FFTW_SIMPLE OFF)
set(FFTW_LOOK_FOR_FFTW_DOUBLE ON)
set(FFTW_LOOK_FOR_FFTW_LONG OFF)
set(FFTW_LOOK_FOR_FFTW_QUAD OFF)
endif()
if (${component} STREQUAL "LONG")
# means we look for FFTW long double precision (fftw3l)
set(FFTW_LOOK_FOR_FFTW_SIMPLE OFF)
set(FFTW_LOOK_FOR_FFTW_DOUBLE OFF)
set(FFTW_LOOK_FOR_FFTW_LONG ON)
set(FFTW_LOOK_FOR_FFTW_QUAD OFF)
endif()
if (${component} STREQUAL "QUAD")
# means we look for FFTW quad precision (fftw3q)
set(FFTW_LOOK_FOR_FFTW_SIMPLE OFF)
set(FFTW_LOOK_FOR_FFTW_DOUBLE OFF)
set(FFTW_LOOK_FOR_FFTW_LONG OFF)
set(FFTW_LOOK_FOR_FFTW_QUAD ON)
endif()
if (${component} STREQUAL "MKL")
# means we look for the Intel MKL version of FFTW
set(FFTW_LOOK_FOR_MKL ON)
if (FFTW_LOOK_FOR_FFTW_LONG)
message(WARNING "Looking for FFTW -- long precision functions do not exist in MKL FFTW")
set(FFTW_LOOK_FOR_FFTW_LONG OFF)
endif()
if (FFTW_LOOK_FOR_FFTW_QUAD)
message(WARNING "Looking for FFTW -- quadruple functions do not exist in MKL FFTW")
set(FFTW_LOOK_FOR_FFTW_QUAD OFF)
endif()
endif()
endforeach()
endif()
if (FFTW_LOOK_FOR_THREADS)
if (FFTW_FIND_REQUIRED AND FFTW_FIND_REQUIRED_THREADS)
find_package(Threads REQUIRED)
else()
find_package(Threads)
endif()
if (FFTW_FIND_REQUIRED AND FFTW_FIND_REQUIRED_THREADS)
find_package(Threads REQUIRED)
else()
find_package(Threads)
endif()
endif()
if (FFTW_LOOK_FOR_MKL)
if (FFTW_FIND_REQUIRED AND FFTW_FIND_REQUIRED_MKL)
find_package(Threads REQUIRED)
else()
find_package(Threads)
endif()
if (FFTW_FIND_REQUIRED AND FFTW_FIND_REQUIRED_MKL)
find_package(Threads REQUIRED)
else()
find_package(Threads)
endif()
endif()
if (FFTW_LOOK_FOR_OMP)
if (FFTW_FIND_REQUIRED AND FFTW_FIND_REQUIRED_OMP)
find_package(OpenMP REQUIRED)
else()
find_package(OpenMP)
endif()
if (FFTW_FIND_REQUIRED AND FFTW_FIND_REQUIRED_OMP)
find_package(OpenMP REQUIRED)
else()
find_package(OpenMP)
endif()
endif()
# Looking for include
# -------------------
# Add system include paths to search include
# ------------------------------------------
unset(_inc_env)
set(ENV_MKLROOT "$ENV{MKLROOT}")
set(ENV_FFTW_DIR "$ENV{FFTW_DIR}")
set(ENV_FFTW_INCDIR "$ENV{FFTW_INCDIR}")
if(ENV_FFTW_INCDIR)
set(ENV_FFTW_LIBDIR "$ENV{FFTW_LIBDIR}")
set(FFTW_GIVEN_BY_USER "FALSE")
if ( FFTW_DIR OR ( FFTW_INCDIR AND FFTW_LIBDIR) OR ENV_FFTW_DIR OR (ENV_FFTW_INCDIR AND ENV_FFTW_LIBDIR) )
set(FFTW_GIVEN_BY_USER "TRUE")
endif()
# Optionally use pkg-config to detect include/library dirs (if pkg-config is available)
# -------------------------------------------------------------------------------------
include(FindPkgConfig)
find_package(PkgConfig QUIET)
if( PKG_CONFIG_EXECUTABLE AND NOT FFTW_GIVEN_BY_USER )
pkg_search_module(FFTW fftw3)
if (NOT FFTW_FIND_QUIETLY)
if (FFTW_FOUND AND FFTW_LIBRARIES)
message(STATUS "Looking for FFTW - found using PkgConfig")
#if(NOT FFTW_INCLUDE_DIRS)
# message("${Magenta}FFTW_INCLUDE_DIRS is empty using PkgConfig."
# "Perhaps the path to hwloc headers is already present in your"
# "C(PLUS)_INCLUDE_PATH environment variable.${ColourReset}")
#endif()
else()
message("${Magenta}Looking for FFTW - not found using PkgConfig."
"Perhaps you should add the directory containing fftw3.pc to"
"the PKG_CONFIG_PATH environment variable.${ColourReset}")
endif()
endif()
set(FFTW_INCLUDE_DIRS_DEP "${FFTW_INCLUDE_DIRS}")
set(FFTW_LIBRARY_DIRS_DEP "${FFTW_LIBRARY_DIRS}")
set(FFTW_LIBRARIES_DEP "${FFTW_LIBRARIES}")
set(FFTW_WORKS TRUE)
endif( PKG_CONFIG_EXECUTABLE AND NOT FFTW_GIVEN_BY_USER )
if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT FFTW_FOUND) OR (FFTW_GIVEN_BY_USER) )
# Looking for include
# -------------------
# Add system include paths to search include
# ------------------------------------------
unset(_inc_env)
set(ENV_MKLROOT "$ENV{MKLROOT}")
set(ENV_FFTW_DIR "$ENV{FFTW_DIR}")
set(ENV_FFTW_INCDIR "$ENV{FFTW_INCDIR}")
if(ENV_FFTW_INCDIR)
list(APPEND _inc_env "${ENV_FFTW_INCDIR}")
elseif(ENV_FFTW_DIR)
elseif(ENV_FFTW_DIR)
list(APPEND _inc_env "${ENV_FFTW_DIR}")
list(APPEND _inc_env "${ENV_FFTW_DIR}/include")
list(APPEND _inc_env "${ENV_FFTW_DIR}/include/fftw")
else()
else()
if (ENV_MKLROOT)
list(APPEND _inc_env "${ENV_MKLROOT}/include/fftw")
list(APPEND _inc_env "${ENV_MKLROOT}/include/fftw")
endif()
# system variables
if(WIN32)
string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}")
list(APPEND _inc_env "${_path_env}")
else()
string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{CPATH}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{CPATH}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}")
list(APPEND _inc_env "${_path_env}")
endif()
endif()
list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}")
list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}")
list(REMOVE_DUPLICATES _inc_env)
# set paths where to look for
set(PATH_TO_LOOK_FOR "${_inc_env}")
# Try to find the fftw header in the given paths
# -------------------------------------------------
# call cmake macro to find the header path
if(FFTW_INCDIR)
endif()
list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}")
list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}")
list(REMOVE_DUPLICATES _inc_env)
# set paths where to look for
set(PATH_TO_LOOK_FOR "${_inc_env}")
# Try to find the fftw header in the given paths
# -------------------------------------------------
# call cmake macro to find the header path
if(FFTW_INCDIR)
set(FFTW_fftw3.h_DIRS "FFTW_fftw3.h_DIRS-NOTFOUND")
find_path(FFTW_fftw3.h_DIRS
NAMES fftw3.h
HINTS ${FFTW_INCDIR})
else()
else()
if(FFTW_DIR)
set(FFTW_fftw3.h_DIRS "FFTW_fftw3.h_DIRS-NOTFOUND")
find_path(FFTW_fftw3.h_DIRS
NAMES fftw3.h
HINTS ${FFTW_DIR}
PATH_SUFFIXES "include" "include/fftw")
set(FFTW_fftw3.h_DIRS "FFTW_fftw3.h_DIRS-NOTFOUND")
find_path(FFTW_fftw3.h_DIRS
NAMES fftw3.h
HINTS ${FFTW_DIR}
PATH_SUFFIXES "include" "include/fftw")
else()
set(FFTW_fftw3.h_DIRS "FFTW_fftw3.h_DIRS-NOTFOUND")
find_path(FFTW_fftw3.h_DIRS
NAMES fftw3.h
HINTS ${PATH_TO_LOOK_FOR}
PATH_SUFFIXES "fftw")
set(FFTW_fftw3.h_DIRS "FFTW_fftw3.h_DIRS-NOTFOUND")
find_path(FFTW_fftw3.h_DIRS
NAMES fftw3.h
HINTS ${PATH_TO_LOOK_FOR}
PATH_SUFFIXES "fftw")
endif()
endif()
mark_as_advanced(FFTW_fftw3.h_DIRS)
endif()
mark_as_advanced(FFTW_fftw3.h_DIRS)
# Add path to cmake variable
# ------------------------------------
if (FFTW_fftw3.h_DIRS)
# Add path to cmake variable
# ------------------------------------
if (FFTW_fftw3.h_DIRS)
set(FFTW_INCLUDE_DIRS "${FFTW_fftw3.h_DIRS}")
else ()
else ()
set(FFTW_INCLUDE_DIRS "FFTW_INCLUDE_DIRS-NOTFOUND")
if(NOT FFTW_FIND_QUIETLY)
message(STATUS "Looking for FFTW -- fftw3.h not found")
message(STATUS "Looking for FFTW -- fftw3.h not found")
endif()
endif ()
endif ()
# Looking for lib
# ---------------
# Looking for lib
# ---------------
# Add system library paths to search lib
# --------------------------------------
unset(_lib_env)
set(ENV_FFTW_LIBDIR "$ENV{FFTW_LIBDIR}")
if(ENV_FFTW_LIBDIR)
# Add system library paths to search lib
# --------------------------------------
unset(_lib_env)
set(ENV_FFTW_LIBDIR "$ENV{FFTW_LIBDIR}")
if(ENV_FFTW_LIBDIR)
list(APPEND _lib_env "${ENV_FFTW_LIBDIR}")
elseif(ENV_FFTW_DIR)
elseif(ENV_FFTW_DIR)
list(APPEND _lib_env "${ENV_FFTW_DIR}")
list(APPEND _lib_env "${ENV_FFTW_DIR}/lib")
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
list(APPEND _lib_env "${ENV_FFTW_DIR}/lib64")
list(APPEND _lib_env "${ENV_FFTW_DIR}/lib/intel64")
list(APPEND _lib_env "${ENV_FFTW_DIR}/lib64")
list(APPEND _lib_env "${ENV_FFTW_DIR}/lib/intel64")
else()
list(APPEND _lib_env "${ENV_FFTW_DIR}/lib32")
list(APPEND _lib_env "${ENV_FFTW_DIR}/lib/ia32")
list(APPEND _lib_env "${ENV_FFTW_DIR}/lib32")
list(APPEND _lib_env "${ENV_FFTW_DIR}/lib/ia32")
endif()
else()
else()
if (ENV_MKLROOT)
list(APPEND _lib_env "${ENV_MKLROOT}/lib")
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
list(APPEND _lib_env "${ENV_MKLROOT}/lib64")
list(APPEND _lib_env "${ENV_MKLROOT}/lib/intel64")
else()
list(APPEND _lib_env "${ENV_MKLROOT}/lib32")
list(APPEND _lib_env "${ENV_MKLROOT}/lib/ia32")
endif()
list(APPEND _lib_env "${ENV_MKLROOT}/lib")
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
list(APPEND _lib_env "${ENV_MKLROOT}/lib64")
list(APPEND _lib_env "${ENV_MKLROOT}/lib/intel64")
else()
list(APPEND _lib_env "${ENV_MKLROOT}/lib32")
list(APPEND _lib_env "${ENV_MKLROOT}/lib/ia32")
endif()
endif()
if(WIN32)
string(REPLACE ":" ";" _lib_env2 "$ENV{LIB}")
string(REPLACE ":" ";" _lib_env2 "$ENV{LIB}")
else()
if(APPLE)
string(REPLACE ":" ";" _lib_env2 "$ENV{DYLD_LIBRARY_PATH}")
else()
string(REPLACE ":" ";" _lib_env2 "$ENV{LD_LIBRARY_PATH}")
endif()
list(APPEND _lib_env "${_lib_env2}")
list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}")
list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}")
if(APPLE)
string(REPLACE ":" ";" _lib_env2 "$ENV{DYLD_LIBRARY_PATH}")
else()
string(REPLACE ":" ";" _lib_env2 "$ENV{LD_LIBRARY_PATH}")
endif()
list(APPEND _lib_env "${_lib_env2}")
list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}")
list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}")
endif()
endif()
list(REMOVE_DUPLICATES _lib_env)
endif()
list(REMOVE_DUPLICATES _lib_env)
# set paths where to look for
set(PATH_TO_LOOK_FOR "${_lib_env}")
# set paths where to look for
set(PATH_TO_LOOK_FOR "${_lib_env}")
if(FFTW_LOOK_FOR_FFTW_SIMPLE)
if(FFTW_LOOK_FOR_FFTW_SIMPLE)
set(FFTW_PREC "f")
set(FFTW_PREC_TESTFUNC "s")
elseif(FFTW_LOOK_FOR_FFTW_DOUBLE)
elseif(FFTW_LOOK_FOR_FFTW_DOUBLE)
set(FFTW_PREC "")
set(FFTW_PREC_TESTFUNC "d")
elseif(FFTW_LOOK_FOR_FFTW_LONG)
elseif(FFTW_LOOK_FOR_FFTW_LONG)
set(FFTW_PREC "l")
set(FFTW_PREC_TESTFUNC "l")
elseif(FFTW_LOOK_FOR_FFTW_QUAD)
elseif(FFTW_LOOK_FOR_FFTW_QUAD)
set(FFTW_PREC "q")
set(FFTW_PREC_TESTFUNC "q")
endif()
endif()
if (FFTW_LOOK_FOR_MKL)
if (FFTW_LOOK_FOR_MKL)
set(FFTW_libs_to_find "mkl_intel_lp64;mkl_sequential;mkl_core")
......@@ -305,39 +346,39 @@ if (FFTW_LOOK_FOR_MKL)
# call cmake macro to find the lib path
if(FFTW_LIBDIR)
foreach(fftw_lib ${FFTW_libs_to_find})
set(FFTW_${fftw_lib}_LIBRARY "FFTW_${fftw_lib}_LIBRARY-NOTFOUND")
find_library(FFTW_${fftw_lib}_LIBRARY
NAMES ${fftw_lib}
HINTS ${FFTW_LIBDIR})
endforeach()
foreach(fftw_lib ${FFTW_libs_to_find})
set(FFTW_${fftw_lib}_LIBRARY "FFTW_${fftw_lib}_LIBRARY-NOTFOUND")
find_library(FFTW_${fftw_lib}_LIBRARY
NAMES ${fftw_lib}
HINTS ${FFTW_LIBDIR})
endforeach()
else()
if(FFTW_DIR)
foreach(fftw_lib ${FFTW_libs_to_find})
set(FFTW_${fftw_lib}_LIBRARY "FFTW_${fftw_lib}_LIBRARY-NOTFOUND")
find_library(FFTW_${fftw_lib}_LIBRARY
NAMES ${fftw_lib}
HINTS ${FFTW_DIR}
PATH_SUFFIXES lib lib32 lib64)
endforeach()
else()
foreach(fftw_lib ${FFTW_libs_to_find})
set(FFTW_${fftw_lib}_LIBRARY "FFTW_${fftw_lib}_LIBRARY-NOTFOUND")
find_library(FFTW_${fftw_lib}_LIBRARY
NAMES ${fftw_lib}
HINTS ${PATH_TO_LOOK_FOR})
endforeach()
endif()
if(FFTW_DIR)
foreach(fftw_lib ${FFTW_libs_to_find})
set(FFTW_${fftw_lib}_LIBRARY "FFTW_${fftw_lib}_LIBRARY-NOTFOUND")
find_library(FFTW_${fftw_lib}_LIBRARY
NAMES ${fftw_lib}
HINTS ${FFTW_DIR}
PATH_SUFFIXES lib lib32 lib64)
endforeach()
else()
foreach(fftw_lib ${FFTW_libs_to_find})
set(FFTW_${fftw_lib}_LIBRARY "FFTW_${fftw_lib}_LIBRARY-NOTFOUND")
find_library(FFTW_${fftw_lib}_LIBRARY
NAMES ${fftw_lib}
HINTS ${PATH_TO_LOOK_FOR})
endforeach()
endif()
endif()
else(FFTW_LOOK_FOR_MKL)
else(FFTW_LOOK_FOR_MKL)
if (FFTW_LOOK_FOR_THREADS)
set(FFTW_libs_to_find "fftw3${FFTW_PREC}_threads;fftw3${FFTW_PREC};fftw3")
set(FFTW_libs_to_find "fftw3${FFTW_PREC}_threads;fftw3${FFTW_PREC};fftw3")
elseif (FFTW_LOOK_FOR_OMP)
set(FFTW_libs_to_find "fftw3${FFTW_PREC}_omp;fftw3${FFTW_PREC};fftw3")
set(FFTW_libs_to_find "fftw3${FFTW_PREC}_omp;fftw3${FFTW_PREC};fftw3")
else()
set(FFTW_libs_to_find "fftw3${FFTW_PREC};fftw3")
set(FFTW_libs_to_find "fftw3${FFTW_PREC};fftw3")
endif()
# Try to find the fftw lib in the given paths
......@@ -345,59 +386,59 @@ else(FFTW_LOOK_FOR_MKL)
# call cmake macro to find the lib path
if(FFTW_LIBDIR)
foreach(fftw_lib ${FFTW_libs_to_find})
set(FFTW_${fftw_lib}_LIBRARY "FFTW_${fftw_lib}_LIBRARY-NOTFOUND")
find_library(FFTW_${fftw_lib}_LIBRARY
NAMES ${fftw_lib}
HINTS ${FFTW_LIBDIR})
endforeach()
foreach(fftw_lib ${FFTW_libs_to_find})
set(FFTW_${fftw_lib}_LIBRARY "FFTW_${fftw_lib}_LIBRARY-NOTFOUND")
find_library(FFTW_${fftw_lib}_LIBRARY
NAMES ${fftw_lib}
HINTS ${FFTW_LIBDIR})
endforeach()
else()
if(FFTW_DIR)
foreach(fftw_lib ${FFTW_libs_to_find})
set(FFTW_${fftw_lib}_LIBRARY "FFTW_${fftw_lib}_LIBRARY-NOTFOUND")
find_library(FFTW_${fftw_lib}_LIBRARY
NAMES ${fftw_lib}
HINTS ${FFTW_DIR}
PATH_SUFFIXES lib lib32 lib64)
endforeach()
else()
foreach(fftw_lib ${FFTW_libs_to_find})
set(FFTW_${fftw_lib}_LIBRARY "FFTW_${fftw_lib}_LIBRARY-NOTFOUND")
find_library(FFTW_${fftw_lib}_LIBRARY
NAMES ${fftw_lib}
HINTS ${PATH_TO_LOOK_FOR})
endforeach()
endif()
if(FFTW_DIR)
foreach(fftw_lib ${FFTW_libs_to_find})
set(FFTW_${fftw_lib}_LIBRARY "FFTW_${fftw_lib}_LIBRARY-NOTFOUND")
find_library(FFTW_${fftw_lib}_LIBRARY
NAMES ${fftw_lib}
HINTS ${FFTW_DIR}
PATH_SUFFIXES lib lib32 lib64)
endforeach()
else()
foreach(fftw_lib ${FFTW_libs_to_find})
set(FFTW_${fftw_lib}_LIBRARY "FFTW_${fftw_lib}_LIBRARY-NOTFOUND")
find_library(FFTW_${fftw_lib}_LIBRARY
NAMES ${fftw_lib}
HINTS ${PATH_TO_LOOK_FOR})
endforeach()
endif()
endif()
endif(FFTW_LOOK_FOR_MKL)
endif(FFTW_LOOK_FOR_MKL)
# If found, add path to cmake variable
# ------------------------------------
set(FFTW_LIBRARIES "")
set(FFTW_LIBRARY_DIRS "")
foreach(fftw_lib ${FFTW_libs_to_find})
# If found, add path to cmake variable
# ------------------------------------
set(FFTW_LIBRARIES "")
set(FFTW_LIBRARY_DIRS "")
foreach(fftw_lib ${FFTW_libs_to_find})
if (FFTW_${fftw_lib}_LIBRARY)
get_filename_component(${fftw_lib}_lib_path "${FFTW_${fftw_lib}_LIBRARY}" PATH)
# set cmake variables
list(APPEND FFTW_LIBRARIES "${FFTW_${fftw_lib}_LIBRARY}")
list(APPEND FFTW_LIBRARY_DIRS "${${fftw_lib}_lib_path}")
get_filename_component(${fftw_lib}_lib_path "${FFTW_${fftw_lib}_LIBRARY}" PATH)
# set cmake variables
list(APPEND FFTW_LIBRARIES "${FFTW_${fftw_lib}_LIBRARY}")
list(APPEND FFTW_LIBRARY_DIRS "${${fftw_lib}_lib_path}")
else ()
list(APPEND FFTW_LIBRARIES "${FFTW_${fftw_lib}_LIBRARY}")
if (NOT FFTW_FIND_QUIETLY)
message(STATUS "Looking for FFTW -- lib ${fftw_lib} not found")
endif()
list(APPEND FFTW_LIBRARIES "${FFTW_${fftw_lib}_LIBRARY}")
if (NOT FFTW_FIND_QUIETLY)
message(STATUS "Looking for FFTW -- lib ${fftw_lib} not found")
endif()
endif ()
mark_as_advanced(FFTW_${fftw_lib}_LIBRARY)
endforeach()
endforeach()
list(REMOVE_DUPLICATES FFTW_INCLUDE_DIRS)
list(REMOVE_DUPLICATES FFTW_LIBRARY_DIRS)
list(REMOVE_DUPLICATES FFTW_INCLUDE_DIRS)
list(REMOVE_DUPLICATES FFTW_LIBRARY_DIRS)
# check a function to validate the find
if(FFTW_LIBRARIES)
# check a function to validate the find
if(FFTW_LIBRARIES)
set(REQUIRED_FLAGS)
set(REQUIRED_LDFLAGS)
......@@ -407,39 +448,39 @@ if(FFTW_LIBRARIES)
# FFTW
if (FFTW_INCLUDE_DIRS)
set(REQUIRED_INCDIRS "${FFTW_INCLUDE_DIRS}")
set(REQUIRED_INCDIRS "${FFTW_INCLUDE_DIRS}")
endif()
if (FFTW_LIBRARY_DIRS)
set(REQUIRED_LIBDIRS "${FFTW_LIBRARY_DIRS}")
set(REQUIRED_LIBDIRS "${FFTW_LIBRARY_DIRS}")
endif()
set(REQUIRED_LIBS "${FFTW_LIBRARIES}")
# THREADS
if (FFTW_LOOK_FOR_THREADS)
list(APPEND REQUIRED_LIBS "${CMAKE_THREAD_LIBS_INIT}")
list(APPEND REQUIRED_LIBS "${CMAKE_THREAD_LIBS_INIT}")
endif()
# OMP
if(FFTW_LOOK_FOR_OMP)
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
# either gomp ...
#set(REQUIRED_FLAGS "-fopenmp")
#list(APPEND REQUIRED_LIBS "-lgomp")
# or iomp5
list(APPEND REQUIRED_LIBS "-liomp5")
elseif (CMAKE_C_COMPILER_ID STREQUAL "Intel")
list(APPEND REQUIRED_LIBS "-liomp5")
endif()
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
# either gomp ...