Commit 54c18ffc authored by Florent Pruvost's avatar Florent Pruvost

_DEP variables are now always defined in Finds so that test on them are not useful anymore

parent 331d2196
......@@ -318,25 +318,11 @@ if (MORSE_DISTRIB_DIR OR EXISTS "${CMAKE_SOURCE_DIR}/CMakeModules/morse/")
# MKL, THREADS|OMP and/or SIMPLE|DOUBLE|LONG|QUAD
# Default is DOUBLE and without THREADS|OMP
find_package(FFTW REQUIRED COMPONENTS MKL)
if(FFTW_LIBRARY_DIRS_DEP)
set(FFT_LIBRARIES "-L${FFTW_LIBRARY_DIRS_DEP};" CACHE STRING "Set your MKL flags")
elseif(FFTW_LIBRARY_DIRS)
set(FFT_LIBRARIES "-L${FFTW_LIBRARY_DIRS};" CACHE STRING "Set your MKL flags")
endif()
if (FFTW_LIBRARIES_DEP)
foreach (fft_lib ${FFTW_LIBRARIES_DEP})
set(FFT_LIBRARIES "${FFT_LIBRARIES} ${fft_lib};")
endforeach()
elseif(FFTW_LIBRARIES)
foreach (fft_lib ${FFTW_LIBRARIES})
set(FFT_LIBRARIES "${FFT_LIBRARIES} ${fft_lib};")
endforeach()
endif()
if (FFTW_INCLUDE_DIRS_DEP)
set(FFT_INCLUDES "${FFTW_INCLUDE_DIRS_DEP}" )
elseif (FFTW_INCLUDE_DIRS)
set(FFT_INCLUDES "${FFTW_INCLUDE_DIRS}" )
endif()
set(FFT_LIBRARIES "-L${FFTW_LIBRARY_DIRS_DEP};" CACHE STRING "Set your MKL flags")
foreach (fft_lib ${FFTW_LIBRARIES_DEP})
set(FFT_LIBRARIES "${FFT_LIBRARIES} ${fft_lib};")
endforeach()
set(FFT_INCLUDES "${FFTW_INCLUDE_DIRS_DEP}" )
set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES}; ${FFT_LIBRARIES}")
endif(ScalFMM_USE_MKL_AS_BLAS)
......@@ -349,25 +335,11 @@ if (MORSE_DISTRIB_DIR OR EXISTS "${CMAKE_SOURCE_DIR}/CMakeModules/morse/")
# Default is DOUBLE and without THREADS|OMP
find_package(FFTW REQUIRED)
if(FFTW_LIBRARY_DIRS_DEP)
set(FFT_LIBRARIES "-L${FFTW_LIBRARY_DIRS_DEP};" CACHE STRING "Set your MKL flags")
elseif(FFTW_LIBRARY_DIRS)
set(FFT_LIBRARIES "-L${FFTW_LIBRARY_DIRS};" CACHE STRING "Set your MKL flags")
endif()
if (FFTW_LIBRARIES_DEP)
foreach (fft_lib ${FFTW_LIBRARIES_DEP})
set(FFT_LIBRARIES "${FFT_LIBRARIES} ${fft_lib};")
endforeach()
elseif(FFTW_LIBRARIES)
foreach (fft_lib ${FFTW_LIBRARIES})
set(FFT_LIBRARIES "${FFT_LIBRARIES} ${fft_lib};")
endforeach()
endif()
if (FFTW_INCLUDE_DIRS_DEP)
set(FFT_INCLUDES "${FFTW_INCLUDE_DIRS_DEP}" )
elseif (FFTW_INCLUDE_DIRS)
set(FFT_INCLUDES "${FFTW_INCLUDE_DIRS}" )
endif()
set(FFT_LIBRARIES "-L${FFTW_LIBRARY_DIRS_DEP};" CACHE STRING "Set your MKL flags")
foreach (fft_lib ${FFTW_LIBRARIES_DEP})
set(FFT_LIBRARIES "${FFT_LIBRARIES} ${fft_lib};")
endforeach()
set(FFT_INCLUDES "${FFTW_INCLUDE_DIRS_DEP}" )
set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES}; ${FFT_LIBRARIES}")
endif(ScalFMM_USE_MKL_AS_FFTW)
......@@ -451,45 +423,21 @@ if (MORSE_DISTRIB_DIR OR EXISTS "${CMAKE_SOURCE_DIR}/CMakeModules/morse/")
COMPONENTS ${STARPU_COMPONENT_LIST})
# Append list of libraries and include dirs
if (STARPU_INCLUDE_DIRS_DEP)
include_directories(${STARPU_INCLUDE_DIRS_DEP})
elseif(STARPU_INCLUDE_DIRS)
include_directories(${STARPU_INCLUDE_DIRS})
endif()
if (STARPU_LIBRARY_DIRS_DEP)
foreach (starpu_libdir ${STARPU_LIBRARY_DIRS_DEP})
if (${starpu_libdir} MATCHES "^ *-L")
set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES}; ${starpu_libdir}")
else()
set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES}; -L${starpu_libdir}")
endif()
endforeach()
elseif(STARPU_LIBRARY_DIRS)
foreach (starpu_libdir ${STARPU_LIBRARY_DIRS})
if (${starpu_libdir} MATCHES "^ *-L")
set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES}; ${starpu_libdir}")
else()
set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES}; -L${starpu_libdir}")
endif()
endforeach()
endif()
if (STARPU_LIBRARIES_DEP)
foreach (starpu_lib ${STARPU_LIBRARIES_DEP})
if (EXISTS ${starpu_lib} OR ${starpu_lib} MATCHES "^ *-")
set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES}; ${starpu_lib}")
else()
set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES}; -l${starpu_lib}")
endif()
endforeach()
elseif(STARPU_LIBRARIES)
foreach (starpu_lib ${STARPU_LIBRARIES})
if (EXISTS ${starpu_lib} OR ${starpu_lib} MATCHES "^ *-")
set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES}; ${starpu_lib}")
else()
set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES}; -l${starpu_lib}")
endif()
endforeach()
endif()
include_directories(${STARPU_INCLUDE_DIRS_DEP})
foreach (starpu_libdir ${STARPU_LIBRARY_DIRS_DEP})
if (${starpu_libdir} MATCHES "^ *-L")
set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES}; ${starpu_libdir}")
else()
set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES}; -L${starpu_libdir}")
endif()
endforeach()
foreach (starpu_lib ${STARPU_LIBRARIES_DEP})
if (EXISTS ${starpu_lib} OR ${starpu_lib} MATCHES "^ *-")
set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES}; ${starpu_lib}")
else()
set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES}; -l${starpu_lib}")
endif()
endforeach()
if (CUDA_LIBRARIES)
set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES}; ${CUDA_LIBRARIES}")
......@@ -500,11 +448,10 @@ if (MORSE_DISTRIB_DIR OR EXISTS "${CMAKE_SOURCE_DIR}/CMakeModules/morse/")
if (STARPU_INCLUDE_DIRS)
message(STATUS " STARPU_INCLUDES = ${STARPU_INCLUDE_DIRS}")
endif()
OPTION( ScalFMM_USE_OPENCL "Set to ON to use OPENCL with StarPU" OFF )
MESSAGE( STATUS "ScalFMM_USE_OPENCL = ${ScalFMM_USE_OPENCL}" )
if(ScalFMM_USE_OPENCL)
if(ScalFMM_USE_OPENCL)
include_directories($ENV{OPENCL_INC})
SET(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES}; -L$ENV{OPENCL_LIB}; -lOpenCL")
endif()
......
......@@ -110,7 +110,7 @@ macro(Print_Find_Library_Blas_Status _libname _lib_to_find)
endif()
endif()
message("${BoldYellow}Please indicate where to find ${_lib_to_find}. You have three options:\n"
"- Option 1: Provide the root directory of the library with cmake option: -D${LIBNAME}_DIR=your/path/to/${libname}/\n"
"- Option 1: Provide the Installation directory of BLAS library with cmake option: -D${LIBNAME}_DIR=your/path/to/${libname}/\n"
"- Option 2: Provide the directory where to find the library with cmake option: -D${LIBNAME}_LIBDIR=your/path/to/${libname}/lib/\n"
"- Option 3: Update your environment variable (Linux: LD_LIBRARY_PATH, Windows: LIB, Mac: DYLD_LIBRARY_PATH)\n"
"- Option 4: If your library provides a PkgConfig file, make sure pkg-config finds your library${ColourReset}")
......@@ -135,14 +135,13 @@ macro(Print_Find_Library_Blas_CheckFunc_Status _name)
endmacro()
if (NOT BLAS_FOUND)
set(BLAS_DIR "" CACHE PATH "Root directory of BLAS library")
set(BLAS_DIR "" CACHE PATH "Installation directory of BLAS library")
if (NOT BLAS_FIND_QUIETLY)
message(STATUS "A cache variable, namely BLAS_DIR, has been set to specify the install directory of BLAS")
endif()
endif()
option(BLAS_VERBOSE "Print some additional information during BLAS
libraries detection" OFF)
option(BLAS_VERBOSE "Print some additional information during BLAS libraries detection" OFF)
include(CheckFunctionExists)
include(CheckFortranFunctionExists)
......@@ -179,7 +178,7 @@ macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _thread)
set(_libdir ${ARGN})
set(_libraries_work TRUE)
set(${LIBRARIES} ${_flags})
set(${LIBRARIES})
set(_combined_name)
if (NOT _libdir)
if (BLAS_DIR)
......@@ -192,20 +191,20 @@ macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _thread)
list(APPEND _libdir "${BLAS_DIR}/lib32")
list(APPEND _libdir "${BLAS_DIR}/lib/ia32")
endif()
endif ()
if (BLAS_LIBDIR)
elseif (BLAS_LIBDIR)
list(APPEND _libdir "${BLAS_LIBDIR}")
endif ()
if (WIN32)
string(REPLACE ":" ";" _libdir2 "$ENV{LIB}")
elseif (APPLE)
string(REPLACE ":" ";" _libdir2 "$ENV{DYLD_LIBRARY_PATH}")
else ()
string(REPLACE ":" ";" _libdir2 "$ENV{LD_LIBRARY_PATH}")
endif ()
list(APPEND _libdir "${_libdir2}")
list(APPEND _libdir "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}")
list(APPEND _libdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}")
else()
if (WIN32)
string(REPLACE ":" ";" _libdir2 "$ENV{LIB}")
elseif (APPLE)
string(REPLACE ":" ";" _libdir2 "$ENV{DYLD_LIBRARY_PATH}")
else ()
string(REPLACE ":" ";" _libdir2 "$ENV{LD_LIBRARY_PATH}")
endif ()
list(APPEND _libdir "${_libdir2}")
list(APPEND _libdir "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}")
list(APPEND _libdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}")
endif()
endif ()
if (BLAS_VERBOSE)
......@@ -272,10 +271,10 @@ macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _thread)
endif()
if(_libraries_work)
set(${LIBRARIES} ${${LIBRARIES}} ${_thread})
else()
set(${LIBRARIES} ${${LIBRARIES}} ${_thread})
else(_libraries_work)
set(${LIBRARIES} FALSE)
endif()
endif(_libraries_work)
# message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}")
......@@ -476,6 +475,9 @@ if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All")
"${SEARCH_LIBS}"
"${CMAKE_THREAD_LIBS_INIT};${LM}"
)
if(_LIBRARIES)
set(BLAS_LINKER_FLAGS "${additional_flags}")
endif()
endif()
endforeach ()
......@@ -870,7 +872,7 @@ if(BLA_F95)
else(BLAS95_FOUND)
message(WARNING "BLA_VENDOR has been set to ${BLA_VENDOR} but blas 95 libraries could not be found or check of symbols failed."
"\nPlease indicate where to find blas libraries. You have three options:\n"
"- Option 1: Provide the root directory of BLAS library with cmake option: -DBLAS_DIR=your/path/to/blas\n"
"- Option 1: Provide the installation directory of BLAS library with cmake option: -DBLAS_DIR=your/path/to/blas\n"
"- Option 2: Provide the directory where to find BLAS libraries with cmake option: -DBLAS_LIBDIR=your/path/to/blas/libs\n"
"- Option 3: Update your environment variable (Linux: LD_LIBRARY_PATH, Windows: LIB, Mac: DYLD_LIBRARY_PATH)\n"
"\nTo follow libraries detection more precisely you can activate a verbose mode with -DBLAS_VERBOSE=ON at cmake configure."
......@@ -890,6 +892,9 @@ if(BLA_F95)
set(BLAS_FOUND TRUE)
set(BLAS_LIBRARIES "${BLAS95_LIBRARIES}")
if (NOT BLAS_LIBRARIES_DEP)
set(BLAS_LIBRARIES_DEP "${BLAS95_LIBRARIES}")
endif()
else(BLA_F95)
......@@ -906,7 +911,7 @@ else(BLA_F95)
else(BLAS_FOUND)
message(WARNING "BLA_VENDOR has been set to ${BLA_VENDOR} but blas libraries could not be found or check of symbols failed."
"\nPlease indicate where to find blas libraries. You have three options:\n"
"- Option 1: Provide the root directory of BLAS library with cmake option: -DBLAS_DIR=your/path/to/blas\n"
"- Option 1: Provide the installation directory of BLAS library with cmake option: -DBLAS_DIR=your/path/to/blas\n"
"- Option 2: Provide the directory where to find BLAS libraries with cmake option: -DBLAS_LIBDIR=your/path/to/blas/libs\n"
"- Option 3: Update your environment variable (Linux: LD_LIBRARY_PATH, Windows: LIB, Mac: DYLD_LIBRARY_PATH)\n"
"\nTo follow libraries detection more precisely you can activate a verbose mode with -DBLAS_VERBOSE=ON at cmake configure."
......@@ -927,3 +932,13 @@ else(BLA_F95)
endif(BLA_F95)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
if (BLAS_FOUND AND NOT BLAS_DIR)
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)
endif()
endif()
......@@ -26,6 +26,7 @@
# This module finds headers and cblas library.
# Results are reported in variables:
# CBLAS_FOUND - True if headers and requested libraries were found
# CBLAS_LINKER_FLAGS - list of required linker flags (excluding -l and -L)
# CBLAS_INCLUDE_DIRS - cblas include directories
# CBLAS_LIBRARY_DIRS - Link directories for cblas libraries
# CBLAS_LIBRARIES - cblas component libraries to be linked
......@@ -65,7 +66,7 @@
if (NOT CBLAS_FOUND)
set(CBLAS_DIR "" CACHE PATH "Root directory of CBLAS library")
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()
......@@ -107,7 +108,7 @@ if (BLAS_FOUND)
# check if a cblas function exists in the BLAS lib
# this can be the case with libs such as MKL, ACML
include(CheckFunctionExists)
set(CMAKE_REQUIRED_LIBRARIES "${BLAS_LIBRARIES}")
set(CMAKE_REQUIRED_LIBRARIES "${BLAS_LINKER_FLAGS};${BLAS_LIBRARIES}")
unset(CBLAS_WORKS CACHE)
check_function_exists(cblas_dscal CBLAS_WORKS)
mark_as_advanced(CBLAS_WORKS)
......@@ -119,10 +120,15 @@ if (BLAS_FOUND)
endif()
# test succeeds: CBLAS is in BLAS
set(CBLAS_LIBRARIES "${BLAS_LIBRARIES}")
set(CBLAS_LIBRARY_DIRS "${BLAS_LIBRARY_DIRS}")
if (BLAS_LIBRARY_DIRS)
set(CBLAS_LIBRARY_DIRS "${BLAS_LIBRARY_DIRS}")
endif()
if(BLAS_INCLUDE_DIRS)
set(CBLAS_INCLUDE_DIRS "${BLAS_INCLUDE_DIRS}")
endif()
if (BLAS_LINKER_FLAGS)
set(CBLAS_LINKER_FLAGS "${BLAS_LINKER_FLAGS}")
endif()
endif()
endif (NOT CBLAS_STANDALONE)
......@@ -258,6 +264,7 @@ if (BLAS_FOUND)
if(CBLAS_LIBRARIES)
set(REQUIRED_INCDIRS)
set(REQUIRED_LDFLAGS)
set(REQUIRED_LIBDIRS)
set(REQUIRED_LIBS)
......@@ -277,10 +284,14 @@ if (BLAS_FOUND)
list(APPEND REQUIRED_LIBDIRS "${BLAS_LIBRARY_DIRS}")
endif()
list(APPEND REQUIRED_LIBS "${BLAS_LIBRARIES}")
if (BLAS_LINKER_FLAGS)
list(APPEND REQUIRED_LDFLAGS "${BLAS_LINKER_FLAGS}")
endif()
# set required libraries for link
set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
set(CMAKE_REQUIRED_LIBRARIES)
list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
foreach(lib_dir ${REQUIRED_LIBDIRS})
list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
endforeach()
......@@ -297,8 +308,10 @@ if (BLAS_FOUND)
set(CBLAS_LIBRARIES_DEP "${REQUIRED_LIBS}")
set(CBLAS_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}")
set(CBLAS_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}")
set(CBLAS_LINKER_FLAGS "${REQUIRED_LDFLAGS}")
list(REMOVE_DUPLICATES CBLAS_LIBRARY_DIRS_DEP)
list(REMOVE_DUPLICATES CBLAS_INCLUDE_DIRS_DEP)
list(REMOVE_DUPLICATES CBLAS_LINKER_FLAGS)
else()
if(NOT CBLAS_FIND_QUIETLY)
message(STATUS "Looking for cblas : test of cblas_dscal with cblas and blas libraries fails")
......@@ -323,6 +336,14 @@ else(BLAS_FOUND)
endif(BLAS_FOUND)
if (CBLAS_LIBRARIES AND NOT CBLAS_DIR)
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)
endif()
endif()
# check that CBLAS has been found
# -------------------------------
......
......@@ -37,6 +37,7 @@
# This module finds headers and chameleon library.
# Results are reported in variables:
# CHAMELEON_FOUND - True if headers and requested libraries were found
# CHAMELEON_LINKER_FLAGS - list of required linker flags (excluding -l and -L)
# CHAMELEON_INCLUDE_DIRS - chameleon include directories
# CHAMELEON_LIBRARY_DIRS - Link directories for chameleon libraries
# CHAMELEON_INCLUDE_DIRS_DEP - chameleon + dependencies include directories
......@@ -67,7 +68,7 @@
if (NOT CHAMELEON_FOUND)
set(CHAMELEON_DIR "" CACHE PATH "Root directory of CHAMELEON library")
set(CHAMELEON_DIR "" CACHE PATH "Installation directory of CHAMELEON library")
if (NOT CHAMELEON_FIND_QUIETLY)
message(STATUS "A cache variable, namely CHAMELEON_DIR, has been set to specify the install directory of CHAMELEON")
endif()
......@@ -155,9 +156,13 @@ if(PKG_CONFIG_EXECUTABLE)
endif()
endif()
endif(PKG_CONFIG_EXECUTABLE)
set(CHAMELEON_INCLUDE_DIRS_DEP "${CHAMELEON_INCLUDE_DIRS}")
set(CHAMELEON_LIBRARY_DIRS_DEP "${CHAMELEON_LIBRARY_DIRS}")
set(CHAMELEON_LIBRARIES_DEP "${CHAMELEON_LIBRARIES}")
if( (NOT PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR NOT CHAMELEON_FOUND )
endif()
if( (NOT PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR NOT CHAMELEON_FOUND OR CHAMELEON_DIR )
if (NOT CHAMELEON_FIND_QUIETLY)
message(STATUS "Looking for CHAMELEON - PkgConfig not used")
......@@ -265,7 +270,7 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR NOT CHAMELEON_FOUND )
# CHAMELEON may depend on CUDA/CUBLAS
#------------------------------------
if (NOT CUDA_FOUND AND CHAMELEON_LOOK_FOR_CUDA)
if (CHAMELEON_FIND_REQUIRED)
if (CHAMELEON_FIND_REQUIRED AND CHAMELEON_FIND_REQUIRED_CUDA)
find_package(CUDA REQUIRED)
else()
find_package(CUDA)
......@@ -285,7 +290,7 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR NOT CHAMELEON_FOUND )
#-------------------------------------------------
if( CUDA_FOUND AND CHAMELEON_LOOK_FOR_MAGMA )
set(CHAMELEON_MAGMA_VERSION "1.4" CACHE STRING "oldest MAGMA version desired")
if (CHAMELEON_FIND_REQUIRED)
if (CHAMELEON_FIND_REQUIRED AND CHAMELEON_FIND_REQUIRED_MAGMA)
find_package(MAGMA ${CHAMELEON_MAGMA_VERSION} REQUIRED)
else()
find_package(MAGMA ${CHAMELEON_MAGMA_VERSION})
......@@ -302,7 +307,7 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR NOT CHAMELEON_FOUND )
if(NOT MPI_C_COMPILER)
set(MPI_C_COMPILER mpicc)
endif()
if (CHAMELEON_FIND_REQUIRED)
if (CHAMELEON_FIND_REQUIRED AND CHAMELEON_FIND_REQUIRED_MPI)
find_package(MPI REQUIRED)
else()
find_package(MPI)
......@@ -338,7 +343,7 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR NOT CHAMELEON_FOUND )
if (CHAMELEON_LOOK_FOR_FXT)
list(APPEND STARPU_COMPONENT_LIST "FXT")
endif()
if (CHAMELEON_FIND_REQUIRED)
if (CHAMELEON_FIND_REQUIRED AND CHAMELEON_FIND_REQUIRED_STARPU)
find_package(STARPU ${CHAMELEON_STARPU_VERSION} REQUIRED
COMPONENTS ${STARPU_COMPONENT_LIST})
else()
......@@ -351,7 +356,7 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR NOT CHAMELEON_FOUND )
if( NOT QUARK_FOUND AND CHAMELEON_LOOK_FOR_QUARK )
# try to find quark runtime
if (CHAMELEON_FIND_REQUIRED)
if (CHAMELEON_FIND_REQUIRED AND CHAMELEON_FIND_REQUIRED_QUARK)
find_package(QUARK REQUIRED COMPONENTS HWLOC)
else()
find_package(QUARK COMPONENTS HWLOC)
......@@ -499,10 +504,10 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR NOT CHAMELEON_FOUND )
# check a function to validate the find
if(CHAMELEON_LIBRARIES)
set(REQUIRED_LDFLAGS)
set(REQUIRED_INCDIRS)
set(REQUIRED_LIBDIRS)
set(REQUIRED_LIBS)
set(REQUIRED_FLAGS)
# CHAMELEON
if (CHAMELEON_INCLUDE_DIRS)
......@@ -598,7 +603,7 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR NOT CHAMELEON_FOUND )
list(APPEND REQUIRED_INCDIRS "${MPI_C_INCLUDE_PATH}")
endif()
if (MPI_C_LINK_FLAGS)
list(APPEND REQUIRED_FLAGS "${MPI_C_LINK_FLAGS}")
list(APPEND REQUIRED_LDFLAGS "${MPI_C_LINK_FLAGS}")
endif()
list(APPEND REQUIRED_LIBS "${MPI_C_LIBRARIES}")
endif()
......@@ -637,6 +642,9 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR NOT CHAMELEON_FOUND )
elseif(TMG_LIBRARIES)
list(APPEND REQUIRED_LIBS "${TMG_LIBRARIES}")
endif()
if (TMG_LINKER_FLAGS)
list(APPEND REQUIRED_LDFLAGS "${TMG_LINKER_FLAGS}")
endif()
endif()
# LAPACKE
if (LAPACKE_FOUND)
......@@ -655,6 +663,9 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR NOT CHAMELEON_FOUND )
elseif(LAPACKE_LIBRARIES)
list(APPEND REQUIRED_LIBS "${LAPACKE_LIBRARIES}")
endif()
if (LAPACK_LINKER_FLAGS)
list(APPEND REQUIRED_LDFLAGS "${LAPACK_LINKER_FLAGS}")
endif()
endif()
# CBLAS
if (CBLAS_FOUND)
......@@ -673,6 +684,9 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR NOT CHAMELEON_FOUND )
elseif(CBLAS_LIBRARIES)
list(APPEND REQUIRED_LIBS "${CBLAS_LIBRARIES}")
endif()
if (BLAS_LINKER_FLAGS)
list(APPEND REQUIRED_LDFLAGS "${BLAS_LINKER_FLAGS}")
endif()
endif()
# EXTRA LIBS such that pthread, m, rt
list(APPEND REQUIRED_LIBS ${CHAMELEON_EXTRA_LIBRARIES})
......@@ -680,11 +694,11 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR NOT CHAMELEON_FOUND )
# set required libraries for link
set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
set(CMAKE_REQUIRED_LIBRARIES)
list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
foreach(lib_dir ${REQUIRED_LIBDIRS})
list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
endforeach()
list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
list(APPEND CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
# test link
unset(CHAMELEON_WORKS CACHE)
......@@ -694,15 +708,13 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR NOT CHAMELEON_FOUND )
if(CHAMELEON_WORKS)
# save link with dependencies
if (REQUIRED_FLAGS)
set(CHAMELEON_LIBRARIES_DEP "${REQUIRED_FLAGS};${REQUIRED_LIBS}")
else()
set(CHAMELEON_LIBRARIES_DEP "${REQUIRED_LIBS}")
endif()
set(CHAMELEON_LIBRARIES_DEP "${REQUIRED_LIBS}")
set(CHAMELEON_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}")
set(CHAMELEON_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}")
set(CHAMELEON_LINKER_FLAGS "${REQUIRED_LDFLAGS}")
list(REMOVE_DUPLICATES CHAMELEON_LIBRARY_DIRS_DEP)
list(REMOVE_DUPLICATES CHAMELEON_INCLUDE_DIRS_DEP)
list(REMOVE_DUPLICATES CHAMELEON_LINKER_FLAGS)
else()
if(NOT CHAMELEON_FIND_QUIETLY)
message(STATUS "Looking for chameleon : test of MORSE_Init fails")
......@@ -719,8 +731,24 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR NOT CHAMELEON_FOUND )
set(CMAKE_REQUIRED_LIBRARIES)
endif(CHAMELEON_LIBRARIES)
endif( (NOT PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR NOT CHAMELEON_FOUND )
endif( (NOT PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR NOT CHAMELEON_FOUND OR CHAMELEON_DIR)
if (CHAMELEON_LIBRARIES AND NOT CHAMELEON_DIR)
if (CHAMELEON_LIBRARY_DIRS)
foreach(dir ${CHAMELEON_LIBRARY_DIRS})
if ("${dir}" MATCHES "chameleon")
set(first_lib_path "${dir}")
endif()
endforeach()
else()
list(GET CHAMELEON_LIBRARIES 0 first_lib)
get_filename_component(first_lib_path "${first_lib}" PATH)
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)
endif()
endif()
# check that CHAMELEON has been found
# ---------------------------------
......
......@@ -26,6 +26,8 @@
# This module finds headers and fftw library.
# Results are reported in variables:
# FFTW_FOUND - True if headers and requested libraries were found
# FFTW_C_FLAGS - list of required compilation flags (excluding -I)
# FFTW_LINKER_FLAGS - list of required linker flags (excluding -l and -L)
# FFTW_INCLUDE_DIRS - fftw include directories
# FFTW_LIBRARY_DIRS - Link directories for fftw libraries
# FFTW_LIBRARIES - fftw component libraries to be linked
......@@ -58,7 +60,7 @@
if (NOT FFTW_FOUND)
set(FFTW_DIR "" CACHE PATH "Root directory of FFTW library")
set(FFTW_DIR "" CACHE PATH "Installation directory of FFTW library")
if (NOT FFTW_FIND_QUIETLY)
message(STATUS "A cache variable, namely FFTW_DIR, has been set to specify the install directory of FFTW")
endif()
......@@ -127,7 +129,7 @@ if( FFTW_FIND_COMPONENTS )
endif()
if (FFTW_LOOK_FOR_THREADS)
if (FFTW_FIND_REQUIRED)
if (FFTW_FIND_REQUIRED AND FFTW_FIND_REQUIRED_THREADS)
find_package(Threads REQUIRED)
else()
find_package(Threads)
......@@ -135,7 +137,7 @@ if (FFTW_LOOK_FOR_THREADS)
endif()
if (FFTW_LOOK_FOR_OMP)
if (FFTW_FIND_REQUIRED)
if (FFTW_FIND_REQUIRED AND FFTW_FIND_REQUIRED_OMP)
find_package(OpenMP REQUIRED)
else()
find_package(OpenMP)
......@@ -344,6 +346,8 @@ if( NOT FFTW_FOUND )
# check a function to validate the find
if(FFTW_LIBRARIES)
set(REQUIRED_FLAGS)
set(REQUIRED_LDFLAGS)
set(REQUIRED_INCDIRS)
set(REQUIRED_LIBDIRS)
set(REQUIRED_LIBS)
......@@ -363,21 +367,24 @@ if( NOT FFTW_FOUND )
# OMP
if(FFTW_LOOK_FOR_OMP)
if (CMAKE_C_COMPILER MATCHES ".+gcc.*")
set(CMAKE_REQUIRED_FLAGS "-fopenmp")
set(REQUIRED_FLAGS "-fopenmp")
endif()
endif()
# MKL
if(FFTW_LOOK_FOR_MKL)
list(APPEND REQUIRED_LIBS "-Wl,--no-as-needed;${CMAKE_REQUIRED_LIBRARIES};${CMAKE_THREAD_LIBS_INIT};-lm")
list(APPEND REQUIRED_LIBS "${CMAKE_THREAD_LIBS_INIT};-lm")
list(APPEND REQUIRED_LDFLAGS "-Wl,--no-as-needed")
endif()
# set required libraries for link
set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
set(CMAKE_REQUIRED_LIBRARIES)
list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
foreach(lib_dir ${REQUIRED_LIBDIRS})
list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
endforeach()
list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
list(APPEND CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
# test link
unset(FFTW_WORKS CACHE)
......@@ -390,13 +397,17 @@ if( NOT FFTW_FOUND )
set(FFTW_LIBRARIES_DEP "${REQUIRED_LIBS}")
set(FFTW_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}")
set(FFTW_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}")
set(FFTW_C_FLAGS "${REQUIRED_FLAGS}")
set(FFTW_LINKER_FLAGS "${REQUIRED_LDFLAGS}")
list(REMOVE_DUPLICATES FFTW_LIBRARY_DIRS_DEP)
list(REMOVE_DUPLICATES FFTW_INCLUDE_DIRS_DEP)
list(REMOVE_DUPLICATES FFTW_LINKER_FLAGS)
else()
if(NOT FFTW_FIND_QUIETLY)
message(STATUS "Looking for FFTW : test of ${FFTW_PREC_TESTFUNC}fftw_execute_ with fftw library fails")
message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
message(STATUS "CMAKE_REQUIRED_FLAGS: ${CMAKE_REQUIRED_FLAGS}")
message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
endif()
else()
......@@ -409,6 +420,14 @@ if( NOT FFTW_FOUND )
endif( NOT FFTW_FOUND )
if (FFTW_LIBRARIES AND NOT FFTW_DIR)
list(GET FFTW_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(FFTW_DIR "${not_cached_dir}" CACHE PATH "Installation directory of FFTW library" FORCE)
endif()
endif()
# check that FFTW has been found
# -------------------------------
......
......@@ -44,7 +44,7 @@
# License text for the above reference.)
if (NOT FXT_FOUND)
set(FXT_DIR "" CACHE PATH "Root directory of FXT library")
set(FXT_DIR "" CACHE PATH "Installation directory of FXT library")
if (NOT FXT_FIND_QUIETLY)
message(STATUS "A cache variable, namely FXT_DIR, has been set to specify the install directory of FXT")
endif()
......@@ -72,9 +72,9 @@ if(PKG_CONFIG_EXECUTABLE)
endif()
endif()
endif(PKG_CONFIG_EXECUTABLE)
endif()
if( (NOT PKG_CONFIG_EXECUTABLE AND NOT FXT_FOUND) OR NOT FXT_FOUND )
if( (NOT PKG_CONFIG_EXECUTABLE AND NOT FXT_FOUND) OR NOT FXT_FOUND OR FXT_DIR)
if (NOT FXT_FIND_QUIETLY)
message(STATUS "Looking for FXT - PkgConfig not used")
......@@ -248,8 +248,20 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT FXT_FOUND) OR NOT FXT_FOUND )
set(CMAKE_REQUIRED_LIBRARIES)
endif(FXT_LIBRARIES)
endif( (NOT PKG_CONFIG_EXECUTABLE AND NOT FXT_FOUND) OR NOT FXT_FOUND )
endif( (NOT PKG_CONFIG_EXECUTABLE AND NOT FXT_FOUND) OR NOT FXT_FOUND OR FXT_DIR)
if (FXT_LIBRARIES AND NOT FXT_DIR)
if (FXT_LIBRARY_DIRS)
list(GET FXT_LIBRARY_DIRS 0 first_lib_path)
else()
list(GET FXT_LIBRARIES 0 first_lib)
get_filename_component(first_lib_path "${first_lib}" PATH)
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)
endif()
endif()
# check that FXT has been found
# -------------------------------
......
......@@ -45,7 +45,7 @@
if (NOT HWLOC_FOUND)
set(HWLOC_DIR "" CACHE PATH "Root directory of HWLOC library")
set(HWLOC_DIR "" CACHE PATH "Installation directory of HWLOC library")
if (NOT HWLOC_FIND_QUIETLY)
message(STATUS "A cache variable, namely HWLOC_DIR, has been set to specify the install directory of HWLOC")
endif()
......@@ -73,9 +73,9 @@ if(PKG_CONFIG_EXECUTABLE)
endif()
endif()
endif(PKG_CONFIG_EXECUTABLE)
endif()
if( (NOT PKG_CONFIG_EXECUTABLE AND NOT HWLOC_FOUND) OR NOT HWLOC_FOUND )
if( (NOT PKG_CONFIG_EXECUTABLE AND NOT HWLOC_FOUND) OR NOT HWLOC_FOUND OR HWLOC_DIR)
if (NOT HWLOC_FIND_QUIETLY)
message(STATUS "Looking for HWLOC - PkgConfig not used")
......@@ -255,8 +255,20 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT HWLOC_FOUND) OR NOT HWLOC_FOUND )
set(CMAKE_REQUIRED_LIBRARIES)
endif(HWLOC_LIBRARIES)
endif( (NOT PKG_CONFIG_EXECUTABLE AND NOT HWLOC_FOUND) OR NOT HWLOC_FOUND )
endif( (NOT PKG_CONFIG_EXECUTABLE AND NOT HWLOC_FOUND) OR NOT HWLOC_FOUND OR HWLOC_DIR)
if (HWLOC_LIBRARIES AND NOT HWLOC_DIR)
if (HWLOC_LIBRARY_DIRS)
list(GET HWLOC_LIBRARY_DIRS 0 first_lib_path)
else()
list(GET HWLOC_LIBRARIES 0 first_lib)
get_filename_component(first_lib_path "${first_lib}" PATH)
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)
endif()
endif()
# check that HWLOC has been found
# -------------------------------
......
......@@ -106,7 +106,7 @@ macro(Print_Find_Library_Blas_Status _libname _lib_to_find)
endif()
endif()
message("${BoldYellow}Please indicate where to find ${_lib_to_find}. You have three options:\n"
"- Option 1: Provide the