Commit 9a0d303a authored by Florent Pruvost's avatar Florent Pruvost
Browse files

use MKLROOT env var if set, use [BLAS,LAPACK,FFTW]_[DIR,LIBDIR] env var is set

parent 32f4739b
......@@ -35,6 +35,13 @@
# BLAS_DIR - Where to find the base directory of blas
# BLAS_INCDIR - Where to find the header files
# BLAS_LIBDIR - Where to find the library files
# The module can also look after the following environment variables if paths
# are not given as cmake variable
# BLAS_DIR - Where to find the base directory of blas
# BLAS_INCDIR - Where to find the header files
# BLAS_LIBDIR - Where to find the library files
# For MKL case and if no paths are given as hints, we will try to use the MKLROOT
# environment variable
##########
### List of vendors (BLA_VENDOR) valid in this module
########## List of vendors (BLA_VENDOR) valid in this module
......@@ -180,6 +187,9 @@ macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _thread)
set(_libraries_work TRUE)
set(${LIBRARIES})
set(_combined_name)
set(ENV_MKLROOT "$ENV{MKLROOT}")
set(ENV_BLAS_DIR "$ENV{BLAS_DIR}")
set(ENV_BLAS_LIBDIR "$ENV{BLAS_LIBDIR}")
if (NOT _libdir)
if (BLAS_DIR)
list(APPEND _libdir "${BLAS_DIR}")
......@@ -193,7 +203,28 @@ macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _thread)
endif()
elseif (BLAS_LIBDIR)
list(APPEND _libdir "${BLAS_LIBDIR}")
elseif(ENV_BLAS_DIR)
list(APPEND _libdir "${ENV_BLAS_DIR}")
list(APPEND _libdir "${ENV_BLAS_DIR}/lib")
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
list(APPEND _libdir "${ENV_BLAS_DIR}/lib64")
list(APPEND _libdir "${ENV_BLAS_DIR}/lib/intel64")
else()
list(APPEND _libdir "${ENV_BLAS_DIR}/lib32")
list(APPEND _libdir "${ENV_BLAS_DIR}/lib/ia32")
endif()
elseif(ENV_BLAS_LIBDIR)
list(APPEND _libdir "${ENV_BLAS_LIBDIR}")
else()
if (ENV_MKLROOT)
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
list(APPEND _libdir "${ENV_MKLROOT}/lib64")
list(APPEND _libdir "${ENV_MKLROOT}/lib/intel64")
else()
list(APPEND _libdir "${ENV_MKLROOT}/lib32")
list(APPEND _libdir "${ENV_MKLROOT}/lib/ia32")
endif()
endif()
if (WIN32)
string(REPLACE ":" ";" _libdir2 "$ENV{LIB}")
elseif (APPLE)
......@@ -370,10 +401,12 @@ if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All")
if (CMAKE_C_COMPILER_NAME STREQUAL "gcc" OR
CMAKE_C_COMPILER_NAME STREQUAL "cc")
list(APPEND BLAS_SEARCH_LIBS
"mkl_blas95_lp64 mkl_intel_lp64 mkl_gnu_thread mkl_core gomp")
"mkl_blas95_lp64 mkl_intel_lp64 mkl_gnu_thread mkl_core")
set(OMP_LIB "-lgomp")
else ()
list(APPEND BLAS_SEARCH_LIBS
"mkl_blas95_lp64 mkl_intel_lp64 mkl_intel_thread mkl_core iomp5")
"mkl_blas95_lp64 mkl_intel_lp64 mkl_intel_thread mkl_core")
set(OMP_LIB "-liomp5")
endif ()
endif ()
if (BLA_VENDOR STREQUAL "Intel10_64lp_seq" OR BLA_VENDOR STREQUAL "All")
......@@ -442,10 +475,12 @@ if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All")
if (CMAKE_C_COMPILER_NAME STREQUAL "gcc" OR
CMAKE_C_COMPILER_NAME STREQUAL "cc")
list(APPEND BLAS_SEARCH_LIBS
"mkl_intel_lp64 mkl_gnu_thread mkl_core gomp")
"mkl_intel_lp64 mkl_gnu_thread mkl_core")
set(OMP_LIB "-lgomp")
else ()
list(APPEND BLAS_SEARCH_LIBS
"mkl_intel_lp64 mkl_intel_thread mkl_core iomp5")
"mkl_intel_lp64 mkl_intel_thread mkl_core")
set(OMP_LIB "-liomp5")
endif ()
endif ()
if (BLA_VENDOR STREQUAL "Intel10_64lp_seq" OR BLA_VENDOR STREQUAL "All")
......@@ -476,7 +511,7 @@ if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All")
${BLAS_mkl_SEARCH_SYMBOL}
"${additional_flags}"
"${SEARCH_LIBS}"
"${CMAKE_THREAD_LIBS_INIT};${LM}"
"${OMP_LIB};${CMAKE_THREAD_LIBS_INIT};${LM}"
)
if(_LIBRARIES)
set(BLAS_LINKER_FLAGS "${additional_flags}")
......@@ -942,6 +977,8 @@ if (BLAS_FOUND AND NOT BLAS_DIR)
if (${first_lib_path} MATCHES "(/lib(32|64)?$)|(/lib/intel64$|/lib/ia32$)")
string(REGEX REPLACE "(/lib(32|64)?$)|(/lib/intel64$|/lib/ia32$)" "" not_cached_dir "${first_lib_path}")
set(BLAS_DIR "${not_cached_dir}" CACHE PATH "Installation directory of BLAS library" FORCE)
else()
set(BLAS_DIR "${first_lib_path}" CACHE PATH "Installation directory of BLAS library" FORCE)
endif()
endif()
......@@ -40,6 +40,13 @@
# FFTW_DIR - Where to find the base directory of fftw
# FFTW_INCDIR - Where to find the header files
# FFTW_LIBDIR - Where to find the library files
# The module can also look after the following environment variables if paths
# are not given as cmake variable
# FFTW_DIR - Where to find the base directory of fftw
# FFTW_INCDIR - Where to find the header files
# FFTW_LIBDIR - Where to find the library files
# For MKL case and if no paths are given as hints, we will try to use the MKLROOT
# environment variable
#=============================================================================
# Copyright 2012-2013 Inria
......@@ -136,6 +143,14 @@ if (FFTW_LOOK_FOR_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()
endif()
if (FFTW_LOOK_FOR_OMP)
if (FFTW_FIND_REQUIRED AND FFTW_FIND_REQUIRED_OMP)
find_package(OpenMP REQUIRED)
......@@ -152,17 +167,32 @@ if( NOT FFTW_FOUND )
# Add system include paths to search include
# ------------------------------------------
unset(_inc_env)
if(WIN32)
string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}")
set(ENV_MKLROOT "$ENV{MKLROOT}")
set(ENV_FFTW_DIR "$ENV{FFTW_DIR}")
set(ENV_FFTW_INCDIR "$ENV{FFTW_INCDIR}")
if(ENV_FFTW_DIR)
list(APPEND _inc_env "${ENV_FFTW_DIR}")
list(APPEND _inc_env "${ENV_FFTW_DIR}/include")
elseif(ENV_FFTW_INCDIR)
list(APPEND _inc_env "${ENV_FFTW_INCDIR}")
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}")
if (ENV_MKLROOT)
list(APPEND _inc_env "${ENV_MKLROOT}")
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()
endif()
list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}")
list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}")
......@@ -213,16 +243,35 @@ if( NOT FFTW_FOUND )
# Add system library paths to search lib
# --------------------------------------
unset(_lib_env)
if(WIN32)
string(REPLACE ":" ";" _lib_env "$ENV{LIB}")
set(ENV_FFTW_LIBDIR "$ENV{FFTW_LIBDIR}")
if(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()
elseif(ENV_FFTW_LIBDIR)
list(APPEND _lib_env "${ENV_FFTW_LIBDIR}")
else()
if(APPLE)
string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}")
if (ENV_MKLROOT)
list(APPEND _lib_env "${ENV_MKLROOT}")
endif()
if(WIN32)
string(REPLACE ":" ";" _lib_env2 "$ENV{LIB}")
else()
string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}")
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()
list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}")
list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}")
endif()
list(REMOVE_DUPLICATES _lib_env)
......@@ -429,6 +478,8 @@ if (FFTW_LIBRARIES AND NOT FFTW_DIR)
if (${first_lib_path} MATCHES "(/lib(32|64)?$)|(/lib/intel64$|/lib/ia32$)")
string(REGEX REPLACE "(/lib(32|64)?$)|(/lib/intel64$|/lib/ia32$)" "" not_cached_dir "${first_lib_path}")
set(FFTW_DIR "${not_cached_dir}" CACHE PATH "Installation directory of FFTW library" FORCE)
else()
set(FFTW_DIR "${first_lib_path}" CACHE PATH "Installation directory of FFTW library" FORCE)
endif()
endif()
......
......@@ -35,6 +35,13 @@
# LAPACK_DIR - Where to find the base directory of lapack
# LAPACK_INCDIR - Where to find the header files
# LAPACK_LIBDIR - Where to find the library files
# The module can also look after the following environment variables if paths
# are not given as cmake variable
# LAPACK_DIR - Where to find the base directory of lapack
# LAPACK_INCDIR - Where to find the header files
# LAPACK_LIBDIR - Where to find the library files
# For MKL case and if no paths are given as hints, we will try to use the MKLROOT
# environment variable
# Note that if BLAS_DIR is set, it will also look for lapack in it
### List of vendors (BLA_VENDOR) valid in this module
## Intel(mkl), ACML,Apple, NAS, Generic
......@@ -154,20 +161,37 @@ macro(Check_Lapack_Libraries LIBRARIES _prefix _name _flags _list _blas _threads
set(_libraries_work TRUE)
set(${LIBRARIES})
set(_combined_name)
set(ENV_MKLROOT "$ENV{MKLROOT}")
set(ENV_BLAS_DIR "$ENV{BLAS_DIR}")
set(ENV_BLAS_LIBDIR "$ENV{BLAS_LIBDIR}")
set(ENV_LAPACK_DIR "$ENV{LAPACK_DIR}")
set(ENV_LAPACK_LIBDIR "$ENV{LAPACK_LIBDIR}")
if (NOT _libdir)
if (BLAS_DIR)
list(APPEND _libdir "${BLAS_DIR}")
list(APPEND _libdir "${BLAS_DIR}/lib")
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
list(APPEND _libdir "${BLAS_DIR}/lib64")
list(APPEND _libdir "${BLAS_DIR}/lib/intel64")
else()
list(APPEND _libdir "${BLAS_DIR}/lib32")
list(APPEND _libdir "${BLAS_DIR}/lib/ia32")
endif()
list(APPEND _libdir "${BLAS_DIR}")
list(APPEND _libdir "${BLAS_DIR}/lib")
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
list(APPEND _libdir "${BLAS_DIR}/lib64")
list(APPEND _libdir "${BLAS_DIR}/lib/intel64")
else()
list(APPEND _libdir "${BLAS_DIR}/lib32")
list(APPEND _libdir "${BLAS_DIR}/lib/ia32")
endif()
elseif (BLAS_LIBDIR)
list(APPEND _libdir "${BLAS_LIBDIR}")
endif ()
list(APPEND _libdir "${BLAS_LIBDIR}")
elseif(ENV_BLAS_DIR)
list(APPEND _libdir "${ENV_BLAS_DIR}")
list(APPEND _libdir "${ENV_BLAS_DIR}/lib")
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
list(APPEND _libdir "${ENV_BLAS_DIR}/lib64")
list(APPEND _libdir "${ENV_BLAS_DIR}/lib/intel64")
else()
list(APPEND _libdir "${ENV_BLAS_DIR}/lib32")
list(APPEND _libdir "${ENV_BLAS_DIR}/lib/ia32")
endif()
elseif(ENV_BLAS_LIBDIR)
list(APPEND _libdir "${ENV_BLAS_LIBDIR}")
endif()
if (LAPACK_DIR)
list(APPEND _libdir "${LAPACK_DIR}")
list(APPEND _libdir "${LAPACK_DIR}/lib")
......@@ -180,7 +204,28 @@ if (NOT _libdir)
endif()
elseif (LAPACK_LIBDIR)
list(APPEND _libdir "${LAPACK_LIBDIR}")
elseif(ENV_LAPACK_DIR)
list(APPEND _libdir "${ENV_LAPACK_DIR}")
list(APPEND _libdir "${ENV_LAPACK_DIR}/lib")
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
list(APPEND _libdir "${ENV_LAPACK_DIR}/lib64")
list(APPEND _libdir "${ENV_LAPACK_DIR}/lib/intel64")
else()
list(APPEND _libdir "${ENV_LAPACK_DIR}/lib32")
list(APPEND _libdir "${ENV_LAPACK_DIR}/lib/ia32")
endif()
elseif(ENV_LAPACK_LIBDIR)
list(APPEND _libdir "${ENV_LAPACK_LIBDIR}")
else()
if (ENV_MKLROOT)
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
list(APPEND _libdir "${ENV_MKLROOT}/lib64")
list(APPEND _libdir "${ENV_MKLROOT}/lib/intel64")
else()
list(APPEND _libdir "${ENV_MKLROOT}/lib32")
list(APPEND _libdir "${ENV_MKLROOT}/lib/ia32")
endif()
endif()
if (WIN32)
string(REPLACE ":" ";" _libdir2 "$ENV{LIB}")
elseif (APPLE)
......@@ -212,7 +257,7 @@ foreach(_library ${_list})
set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
endif (APPLE)
else (BLA_STATIC)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
# for ubuntu's libblas3gf and liblapack3gf packages
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf)
endif ()
......@@ -287,71 +332,6 @@ if(BLAS_FOUND)
endif(NOT BLA_VENDOR)
endif ($ENV{BLA_VENDOR} MATCHES ".+")
if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All")
if(NOT LAPACK_LIBRARIES)
check_lapack_libraries(
LAPACK_LIBRARIES
LAPACK
cheev
""
"goto2"
"${BLAS_LIBRARIES}"
""
)
endif(NOT LAPACK_LIBRARIES)
endif (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All")
#acml lapack
if (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All")
if (BLAS_LIBRARIES MATCHES ".+acml.+")
set (LAPACK_LIBRARIES ${BLAS_LIBRARIES})
endif ()
endif ()
# Apple LAPACK library?
if (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All")
if(NOT LAPACK_LIBRARIES)
check_lapack_libraries(
LAPACK_LIBRARIES
LAPACK
cheev
""
"Accelerate"
"${BLAS_LIBRARIES}"
""
)
endif(NOT LAPACK_LIBRARIES)
endif (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All")
if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All")
if ( NOT LAPACK_LIBRARIES )
check_lapack_libraries(
LAPACK_LIBRARIES
LAPACK
cheev
""
"vecLib"
"${BLAS_LIBRARIES}"
""
)
endif ( NOT LAPACK_LIBRARIES )
endif (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All")
# Generic LAPACK library?
if (BLA_VENDOR STREQUAL "Generic" OR
BLA_VENDOR STREQUAL "ATLAS" OR
BLA_VENDOR STREQUAL "All")
if ( NOT LAPACK_LIBRARIES )
check_lapack_libraries(
LAPACK_LIBRARIES
LAPACK
cheev
""
"lapack"
"${BLAS_LIBRARIES}"
""
)
endif ( NOT LAPACK_LIBRARIES )
endif ()
#intel lapack
if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All")
if (NOT WIN32)
......@@ -431,6 +411,73 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All")
endforeach ()
endif ()
endif()
#goto lapack
if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All")
if(NOT LAPACK_LIBRARIES)
check_lapack_libraries(
LAPACK_LIBRARIES
LAPACK
cheev
""
"goto2"
"${BLAS_LIBRARIES}"
""
)
endif(NOT LAPACK_LIBRARIES)
endif (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All")
#acml lapack
if (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All")
if (BLAS_LIBRARIES MATCHES ".+acml.+")
set (LAPACK_LIBRARIES ${BLAS_LIBRARIES})
endif ()
endif ()
# Apple LAPACK library?
if (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All")
if(NOT LAPACK_LIBRARIES)
check_lapack_libraries(
LAPACK_LIBRARIES
LAPACK
cheev
""
"Accelerate"
"${BLAS_LIBRARIES}"
""
)
endif(NOT LAPACK_LIBRARIES)
endif (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All")
if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All")
if ( NOT LAPACK_LIBRARIES )
check_lapack_libraries(
LAPACK_LIBRARIES
LAPACK
cheev
""
"vecLib"
"${BLAS_LIBRARIES}"
""
)
endif ( NOT LAPACK_LIBRARIES )
endif (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All")
# Generic LAPACK library?
if (BLA_VENDOR STREQUAL "Generic" OR
BLA_VENDOR STREQUAL "ATLAS" OR
BLA_VENDOR STREQUAL "All")
if ( NOT LAPACK_LIBRARIES )
check_lapack_libraries(
LAPACK_LIBRARIES
LAPACK
cheev
""
"lapack"
"${BLAS_LIBRARIES}"
""
)
endif ( NOT LAPACK_LIBRARIES )
endif ()
else(BLAS_FOUND)
message(STATUS "LAPACK requires BLAS")
endif(BLAS_FOUND)
......@@ -512,5 +559,7 @@ if (LAPACK_FOUND AND NOT LAPACK_DIR)
if (${first_lib_path} MATCHES "(/lib(32|64)?$)|(/lib/intel64$|/lib/ia32$)")
string(REGEX REPLACE "(/lib(32|64)?$)|(/lib/intel64$|/lib/ia32$)" "" not_cached_dir "${first_lib_path}")
set(LAPACK_DIR "${not_cached_dir}" CACHE PATH "Installation directory of LAPACK library" FORCE)
else()
set(LAPACK_DIR "${first_lib_path}" CACHE PATH "Installation directory of LAPACK library" FORCE)
endif()
endif()
......@@ -224,7 +224,7 @@ if(QUARK_LIBRARIES)
set(REQUIRED_INCDIRS "${QUARK_INCLUDE_DIRS}")
endif()
if (QUARK_LIBRARY_DIRS)
set(CMAKE_REQUIRED_FLAGS "${QUARK_LIBRARY_DIRS}")
set(REQUIRED_LIBDIRS "${QUARK_LIBRARY_DIRS}")
endif()
set(REQUIRED_LIBS "${QUARK_LIBRARIES}")
# HWLOC
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment