Commit e9ae8c89 authored by Florent Pruvost's avatar Florent Pruvost

improve cmake Finds modules: MKLROOT env var. is considered - env var. for...

improve cmake Finds modules: MKLROOT env var. is considered - env var. for libraries dir. are considered (ex: export HWLOC_DIR=/home/toto/install/hwloc)
parent 5d8596f4
......@@ -35,11 +35,8 @@
# 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
# The module can also look for the following environment variables if paths
# are not given as cmake variable: BLAS_DIR, BLAS_INCDIR, BLAS_LIBDIR
# For MKL case and if no paths are given as hints, we will try to use the MKLROOT
# environment variable
##########
......@@ -191,7 +188,9 @@ macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _thread)
set(ENV_BLAS_DIR "$ENV{BLAS_DIR}")
set(ENV_BLAS_LIBDIR "$ENV{BLAS_LIBDIR}")
if (NOT _libdir)
if (BLAS_DIR)
if (BLAS_LIBDIR)
list(APPEND _libdir "${BLAS_LIBDIR}")
elseif (BLAS_DIR)
list(APPEND _libdir "${BLAS_DIR}")
list(APPEND _libdir "${BLAS_DIR}/lib")
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
......@@ -201,8 +200,8 @@ macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _thread)
list(APPEND _libdir "${BLAS_DIR}/lib32")
list(APPEND _libdir "${BLAS_DIR}/lib/ia32")
endif()
elseif (BLAS_LIBDIR)
list(APPEND _libdir "${BLAS_LIBDIR}")
elseif(ENV_BLAS_LIBDIR)
list(APPEND _libdir "${ENV_BLAS_LIBDIR}")
elseif(ENV_BLAS_DIR)
list(APPEND _libdir "${ENV_BLAS_DIR}")
list(APPEND _libdir "${ENV_BLAS_DIR}/lib")
......@@ -213,8 +212,6 @@ macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _thread)
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")
......
......@@ -39,6 +39,8 @@
# CBLAS_DIR - Where to find the base directory of cblas
# CBLAS_INCDIR - Where to find the header files
# CBLAS_LIBDIR - Where to find the library files
# The module can also look for the following environment variables if paths
# are not given as cmake variable: CBLAS_DIR, CBLAS_INCDIR, CBLAS_LIBDIR
#
# CBLAS could be directly embedded in BLAS library (ex: Intel MKL) so that
# we test a cblas function with the blas libraries found and set CBLAS
......@@ -148,17 +150,28 @@ if (BLAS_FOUND)
# Add system include paths to search include
# ------------------------------------------
unset(_inc_env)
if(WIN32)
string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}")
set(ENV_CBLAS_DIR "$ENV{CBLAS_DIR}")
set(ENV_CBLAS_INCDIR "$ENV{CBLAS_INCDIR}")
if(ENV_CBLAS_INCDIR)
list(APPEND _inc_env "${ENV_CBLAS_INCDIR}")
elseif(ENV_CBLAS_DIR)
list(APPEND _inc_env "${ENV_CBLAS_DIR}")
list(APPEND _inc_env "${ENV_CBLAS_DIR}/include")
list(APPEND _inc_env "${ENV_CBLAS_DIR}/include/cblas")
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(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}")
......@@ -179,7 +192,7 @@ if (BLAS_FOUND)
find_path(CBLAS_cblas.h_DIRS
NAMES cblas.h
HINTS ${CBLAS_DIR}
PATH_SUFFIXES include)
PATH_SUFFIXES "include" "include/cblas")
else()
set(CBLAS_cblas.h_DIRS "CBLAS_cblas.h_DIRS-NOTFOUND")
find_path(CBLAS_cblas.h_DIRS
......@@ -207,16 +220,24 @@ if (BLAS_FOUND)
# Add system library paths to search lib
# --------------------------------------
unset(_lib_env)
if(WIN32)
string(REPLACE ":" ";" _lib_env "$ENV{LIB}")
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()
if(APPLE)
string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}")
if(WIN32)
string(REPLACE ":" ";" _lib_env "$ENV{LIB}")
else()
string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}")
if(APPLE)
string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}")
else()
string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}")
endif()
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)
......@@ -337,12 +358,14 @@ else(BLAS_FOUND)
endif(BLAS_FOUND)
if (CBLAS_LIBRARIES AND NOT CBLAS_DIR)
if (CBLAS_LIBRARIES)
list(GET CBLAS_LIBRARIES 0 first_lib)
get_filename_component(first_lib_path "${first_lib}" PATH)
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(CBLAS_DIR "${not_cached_dir}" CACHE PATH "Installation directory of CBLAS library" FORCE)
set(CBLAS_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of CBLAS library" FORCE)
else()
set(CBLAS_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of CBLAS library" FORCE)
endif()
endif()
......
......@@ -48,6 +48,8 @@
# CHAMELEON_DIR - Where to find the base directory of chameleon
# CHAMELEON_INCDIR - Where to find the header files
# CHAMELEON_LIBDIR - Where to find the library files
# The module can also look for the following environment variables if paths
# are not given as cmake variable: CHAMELEON_DIR, CHAMELEON_INCDIR, CHAMELEON_LIBDIR
#=============================================================================
# Copyright 2012-2013 Inria
......@@ -162,7 +164,7 @@ if(PKG_CONFIG_EXECUTABLE)
endif()
if( (NOT PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR NOT CHAMELEON_FOUND OR CHAMELEON_DIR )
if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR (CHAMELEON_DIR) )
if (NOT CHAMELEON_FIND_QUIETLY)
message(STATUS "Looking for CHAMELEON - PkgConfig not used")
......@@ -370,17 +372,27 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR NOT CHAMELEON_FOUND O
# Add system include paths to search include
# ------------------------------------------
unset(_inc_env)
if(WIN32)
string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}")
set(ENV_CHAMELEON_DIR "$ENV{CHAMELEON_DIR}")
set(ENV_CHAMELEON_INCDIR "$ENV{CHAMELEON_INCDIR}")
if(ENV_CHAMELEON_INCDIR)
list(APPEND _inc_env "${ENV_CHAMELEON_INCDIR}")
elseif(ENV_CHAMELEON_DIR)
list(APPEND _inc_env "${ENV_CHAMELEON_DIR}")
list(APPEND _inc_env "${ENV_CHAMELEON_DIR}/include")
list(APPEND _inc_env "${ENV_CHAMELEON_DIR}/include/chameleon")
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(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_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}")
list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}")
......@@ -429,16 +441,24 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR NOT CHAMELEON_FOUND O
# Add system library paths to search lib
# --------------------------------------
unset(_lib_env)
if(WIN32)
string(REPLACE ":" ";" _lib_env "$ENV{LIB}")
set(ENV_CHAMELEON_LIBDIR "$ENV{CHAMELEON_LIBDIR}")
if(ENV_CHAMELEON_LIBDIR)
list(APPEND _lib_env "${ENV_CHAMELEON_LIBDIR}")
elseif(ENV_CHAMELEON_DIR)
list(APPEND _lib_env "${ENV_CHAMELEON_DIR}")
list(APPEND _lib_env "${ENV_CHAMELEON_DIR}/lib")
else()
if(APPLE)
string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}")
if(WIN32)
string(REPLACE ":" ";" _lib_env "$ENV{LIB}")
else()
string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}")
if(APPLE)
string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}")
else()
string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}")
endif()
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)
......@@ -735,9 +755,9 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR NOT CHAMELEON_FOUND O
set(CMAKE_REQUIRED_LIBRARIES)
endif(CHAMELEON_LIBRARIES)
endif( (NOT PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR NOT CHAMELEON_FOUND OR CHAMELEON_DIR)
endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR (CHAMELEON_DIR) )
if (CHAMELEON_LIBRARIES AND NOT CHAMELEON_DIR)
if (CHAMELEON_LIBRARIES)
if (CHAMELEON_LIBRARY_DIRS)
foreach(dir ${CHAMELEON_LIBRARY_DIRS})
if ("${dir}" MATCHES "chameleon")
......@@ -750,7 +770,9 @@ if (CHAMELEON_LIBRARIES AND NOT CHAMELEON_DIR)
endif()
if (${first_lib_path} MATCHES "/lib(32|64)?$")
string(REGEX REPLACE "/lib(32|64)?$" "" not_cached_dir "${first_lib_path}")
set(CHAMELEON_DIR "${not_cached_dir}" CACHE PATH "Installation directory of CHAMELEON library" FORCE)
set(CHAMELEON_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of CHAMELEON library" FORCE)
else()
set(CHAMELEON_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of CHAMELEON library" FORCE)
endif()
endif()
......
......@@ -211,7 +211,7 @@ else()
find_path(FFTW_fftw3.h_DIRS
NAMES fftw3.h
HINTS ${FFTW_DIR}
PATH_SUFFIXES include include/fftw)
PATH_SUFFIXES "include" "include/fftw")
else()
set(FFTW_fftw3.h_DIRS "FFTW_fftw3.h_DIRS-NOTFOUND")
find_path(FFTW_fftw3.h_DIRS
......
......@@ -25,6 +25,8 @@
# FXT_DIR - Where to find the base directory of fxt
# FXT_INCDIR - Where to find the header files
# FXT_LIBDIR - Where to find the library files
# The module can also look for the following environment variables if paths
# are not given as cmake variable: FXT_DIR, FXT_INCDIR, FXT_LIBDIR
#=============================================================================
# Copyright 2012-2013 Inria
......@@ -74,7 +76,7 @@ if(PKG_CONFIG_EXECUTABLE)
endif()
if( (NOT PKG_CONFIG_EXECUTABLE AND NOT FXT_FOUND) OR NOT FXT_FOUND OR FXT_DIR)
if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT FXT_FOUND) OR (FXT_DIR) )
if (NOT FXT_FIND_QUIETLY)
message(STATUS "Looking for FXT - PkgConfig not used")
......@@ -86,17 +88,27 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT FXT_FOUND) OR NOT FXT_FOUND OR FXT_DIR)
# Add system include paths to search include
# ------------------------------------------
unset(_inc_env)
if(WIN32)
string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}")
set(ENV_FXT_DIR "$ENV{FXT_DIR}")
set(ENV_FXT_INCDIR "$ENV{FXT_INCDIR}")
if(ENV_FXT_INCDIR)
list(APPEND _inc_env "${ENV_FXT_INCDIR}")
elseif(ENV_FXT_DIR)
list(APPEND _inc_env "${ENV_FXT_DIR}")
list(APPEND _inc_env "${ENV_FXT_DIR}/include")
list(APPEND _inc_env "${ENV_FXT_DIR}/include/fxt")
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(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_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}")
list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}")
......@@ -116,7 +128,7 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT FXT_FOUND) OR NOT FXT_FOUND OR FXT_DIR)
find_path(FXT_fxt.h_DIRS
NAMES fxt.h
HINTS ${FXT_DIR}
PATH_SUFFIXES include)
PATH_SUFFIXES "include" "include/fxt")
else()
set(FXT_fxt.h_DIRS "FXT_fxt.h_DIRS-NOTFOUND")
find_path(FXT_fxt.h_DIRS
......@@ -148,16 +160,24 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT FXT_FOUND) OR NOT FXT_FOUND OR FXT_DIR)
# Add system library paths to search lib
# --------------------------------------
unset(_lib_env)
if(WIN32)
string(REPLACE ":" ";" _lib_env "$ENV{LIB}")
set(ENV_FXT_LIBDIR "$ENV{FXT_LIBDIR}")
if(ENV_FXT_LIBDIR)
list(APPEND _lib_env "${ENV_FXT_LIBDIR}")
elseif(ENV_FXT_DIR)
list(APPEND _lib_env "${ENV_FXT_DIR}")
list(APPEND _lib_env "${ENV_FXT_DIR}/lib")
else()
if(APPLE)
string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}")
if(WIN32)
string(REPLACE ":" ";" _lib_env "$ENV{LIB}")
else()
string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}")
if(APPLE)
string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}")
else()
string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}")
endif()
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)
......@@ -249,9 +269,9 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT FXT_FOUND) OR NOT FXT_FOUND OR FXT_DIR)
set(CMAKE_REQUIRED_LIBRARIES)
endif(FXT_LIBRARIES)
endif( (NOT PKG_CONFIG_EXECUTABLE AND NOT FXT_FOUND) OR NOT FXT_FOUND OR FXT_DIR)
endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT FXT_FOUND) OR (FXT_DIR) )
if (FXT_LIBRARIES AND NOT FXT_DIR)
if (FXT_LIBRARIES)
if (FXT_LIBRARY_DIRS)
list(GET FXT_LIBRARY_DIRS 0 first_lib_path)
else()
......@@ -260,7 +280,9 @@ if (FXT_LIBRARIES AND NOT FXT_DIR)
endif()
if (${first_lib_path} MATCHES "/lib(32|64)?$")
string(REGEX REPLACE "/lib(32|64)?$" "" not_cached_dir "${first_lib_path}")
set(FXT_DIR "${not_cached_dir}" CACHE PATH "Installation directory of FXT library" FORCE)
set(FXT_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of FXT library" FORCE)
else()
set(FXT_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of FXT library" FORCE)
endif()
endif()
......
......@@ -25,6 +25,8 @@
# HWLOC_DIR - Where to find the base directory of hwloc
# HWLOC_INCDIR - Where to find the header files
# HWLOC_LIBDIR - Where to find the library files
# The module can also look for the following environment variables if paths
# are not given as cmake variable: HWLOC_DIR, HWLOC_INCDIR, HWLOC_LIBDIR
#=============================================================================
# Copyright 2012-2013 Inria
......@@ -75,7 +77,7 @@ if(PKG_CONFIG_EXECUTABLE)
endif()
if( (NOT PKG_CONFIG_EXECUTABLE AND NOT HWLOC_FOUND) OR NOT HWLOC_FOUND OR HWLOC_DIR)
if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT HWLOC_FOUND) OR (HWLOC_DIR) )
if (NOT HWLOC_FIND_QUIETLY)
message(STATUS "Looking for HWLOC - PkgConfig not used")
......@@ -87,17 +89,27 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT HWLOC_FOUND) OR NOT HWLOC_FOUND OR HWLOC_
# Add system include paths to search include
# ------------------------------------------
unset(_inc_env)
if(WIN32)
string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}")
set(ENV_HWLOC_DIR "$ENV{HWLOC_DIR}")
set(ENV_HWLOC_INCDIR "$ENV{HWLOC_INCDIR}")
if(ENV_HWLOC_INCDIR)
list(APPEND _inc_env "${ENV_HWLOC_INCDIR}")
elseif(ENV_HWLOC_DIR)
list(APPEND _inc_env "${ENV_HWLOC_DIR}")
list(APPEND _inc_env "${ENV_HWLOC_DIR}/include")
list(APPEND _inc_env "${ENV_HWLOC_DIR}/include/hwloc")
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(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_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}")
list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}")
......@@ -120,7 +132,7 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT HWLOC_FOUND) OR NOT HWLOC_FOUND OR HWLOC_
find_path(HWLOC_hwloc.h_DIRS
NAMES hwloc.h
HINTS ${HWLOC_DIR}
PATH_SUFFIXES include)
PATH_SUFFIXES "include" "include/hwloc")
else()
set(HWLOC_hwloc.h_DIRS "HWLOC_hwloc.h_DIRS-NOTFOUND")
find_path(HWLOC_hwloc.h_DIRS
......@@ -152,16 +164,24 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT HWLOC_FOUND) OR NOT HWLOC_FOUND OR HWLOC_
# Add system library paths to search lib
# --------------------------------------
unset(_lib_env)
if(WIN32)
string(REPLACE ":" ";" _lib_env "$ENV{LIB}")
set(ENV_HWLOC_LIBDIR "$ENV{HWLOC_LIBDIR}")
if(ENV_HWLOC_LIBDIR)
list(APPEND _lib_env "${ENV_HWLOC_LIBDIR}")
elseif(ENV_HWLOC_DIR)
list(APPEND _lib_env "${ENV_HWLOC_DIR}")
list(APPEND _lib_env "${ENV_HWLOC_DIR}/lib")
else()
if(APPLE)
string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}")
if(WIN32)
string(REPLACE ":" ";" _lib_env "$ENV{LIB}")
else()
string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}")
if(APPLE)
string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}")
else()
string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}")
endif()
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)
......@@ -256,9 +276,9 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT HWLOC_FOUND) OR NOT HWLOC_FOUND OR HWLOC_
set(CMAKE_REQUIRED_LIBRARIES)
endif(HWLOC_LIBRARIES)
endif( (NOT PKG_CONFIG_EXECUTABLE AND NOT HWLOC_FOUND) OR NOT HWLOC_FOUND OR HWLOC_DIR)
endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT HWLOC_FOUND) OR (HWLOC_DIR) )
if (HWLOC_LIBRARIES AND NOT HWLOC_DIR)
if (HWLOC_LIBRARIES)
if (HWLOC_LIBRARY_DIRS)
list(GET HWLOC_LIBRARY_DIRS 0 first_lib_path)
else()
......@@ -267,7 +287,9 @@ if (HWLOC_LIBRARIES AND NOT HWLOC_DIR)
endif()
if (${first_lib_path} MATCHES "/lib(32|64)?$")
string(REGEX REPLACE "/lib(32|64)?$" "" not_cached_dir "${first_lib_path}")
set(HWLOC_DIR "${not_cached_dir}" CACHE PATH "Installation directory of HWLOC library" FORCE)
set(HWLOC_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of HWLOC library" FORCE)
else()
set(HWLOC_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of HWLOC library" FORCE)
endif()
endif()
......
......@@ -35,11 +35,8 @@
# 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
# The module can also look for the following environment variables if paths
# are not given as cmake variable: LAPACK_DIR, LAPACK_INCDIR, LAPACK_LIBDIR
# 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
......@@ -167,7 +164,9 @@ 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)
if (BLAS_LIBDIR)
list(APPEND _libdir "${BLAS_LIBDIR}")
elseif (BLAS_DIR)
list(APPEND _libdir "${BLAS_DIR}")
list(APPEND _libdir "${BLAS_DIR}/lib")
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
......@@ -177,8 +176,8 @@ if (NOT _libdir)
list(APPEND _libdir "${BLAS_DIR}/lib32")
list(APPEND _libdir "${BLAS_DIR}/lib/ia32")
endif()
elseif (BLAS_LIBDIR)
list(APPEND _libdir "${BLAS_LIBDIR}")
elseif(ENV_BLAS_LIBDIR)
list(APPEND _libdir "${ENV_BLAS_LIBDIR}")
elseif(ENV_BLAS_DIR)
list(APPEND _libdir "${ENV_BLAS_DIR}")
list(APPEND _libdir "${ENV_BLAS_DIR}/lib")
......@@ -189,10 +188,10 @@ if (NOT _libdir)
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)
if (LAPACK_LIBDIR)
list(APPEND _libdir "${LAPACK_LIBDIR}")
elseif (LAPACK_DIR)
list(APPEND _libdir "${LAPACK_DIR}")
list(APPEND _libdir "${LAPACK_DIR}/lib")
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
......@@ -202,8 +201,8 @@ if (NOT _libdir)
list(APPEND _libdir "${LAPACK_DIR}/lib32")
list(APPEND _libdir "${LAPACK_DIR}/lib/ia32")
endif()
elseif (LAPACK_LIBDIR)
list(APPEND _libdir "${LAPACK_LIBDIR}")
elseif(ENV_LAPACK_LIBDIR)
list(APPEND _libdir "${ENV_LAPACK_LIBDIR}")
elseif(ENV_LAPACK_DIR)
list(APPEND _libdir "${ENV_LAPACK_DIR}")
list(APPEND _libdir "${ENV_LAPACK_DIR}/lib")
......@@ -214,8 +213,6 @@ if (NOT _libdir)
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")
......
......@@ -39,6 +39,8 @@
# LAPACKE_DIR - Where to find the base directory of lapacke
# LAPACKE_INCDIR - Where to find the header files
# LAPACKE_LIBDIR - Where to find the library files
# The module can also look for the following environment variables if paths
# are not given as cmake variable: LAPACKE_DIR, LAPACKE_INCDIR, LAPACKE_LIBDIR
#
# LAPACKE could be directly embedded in LAPACK library (ex: Intel MKL) so that
# we test a lapacke function with the lapack libraries found and set LAPACKE
......@@ -143,17 +145,27 @@ if (LAPACK_FOUND)
# Add system include paths to search include
# ------------------------------------------
unset(_inc_env)
if(WIN32)
string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}")
set(ENV_LAPACKE_DIR "$ENV{LAPACKE_DIR}")
set(ENV_LAPACKE_INCDIR "$ENV{LAPACKE_INCDIR}")
if(ENV_LAPACKE_INCDIR)
list(APPEND _inc_env "${ENV_LAPACKE_INCDIR}")
elseif(ENV_LAPACKE_DIR)
list(APPEND _inc_env "${ENV_LAPACKE_DIR}")
list(APPEND _inc_env "${ENV_LAPACKE_DIR}/include")
list(APPEND _inc_env "${ENV_LAPACKE_DIR}/include/lapacke")
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(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_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}")
list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}")
......@@ -174,7 +186,7 @@ if (LAPACK_FOUND)
find_path(LAPACKE_lapacke.h_DIRS
NAMES lapacke.h
HINTS ${LAPACKE_DIR}
PATH_SUFFIXES include)
PATH_SUFFIXES "include" "include/lapacke")