Commit 52be6c70 authored by Mathieu Faverge's avatar Mathieu Faverge
Browse files

Use the newly introduce morse_find_{path|library} to factorize the code

parent 888bef85
......@@ -74,21 +74,15 @@
# Here is the order of precedence:
# 1) we look in cmake variable CBLAS_LIBDIR or CBLAS_DIR (we guess the libdirs) if defined
# 2) we look in environment variable CBLAS_LIBDIR or CBLAS_DIR (we guess the libdirs) if defined
# 3) we look in common environnment variables depending on the system (INCLUDE, C_INCLUDE_PATH, CPATH - LIB, DYLD_LIBRARY_PATH, LD_LIBRARY_PATH, LIBRARY_PATH)
# 4) we look in common system paths depending on the system, see for example paths contained in the following cmake variables:
# - CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES, CMAKE_C_IMPLICIT_LINK_DIRECTORIES
#
#=============================================================================
# Common macros to use in finds
include(FindMorseInit)
if (NOT CBLAS_FOUND)
set(CBLAS_DIR "" CACHE PATH "Installation directory of CBLAS library")
if (NOT CBLAS_FIND_QUIETLY)
message(STATUS "A cache variable, namely CBLAS_DIR, has been set to specify the install directory of CBLAS")
endif()
endif()
# Set variables from environment if needed
# ----------------------------------------
morse_find_package_get_envdir(CBLAS)
# Check if a cblas function exists in the lib, and check if the
# advanced complex gemm functions are available
......@@ -128,16 +122,6 @@ macro(check_cblas_include)
return()
endif()
# Add system include paths to search include
# ------------------------------------------
if(NOT CBLAS_DIR AND DEFINED ENV{CBLAS_DIR})
set(CBLAS_DIR "$ENV{CBLAS_DIR}")
endif()
if(NOT CBLAS_INCDIR AND DEFINED ENV{CBLAS_INCDIR})
set(CBLAS_INCDIR "$ENV{CBLAS_INCDIR}")
endif()
# Try to find the cblas header in the given paths
# -------------------------------------------------
if (CBLAS_LIBRARIES MATCHES "libmkl")
......@@ -148,37 +132,10 @@ macro(check_cblas_include)
# call cmake macro to find the header path
# ----------------------------------------
set(CBLAS_${CBLAS_hdrs_to_find}_DIRS "CBLAS_${CBLAS_hdrs_to_find}_DIRS-NOTFOUND")
if(CBLAS_INCDIR)
find_path(CBLAS_${CBLAS_hdrs_to_find}_DIRS
NAMES ${CBLAS_hdrs_to_find}
HINTS ${CBLAS_INCDIR}
NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH)
else()
if(CBLAS_DIR)
find_path(CBLAS_${CBLAS_hdrs_to_find}_DIRS
NAMES ${CBLAS_hdrs_to_find}
HINTS ${CBLAS_DIR}
PATH_SUFFIXES "include" "include/cblas"
NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH)
else()
find_path(CBLAS_${CBLAS_hdrs_to_find}_DIRS
NAMES ${CBLAS_hdrs_to_find}
PATH_SUFFIXES "cblas")
endif()
endif()
mark_as_advanced(CBLAS_${CBLAS_hdrs_to_find}_DIRS)
# If found, add path to cmake variable
# ------------------------------------
if (CBLAS_${CBLAS_hdrs_to_find}_DIRS)
set(CBLAS_INCLUDE_DIRS "${CBLAS_${CBLAS_hdrs_to_find}_DIRS}")
else ()
set(CBLAS_INCLUDE_DIRS "CBLAS_INCLUDE_DIRS-NOTFOUND")
if(NOT CBLAS_FIND_QUIETLY)
message(STATUS "Looking for cblas -- ${CBLAS_hdrs_to_find} not found")
endif()
endif()
morse_find_path(CBLAS
HEADERS ${CBLAS_hdrs_to_find}
SUFFIXES "include" "include/cblas")
endmacro()
# CBLAS depends on BLAS anyway, try to find it
......@@ -248,17 +205,14 @@ if (BLASEXT_FOUND)
endif()
# try with pkg-config
set(ENV_CBLAS_DIR "$ENV{CBLAS_DIR}")
set(ENV_MKL_DIR "$ENV{MKLROOT}")
set(ENV_CBLAS_INCDIR "$ENV{CBLAS_INCDIR}")
set(ENV_CBLAS_LIBDIR "$ENV{CBLAS_LIBDIR}")
set(ENV_MKLROOT "$ENV{MKLROOT}")
set(CBLAS_GIVEN_BY_USER "FALSE")
if ( CBLAS_DIR OR ( CBLAS_INCDIR AND CBLAS_LIBDIR) OR ENV_CBLAS_DIR OR ENV_MKL_DIR OR (ENV_CBLAS_INCDIR AND ENV_CBLAS_LIBDIR) )
if ( CBLAS_DIR OR ( CBLAS_INCDIR AND CBLAS_LIBDIR ) OR ( ENV_MKLROOT ) )
set(CBLAS_GIVEN_BY_USER "TRUE")
endif()
find_package(PkgConfig QUIET)
if( PKG_CONFIG_EXECUTABLE AND NOT CBLAS_GIVEN_BY_USER)
if( PKG_CONFIG_EXECUTABLE AND (NOT (CBLAS_GIVEN_BY_USER)))
if (BLA_STATIC)
set(MKL_STR_BLA_STATIC "static")
......@@ -319,80 +273,10 @@ if (BLASEXT_FOUND)
# Looking for lib
# ---------------
morse_find_library(CBLAS
LIBRARIES cblas
SUFFIXES lib lib32 lib64)
# Add system library paths to search lib
# --------------------------------------
unset(_lib_env)
set(ENV_CBLAS_LIBDIR "$ENV{CBLAS_LIBDIR}")
if(ENV_CBLAS_LIBDIR)
list(APPEND _lib_env "${ENV_CBLAS_LIBDIR}")
elseif(ENV_CBLAS_DIR)
list(APPEND _lib_env "${ENV_CBLAS_DIR}")
list(APPEND _lib_env "${ENV_CBLAS_DIR}/lib")
else()
list(APPEND _lib_env "$ENV{LIBRARY_PATH}")
if(WIN32)
string(REPLACE ":" ";" _lib_env2 "$ENV{LIB}")
elseif(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_C_IMPLICIT_LINK_DIRECTORIES}")
endif()
list(REMOVE_DUPLICATES _lib_env)
# Try to find the cblas lib in the given paths
# ----------------------------------------------
if (CBLAS_STATIC)
set (CMAKE_FIND_LIBRARY_SUFFIXES_COPY ${CMAKE_FIND_LIBRARY_SUFFIXES})
set (CMAKE_FIND_LIBRARY_SUFFIXES ".a")
endif()
# call cmake macro to find the lib path
if(CBLAS_LIBDIR)
set(CBLAS_cblas_LIBRARY "CBLAS_cblas_LIBRARY-NOTFOUND")
find_library(CBLAS_cblas_LIBRARY
NAMES cblas
HINTS ${CBLAS_LIBDIR}
NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH)
else()
if(CBLAS_DIR)
set(CBLAS_cblas_LIBRARY "CBLAS_cblas_LIBRARY-NOTFOUND")
find_library(CBLAS_cblas_LIBRARY
NAMES cblas
HINTS ${CBLAS_DIR}
PATH_SUFFIXES lib lib32 lib64
NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH)
else()
set(CBLAS_cblas_LIBRARY "CBLAS_cblas_LIBRARY-NOTFOUND")
find_library(CBLAS_cblas_LIBRARY
NAMES cblas
HINTS ${_lib_env})
endif()
endif()
mark_as_advanced(CBLAS_cblas_LIBRARY)
if (CBLAS_STATIC)
set (CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_COPY})
endif()
# If found, add path to cmake variable
# ------------------------------------
if (CBLAS_cblas_LIBRARY)
get_filename_component(cblas_lib_path "${CBLAS_cblas_LIBRARY}" PATH)
# set cmake variables
set(CBLAS_LIBRARIES "${CBLAS_cblas_LIBRARY}")
set(CBLAS_LIBRARY_DIRS "${cblas_lib_path}")
else ()
set(CBLAS_LIBRARIES "CBLAS_LIBRARIES-NOTFOUND")
set(CBLAS_LIBRARY_DIRS "CBLAS_LIBRARY_DIRS-NOTFOUND")
if (NOT CBLAS_FIND_QUIETLY)
message(STATUS "Looking for cblas -- lib cblas not found")
endif()
endif ()
endif (NOT CBLAS_FOUND_WITH_PKGCONFIG OR CBLAS_GIVEN_BY_USER)
endif (CBLAS_STANDALONE OR NOT CBLAS_WORKS)
......
......@@ -21,22 +21,18 @@
# The module can also look for the following environment variables if paths
# are not given as cmake variable: CPPCHECK_DIR, CPPCHECK_BINDIR
if (NOT CPPCHECK_FOUND)
set(CPPCHECK_DIR "" CACHE PATH "Installation directory of CPPCHECK library")
mark_as_advanced(CPPCHECK_DIR)
if (NOT CPPCHECK_FIND_QUIETLY)
message(STATUS "A cache variable, namely CPPCHECK_DIR, has been set to specify the install directory of CPPCHECK")
endif()
endif()
# Common macros to use in finds
include(FindMorseInit)
# Set variables from environment if needed
# ----------------------------------------
morse_find_package_get_envdir(CPPCHECK)
set(ENV_CPPCHECK_DIR "$ENV{CPPCHECK_DIR}")
set(ENV_CPPCHECK_BINDIR "$ENV{CPPCHECK_BINDIR}")
set(CPPCHECK_GIVEN_BY_USER "FALSE")
if ( CPPCHECK_DIR OR CPPCHECK_BINDIR OR ENV_CPPCHECK_DIR OR ENV_CPPCHECK_BINDIR )
if ( CPPCHECK_DIR OR CPPCHECK_BINDIR )
set(CPPCHECK_GIVEN_BY_USER "TRUE")
endif()
if (NOT CPPCHECK_FIND_QUIETLY)
message(STATUS "Looking for CPPCHECK")
endif()
......@@ -51,15 +47,10 @@ if(CPPCHECK_BINDIR)
list(APPEND where_to_look "${CPPCHECK_BINDIR}")
elseif(CPPCHECK_DIR)
list(APPEND where_to_look "${CPPCHECK_DIR}")
elseif(ENV_CPPCHECK_BINDIR)
list(APPEND where_to_look "${ENV_CPPCHECK_BINDIR}")
elseif(ENV_CPPCHECK_DIR)
list(APPEND where_to_look "${ENV_CPPCHECK_DIR}/bin")
else()
string(REPLACE ":" ";" _path_env "$ENV{PATH}")
list(APPEND where_to_look "${_path_env}")
endif()
list(APPEND where_to_look "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}")
list(REMOVE_DUPLICATES where_to_look)
find_program(CPPCHECK_EXECUTABLE
......
......@@ -146,4 +146,4 @@ find_package_handle_standard_args(EZTRACE DEFAULT_MSG
# Add imported targe
if (EZTRACE_FOUND)
morse_create_imported_target(EZTRACE)
endif()
\ No newline at end of file
endif()
......@@ -81,13 +81,6 @@
# Common macros to use in finds
include(FindMorseInit)
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()
endif()
# Set the version to find
set(FFTW_LOOK_FOR_MKL OFF)
set(FFTW_LOOK_FOR_ESSL OFF)
......@@ -226,11 +219,12 @@ if( THREADS_FOUND AND NOT THREADS_PREFER_PTHREAD_FLAG)
libraries_absolute_path(CMAKE_THREAD_LIBS_INIT "")
endif ()
set(ENV_FFTW_DIR "$ENV{FFTW_DIR}")
set(ENV_FFTW_INCDIR "$ENV{FFTW_INCDIR}")
set(ENV_FFTW_LIBDIR "$ENV{FFTW_LIBDIR}")
# Set variables from environment if needed
# ----------------------------------------
morse_find_package_get_envdir(FFTW)
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) )
if ( FFTW_DIR OR ( FFTW_INCDIR AND FFTW_LIBDIR ) )
set(FFTW_GIVEN_BY_USER "TRUE")
endif()
......@@ -403,40 +397,10 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR
# 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)
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()
if (ENV_MKLROOT)
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}")
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}")
endif()
set(PATH_TO_LOOK_FOR)
if (DEFINED $ENV{MKLROOT})
list(APPEND PATH_TO_LOOK_FOR "$ENV{MKLROOT}/include/fftw")
endif()
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}")
if (FFTW_LOOK_FOR_ESSL)
set(FFTW3_HEADER_TO_FIND "fftw3_essl.h")
......@@ -444,90 +408,27 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR
set(FFTW3_HEADER_TO_FIND "fftw3.h")
endif()
# Try to find the fftw header in the given paths
# -------------------------------------------------
# call cmake macro to find the header path
if(FFTW_INCDIR)
set(FFTW_${FFTW3_HEADER_TO_FIND}_DIRS "FFTW_${FFTW3_HEADER_TO_FIND}_DIRS-NOTFOUND")
find_path(FFTW_${FFTW3_HEADER_TO_FIND}_DIRS
NAMES ${FFTW3_HEADER_TO_FIND}
HINTS ${FFTW_INCDIR}
NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH)
else()
if(FFTW_DIR)
set(FFTW_${FFTW3_HEADER_TO_FIND}_DIRS "FFTW_${FFTW3_HEADER_TO_FIND}_DIRS-NOTFOUND")
find_path(FFTW_${FFTW3_HEADER_TO_FIND}_DIRS
NAMES ${FFTW3_HEADER_TO_FIND}
HINTS ${FFTW_DIR}
PATH_SUFFIXES "include" "include/fftw"
NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH)
else()
set(FFTW_${FFTW3_HEADER_TO_FIND}_DIRS "FFTW_${FFTW3_HEADER_TO_FIND}_DIRS-NOTFOUND")
find_path(FFTW_${FFTW3_HEADER_TO_FIND}_DIRS
NAMES ${FFTW3_HEADER_TO_FIND}
HINTS ${PATH_TO_LOOK_FOR}
PATH_SUFFIXES "fftw")
endif()
endif()
mark_as_advanced(FFTW_${FFTW3_HEADER_TO_FIND}_DIRS)
# Add path to cmake variable
# ------------------------------------
if (FFTW_${FFTW3_HEADER_TO_FIND}_DIRS)
set(FFTW_INCLUDE_DIRS "${FFTW_${FFTW3_HEADER_TO_FIND}_DIRS}")
else ()
set(FFTW_INCLUDE_DIRS "FFTW_INCLUDE_DIRS-NOTFOUND")
if(NOT FFTW_FIND_QUIETLY)
message(STATUS "Looking for FFTW -- ${FFTW3_HEADER_TO_FIND} not found")
endif()
endif ()
morse_find_path(FFTW
HEADERS ${FFTW3_HEADER_TO_FIND}
SUFFIXES "include" "include/fftw"
HINTS ${PATH_TO_LOOK_FOR})
# Looking for lib
# ---------------
# 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)
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")
else()
list(APPEND _lib_env "${ENV_FFTW_DIR}/lib32")
list(APPEND _lib_env "${ENV_FFTW_DIR}/lib/ia32")
endif()
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()
endif()
list(APPEND _lib_env "$ENV{LIBRARY_PATH}")
if(WIN32)
string(REPLACE ":" ";" _lib_env2 "$ENV{LIB}")
elseif(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_C_IMPLICIT_LINK_DIRECTORIES}")
set(PATH_TO_LOOK_FOR)
if (DEFINED $ENV{MKLROOT})
list(APPEND PATH_TO_LOOK_FOR "$ENV{MKLROOT}/lib")
endif()
list(REMOVE_DUPLICATES _lib_env)
# set paths where to look for
set(PATH_TO_LOOK_FOR "${_lib_env}")
set( _lib_suffixes lib )
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
list(APPEND _lib_suffixes "lib64" "lib/intel64" )
else()
list(APPEND _lib_suffixes "lib32" "lib/ia32" )
endif()
if(FFTW_LOOK_FOR_FFTW_SIMPLE)
set(FFTW_PREC "f")
......@@ -547,7 +448,6 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR
set(FFTW_LIBRARY_DIRS "")
if(NOT FFTW_LOOK_FOR_MKL)
if (FFTW_LOOK_FOR_THREADS)
set(FFTW_libs_to_find "fftw3${FFTW_PREC}_threads;fftw3${FFTW_PREC};fftw3")
elseif (FFTW_LOOK_FOR_OMP)
......@@ -567,61 +467,10 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR
# Try to find the fftw lib in the given paths
# ----------------------------------------------
# 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}
NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH)
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
NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH)
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()
# If found, add path to cmake variable
# ------------------------------------
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}")
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()
endif ()
mark_as_advanced(FFTW_${fftw_lib}_LIBRARY)
endforeach()
# check if one lib is NOTFOUND
foreach(lib ${FFTW_LIBRARIES})
if (NOT lib)
set(FFTW_LIBRARIES "FFTW_LIBRARIES-NOTFOUND")
endif()
endforeach()
morse_find_library(FFTW
LIBRARIES ${FFTW_libs_to_find}
SUFFIXES ${_lib_suffixes}
HINTS ${PATH_TO_LOOK_FOR})
endif(NOT FFTW_LOOK_FOR_MKL)
......@@ -861,4 +710,4 @@ if (FFTW_FOUND)
set_property(TARGET FFTW::FFTW APPEND PROPERTY INTERFACE_LINNK_OPTIONS "${FFTW_LDFLAGS_OTHER}")
endif()
morse_create_imported_target(FFTW)
endif()
\ No newline at end of file
endif()
......@@ -53,18 +53,12 @@
# Common macros to use in finds
include(FindMorseInit)
if (NOT HYPRE_FOUND)
set(HYPRE_DIR "" CACHE PATH "Installation directory of HYPRE library")
if (NOT HYPRE_FIND_QUIETLY)
message(STATUS "A cache variable, namely HYPRE_DIR, has been set to specify the install directory of HYPRE")
endif()
endif()
# Set variables from environment if needed
# ----------------------------------------
morse_find_package_get_envdir(HYPRE)
set(ENV_HYPRE_DIR "$ENV{HYPRE_DIR}")
set(ENV_HYPRE_INCDIR "$ENV{HYPRE_INCDIR}")
set(ENV_HYPRE_LIBDIR "$ENV{HYPRE_LIBDIR}")
set(HYPRE_GIVEN_BY_USER "FALSE")
if ( HYPRE_DIR OR ( HYPRE_INCDIR AND HYPRE_LIBDIR) OR ENV_HYPRE_DIR OR (ENV_HYPRE_INCDIR AND ENV_HYPRE_LIBDIR) )
if ( HYPRE_DIR OR ( HYPRE_INCDIR AND HYPRE_LIBDIR ) )
set(HYPRE_GIVEN_BY_USER "TRUE")
endif()
......@@ -77,161 +71,15 @@ endif()
# Looking for include
# -------------------
# Add system include paths to search include
# ------------------------------------------
unset(_inc_env)
if(ENV_HYPRE_INCDIR)
list(APPEND _inc_env "${ENV_HYPRE_INCDIR}")
elseif(ENV_HYPRE_DIR)
list(APPEND _inc_env "${ENV_HYPRE_DIR}")
list(APPEND _inc_env "${ENV_HYPRE_DIR}/include")
list(APPEND _inc_env "${ENV_HYPRE_DIR}/include/hypre")
else()
if(WIN32)
string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}")
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}")
endif()
endif()
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 hypre header in the given paths
# -------------------------------------------------
# call cmake macro to find the header path
if(HYPRE_INCDIR)
set(HYPRE_HYPRE.h_DIRS "HYPRE_HYPRE.h_DIRS-NOTFOUND")
find_path(HYPRE_HYPRE.h_DIRS
NAMES HYPRE.h
HINTS ${HYPRE_INCDIR}
NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH)
else()
if(HYPRE_DIR)
set(HYPRE_HYPRE.h_DIRS "HYPRE_HYPRE.h_DIRS-NOTFOUND")
find_path(HYPRE_HYPRE.h_DIRS
NAMES HYPRE.h
HINTS ${HYPRE_DIR}
PATH_SUFFIXES "include" "include/hypre"
NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH)
else()
set(HYPRE_HYPRE.h_DIRS "HYPRE_HYPRE.h_DIRS-NOTFOUND")
find_path(HYPRE_HYPRE.h_DIRS
NAMES HYPRE.h
HINTS ${PATH_TO_LOOK_FOR}
PATH_SUFFIXES "hypre")
endif()
endif()
mark_as_advanced(HYPRE_HYPRE.h_DIRS)
# Add path to cmake variable
# ------------------------------------
if (HYPRE_HYPRE.h_DIRS)
set(HYPRE_INCLUDE_DIRS "${HYPRE_HYPRE.h_DIRS}")
else ()
set(HYPRE_INCLUDE_DIRS "HYPRE_INCLUDE_DIRS-NOTFOUND")
if(NOT HYPRE_FIND_QUIETLY)
message(STATUS "Looking for hypre -- HYPRE.h not found")
endif()
endif ()
if (HYPRE_INCLUDE_DIRS)
list(REMOVE_DUPLICATES HYPRE_INCLUDE_DIRS)
endif ()
morse_find_path(HYPRE
HEADERS HYPRE.h
SUFFIXES include include/hypre)
# Looking for lib
# ---------------
# Add system library paths to search lib
# --------------------------------------
unset(_lib_env)
if(ENV_HYPRE_LIBDIR)
list(APPEND _lib_env "${ENV_HYPRE_LIBDIR}")
elseif(ENV_HYPRE_DIR)
list(APPEND _lib_env "${ENV_HYPRE_DIR}")
list(APPEND _lib_env "${ENV_HYPRE_DIR}/lib")
else()
list(APPEND _lib_env "$ENV{LIBRARY_PATH}")
if(WIN32)
string(REPLACE ":" ";" _lib_env2 "$ENV{LIB}")
elseif(APPLE)
string(REPLACE ":" ";" _lib_env2 "$ENV{DYLD_LIBRARY_PATH}")
else()
string(REPLACE ":" ";" _lib_env2 "$ENV{LD_LIBRARY_PATH}")