diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ba1662f454011640ddd91ae287521107b6f9772..63bd5e1bb96c09b4a63ae2c52e8eab1b9c69dbc8 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/CMakeModules/morse/find/FindBLAS.cmake b/CMakeModules/morse/find/FindBLAS.cmake index 8c946b77b92f1d0adb3e02ea75108f7f0302bcec..d2b71bcff70eefd571361dc6dafa58823474e850 100644 --- a/CMakeModules/morse/find/FindBLAS.cmake +++ b/CMakeModules/morse/find/FindBLAS.cmake @@ -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() + diff --git a/CMakeModules/morse/find/FindCBLAS.cmake b/CMakeModules/morse/find/FindCBLAS.cmake index bbf09d2767e67af478436363059d1d4c9441eddb..f75ed4b0ca4c180390ad040ef799ada6c4dba6a5 100644 --- a/CMakeModules/morse/find/FindCBLAS.cmake +++ b/CMakeModules/morse/find/FindCBLAS.cmake @@ -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 # ------------------------------- diff --git a/CMakeModules/morse/find/FindCHAMELEON.cmake b/CMakeModules/morse/find/FindCHAMELEON.cmake index 815452956c2986792da3001c478d25a251bea03c..2478fe8e4d9f66ea0cd5613e4a9b8346bafed417 100644 --- a/CMakeModules/morse/find/FindCHAMELEON.cmake +++ b/CMakeModules/morse/find/FindCHAMELEON.cmake @@ -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 # --------------------------------- diff --git a/CMakeModules/morse/find/FindFFTW.cmake b/CMakeModules/morse/find/FindFFTW.cmake index 0d7622c9a33a5f5d23eb55aa0dca26a02bd3bc55..ad742325f00f04d7ecb798878d569924a7ad6fcc 100644 --- a/CMakeModules/morse/find/FindFFTW.cmake +++ b/CMakeModules/morse/find/FindFFTW.cmake @@ -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 # ------------------------------- diff --git a/CMakeModules/morse/find/FindFXT.cmake b/CMakeModules/morse/find/FindFXT.cmake index fdc1490761180c04abc95c2ac436f3f2cdf6efc1..6a0e3f2f46deec7778a4fe0a16e03f1b81f7baf2 100644 --- a/CMakeModules/morse/find/FindFXT.cmake +++ b/CMakeModules/morse/find/FindFXT.cmake @@ -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 # ------------------------------- diff --git a/CMakeModules/morse/find/FindHWLOC.cmake b/CMakeModules/morse/find/FindHWLOC.cmake index ee08a29cf004c124db0e4b0e51ce87e6bccba8cf..4c3be8d792d2a5014240c2a890d418a9c4d4c712 100644 --- a/CMakeModules/morse/find/FindHWLOC.cmake +++ b/CMakeModules/morse/find/FindHWLOC.cmake @@ -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 # ------------------------------- diff --git a/CMakeModules/morse/find/FindLAPACK.cmake b/CMakeModules/morse/find/FindLAPACK.cmake index 93f89b27d9a19c2d6ceb33b486b8927248f37d67..1f27e6c9e7477b59df02139cb683d40c69101084 100644 --- a/CMakeModules/morse/find/FindLAPACK.cmake +++ b/CMakeModules/morse/find/FindLAPACK.cmake @@ -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 root directory of the library with cmake option: -D${LIBNAME}_DIR=your/path/to/${libname}/\n" + "- Option 1: Provide the installation directory of the 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}") @@ -114,7 +114,7 @@ macro(Print_Find_Library_Blas_Status _libname _lib_to_find) endmacro() if (NOT LAPACK_FOUND) - set(LAPACK_DIR "" CACHE PATH "Root directory of LAPACK library") + set(LAPACK_DIR "" CACHE PATH "Installation directory of LAPACK library") if (NOT LAPACK_FIND_QUIETLY) message(STATUS "A cache variable, namely LAPACK_DIR, has been set to specify the install directory of LAPACK") endif() @@ -165,8 +165,7 @@ if (NOT _libdir) 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 (LAPACK_DIR) @@ -179,20 +178,20 @@ if (NOT _libdir) list(APPEND _libdir "${LAPACK_DIR}/lib32") list(APPEND _libdir "${LAPACK_DIR}/lib/ia32") endif() - endif () - if (LAPACK_LIBDIR) + elseif (LAPACK_LIBDIR) list(APPEND _libdir "${LAPACK_LIBDIR}") + 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 () - 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 () if (LAPACK_VERBOSE) @@ -367,6 +366,8 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") set(LAPACK_SEARCH_LIBS "") + set(additional_flags "-Wl,--no-as-needed") + if (BLA_F95) set(LAPACK_mkl_SEARCH_SYMBOL "CHEEV") set(_LIBRARIES LAPACK95_LIBRARIES) @@ -399,11 +400,14 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") ${_LIBRARIES} BLAS ${LAPACK_mkl_SEARCH_SYMBOL} - "" + "${additional_flags}" "" "${_BLAS_LIBRARIES}" "${CMAKE_THREAD_LIBS_INIT};${LM}" ) + if(_LIBRARIES) + set(LAPACK_LINKER_FLAGS "${additional_flags}") + endif() endif () # Then try the search libs foreach (IT ${LAPACK_SEARCH_LIBS}) @@ -412,11 +416,14 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") ${_LIBRARIES} BLAS ${LAPACK_mkl_SEARCH_SYMBOL} - "" + "${additional_flags}" "${IT}" "${_BLAS_LIBRARIES}" "${CMAKE_THREAD_LIBS_INIT};${LM}" ) + if(_LIBRARIES) + set(LAPACK_LINKER_FLAGS "${additional_flags}") + endif() endif () endforeach () endif () @@ -438,7 +445,7 @@ if(BLA_F95) else(LAPACK95_FOUND) message(WARNING "BLA_VENDOR has been set to ${BLA_VENDOR} but LAPACK 95 libraries could not be found or check of symbols failed." "\nPlease indicate where to find LAPACK libraries. You have three options:\n" - "- Option 1: Provide the root directory of LAPACK library with cmake option: -DLAPACK_DIR=your/path/to/lapack\n" + "- Option 1: Provide the installation directory of LAPACK library with cmake option: -DLAPACK_DIR=your/path/to/lapack\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 -DLAPACK_VERBOSE=ON at cmake configure." @@ -473,7 +480,7 @@ else(BLA_F95) else(LAPACK_FOUND) message(WARNING "BLA_VENDOR has been set to ${BLA_VENDOR} but LAPACK libraries could not be found or check of symbols failed." "\nPlease indicate where to find LAPACK libraries. You have three options:\n" - "- Option 1: Provide the root directory of LAPACK library with cmake option: -DLAPACK_DIR=your/path/to/lapack\n" + "- Option 1: Provide the installation directory of LAPACK library with cmake option: -DLAPACK_DIR=your/path/to/lapack\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 -DLAPACK_VERBOSE=ON at cmake configure." @@ -495,3 +502,12 @@ else(BLA_F95) endif(BLA_F95) set(CMAKE_FIND_LIBRARY_SUFFIXES ${_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) + +if (LAPACK_FOUND AND NOT LAPACK_DIR) + list(GET LAPACK_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(LAPACK_DIR "${not_cached_dir}" CACHE PATH "Installation directory of LAPACK library" FORCE) + endif() +endif() diff --git a/CMakeModules/morse/find/FindLAPACKE.cmake b/CMakeModules/morse/find/FindLAPACKE.cmake index 6ef70b8dcc007fbb35a131b3f092c69662ab5d3d..43c7470295c1b2865b0fb101713729530f0cde07 100644 --- a/CMakeModules/morse/find/FindLAPACKE.cmake +++ b/CMakeModules/morse/find/FindLAPACKE.cmake @@ -26,6 +26,7 @@ # This module finds headers and lapacke library. # Results are reported in variables: # LAPACKE_FOUND - True if headers and requested libraries were found +# LAPACKE_LINKER_FLAGS - list of required linker flags (excluding -l and -L) # LAPACKE_INCLUDE_DIRS - lapacke include directories # LAPACKE_LIBRARY_DIRS - Link directories for lapacke libraries # LAPACKE_LIBRARIES - lapacke component libraries to be linked @@ -64,7 +65,7 @@ # License text for the above reference.) if (NOT LAPACKE_FOUND) - set(LAPACKE_DIR "" CACHE PATH "Root directory of LAPACKE library") + set(LAPACKE_DIR "" CACHE PATH "Installation directory of LAPACKE library") if (NOT LAPACKE_FIND_QUIETLY) message(STATUS "A cache variable, namely LAPACKE_DIR, has been set to specify the install directory of LAPACKE") endif() @@ -102,7 +103,7 @@ if (LAPACK_FOUND) if (NOT LAPACKE_STANDALONE) # check if a lapacke function exists in the LAPACK lib include(CheckFunctionExists) - set(CMAKE_REQUIRED_LIBRARIES "${LAPACK_LIBRARIES}") + set(CMAKE_REQUIRED_LIBRARIES "${LAPACK_LINKER_FLAGS};${LAPACK_LIBRARIES}") unset(LAPACKE_WORKS CACHE) check_function_exists(LAPACKE_dgeqrf LAPACKE_WORKS) mark_as_advanced(LAPACKE_WORKS) @@ -114,10 +115,15 @@ if (LAPACK_FOUND) endif() # test succeeds: LAPACKE is in LAPACK set(LAPACKE_LIBRARIES "${LAPACK_LIBRARIES}") - set(LAPACKE_LIBRARY_DIRS "${LAPACK_LIBRARY_DIRS}") + if (LAPACK_LIBRARY_DIRS) + set(LAPACKE_LIBRARY_DIRS "${LAPACK_LIBRARY_DIRS}") + endif() if(LAPACK_INCLUDE_DIRS) set(LAPACKE_INCLUDE_DIRS "${LAPACK_INCLUDE_DIRS}") endif() + if (LAPACK_LINKER_FLAGS) + set(LAPACKE_LINKER_FLAGS "${LAPACK_LINKER_FLAGS}") + endif() endif() endif (NOT LAPACKE_STANDALONE) @@ -252,6 +258,7 @@ if (LAPACK_FOUND) # check a function to validate the find if(LAPACKE_LIBRARIES) + set(REQUIRED_LDFLAGS) set(REQUIRED_INCDIRS) set(REQUIRED_LIBDIRS) set(REQUIRED_LIBS) @@ -272,11 +279,14 @@ if (LAPACK_FOUND) list(APPEND REQUIRED_LIBDIRS "${LAPACK_LIBRARY_DIRS}") endif() list(APPEND REQUIRED_LIBS "${LAPACK_LIBRARIES}") + if (LAPACK_LINKER_FLAGS) + list(APPEND REQUIRED_LDFLAGS "${LAPACK_LINKER_FLAGS}") + endif() # Fortran if (CMAKE_Fortran_COMPILER MATCHES ".+gfortran.*") - list(APPEND CMAKE_REQUIRED_LIBRARIES "-lgfortran") + list(APPEND REQUIRED_LIBS "-lgfortran") elseif (CMAKE_Fortran_COMPILER MATCHES ".+ifort.*") - list(APPEND CMAKE_REQUIRED_LIBRARIES "-lifcore") + list(APPEND REQUIRED_LIBS "-lifcore") endif() # m list(APPEND REQUIRED_LIBS "-lm") @@ -284,6 +294,7 @@ if (LAPACK_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() @@ -300,8 +311,10 @@ if (LAPACK_FOUND) set(LAPACKE_LIBRARIES_DEP "${REQUIRED_LIBS}") set(LAPACKE_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}") set(LAPACKE_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") + set(LAPACKE_LINKER_FLAGS "${REQUIRED_LDFLAGS}") list(REMOVE_DUPLICATES LAPACKE_LIBRARY_DIRS_DEP) list(REMOVE_DUPLICATES LAPACKE_INCLUDE_DIRS_DEP) + list(REMOVE_DUPLICATES LAPACKE_LINKER_FLAGS) else() if(NOT LAPACKE_FIND_QUIETLY) message(STATUS "Looking for lapacke: test of LAPACKE_dgeqrf with lapacke and lapack libraries fails") @@ -326,6 +339,14 @@ else(LAPACK_FOUND) endif(LAPACK_FOUND) +if (LAPACKE_LIBRARIES AND NOT LAPACKE_DIR) + list(GET LAPACKE_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(LAPACKE_DIR "${not_cached_dir}" CACHE PATH "Installation directory of LAPACKE library" FORCE) + endif() +endif() # check that LAPACKE has been found # --------------------------------- diff --git a/CMakeModules/morse/find/FindMAGMA.cmake b/CMakeModules/morse/find/FindMAGMA.cmake index 3438911746ffdfb60cf84fb16f40bd5973821edd..53f8573289848c74c196970900235b5698a4595e 100644 --- a/CMakeModules/morse/find/FindMAGMA.cmake +++ b/CMakeModules/morse/find/FindMAGMA.cmake @@ -27,6 +27,7 @@ # # Results are reported in variables: # MAGMA_FOUND - True if headers and requested libraries were found +# MAGMA_LINKER_FLAGS - list of required linker flags (excluding -l and -L) # MAGMA_INCLUDE_DIRS - magma include directories # MAGMA_LIBRARY_DIRS - Link directories for magma libraries # MAGMA_LIBRARIES - magma libraries @@ -59,7 +60,7 @@ if(NOT MAGMA_FOUND) - set(MAGMA_DIR "" CACHE PATH "Root directory of MAGMA library") + set(MAGMA_DIR "" CACHE PATH "Installation directory of MAGMA library") if (NOT MAGMA_FIND_QUIETLY) message(STATUS "A cache variable, namely MAGMA_DIR, has been set to specify the install directory of MAGMA") endif() @@ -147,11 +148,15 @@ if(PKG_CONFIG_EXECUTABLE) set(MAGMA_INCLUDE_DIRS_DEP "") set(MAGMA_LIBRARY_DIRS_DEP "") set(MAGMA_LIBRARIES_DEP "") + # replace it anyway: we should update it with dependencies given by pkg-config + set(MAGMA_INCLUDE_DIRS_DEP "${MAGMA_INCLUDE_DIRS}") + set(MAGMA_LIBRARY_DIRS_DEP "${MAGMA_LIBRARY_DIRS}") + set(MAGMA_LIBRARIES_DEP "${MAGMA_LIBRARIES}") -endif(PKG_CONFIG_EXECUTABLE) +endif() # if MAGMA is not found using pkg-config -if( (NOT PKG_CONFIG_EXECUTABLE AND NOT MAGMA_FOUND) OR NOT MAGMA_FOUND ) +if( (NOT PKG_CONFIG_EXECUTABLE AND NOT MAGMA_FOUND) OR NOT MAGMA_FOUND OR MAGMA_DIR) if (NOT MAGMA_FIND_QUIETLY) message(STATUS "Looking for MAGMA - PkgConfig not used") @@ -278,6 +283,7 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT MAGMA_FOUND) OR NOT MAGMA_FOUND ) # check a function to validate the find if (MAGMA_LIBRARIES) + set(REQUIRED_LDFLAGS) set(REQUIRED_INCDIRS) set(REQUIRED_LIBDIRS) set(REQUIRED_LIBS) @@ -306,6 +312,9 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT MAGMA_FOUND) OR NOT MAGMA_FOUND ) elseif(CBLAS_LIBRARIES) list(APPEND REQUIRED_LIBS "${CBLAS_LIBRARIES}") endif() + if (BLAS_LINKER_FLAGS) + list(APPEND REQUIRED_LDFLAGS "${BLAS_LINKER_FLAGS}") + endif() # LAPACK if (LAPACK_INCLUDE_DIRS) list(APPEND REQUIRED_INCDIRS "${LAPACK_INCLUDE_DIRS}") @@ -314,6 +323,9 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT MAGMA_FOUND) OR NOT MAGMA_FOUND ) list(APPEND REQUIRED_LIBDIRS "${LAPACK_LIBRARY_DIRS}") endif() list(APPEND REQUIRED_LIBS "${LAPACK_LIBRARIES}") + if (LAPACK_LINKER_FLAGS) + list(APPEND REQUIRED_LDFLAGS "${LAPACK_LINKER_FLAGS}") + endif() # CUDA if (CUDA_INCLUDE_DIRS) list(APPEND REQUIRED_INCDIRS "${CUDA_INCLUDE_DIRS}") @@ -326,6 +338,7 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT MAGMA_FOUND) OR NOT MAGMA_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() @@ -342,8 +355,10 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT MAGMA_FOUND) OR NOT MAGMA_FOUND ) set(MAGMA_LIBRARIES_DEP "${REQUIRED_LIBS}") set(MAGMA_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}") set(MAGMA_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") + set(MAGMA_LINKER_FLAGS "${REQUIRED_LDFLAGS}") list(REMOVE_DUPLICATES MAGMA_LIBRARY_DIRS_DEP) list(REMOVE_DUPLICATES MAGMA_INCLUDE_DIRS_DEP) + list(REMOVE_DUPLICATES MAGMA_LINKER_FLAGS) else() if(NOT MAGMA_FIND_QUIETLY) message(STATUS "Looking for magma : test of magma_dgetrf with @@ -358,8 +373,24 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT MAGMA_FOUND) OR NOT MAGMA_FOUND ) set(CMAKE_REQUIRED_LIBRARIES) endif(MAGMA_LIBRARIES) -endif( (NOT PKG_CONFIG_EXECUTABLE AND NOT MAGMA_FOUND) OR NOT MAGMA_FOUND ) +endif( (NOT PKG_CONFIG_EXECUTABLE AND NOT MAGMA_FOUND) OR NOT MAGMA_FOUND OR MAGMA_DIR) +if (MAGMA_LIBRARIES AND NOT MAGMA_DIR) + if (MAGMA_LIBRARY_DIRS) + foreach(dir ${MAGMA_LIBRARY_DIRS}) + if ("${dir}" MATCHES "magma") + set(first_lib_path "${dir}") + endif() + endforeach() + else() + list(GET MAGMA_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(MAGMA_DIR "${not_cached_dir}" CACHE PATH "Installation directory of MAGMA library" FORCE) + endif() +endif() # check that MAGMA has been found # ------------------------------- diff --git a/CMakeModules/morse/find/FindMETIS.cmake b/CMakeModules/morse/find/FindMETIS.cmake index 0056f9bd7b1fcef59ab69445d906a0332cb3fc67..f41f788c8ecf320d4fb818a862a67a7b1a5adfeb 100644 --- a/CMakeModules/morse/find/FindMETIS.cmake +++ b/CMakeModules/morse/find/FindMETIS.cmake @@ -45,7 +45,7 @@ # License text for the above reference.) if (NOT METIS_FOUND) - set(METIS_DIR "" CACHE PATH "Root directory of METIS library") + set(METIS_DIR "" CACHE PATH "Installation directory of METIS library") if (NOT METIS_FIND_QUIETLY) message(STATUS "A cache variable, namely METIS_DIR, has been set to specify the install directory of METIS") endif() @@ -213,6 +213,15 @@ if(METIS_LIBRARIES) set(CMAKE_REQUIRED_LIBRARIES) endif(METIS_LIBRARIES) +if (METIS_LIBRARIES AND NOT METIS_DIR) + list(GET METIS_LIBRARIES 0 first_lib) + get_filename_component(first_lib_path "${first_lib}" PATH) + if (${first_lib_path} MATCHES "/lib(32|64)?$") + string(REGEX REPLACE "/lib(32|64)?$" "" not_cached_dir "${first_lib_path}") + set(METIS_DIR "${not_cached_dir}" CACHE PATH "Installation directory of METIS library" FORCE) + endif() +endif() + # check that METIS has been found # --------------------------------- include(FindPackageHandleStandardArgs) diff --git a/CMakeModules/morse/find/FindMUMPS.cmake b/CMakeModules/morse/find/FindMUMPS.cmake index 3c0c79fd9db81191bdf07a6e323b3db3f08129d6..9d99eb561fbfb5fa25c70344e68a3ce93f5699bc 100644 --- a/CMakeModules/morse/find/FindMUMPS.cmake +++ b/CMakeModules/morse/find/FindMUMPS.cmake @@ -32,6 +32,7 @@ # This module finds headers and mumps library. # Results are reported in variables: # MUMPS_FOUND - True if headers and requested libraries were found +# MUMPS_LINKER_FLAGS - list of required linker flags (excluding -l and -L) # MUMPS_INCLUDE_DIRS - mumps include directories # MUMPS_LIBRARY_DIRS - Link directories for mumps libraries # MUMPS_LIBRARIES - mumps libraries @@ -62,7 +63,7 @@ if (NOT MUMPS_FOUND) - set(MUMPS_DIR "" CACHE PATH "Root directory of MUMPS library") + set(MUMPS_DIR "" CACHE PATH "Installation directory of MUMPS library") if (NOT MUMPS_FIND_QUIETLY) message(STATUS "A cache variable, namely MUMPS_DIR, has been set to specify the install directory of MUMPS") endif() @@ -159,7 +160,7 @@ if (NOT MPI_FOUND AND MUMPS_LOOK_FOR_MPI) if(NOT MPI_C_COMPILER) set(MPI_C_COMPILER mpicc) endif() - if (MUMPS_FIND_REQUIRED) + if (MUMPS_FIND_REQUIRED AND MUMPS_FIND_REQUIRED_MPI) find_package(MPI REQUIRED) else() find_package(MPI) @@ -177,7 +178,7 @@ if (NOT SCALAPACK_FOUND AND MUMPS_LOOK_FOR_MPI) message(STATUS "Looking for MUMPS - Try to detect SCALAPACK") endif() # SCALAPACK is a required dependency if MPI is used - if (MUMPS_FIND_REQUIRED) + if (MUMPS_FIND_REQUIRED AND MUMPS_FIND_REQUIRED_MPI) find_package(SCALAPACK REQUIRED) else() find_package(SCALAPACK) @@ -190,7 +191,7 @@ if (NOT SCOTCH_FOUND AND MUMPS_LOOK_FOR_SCOTCH) if (NOT MUMPS_FIND_QUIETLY) message(STATUS "Looking for MUMPS - Try to detect SCOTCH") endif() - if (MUMPS_FIND_REQUIRED) + if (MUMPS_FIND_REQUIRED AND MUMPS_FIND_REQUIRED_SCOTCH) find_package(SCOTCH REQUIRED) else() find_package(SCOTCH) @@ -203,7 +204,7 @@ if (NOT METIS_FOUND AND MUMPS_LOOK_FOR_METIS) if (NOT MUMPS_FIND_QUIETLY) message(STATUS "Looking for MUMPS - Try to detect METIS") endif() - if (MUMPS_FIND_REQUIRED) + if (MUMPS_FIND_REQUIRED AND MUMPS_FIND_REQUIRED_METIS) find_package(METIS REQUIRED) else() find_package(METIS) @@ -473,6 +474,7 @@ list(REMOVE_DUPLICATES MUMPS_INCLUDE_DIRS) # check a function to validate the find if(MUMPS_LIBRARIES) + set(REQUIRED_LDFLAGS) set(REQUIRED_INCDIRS) set(REQUIRED_LIBDIRS) set(REQUIRED_LIBS) @@ -498,6 +500,9 @@ if(MUMPS_LIBRARIES) endif() endforeach() list(APPEND REQUIRED_LIBS "${SCALAPACK_LIBRARIES}") + if (SCALAPACK_LINKER_FLAGS) + list(APPEND REQUIRED_LDFLAGS "${SCALAPACK_LINKER_FLAGS}") + endif() endif() # MPI if (MUMPS_LOOK_FOR_MPI AND MPI_FOUND) @@ -505,7 +510,7 @@ if(MUMPS_LIBRARIES) list(APPEND REQUIRED_INCDIRS "${MPI_C_INCLUDE_PATH}") endif() if (MPI_Fortran_LINK_FLAGS) - list(APPEND REQUIRED_LIBS "${MPI_Fortran_LINK_FLAGS}") + list(APPEND REQUIRED_LDFLAGS "${MPI_Fortran_LINK_FLAGS}") endif() list(APPEND REQUIRED_LIBS "${MPI_Fortran_LIBRARIES}") endif() @@ -520,6 +525,9 @@ if(MUMPS_LIBRARIES) endif() endforeach() list(APPEND REQUIRED_LIBS "${BLAS_LIBRARIES}") + if (BLAS_LINKER_FLAGS) + list(APPEND REQUIRED_LDFLAGS "${BLAS_LINKER_FLAGS}") + endif() endif() # SCOTCH if (MUMPS_LOOK_FOR_SCOTCH AND SCOTCH_FOUND) @@ -557,6 +565,7 @@ if(MUMPS_LIBRARIES) # 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() @@ -587,8 +596,10 @@ if(MUMPS_LIBRARIES) set(MUMPS_LIBRARIES_DEP "${REQUIRED_LIBS}") set(MUMPS_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}") set(MUMPS_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") + set(MUMPS_LINKER_FLAGS "${REQUIRED_LDFLAGS}") list(REMOVE_DUPLICATES MUMPS_LIBRARY_DIRS_DEP) list(REMOVE_DUPLICATES MUMPS_INCLUDE_DIRS_DEP) + list(REMOVE_DUPLICATES MUMPS_LINKER_FLAGS) else() if(NOT MUMPS_FIND_QUIETLY) message(STATUS "Looking for MUMPS : test of [sdcz]mumps() fails") @@ -605,6 +616,14 @@ if(MUMPS_LIBRARIES) set(CMAKE_REQUIRED_LIBRARIES) endif(MUMPS_LIBRARIES) +if (MUMPS_LIBRARIES AND NOT MUMPS_DIR) + list(GET MUMPS_LIBRARIES 0 first_lib) + get_filename_component(first_lib_path "${first_lib}" PATH) + if (${first_lib_path} MATCHES "/lib(32|64)?$") + string(REGEX REPLACE "/lib(32|64)?$" "" not_cached_dir "${first_lib_path}") + set(MUMPS_DIR "${not_cached_dir}" CACHE PATH "Installation directory of MUMPS library" FORCE) + endif() +endif() # check that MUMPS has been found # ------------------------------- diff --git a/CMakeModules/morse/find/FindPARMETIS.cmake b/CMakeModules/morse/find/FindPARMETIS.cmake index c009e48c36bce89236582e33ed21b2cb5db65530..75e59a4f0528acbd7dd537cd896160275f378298 100644 --- a/CMakeModules/morse/find/FindPARMETIS.cmake +++ b/CMakeModules/morse/find/FindPARMETIS.cmake @@ -45,7 +45,7 @@ # License text for the above reference.) if (NOT PARMETIS_FOUND) - set(PARMETIS_DIR "" CACHE PATH "Root directory of PARMETIS library") + set(PARMETIS_DIR "" CACHE PATH "Installation directory of PARMETIS library") if (NOT PARMETIS_FIND_QUIETLY) message(STATUS "A cache variable, namely PARMETIS_DIR, has been set to specify the install directory of PARMETIS") endif() @@ -213,6 +213,14 @@ if(PARMETIS_LIBRARIES) set(CMAKE_REQUIRED_LIBRARIES) endif(PARMETIS_LIBRARIES) +if (PARMETIS_LIBRARIES AND NOT PARMETIS_DIR) + list(GET PARMETIS_LIBRARIES 0 first_lib) + get_filename_component(first_lib_path "${first_lib}" PATH) + if (${first_lib_path} MATCHES "/lib(32|64)?$") + string(REGEX REPLACE "/lib(32|64)?$" "" not_cached_dir "${first_lib_path}") + set(PARMETIS_DIR "${not_cached_dir}" CACHE PATH "Installation directory of PARMETIS library" FORCE) + endif() +endif() # check that PARMETIS has been found # ---------------------------------- diff --git a/CMakeModules/morse/find/FindPASTIX.cmake b/CMakeModules/morse/find/FindPASTIX.cmake index ff72836cdcb1fdad9c6808ff1fa1235bb2c563bb..59bcb2ed898c52669f2ff330b0571e0dc894a839 100644 --- a/CMakeModules/morse/find/FindPASTIX.cmake +++ b/CMakeModules/morse/find/FindPASTIX.cmake @@ -38,6 +38,7 @@ # This module finds headers and pastix library. # Results are reported in variables: # PASTIX_FOUND - True if headers and requested libraries were found +# PASTIX_LINKER_FLAGS - list of required linker flags (excluding -l and -L) # PASTIX_INCLUDE_DIRS - pastix include directories # PASTIX_LIBRARY_DIRS - Link directories for pastix libraries # PASTIX_LIBRARIES - pastix libraries @@ -70,7 +71,7 @@ if (NOT PASTIX_FOUND) - set(PASTIX_DIR "" CACHE PATH "Root directory of PASTIX library") + set(PASTIX_DIR "" CACHE PATH "Installation directory of PASTIX library") if (NOT PASTIX_FIND_QUIETLY) message(STATUS "A cache variable, namely PASTIX_DIR, has been set to specify the install directory of PASTIX") endif() @@ -123,7 +124,6 @@ if( PASTIX_FIND_COMPONENTS ) endforeach() endif() - # Dependencies detection # ---------------------- @@ -226,7 +226,7 @@ if (NOT MPI_FOUND AND PASTIX_LOOK_FOR_MPI) if(NOT MPI_C_COMPILER) set(MPI_C_COMPILER mpicc) endif() - if (PASTIX_FIND_REQUIRED) + if (PASTIX_FIND_REQUIRED AND PASTIX_FIND_REQUIRED_MPI) find_package(MPI REQUIRED) else() find_package(MPI) @@ -268,7 +268,7 @@ if( NOT STARPU_FOUND AND PASTIX_LOOK_FOR_STARPU) list(APPEND STARPU_COMPONENT_LIST "FXT") endif() # set the list of optional dependencies we may discover - if (PASTIX_FIND_REQUIRED) + if (PASTIX_FIND_REQUIRED AND PASTIX_FIND_REQUIRED_STARPU) find_package(STARPU ${PASTIX_STARPU_VERSION} REQUIRED COMPONENTS ${STARPU_COMPONENT_LIST}) else() @@ -284,7 +284,7 @@ if (NOT SCOTCH_FOUND AND PASTIX_LOOK_FOR_SCOTCH) if (NOT PASTIX_FIND_QUIETLY) message(STATUS "Looking for PASTIX - Try to detect SCOTCH") endif() - if (PASTIX_FIND_REQUIRED ) + if (PASTIX_FIND_REQUIRED AND PASTIX_FIND_REQUIRED_SCOTCH) find_package(SCOTCH REQUIRED) else() find_package(SCOTCH) @@ -297,7 +297,7 @@ if (NOT PTSCOTCH_FOUND AND PASTIX_LOOK_FOR_PTSCOTCH) if (NOT PASTIX_FIND_QUIETLY) message(STATUS "Looking for PASTIX - Try to detect PTSCOTCH") endif() - if (PASTIX_FIND_REQUIRED) + if (PASTIX_FIND_REQUIRED AND PASTIX_FIND_REQUIRED_PTSCOTCH) find_package(PTSCOTCH REQUIRED) else() find_package(PTSCOTCH) @@ -310,7 +310,7 @@ if (NOT METIS_FOUND AND PASTIX_LOOK_FOR_METIS) if (NOT PASTIX_FIND_QUIETLY) message(STATUS "Looking for PASTIX - Try to detect METIS") endif() - if (PASTIX_FIND_REQUIRED) + if (PASTIX_FIND_REQUIRED AND PASTIX_FIND_REQUIRED_METIS) find_package(METIS REQUIRED) else() find_package(METIS) @@ -461,10 +461,10 @@ endforeach(pastix_lib ${PASTIX_libs_to_find}) # check a function to validate the find if(PASTIX_LIBRARIES) + set(REQUIRED_LDFLAGS) set(REQUIRED_INCDIRS) set(REQUIRED_LIBDIRS) set(REQUIRED_LIBS) - set(REQUIRED_FLAGS) # PASTIX if (PASTIX_INCLUDE_DIRS) @@ -518,7 +518,7 @@ if(PASTIX_LIBRARIES) 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() @@ -551,6 +551,9 @@ if(PASTIX_LIBRARIES) endif() endforeach() list(APPEND REQUIRED_LIBS "${BLAS_LIBRARIES}") + if (BLAS_LINKER_FLAGS) + list(APPEND REQUIRED_LDFLAGS "${BLAS_LINKER_FLAGS}") + endif() endif() # SCOTCH if (PASTIX_LOOK_FOR_SCOTCH AND SCOTCH_FOUND) @@ -594,6 +597,7 @@ if(PASTIX_LIBRARIES) # 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() @@ -608,15 +612,13 @@ if(PASTIX_LIBRARIES) if(PASTIX_WORKS) # save link with dependencies - if (REQUIRED_FLAGS) - set(PASTIX_LIBRARIES_DEP "${REQUIRED_FLAGS};${REQUIRED_LIBS}") - else() - set(PASTIX_LIBRARIES_DEP "${REQUIRED_LIBS}") - endif() + set(PASTIX_LIBRARIES_DEP "${REQUIRED_LIBS}") set(PASTIX_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}") set(PASTIX_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") + set(PASTIX_LINKER_FLAGS "${REQUIRED_LDFLAGS}") list(REMOVE_DUPLICATES PASTIX_LIBRARY_DIRS_DEP) list(REMOVE_DUPLICATES PASTIX_INCLUDE_DIRS_DEP) + list(REMOVE_DUPLICATES PASTIX_LINKER_FLAGS) else() if(NOT PASTIX_FIND_QUIETLY) message(STATUS "Looking for PASTIX : test of pastix() fails") @@ -633,6 +635,14 @@ if(PASTIX_LIBRARIES) set(CMAKE_REQUIRED_LIBRARIES) endif(PASTIX_LIBRARIES) +if (PASTIX_LIBRARIES AND NOT PASTIX_DIR) + list(GET PASTIX_LIBRARIES 0 first_lib) + get_filename_component(first_lib_path "${first_lib}" PATH) + if (${first_lib_path} MATCHES "/lib(32|64)?$") + string(REGEX REPLACE "/lib(32|64)?$" "" not_cached_dir "${first_lib_path}") + set(PASTIX_DIR "${not_cached_dir}" CACHE PATH "Installation directory of PASTIX library" FORCE) + endif() +endif() # check that PASTIX has been found # --------------------------------- diff --git a/CMakeModules/morse/find/FindPTSCOTCH.cmake b/CMakeModules/morse/find/FindPTSCOTCH.cmake index b9fac6d555de590dccc66da3a927e42e456ac3ac..bb62202212ee0f5b02827107474338e4d03d6053 100644 --- a/CMakeModules/morse/find/FindPTSCOTCH.cmake +++ b/CMakeModules/morse/find/FindPTSCOTCH.cmake @@ -21,6 +21,7 @@ # This module finds headers and ptscotch library. # Results are reported in variables: # PTSCOTCH_FOUND - True if headers and requested libraries were found +# PTSCOTCH_LINKER_FLAGS - list of required linker flags (excluding -l and -L) # PTSCOTCH_INCLUDE_DIRS - ptscotch include directories # PTSCOTCH_LIBRARY_DIRS - Link directories for ptscotch libraries # PTSCOTCH_LIBRARIES - ptscotch component libraries to be linked @@ -53,7 +54,7 @@ # License text for the above reference.) if (NOT PTSCOTCH_FOUND) - set(PTSCOTCH_DIR "" CACHE PATH "Root directory of PTSCOTCH library") + set(PTSCOTCH_DIR "" CACHE PATH "Installation directory of PTSCOTCH library") if (NOT PTSCOTCH_FIND_QUIETLY) message(STATUS "A cache variable, namely PTSCOTCH_DIR, has been set to specify the install directory of PTSCOTCH") endif() @@ -212,10 +213,10 @@ endforeach() # check a function to validate the find if(PTSCOTCH_LIBRARIES) + set(REQUIRED_LDFLAGS) set(REQUIRED_INCDIRS) set(REQUIRED_LIBDIRS) set(REQUIRED_LIBS) - set(REQUIRED_FLAGS) # PTSCOTCH if (PTSCOTCH_INCLUDE_DIRS) @@ -231,7 +232,7 @@ if(PTSCOTCH_LIBRARIES) list(APPEND CMAKE_REQUIRED_INCLUDES "${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() @@ -243,6 +244,7 @@ if(PTSCOTCH_LIBRARIES) # 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() @@ -257,15 +259,13 @@ if(PTSCOTCH_LIBRARIES) if(PTSCOTCH_WORKS) # save link with dependencies - if (REQUIRED_FLAGS) - set(PTSCOTCH_LIBRARIES_DEP "${REQUIRED_FLAGS};${REQUIRED_LIBS}") - else() - set(PTSCOTCH_LIBRARIES_DEP "${REQUIRED_LIBS}") - endif() + set(PTSCOTCH_LIBRARIES_DEP "${REQUIRED_LIBS}") set(PTSCOTCH_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}") set(PTSCOTCH_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") + set(PTSCOTCH_LINKER_FLAGS "${REQUIRED_LDFLAGS}") list(REMOVE_DUPLICATES PTSCOTCH_LIBRARY_DIRS_DEP) list(REMOVE_DUPLICATES PTSCOTCH_INCLUDE_DIRS_DEP) + list(REMOVE_DUPLICATES PTSCOTCH_LINKER_FLAGS) else() if(NOT PTSCOTCH_FIND_QUIETLY) message(STATUS "Looking for PTSCOTCH : test of SCOTCH_dgraphInit with PTSCOTCH library fails") @@ -279,6 +279,14 @@ if(PTSCOTCH_LIBRARIES) set(CMAKE_REQUIRED_LIBRARIES) endif(PTSCOTCH_LIBRARIES) +if (PTSCOTCH_LIBRARIES AND NOT PTSCOTCH_DIR) + list(GET PTSCOTCH_LIBRARIES 0 first_lib) + get_filename_component(first_lib_path "${first_lib}" PATH) + if (${first_lib_path} MATCHES "/lib(32|64)?$") + string(REGEX REPLACE "/lib(32|64)?$" "" not_cached_dir "${first_lib_path}") + set(PTSCOTCH_DIR "${not_cached_dir}" CACHE PATH "Installation directory of PTSCOTCH library" FORCE) + endif() +endif() # Check the size of SCOTCH_Num # --------------------------------- diff --git a/CMakeModules/morse/find/FindQUARK.cmake b/CMakeModules/morse/find/FindQUARK.cmake index 5ac3a64bbcc5e561c08ec06ff772d7d20033e74e..7dbf0b4e12926d1e853e993852452308d9bd96d2 100644 --- a/CMakeModules/morse/find/FindQUARK.cmake +++ b/CMakeModules/morse/find/FindQUARK.cmake @@ -58,7 +58,7 @@ if (NOT QUARK_FOUND) - set(QUARK_DIR "" CACHE PATH "Root directory of QUARK library") + set(QUARK_DIR "" CACHE PATH "Installation directory of QUARK library") if (NOT QUARK_FIND_QUIETLY) message(STATUS "A cache variable, namely QUARK_DIR, has been set to specify the install directory of QUARK") endif() @@ -87,7 +87,7 @@ endif() # QUARK may depend on HWLOC, try to find it if (NOT HWLOC_FOUND AND QUARK_LOOK_FOR_HWLOC) - if (QUARK_FIND_REQUIRED) + if (QUARK_FIND_REQUIRED AND QUARK_FIND_REQUIRED_HWLOC) find_package(HWLOC REQUIRED) else() find_package(HWLOC) @@ -282,6 +282,14 @@ if(QUARK_LIBRARIES) set(CMAKE_REQUIRED_LIBRARIES) endif(QUARK_LIBRARIES) +if (QUARK_LIBRARIES AND NOT QUARK_DIR) + list(GET QUARK_LIBRARIES 0 first_lib) + get_filename_component(first_lib_path "${first_lib}" PATH) + if (${first_lib_path} MATCHES "/lib(32|64)?$") + string(REGEX REPLACE "/lib(32|64)?$" "" not_cached_dir "${first_lib_path}") + set(QUARK_DIR "${not_cached_dir}" CACHE PATH "Installation directory of QUARK library" FORCE) + endif() +endif() # check that QUARK has been found # --------------------------------- diff --git a/CMakeModules/morse/find/FindSCALAPACK.cmake b/CMakeModules/morse/find/FindSCALAPACK.cmake index 4d9151880e88dbf9f488957dc7b7b447397d0ec0..e8107788cf2ab51f10612113d2796d9fc14bb1a7 100644 --- a/CMakeModules/morse/find/FindSCALAPACK.cmake +++ b/CMakeModules/morse/find/FindSCALAPACK.cmake @@ -103,7 +103,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 the 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}") @@ -111,7 +111,7 @@ macro(Print_Find_Library_Blas_Status _libname _lib_to_find) endmacro() if (NOT SCALAPACK_FOUND) - set(SCALAPACK_DIR "" CACHE PATH "Root directory of SCALAPACK library") + set(SCALAPACK_DIR "" CACHE PATH "Installation directory of SCALAPACK library") if (NOT SCALAPACK_FIND_QUIETLY) message(STATUS "A cache variable, namely SCALAPACK_DIR, has been set to specify the install directory of SCALAPACK") endif() @@ -163,7 +163,7 @@ if (NOT _libdir) list(APPEND _libdir "${BLAS_DIR}/lib/ia32") endif() endif () - if (BLAS_LIBDIR) + elseif (BLAS_LIBDIR) list(APPEND _libdir "${BLAS_LIBDIR}") endif () if (SCALAPACK_DIR) @@ -177,19 +177,20 @@ if (NOT _libdir) list(APPEND _libdir "${SCALAPACK_DIR}/lib/ia32") endif() endif () - if (SCALAPACK_LIBDIR) + elseif (SCALAPACK_LIBDIR) list(APPEND _libdir "${SCALAPACK_LIBDIR}") + 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 () - 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 () if (SCALAPACK_VERBOSE) @@ -391,7 +392,7 @@ if(BLA_F95) else(SCALAPACK95_FOUND) message(WARNING "BLA_VENDOR has been set to ${BLA_VENDOR} but SCALAPACK 95 libraries could not be found or check of symbols failed." "\nPlease indicate where to find SCALAPACK libraries. You have three options:\n" - "- Option 1: Provide the root directory of SCALAPACK library with cmake option: -DSCALAPACK_DIR=your/path/to/scalapack\n" + "- Option 1: Provide the installation directory of SCALAPACK library with cmake option: -DSCALAPACK_DIR=your/path/to/scalapack\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 -DSCALAPACK_VERBOSE=ON at cmake configure." @@ -426,7 +427,7 @@ else(BLA_F95) else(SCALAPACK_FOUND) message(WARNING "BLA_VENDOR has been set to ${BLA_VENDOR} but SCALAPACK libraries could not be found or check of symbols failed." "\nPlease indicate where to find SCALAPACK libraries. You have three options:\n" - "- Option 1: Provide the root directory of SCALAPACK library with cmake option: -DSCALAPACK_DIR=your/path/to/scalapack\n" + "- Option 1: Provide the installation directory of SCALAPACK library with cmake option: -DSCALAPACK_DIR=your/path/to/scalapack\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 -DSCALAPACK_VERBOSE=ON at cmake configure." @@ -448,3 +449,12 @@ else(BLA_F95) endif(BLA_F95) set(CMAKE_FIND_LIBRARY_SUFFIXES ${_scalapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) + +if (SCALAPACK_LIBRARIES AND NOT SCALAPACK_DIR) + list(GET SCALAPACK_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(SCALAPACK_DIR "${not_cached_dir}" CACHE PATH "Installation directory of SCALAPACK library" FORCE) + endif() +endif() diff --git a/CMakeModules/morse/find/FindSCOTCH.cmake b/CMakeModules/morse/find/FindSCOTCH.cmake index 1be82357830851cd28c5a0d07bb1fd4567aa035d..8b7eace5d6e52d23637150c32d9c6fbc68d09fef 100644 --- a/CMakeModules/morse/find/FindSCOTCH.cmake +++ b/CMakeModules/morse/find/FindSCOTCH.cmake @@ -46,7 +46,7 @@ # License text for the above reference.) if (NOT SCOTCH_FOUND) - set(SCOTCH_DIR "" CACHE PATH "Root directory of SCOTCH library") + set(SCOTCH_DIR "" CACHE PATH "Installation directory of SCOTCH library") if (NOT SCOTCH_FIND_QUIETLY) message(STATUS "A cache variable, namely SCOTCH_DIR, has been set to specify the install directory of SCOTCH") endif() @@ -210,7 +210,7 @@ if(SCOTCH_LIBRARIES) set(REQUIRED_LIBS "${SCOTCH_LIBRARIES}") # THREADS if(CMAKE_THREAD_LIBS_INIT) - list(APPEND CMAKE_REQUIRED_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}") + list(APPEND REQUIRED_LIBS "${CMAKE_THREAD_LIBS_INIT}") endif() # set required libraries for link @@ -243,6 +243,14 @@ if(SCOTCH_LIBRARIES) set(CMAKE_REQUIRED_LIBRARIES) endif(SCOTCH_LIBRARIES) +if (SCOTCH_LIBRARIES AND NOT SCOTCH_DIR) + list(GET SCOTCH_LIBRARIES 0 first_lib) + get_filename_component(first_lib_path "${first_lib}" PATH) + if (${first_lib_path} MATCHES "/lib(32|64)?$") + string(REGEX REPLACE "/lib(32|64)?$" "" not_cached_dir "${first_lib_path}") + set(SCOTCH_DIR "${not_cached_dir}" CACHE PATH "Installation directory of SCOTCH library" FORCE) + endif() +endif() # Check the size of SCOTCH_Num # --------------------------------- diff --git a/CMakeModules/morse/find/FindSTARPU.cmake b/CMakeModules/morse/find/FindSTARPU.cmake index 195fce882f581d6be8db129446c18611cb57a142..ff166ceb339ca10823c174ceea60fea2992517b1 100644 --- a/CMakeModules/morse/find/FindSTARPU.cmake +++ b/CMakeModules/morse/find/FindSTARPU.cmake @@ -28,14 +28,16 @@ # # Results are reported in variables: # STARPU_FOUND - True if headers and requested libraries were found +# STARPU_C_FLAGS - list of required compilation flags (excluding -I) +# STARPU_LINKER_FLAGS - list of required linker flags (excluding -l and -L) # STARPU_INCLUDE_DIRS - starpu include directories # STARPU_LIBRARY_DIRS - Link directories for starpu libraries # STARPU_LIBRARIES - starpu libraries # STARPU_SHM_LIBRARIES - starpu libraries without libstarpumpi # STARPU_MPI_LIBRARIES - starpu libraries with libstarpumpi -# STARPU_INCLUDE_DIRS_DEP - starpu + dependencies include directories -# STARPU_LIBRARY_DIRS_DEP - starpu + dependencies link directories -# STARPU_LIBRARIES_DEP - starpu libraries + dependencies +# STARPU_INCLUDE_DIRS_DEP - starpu + dependencies include directories +# STARPU_LIBRARY_DIRS_DEP - starpu + dependencies link directories +# STARPU_LIBRARIES_DEP - starpu libraries + dependencies # STARPU_VERSION_STRING - A human-readable string containing the version of the package found # STARPU_VERSION_MAJOR - The major version of the package found # STARPU_VERSION_MINOR - The minor version of the package found @@ -64,7 +66,7 @@ # License text for the above reference.) if (NOT STARPU_FOUND) - set(STARPU_DIR "" CACHE PATH "Root directory of STARPU library") + set(STARPU_DIR "" CACHE PATH "Installation directory of STARPU library") if (NOT STARPU_FIND_QUIETLY) message(STATUS "A cache variable, namely STARPU_DIR, has been set to specify the install directory of STARPU") endif() @@ -99,7 +101,7 @@ endif() # STARPU may depend on HWLOC, try to find it if (NOT HWLOC_FOUND AND STARPU_LOOK_FOR_HWLOC) - if (STARPU_FIND_REQUIRED) + if (STARPU_FIND_REQUIRED AND STARPU_FIND_REQUIRED_HWLOC) find_package(HWLOC REQUIRED) else() find_package(HWLOC) @@ -108,7 +110,7 @@ endif() # STARPU may depend on CUDA, try to find it if (NOT CUDA_FOUND AND STARPU_LOOK_FOR_CUDA) - if (STARPU_FIND_REQUIRED) + if (STARPU_FIND_REQUIRED AND STARPU_FIND_REQUIRED_CUDA) find_package(CUDA REQUIRED) else() find_package(CUDA) @@ -124,7 +126,7 @@ endif() # STARPU may depend on MPI, try to find it if (NOT MPI_FOUND AND STARPU_LOOK_FOR_MPI) - if (STARPU_FIND_REQUIRED) + if (STARPU_FIND_REQUIRED AND STARPU_FIND_REQUIRED_MPI) find_package(MPI REQUIRED) else() find_package(MPI) @@ -137,7 +139,7 @@ endif() # STARPU may depend on BLAS, try to find it if (NOT BLAS_FOUND AND STARPU_LOOK_FOR_BLAS) - if (STARPU_FIND_REQUIRED) + if (STARPU_FIND_REQUIRED AND STARPU_FIND_REQUIRED_BLAS) find_package(BLAS REQUIRED) else() find_package(BLAS) @@ -146,7 +148,7 @@ endif() # STARPU may depend on MAGMA, try to find it if (NOT MAGMA_FOUND AND STARPU_LOOK_FOR_MAGMA) - if (STARPU_FIND_REQUIRED) + if (STARPU_FIND_REQUIRED AND STARPU_FIND_REQUIRED_MAGMA) find_package(MAGMA REQUIRED) else() find_package(MAGMA) @@ -155,7 +157,7 @@ endif() # STARPU may depend on FXT, try to find it if (NOT FXT_FOUND AND STARPU_LOOK_FOR_FXT) - if (STARPU_FIND_REQUIRED) + if (STARPU_FIND_REQUIRED AND STARPU_FIND_REQUIRED_FXT) find_package(FXT REQUIRED) else() find_package(FXT) @@ -227,12 +229,14 @@ if(PKG_CONFIG_EXECUTABLE) else() set(STARPU_LIBRARIES "STARPU_LIBRARIES-NOTFOUND") endif() - -endif(PKG_CONFIG_EXECUTABLE) + set(STARPU_INCLUDE_DIRS_DEP "${STARPU_INCLUDE_DIRS}") + set(STARPU_LIBRARY_DIRS_DEP "${STARPU_LIBRARY_DIRS}") +endif() if( (NOT PKG_CONFIG_EXECUTABLE AND NOT STARPU_FOUND) OR (NOT STARPU_SHM_FOUND OR (NOT STARPU_MPI_FOUND AND STARPU_LOOK_FOR_MPI)) + OR STARPU_DIR ) # Looking for include @@ -603,10 +607,11 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT STARPU_FOUND) OR # check a function to validate the find if(STARPU_LIBRARIES) + set(REQUIRED_FLAGS) + set(REQUIRED_LDFLAGS) set(REQUIRED_INCDIRS) set(REQUIRED_LIBDIRS) set(REQUIRED_LIBS) - set(REQUIRED_FLAGS) # STARPU if (STARPU_INCLUDE_DIRS) @@ -641,7 +646,7 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT STARPU_FOUND) OR 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() @@ -668,6 +673,9 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT STARPU_FOUND) OR endif() endforeach() endif() + if (MAGMA_LINKER_FLAGS) + list(APPEND REQUIRED_LDFLAGS "${MAGMA_LINKER_FLAGS}") + endif() endif() # CUDA if (CUDA_FOUND AND STARPU_LOOK_FOR_CUDA) @@ -704,6 +712,9 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT STARPU_FOUND) OR 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() endif() # Fortran if (CMAKE_Fortran_COMPILER MATCHES ".+gfortran.*") @@ -715,6 +726,7 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT STARPU_FOUND) OR # 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() @@ -736,8 +748,10 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT STARPU_FOUND) OR endif() set(STARPU_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}") set(STARPU_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") + set(STARPU_LINKER_FLAGS "${REQUIRED_LDFLAGS}") list(REMOVE_DUPLICATES STARPU_LIBRARY_DIRS_DEP) list(REMOVE_DUPLICATES STARPU_INCLUDE_DIRS_DEP) + list(REMOVE_DUPLICATES STARPU_LINKER_FLAGS) else() if(NOT STARPU_FIND_QUIETLY) message(STATUS "Looking for starpu : test of starpu_init fails") @@ -756,8 +770,25 @@ if( (NOT PKG_CONFIG_EXECUTABLE AND NOT STARPU_FOUND) OR endif( (NOT PKG_CONFIG_EXECUTABLE AND NOT STARPU_FOUND) OR (NOT STARPU_SHM_FOUND OR (NOT STARPU_MPI_FOUND AND STARPU_LOOK_FOR_MPI)) + OR STARPU_DIR ) +if (STARPU_LIBRARIES AND NOT STARPU_DIR) + if (STARPU_LIBRARY_DIRS) + foreach(dir ${STARPU_LIBRARY_DIRS}) + if ("${dir}" MATCHES "starpu") + set(first_lib_path "${dir}") + endif() + endforeach() + else() + list(GET STARPU_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(STARPU_DIR "${not_cached_dir}" CACHE PATH "Installation directory of STARPU library" FORCE) + endif() +endif() # check that STARPU has been found # -------------------------------- diff --git a/CMakeModules/morse/find/FindTMG.cmake b/CMakeModules/morse/find/FindTMG.cmake index d781da4096465eb0a6fadc1e748f832eeef6524b..83b65ad49e7da447183a6e21d67499f16f866cc0 100644 --- a/CMakeModules/morse/find/FindTMG.cmake +++ b/CMakeModules/morse/find/FindTMG.cmake @@ -17,6 +17,7 @@ # This module finds headers and tmg library. # Results are reported in variables: # TMG_FOUND - True if headers and requested libraries were found +# TMG_LINKER_FLAGS - list of required linker flags (excluding -l and -L) # TMG_INCLUDE_DIRS - tmg include directories # TMG_LIBRARY_DIRS - Link directories for tmg libraries # TMG_LIBRARIES - tmg component libraries to be linked @@ -49,7 +50,7 @@ if (NOT TMG_FOUND) - set(TMG_DIR "" CACHE PATH "Root directory of TMG library") + set(TMG_DIR "" CACHE PATH "Installation directory of TMG library") if (NOT TMG_FIND_QUIETLY) message(STATUS "A cache variable, namely TMG_DIR, has been set to specify the install directory of TMG") endif() @@ -77,7 +78,7 @@ endif() if (LAPACK_FOUND) # check if a tmg function exists in the LAPACK lib - set(CMAKE_REQUIRED_LIBRARIES "${LAPACK_LIBRARIES}") + set(CMAKE_REQUIRED_LIBRARIES "${LAPACK_LINKER_FLAGS};${LAPACK_LIBRARIES}") include(CheckFunctionExists) include(CheckFortranFunctionExists) unset(TMG_WORKS CACHE) @@ -103,10 +104,15 @@ if (LAPACK_FOUND) endif() # test succeeds: TMG is in LAPACK set(TMG_LIBRARIES "${LAPACK_LIBRARIES}") - set(TMG_LIBRARY_DIRS "${LAPACK_LIBRARY_DIRS}") + if (LAPACK_LIBRARY_DIRS) + set(TMG_LIBRARY_DIRS "${LAPACK_LIBRARY_DIRS}") + endif() if(LAPACK_INCLUDE_DIRS) set(TMG_INCLUDE_DIRS "${LAPACK_INCLUDE_DIRS}") endif() + if (LAPACK_LINKER_FLAGS) + set(TMG_LINKER_FLAGS "${LAPACK_LINKER_FLAGS}") + endif() else() if(NOT TMG_FIND_QUIETLY) @@ -181,6 +187,7 @@ if (LAPACK_FOUND) # check a function to validate the find if(TMG_LIBRARIES) + set(REQUIRED_LDFLAGS) set(REQUIRED_INCDIRS) set(REQUIRED_LIBDIRS) set(REQUIRED_LIBS) @@ -201,10 +208,14 @@ if (LAPACK_FOUND) list(APPEND REQUIRED_LIBDIRS "${LAPACK_LIBRARY_DIRS}") endif() list(APPEND REQUIRED_LIBS "${LAPACK_LIBRARIES}") + if (LAPACK_LINKER_FLAGS) + list(APPEND REQUIRED_LDFLAGS "${LAPACK_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() @@ -234,8 +245,10 @@ if (LAPACK_FOUND) set(TMG_LIBRARIES_DEP "${REQUIRED_LIBS}") set(TMG_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}") set(TMG_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") + set(TMG_LINKER_FLAGS "${REQUIRED_LDFLAGS}") list(REMOVE_DUPLICATES TMG_LIBRARY_DIRS_DEP) list(REMOVE_DUPLICATES TMG_INCLUDE_DIRS_DEP) + list(REMOVE_DUPLICATES TMG_LINKER_FLAGS) else() if(NOT TMG_FIND_QUIETLY) message(STATUS "Looking for tmg: test of dlarnv and dlagsy with tmg and lapack libraries fails") @@ -260,6 +273,14 @@ else() endif() +if (TMG_LIBRARIES AND NOT TMG_DIR) + list(GET TMG_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(TMG_DIR "${not_cached_dir}" CACHE PATH "Installation directory of TMG library" FORCE) + endif() +endif() # check that TMG has been found # -------------------------------