Commit 1b38bbc9 authored by PRUVOST Florent's avatar PRUVOST Florent

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 31229b32
......@@ -544,7 +544,7 @@ if (MORSE_DISTRIB_DIR OR EXISTS "${CMAKE_SOURCE_DIR}/cmake_modules/")
list(APPEND STARPU_COMPONENT_LIST "FXT")
endif()
find_package(STARPU ${CHAMELEON_STARPU_VERSION}
find_package(STARPU ${CHAMELEON_STARPU_VERSION} REQUIRED
COMPONENTS ${STARPU_COMPONENT_LIST})
# Add definition and include_dir if found
......
......@@ -35,6 +35,10 @@
# 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
##########
### List of vendors (BLA_VENDOR) valid in this module
########## List of vendors (BLA_VENDOR) valid in this module
......@@ -180,8 +184,13 @@ 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)
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")
......@@ -191,9 +200,28 @@ 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")
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()
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 +398,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 +472,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 +508,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}")
......@@ -936,12 +968,14 @@ endif(BLA_F95)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
if (BLAS_FOUND AND NOT BLAS_DIR)
if (BLAS_FOUND)
list(GET BLAS_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(BLAS_DIR "${not_cached_dir}" CACHE PATH "Installation directory of BLAS library" FORCE)
set(BLAS_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of BLAS library" FORCE)
else()
set(BLAS_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of BLAS library" FORCE)
endif()
endif()
......@@ -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()
......
This diff is collapsed.
......@@ -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,6 +35,10 @@
# 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
### List of vendors (BLA_VENDOR) valid in this module
## Intel(mkl), ACML,Apple, NAS, Generic
......@@ -154,21 +158,40 @@ 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()
elseif (BLAS_LIBDIR)
list(APPEND _libdir "${BLAS_LIBDIR}")
endif ()
if (LAPACK_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")
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(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")
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()
endif()
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")
......@@ -178,9 +201,28 @@ 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")
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()
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")