diff --git a/cmake_modules/morse/find/FindBLAS.cmake b/cmake_modules/morse/find/FindBLAS.cmake index 829babf61fd391c28850286e3b9c21aca266adbb..3c6fc68f03178013c934f1f893f359672d68fda8 100644 --- a/cmake_modules/morse/find/FindBLAS.cmake +++ b/cmake_modules/morse/find/FindBLAS.cmake @@ -134,6 +134,10 @@ macro(Print_Find_Library_Blas_CheckFunc_Status _name) endmacro() +if (NOT BLAS_FOUND) + set(BLAS_DIR "" CACHE PATH "Root directory of BLAS library") +endif() + option(BLAS_VERBOSE "Print some additional information during BLAS libraries detection" OFF) @@ -264,7 +268,9 @@ macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _thread) set(CMAKE_REQUIRED_LIBRARIES) endif() - if(NOT _libraries_work) + if(_libraries_work) + set(${LIBRARIES} ${${LIBRARIES}} ${_thread}) + else() set(${LIBRARIES} FALSE) endif() diff --git a/cmake_modules/morse/find/FindCBLAS.cmake b/cmake_modules/morse/find/FindCBLAS.cmake index 0a0ddf04a38956162243b40fe8b3380d324305a7..a0015b3f06e52012172a911c7afa46fe5f4ec05d 100644 --- a/cmake_modules/morse/find/FindCBLAS.cmake +++ b/cmake_modules/morse/find/FindCBLAS.cmake @@ -50,7 +50,12 @@ # License text for the above reference.) -# CBLAS depends on BLAS +if (NOT CBLAS_FOUND) + set(CBLAS_DIR "" CACHE PATH "Root directory of CBLAS library") +endif() + + +# CBLAS may depend on BLASEXT # try to find it specified as COMPONENTS during the call if (CBLAS_FIND_COMPONENTS) foreach( component ${CBLAS_FIND_COMPONENTS} ) @@ -68,13 +73,24 @@ if (CBLAS_FIND_COMPONENTS) endif () -# CBLAS depends on BLAS +# CBLAS depends on BLAS anyway, try to find it +if (NOT BLAS_FOUND) + if(CBLAS_FIND_REQUIRED) + find_package(BLAS REQUIRED) + else() + find_package(BLAS) + endif() +endif() + + +# find CBLAS if (BLAS_FOUND) if (NOT CBLAS_STANDALONE) # 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};${CMAKE_THREAD_LIBS_INIT};${LM}") + set(CMAKE_REQUIRED_LIBRARIES "${BLAS_LIBRARIES}") unset(CBLAS_WORKS CACHE) check_function_exists(cblas_dscal CBLAS_WORKS) mark_as_advanced(CBLAS_WORKS) @@ -221,11 +237,44 @@ if (BLAS_FOUND) endif() endif () + if(CBLAS_LIBRARIES) + # check a function to validate the find + set(CMAKE_REQUIRED_INCLUDES "${CBLAS_INCLUDE_DIRS};${BLAS_INCLUDE_DIRS}") + set(CMAKE_REQUIRED_LIBRARIES "${CBLAS_LIBRARIES};${BLAS_LIBRARIES}") + set(CMAKE_REQUIRED_FLAGS "-L${CBLAS_LIBRARY_DIRS} -L${BLAS_LIBRARY_DIRS}") + + unset(CBLAS_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(cblas_dscal CBLAS_WORKS) + mark_as_advanced(CBLAS_WORKS) + + if(CBLAS_WORKS) + set(CBLAS_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + set(CBLAS_LIBRARY_DIRS "${CBLAS_LIBRARY_DIRS}" "${BLAS_LIBRARY_DIRS}") + set(CBLAS_INCLUDE_DIRS "${CMAKE_REQUIRED_INCLUDES}") + else() + if (CBLAS_FIND_REQUIRED) + if(NOT CBLAS_FIND_QUIETLY) + message(STATUS "Looking for cblas : test of cblas_dscal with cblas and blas libraries fails") + message(STATUS "CBLAS_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") + message(STATUS "CBLAS_LIBRARY_DIRS: ${CMAKE_REQUIRED_FLAGS}") + message(STATUS "CBLAS_INCLUDE_DIRS: ${CMAKE_REQUIRED_INCLUDES}") + message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") + message(STATUS "Looking for cblas : set CBLAS_LIBRARIES to NOTFOUND") + endif() + set(CBLAS_LIBRARIES "CBLAS_LIBRARIES-NOTFOUND") + endif() + endif() + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) + endif(CBLAS_LIBRARIES) + endif (CBLAS_STANDALONE OR NOT CBLAS_WORKS) else(BLAS_FOUND) - if (NOT CBLAS_FIND_QUIETLY OR NOT MORSE_VERBOSE) + if (NOT CBLAS_FIND_QUIETLY) message(STATUS "CBLAS requires BLAS but BLAS has not been found." "Please look for BLAS first.") endif() @@ -234,7 +283,7 @@ endif(BLAS_FOUND) # check that CBLAS has been found -# --------------------------------- +# ------------------------------- include(FindPackageHandleStandardArgs) find_package_handle_standard_args(CBLAS DEFAULT_MSG CBLAS_LIBRARIES diff --git a/cmake_modules/morse/find/FindHWLOC.cmake b/cmake_modules/morse/find/FindHWLOC.cmake index 0b3f891b9d46742fd0fd312589eec318a28ff4f8..a5948adbbafcd102de5125b54449c1c71bd883c1 100644 --- a/cmake_modules/morse/find/FindHWLOC.cmake +++ b/cmake_modules/morse/find/FindHWLOC.cmake @@ -42,6 +42,10 @@ # License text for the above reference.) +if (NOT HWLOC_FOUND) + set(HWLOC_DIR "" CACHE PATH "Root directory of HWLOC library") +endif() + # Optionally use pkg-config to detect include/library dirs (if pkg-config is available) # ------------------------------------------------------------------------------------- include(FindPkgConfig) @@ -203,6 +207,39 @@ if(NOT HWLOC_FOUND OR NOT HWLOC_LIBRARIES) list(REMOVE_DUPLICATES HWLOC_LIBRARY_DIRS) endif () + if(HWLOC_LIBRARIES) + # check a function to validate the find + set(CMAKE_REQUIRED_INCLUDES "${HWLOC_INCLUDE_DIRS}") + set(CMAKE_REQUIRED_LIBRARIES "${HWLOC_LIBRARIES}") + set(CMAKE_REQUIRED_FLAGS "-L${HWLOC_LIBRARY_DIRS}") + + unset(HWLOC_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(hwloc_topology_init HWLOC_WORKS) + mark_as_advanced(HWLOC_WORKS) + + if(HWLOC_WORKS) + set(HWLOC_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + set(HWLOC_LIBRARY_DIRS "${HWLOC_LIBRARY_DIRS}") + set(HWLOC_INCLUDE_DIRS "${CMAKE_REQUIRED_INCLUDES}") + else() + if (HWLOC_FIND_REQUIRED) + if(NOT HWLOC_FIND_QUIETLY) + message(STATUS "Looking for hwloc : test of hwloc_topology_init with hwloc library fails") + message(STATUS "HWLOC_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") + message(STATUS "HWLOC_LIBRARY_DIRS: ${CMAKE_REQUIRED_FLAGS}") + message(STATUS "HWLOC_INCLUDE_DIRS: ${CMAKE_REQUIRED_INCLUDES}") + message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") + message(STATUS "Looking for hwloc : set HWLOC_LIBRARIES to NOTFOUND") + endif() + set(HWLOC_LIBRARIES "HWLOC_LIBRARIES-NOTFOUND") + endif() + endif() + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) + endif(HWLOC_LIBRARIES) + endif(NOT HWLOC_FOUND OR NOT HWLOC_LIBRARIES) diff --git a/cmake_modules/morse/find/FindLAPACK.cmake b/cmake_modules/morse/find/FindLAPACK.cmake index c6a0145122c6b4878688dbd153e04bb8dd208c16..302c0d34c16bb1d72c57eabe100eb0def09ac3f8 100644 --- a/cmake_modules/morse/find/FindLAPACK.cmake +++ b/cmake_modules/morse/find/FindLAPACK.cmake @@ -113,6 +113,10 @@ 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") +endif (NOT LAPACK_FOUND) + option(LAPACK_VERBOSE "Print some additional information during LAPACK libraries detection" OFF) if (BLAS_VERBOSE) diff --git a/cmake_modules/morse/find/FindLAPACKE.cmake b/cmake_modules/morse/find/FindLAPACKE.cmake index 78788ef5f56661d65c89040e1e571a582560ec77..21095ceaadf198717bf69a8083376d801a356e78 100644 --- a/cmake_modules/morse/find/FindLAPACKE.cmake +++ b/cmake_modules/morse/find/FindLAPACKE.cmake @@ -49,6 +49,9 @@ # (To distribute this file outside of Morse, substitute the full # License text for the above reference.) +if (NOT LAPACKE_FOUND) + set(LAPACKE_DIR "" CACHE PATH "Root directory of LAPACKE library") +endif() # LAPACKE depends on LAPACK # try to find it specified as COMPONENTS during the call @@ -67,6 +70,14 @@ if (LAPACKE_FIND_COMPONENTS) endforeach() endif () +# LAPACKE depends on LAPACK anyway, try to find it +if (NOT LAPACK_FOUND) + if(LAPACKE_FIND_REQUIRED) + find_package(LAPACK REQUIRED) + else() + find_package(LAPACK) + endif() +endif() # LAPACKE depends on LAPACK if (LAPACK_FOUND) @@ -74,7 +85,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};${CMAKE_THREAD_LIBS_INIT};${LM}") + set(CMAKE_REQUIRED_LIBRARIES "${LAPACK_LIBRARIES}") unset(LAPACKE_WORKS CACHE) check_function_exists(LAPACKE_dgeqrf LAPACKE_WORKS) mark_as_advanced(LAPACKE_WORKS) @@ -221,6 +232,42 @@ if (LAPACK_FOUND) endif() endif () + if(LAPACKE_LIBRARIES) + # check a function to validate the find + set(CMAKE_REQUIRED_INCLUDES "${LAPACKE_INCLUDE_DIRS};${LAPACK_INCLUDE_DIRS}") + set(CMAKE_REQUIRED_LIBRARIES "${LAPACKE_LIBRARIES};${LAPACK_LIBRARIES};-lm") + if (CMAKE_Fortran_COMPILER MATCHES ".+gfortran.*") + list(APPEND CMAKE_REQUIRED_LIBRARIES "-lgfortran") + endif() + set(CMAKE_REQUIRED_FLAGS "-L${LAPACKE_LIBRARY_DIRS} -L${LAPACK_LIBRARY_DIRS}") + + unset(LAPACKE_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(LAPACKE_dgeqrf LAPACKE_WORKS) + mark_as_advanced(LAPACKE_WORKS) + + if(LAPACKE_WORKS) + set(LAPACKE_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) + set(LAPACKE_LIBRARY_DIRS "${LAPACKE_LIBRARY_DIRS}" "${LAPACK_LIBRARY_DIRS}") + set(LAPACKE_INCLUDE_DIRS ${CMAKE_REQUIRED_INCLUDES}) + else() + if (LAPACKE_FIND_REQUIRED) + if(NOT LAPACKE_FIND_QUIETLY) + message(STATUS "Looking for lapacke: test of LAPACKE_dgeqrf with lapacke and lapack libraries fails") + message(STATUS "LAPACKE_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") + message(STATUS "LAPACKE_LIBRARY_DIRS: ${CMAKE_REQUIRED_FLAGS}") + message(STATUS "LAPACKE_INCLUDE_DIRS: ${CMAKE_REQUIRED_INCLUDES}") + message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") + message(STATUS "Looking for lapacke : set LAPACKE_LIBRARIES to NOTFOUND") + endif() + set(LAPACKE_LIBRARIES "LAPACKE_LIBRARIES-NOTFOUND") + endif() + endif() + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) + endif(LAPACKE_LIBRARIES) + endif (LAPACKE_STANDALONE OR NOT LAPACKE_WORKS) else(LAPACK_FOUND) diff --git a/cmake_modules/morse/find/FindMAGMA.cmake b/cmake_modules/morse/find/FindMAGMA.cmake index 664c37ab0372a082230ab0e7a1b33f4f6d5ec7c3..c4d84646c8b38d33093c8139d60d90737b2178de 100644 --- a/cmake_modules/morse/find/FindMAGMA.cmake +++ b/cmake_modules/morse/find/FindMAGMA.cmake @@ -43,6 +43,11 @@ # License text for the above reference.) +if(NOT MAGMA_FOUND) + set(MAGMA_DIR "" CACHE PATH "Root directory of MAGMA library") +endif(NOT MAGMA_FOUND) + + # MAGMA may depend on CUDA # try to find it specified as COMPONENTS during the call if( MAGMA_FIND_COMPONENTS ) @@ -68,6 +73,38 @@ if( MAGMA_FIND_COMPONENTS ) endforeach() endif() +# MAGMA depends on CUDA anyway, try to find it +if (NOT CUDA_FOUND) + if(MAGMA_FIND_REQUIRED) + find_package(CUDA REQUIRED) + else() + find_package(CUDA) + endif() +endif() +# MAGMA depends on cuBLAS which should come with CUDA, if not found -> error +if (NOT CUDA_CUBLAS_LIBRARIES) + if(MAGMA_FIND_REQUIRED) + message(FATAL_ERROR "Looking for MAGMA - MAGMA depends on cuBLAS which has + not been found (should come with cuda install)") + endif() +endif() +# MAGMA depends on LAPACK anyway, try to find it +if (NOT LAPACK_FOUND) + if(MAGMA_FIND_REQUIRED) + find_package(LAPACK REQUIRED) + else() + find_package(LAPACK) + endif() +endif() +# MAGMA depends on CBLAS anyway, try to find it +if (NOT CBLAS_FOUND) + if(MAGMA_FIND_REQUIRED) + find_package(CBLAS REQUIRED) + else() + find_package(CBLAS) + endif() +endif() + # Optionally use pkg-config to detect include/library dirs (if pkg-config is available) # ------------------------------------------------------------------------------------- include(FindPkgConfig) @@ -237,6 +274,40 @@ if(NOT MAGMA_FOUND OR NOT MAGMA_LIBRARIES) endif() endif () + if (MAGMA_LIBRARIES) + # check a function to validate the find + set(CMAKE_REQUIRED_INCLUDES "${MAGMA_INCLUDE_DIRS};${CBLAS_INCLUDE_DIRS};${CUDA_INCLUDE_DIRS}") + set(CMAKE_REQUIRED_LIBRARIES "${MAGMA_LIBRARIES};${CBLAS_LIBRARIES};${CUDA_CUBLAS_LIBRARIES};${CUDA_LIBRARIES};${LAPACK_LIBRARIES}") + set(CMAKE_REQUIRED_FLAGS "-L${MAGMA_LIBRARY_DIRS} -L${CBLAS_LIBRARY_DIRS} -L${CUDA_LIBRARY_DIRS} -L${LAPACK_LIBRARY_DIRS}") + + unset(MAGMA_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(magma_dgetrf MAGMA_WORKS) + mark_as_advanced(MAGMA_WORKS) + + if(MAGMA_WORKS) + set(MAGMA_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + set(MAGMA_LIBRARY_DIRS "${MAGMA_LIBRARY_DIRS}" "${CBLAS_LIBRARY_DIRS}" "${CUDA_LIBRARY_DIRS}" "${LAPACK_LIBRARY_DIRS}") + set(MAGMA_INCLUDE_DIRS "${CMAKE_REQUIRED_INCLUDES}") + else() + if (MAGMA_FIND_REQUIRED) + if(NOT MAGMA_FIND_QUIETLY) + message(STATUS "Looking for magma : test of magma_dgetrf with + magma, cblas, cuda and lapack libraries fails") + message(STATUS "MAGMA_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") + message(STATUS "MAGMA_LIBRARY_DIRS: ${CMAKE_REQUIRED_FLAGS}") + message(STATUS "MAGMA_INCLUDE_DIRS: ${CMAKE_REQUIRED_INCLUDES}") + message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") + message(STATUS "Looking for magma : set MAGMA_LIBRARIES to NOTFOUND") + endif() + set(MAGMA_LIBRARIES "MAGMA_LIBRARIES-NOTFOUND") + endif() + endif() + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) + endif(MAGMA_LIBRARIES) + endif(NOT MAGMA_FOUND OR NOT MAGMA_LIBRARIES) diff --git a/cmake_modules/morse/find/FindQUARK.cmake b/cmake_modules/morse/find/FindQUARK.cmake index a0c1f3606a9fc90afde2149e827b3ad13ee5402f..a98226ac8d457406e691ba7f60ab0122ec85fc99 100644 --- a/cmake_modules/morse/find/FindQUARK.cmake +++ b/cmake_modules/morse/find/FindQUARK.cmake @@ -44,6 +44,10 @@ # License text for the above reference.) +if (NOT QUARK_FOUND) + set(QUARK_DIR "" CACHE PATH "Root directory of QUARK library") +endif() + # QUARK may depend on HWLOC # try to find it specified as COMPONENTS during the call if( QUARK_FIND_COMPONENTS ) @@ -179,6 +183,39 @@ else () endif() endif () +if(QUARK_LIBRARIES) + # check a function to validate the find + set(CMAKE_REQUIRED_INCLUDES "${QUARK_INCLUDE_DIRS}") + set(CMAKE_REQUIRED_LIBRARIES "${QUARK_LIBRARIES}") + set(CMAKE_REQUIRED_FLAGS "-L${QUARK_LIBRARY_DIRS}") + + unset(QUARK_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(QUARK_New QUARK_WORKS) + mark_as_advanced(QUARK_WORKS) + + if(QUARK_WORKS) + set(QUARK_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + set(QUARK_LIBRARY_DIRS "${QUARK_LIBRARY_DIRS}") + set(QUARK_INCLUDE_DIRS "${CMAKE_REQUIRED_INCLUDES}") + else() + if (QUARK_FIND_REQUIRED) + if(NOT QUARK_FIND_QUIETLY) + message(STATUS "Looking for quark : test of QUARK_New with quark library fails") + message(STATUS "QUARK_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") + message(STATUS "QUARK_LIBRARY_DIRS: ${CMAKE_REQUIRED_FLAGS}") + message(STATUS "QUARK_INCLUDE_DIRS: ${CMAKE_REQUIRED_INCLUDES}") + message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") + message(STATUS "Looking for quark : set QUARK_LIBRARIES to NOTFOUND") + endif() + set(QUARK_LIBRARIES "QUARK_LIBRARIES-NOTFOUND") + endif() + endif() + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) +endif(QUARK_LIBRARIES) + # check that QUARK has been found # --------------------------------- diff --git a/cmake_modules/morse/find/FindSTARPU.cmake b/cmake_modules/morse/find/FindSTARPU.cmake index e7d2eee6d4dd4596e0d085fd91aa92ba0354bb0e..034646bc712d1ef662cd3d69a0b9ec1b122bca7b 100644 --- a/cmake_modules/morse/find/FindSTARPU.cmake +++ b/cmake_modules/morse/find/FindSTARPU.cmake @@ -50,17 +50,32 @@ # (To distribute this file outside of Morse, substitute the full # License text for the above reference.) +if (NOT STARPU_FOUND) + set(STARPU_DIR "" CACHE PATH "Root directory of STARPU library") +endif() -# STARPU may depend on other packages (HWLOC, MPI, CUDA, ...) +# STARPU may depend on other packages (HWLOC, MPI, CUDA, MAGMA, ...) # try to find them if specified as COMPONENTS during the call +set(STARPU_LOOK_FOR_HWLOC FALSE) set(STARPU_LOOK_FOR_MPI FALSE) set(STARPU_LOOK_FOR_CUDA FALSE) +set(STARPU_LOOK_FOR_MAGMA FALSE) if( STARPU_FIND_COMPONENTS ) foreach( component ${STARPU_FIND_COMPONENTS} ) - if(${component} STREQUAL "MPI") + if(${component} STREQUAL "HWLOC") + set(STARPU_LOOK_FOR_HWLOC TRUE) + if (NOT HWLOC_FOUND) + set(HWLOC_DIR "" CACHE PATH "Root directory of HWLOC library") + endif() + elseif(${component} STREQUAL "MPI") set(STARPU_LOOK_FOR_MPI TRUE) elseif(${component} STREQUAL "CUDA") set(STARPU_LOOK_FOR_CUDA TRUE) + elseif(${component} STREQUAL "MAGMA") + set(STARPU_LOOK_FOR_MAGMA TRUE) + if (NOT MAGMA_FOUND) + set(MAGMA_DIR "" CACHE PATH "Root directory of MAGMA library") + endif() endif() if(${STARPU_FIND_REQUIRED_${component}} STREQUAL 1) find_package(${component} REQUIRED) @@ -146,6 +161,14 @@ if(PKG_CONFIG_EXECUTABLE) endif() endif() + if(STARPU_MPI_LIBRARIES) + set(STARPU_LIBRARIES "${STARPU_MPI_LIBRARIES}") + elseif(STARPU_SHM_LIBRARIES) + set(STARPU_LIBRARIES "${STARPU_SHM_LIBRARIES}") + else() + set(STARPU_LIBRARIES "STARPU_LIBRARIES-NOTFOUND") + endif() + endif(PKG_CONFIG_EXECUTABLE) @@ -498,6 +521,72 @@ if( (NOT STARPU_SHM_FOUND) OR (NOT STARPU_SHM_LIBRARIES) OR endif() endif(STARPU_starpu_config.h_INCLUDE_DIRS) + if(STARPU_MPI_LIBRARIES) + set(STARPU_LIBRARIES "${STARPU_MPI_LIBRARIES}") + elseif(STARPU_SHM_LIBRARIES) + set(STARPU_LIBRARIES "${STARPU_SHM_LIBRARIES}") + else() + set(STARPU_LIBRARIES "STARPU_LIBRARIES-NOTFOUND") + endif() + + if(STARPU_LIBRARIES) + # check a function to validate the find + set(CMAKE_REQUIRED_INCLUDES "${STARPU_INCLUDE_DIRS}") + set(CMAKE_REQUIRED_FLAGS) + foreach(libdir ${STARPU_LIBRARY_DIRS}) + list(APPEND CMAKE_REQUIRED_FLAGS "-L${libdir}") + endforeach() + set(CMAKE_REQUIRED_LIBRARIES "${STARPU_LIBRARIES}") + if (HWLOC_FOUND) + list(APPEND CMAKE_REQUIRED_INCLUDES "${HWLOC_INCLUDE_DIRS}") + list(APPEND CMAKE_REQUIRED_FLAGS "-L${HWLOC_LIBRARY_DIRS}") + list(APPEND CMAKE_REQUIRED_LIBRARIES "${HWLOC_LIBRARIES}") + endif() + if (MPI_FOUND) + list(APPEND CMAKE_REQUIRED_INCLUDES "${MPI_C_INCLUDE_PATH}") + list(APPEND CMAKE_REQUIRED_FLAGS "-L${MPI_C_LINK_FLAGS}") + list(APPEND CMAKE_REQUIRED_LIBRARIES "${MPI_C_LIBRARIES}") + endif() + if (CUDA_FOUND) + list(APPEND CMAKE_REQUIRED_INCLUDES "${CUDA_INCLUDE_DIRS}") + list(APPEND CMAKE_REQUIRED_FLAGS "-L${CUDA_LIBRARY_DIRS}") + list(APPEND CMAKE_REQUIRED_LIBRARIES "${CUDA_CUBLAS_LIBRARIES};${CUDA_LIBRARIES}") + endif() + if (MAGMA_FOUND) + list(APPEND CMAKE_REQUIRED_INCLUDES "${MAGMA_INCLUDE_DIRS}") + list(APPEND CMAKE_REQUIRED_FLAGS "-L${MAGMA_LIBRARY_DIRS}") + list(APPEND CMAKE_REQUIRED_LIBRARIES "${${MAGMA_LIBRARIES}}") + endif() + string(REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") + + unset(STARPU_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(starpu_init STARPU_WORKS) + mark_as_advanced(STARPU_WORKS) + + if(STARPU_WORKS) + string(REPLACE " -L" ";" CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") + set(STARPU_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + set(STARPU_LIBRARY_DIRS "${CMAKE_REQUIRED_FLAGS}") + set(STARPU_INCLUDE_DIRS "${CMAKE_REQUIRED_INCLUDES}") + else() + if (STARPU_FIND_REQUIRED) + if(NOT STARPU_FIND_QUIETLY) + message(STATUS "Looking for starpu : test of starpu_init fails") + message(STATUS "STARPU_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") + message(STATUS "STARPU_LIBRARY_DIRS: ${CMAKE_REQUIRED_FLAGS}") + message(STATUS "STARPU_INCLUDE_DIRS: ${CMAKE_REQUIRED_INCLUDES}") + message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") + message(STATUS "Looking for starpu : set STARPU_LIBRARIES to NOTFOUND") + endif() + set(STARPU_LIBRARIES "STARPU_LIBRARIES-NOTFOUND") + endif() + endif() + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) + endif(STARPU_LIBRARIES) + endif( (NOT STARPU_SHM_FOUND) OR (NOT STARPU_SHM_LIBRARIES) OR ( STARPU_LOOK_FOR_MPI AND (NOT STARPU_MPI_FOUND OR NOT STARPU_MPI_LIBRARIES) ) ) diff --git a/cmake_modules/morse/find/FindTMG.cmake b/cmake_modules/morse/find/FindTMG.cmake index 430056179e24c00731bfcb7fb5f3b21ce15ffe0e..7a3aa3a252b3907a10f4411b5affc1298d23c1eb 100644 --- a/cmake_modules/morse/find/FindTMG.cmake +++ b/cmake_modules/morse/find/FindTMG.cmake @@ -44,12 +44,17 @@ # License text for the above reference.) +if (NOT TMG_FOUND) + set(TMG_DIR "" CACHE PATH "Root directory of TMG library") +endif() + + # used to test a TMG function after get_property(_LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES) if (NOT _LANGUAGES_ MATCHES Fortran) -include(CheckFunctionExists) + include(CheckFunctionExists) else (NOT _LANGUAGES_ MATCHES Fortran) -include(CheckFortranFunctionExists) + include(CheckFortranFunctionExists) endif (NOT _LANGUAGES_ MATCHES Fortran) # TMG depends on LAPACK @@ -69,19 +74,38 @@ if (TMG_FIND_COMPONENTS) endforeach() endif () +# TMG depends on LAPACK anyway, try to find it +if (NOT LAPACK_FOUND) + if(TMG_FIND_REQUIRED) + find_package(LAPACK REQUIRED) + else() + find_package(LAPACK) + endif() +endif() + # TMG depends on LAPACK if (LAPACK_FOUND) # check if a tmg function exists in the LAPACK lib - set(CMAKE_REQUIRED_LIBRARIES "${LAPACK_LIBRARIES};${CMAKE_THREAD_LIBS_INIT};${LM}") + set(CMAKE_REQUIRED_LIBRARIES "${LAPACK_LIBRARIES}") + include(CheckFunctionExists) + include(CheckFortranFunctionExists) unset(TMG_WORKS CACHE) - check_function_exists(dlarnv TMG_WORKS) + if (NOT _LANGUAGES_ MATCHES Fortran) + check_function_exists(dlarnv TMG_WORKS) + else (NOT _LANGUAGES_ MATCHES Fortran) + check_fortran_function_exists(dlarnv TMG_WORKS) + endif (NOT _LANGUAGES_ MATCHES Fortran) if (TMG_WORKS) unset(TMG_WORKS CACHE) - check_function_exists(dlagsy TMG_WORKS) + if (NOT _LANGUAGES_ MATCHES Fortran) + check_function_exists(dlagsy TMG_WORKS) + else (NOT _LANGUAGES_ MATCHES Fortran) + check_fortran_function_exists(dlagsy TMG_WORKS) + endif (NOT _LANGUAGES_ MATCHES Fortran) mark_as_advanced(TMG_WORKS) - set(CMAKE_REQUIRED_LIBRARIES) endif() + set(CMAKE_REQUIRED_LIBRARIES) if(TMG_WORKS) if(NOT TMG_FIND_QUIETLY) @@ -163,6 +187,53 @@ if (LAPACK_FOUND) if (TMG_LIBRARY_DIRS) list(REMOVE_DUPLICATES TMG_LIBRARY_DIRS) endif () + + # check a function to validate the find + set(CMAKE_REQUIRED_INCLUDES "${TMG_INCLUDE_DIRS};${LAPACK_INCLUDE_DIRS}") + set(CMAKE_REQUIRED_LIBRARIES "${TMG_LIBRARIES};${LAPACK_LIBRARIES}") + set(CMAKE_REQUIRED_FLAGS "-L${TMG_LIBRARY_DIRS} -L${LAPACK_LIBRARY_DIRS}") + + if(TMG_LIBRARIES) + unset(TMG_WORKS CACHE) + include(CheckFunctionExists) + include(CheckFortranFunctionExists) + if (NOT _LANGUAGES_ MATCHES Fortran) + check_function_exists(dlarnv TMG_WORKS) + else (NOT _LANGUAGES_ MATCHES Fortran) + check_fortran_function_exists(dlarnv TMG_WORKS) + endif (NOT _LANGUAGES_ MATCHES Fortran) + if (TMG_WORKS) + unset(TMG_WORKS CACHE) + if (NOT _LANGUAGES_ MATCHES Fortran) + check_function_exists(dlagsy TMG_WORKS) + else (NOT _LANGUAGES_ MATCHES Fortran) + check_fortran_function_exists(dlagsy TMG_WORKS) + endif (NOT _LANGUAGES_ MATCHES Fortran) + mark_as_advanced(TMG_WORKS) + endif() + + if(TMG_WORKS) + set(TMG_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) + set(TMG_LIBRARY_DIRS "${TMG_LIBRARY_DIRS}" "${LAPACK_LIBRARY_DIRS}") + set(TMG_INCLUDE_DIRS ${CMAKE_REQUIRED_INCLUDES}) + else() + if (TMG_FIND_REQUIRED) + if(NOT TMG_FIND_QUIETLY) + message(STATUS "Looking for tmg: test of dlarnv and dlagsy with tmg and lapack libraries fails") + message(STATUS "TMG_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") + message(STATUS "TMG_LIBRARY_DIRS: ${CMAKE_REQUIRED_FLAGS}") + message(STATUS "TMG_INCLUDE_DIRS: ${CMAKE_REQUIRED_INCLUDES}") + message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") + message(STATUS "Looking for tmg : set TMG_LIBRARIES to NOTFOUND") + endif() + set(TMG_LIBRARIES "TMG_LIBRARIES-NOTFOUND") + endif() + endif() + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) + endif(TMG_LIBRARIES) + endif() else()