diff --git a/modules/MorseInit.cmake b/modules/MorseInit.cmake index 9d4bf7880db96bd0e573973ea050514c5d2ce563..fc51170401cc17045854de4ee51f477eff1b66c1 100644 --- a/modules/MorseInit.cmake +++ b/modules/MorseInit.cmake @@ -27,6 +27,9 @@ # ### +# Path to Morse modules +get_filename_component(MORSE_CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_FILE} DIRECTORY CACHE) + # Global Morse options option(MORSE_ENABLE_WARNING "Enable warning messages" OFF) option(MORSE_ENABLE_COVERAGE "Enable flags for coverage test" OFF) @@ -47,19 +50,6 @@ if (MORSE_ENABLE_COLOR_MESSAGE) include(ColorizeMessage) endif() -# To find headers and libs -include(FindHeadersAndLibs) - -# To transform relative path from pkg-config into absolute -include(FindPkgconfigLibrariesAbsolutePath) - -# To transform relative path into absolute for a list of libraries -include(LibrariesAbsolutePath) - -# Some macros to print status when search for headers and libs -# PrintFindStatus.cmake is in cmake_modules/morse/find directory -include(PrintFindStatus) - # Define some auxilary flags include(AuxilaryFlags) @@ -69,6 +59,9 @@ include(Ressources) # Add the path where we handle our FindFOO.cmake to seek for liraries list(APPEND CMAKE_MODULE_PATH ${MORSE_CMAKE_MODULE_PATH}/find) +# To load some macros used in Finds (could be useful for other projects) +include(FindInit) + ## ## @end file MorseInit.cmake ## diff --git a/modules/find/FindBLAS.cmake b/modules/find/FindBLAS.cmake index 2b4b916b7e0357d47ee46001ea44787c60108a72..aba7aed1cf89898b22b86527a55200739ca29925 100644 --- a/modules/find/FindBLAS.cmake +++ b/modules/find/FindBLAS.cmake @@ -98,60 +98,8 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -## Some macros to print status when search for headers and libs -# This macro informs why the _lib_to_find file has not been found -macro(Print_Find_Library_Blas_Status _libname _lib_to_find) - - # save _libname upper/lower case - string(TOUPPER ${_libname} LIBNAME) - string(TOLOWER ${_libname} libname) - - # print status - #message(" ") - if(${LIBNAME}_LIBDIR) - message("${Yellow}${LIBNAME}_LIBDIR is defined but ${_lib_to_find}" - "has not been found in ${ARGN}${ColourReset}") - else() - if(${LIBNAME}_DIR) - message("${Yellow}${LIBNAME}_DIR is defined but ${_lib_to_find}" - "has not been found in ${ARGN}${ColourReset}") - else() - message("${Yellow}${_lib_to_find} not found." - "Nor ${LIBNAME}_DIR neither ${LIBNAME}_LIBDIR" - "are defined so that we look for ${_lib_to_find} in" - "system paths (Linux: LD_LIBRARY_PATH, Windows: LIB," - "Mac: DYLD_LIBRARY_PATH," - "CMAKE_C_IMPLICIT_LINK_DIRECTORIES)${ColourReset}") - if(_lib_env) - message("${Yellow}${_lib_to_find} has not been found in" - "${_lib_env}${ColourReset}") - endif() - endif() - endif() - message("${BoldYellow}Please indicate where to find ${_lib_to_find}. You have three options:\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}") - -endmacro() - -# This macro informs why the _lib_to_find file has not been found -macro(Print_Find_Library_Blas_CheckFunc_Status _name) - - # save _libname upper/lower case - string(TOUPPER ${_name} FUNCNAME) - string(TOLOWER ${_name} funcname) - - # print status - #message(" ") - message("${Red}Libs have been found but check of symbol ${_name} failed " - "with following libraries ${ARGN}${ColourReset}") - message("${BoldRed}Please open your error file CMakeFiles/CMakeError.log" - "to figure out why it fails${ColourReset}") - #message(" ") - -endmacro() +# Common macros to use in finds +include(FindInit) if (NOT BLAS_FOUND) set(BLAS_DIR "" CACHE PATH "Installation directory of BLAS library") @@ -346,10 +294,11 @@ else () endif () set(ENV_BLAS_DIR "$ENV{BLAS_DIR}") +set(ENV_MKL_DIR "$ENV{MKLROOT}") set(ENV_BLAS_INCDIR "$ENV{BLAS_INCDIR}") set(ENV_BLAS_LIBDIR "$ENV{BLAS_LIBDIR}") set(BLAS_GIVEN_BY_USER "FALSE") -if ( BLAS_DIR OR ( BLAS_INCDIR AND BLAS_LIBDIR) OR ENV_BLAS_DIR OR (ENV_BLAS_INCDIR AND ENV_BLAS_LIBDIR) ) +if ( BLAS_DIR OR ( BLAS_INCDIR AND BLAS_LIBDIR) OR ENV_BLAS_DIR OR ENV_MKL_DIR OR (ENV_BLAS_INCDIR AND ENV_BLAS_LIBDIR) ) set(BLAS_GIVEN_BY_USER "TRUE") endif() diff --git a/modules/find/FindCBLAS.cmake b/modules/find/FindCBLAS.cmake index feec87fba419aa4fbe0b1696414224f53423e925..ac3e8e338aa2f0fdd2248b6b4c2600ff23512940 100644 --- a/modules/find/FindCBLAS.cmake +++ b/modules/find/FindCBLAS.cmake @@ -91,6 +91,8 @@ # (To distribute this file outside of Morse, substitute the full # License text for the above reference.) +# Common macros to use in finds +include(FindInit) if (NOT CBLAS_FOUND) set(CBLAS_DIR "" CACHE PATH "Installation directory of CBLAS library") @@ -151,10 +153,11 @@ if (BLAS_FOUND) # try with pkg-config set(ENV_CBLAS_DIR "$ENV{CBLAS_DIR}") + set(ENV_MKL_DIR "$ENV{MKLROOT}") set(ENV_CBLAS_INCDIR "$ENV{CBLAS_INCDIR}") set(ENV_CBLAS_LIBDIR "$ENV{CBLAS_LIBDIR}") set(CBLAS_GIVEN_BY_USER "FALSE") - if ( CBLAS_DIR OR ( CBLAS_INCDIR AND CBLAS_LIBDIR) OR ENV_CBLAS_DIR OR (ENV_CBLAS_INCDIR AND ENV_CBLAS_LIBDIR) ) + if ( CBLAS_DIR OR ( CBLAS_INCDIR AND CBLAS_LIBDIR) OR ENV_CBLAS_DIR OR ENV_MKL_DIR OR (ENV_CBLAS_INCDIR AND ENV_CBLAS_LIBDIR) ) set(CBLAS_GIVEN_BY_USER "TRUE") endif() @@ -396,6 +399,7 @@ if (BLAS_FOUND) list(APPEND REQUIRED_FLAGS "${_flag}") endforeach() endif() + finds_remove_duplicates() set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) @@ -424,9 +428,6 @@ if (BLAS_FOUND) set(CBLAS_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") set(CBLAS_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}") set(CBLAS_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}") - list(REMOVE_DUPLICATES CBLAS_LIBRARY_DIRS_DEP) - list(REMOVE_DUPLICATES CBLAS_CFLAGS_OTHER_DEP) - list(REMOVE_DUPLICATES CBLAS_LDFLAGS_OTHER_DEP) else() if(NOT CBLAS_FIND_QUIETLY) message(STATUS "Looking for cblas : test of cblas_dscal with cblas and blas libraries fails") diff --git a/modules/find/FindCHAMELEON.cmake b/modules/find/FindCHAMELEON.cmake index 71b8baf8ecc60ff037843b538e45c7d06e4bede0..06be58efd61a61fceefa98b94f8e2374ca678466 100644 --- a/modules/find/FindCHAMELEON.cmake +++ b/modules/find/FindCHAMELEON.cmake @@ -86,6 +86,8 @@ # (To distribute this file outside of Morse, substitute the full # License text for the above reference.) +# Common macros to use in finds +include(FindInit) if (NOT CHAMELEON_FOUND) set(CHAMELEON_DIR "" CACHE PATH "Installation directory of CHAMELEON library") @@ -707,6 +709,7 @@ if(CHAMELEON_LIBRARIES) list(APPEND REQUIRED_FLAGS "${_flag}") endforeach() endif() + finds_remove_duplicates() set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) @@ -727,9 +730,6 @@ if(CHAMELEON_LIBRARIES) set(CHAMELEON_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") set(CHAMELEON_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}") set(CHAMELEON_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}") - list(REMOVE_DUPLICATES CHAMELEON_LIBRARY_DIRS_DEP) - list(REMOVE_DUPLICATES CHAMELEON_CFLAGS_OTHER_DEP) - list(REMOVE_DUPLICATES CHAMELEON_LDFLAGS_OTHER_DEP) else() if(NOT CHAMELEON_FIND_QUIETLY) message(STATUS "Looking for chameleon : test of MORSE_Init fails") diff --git a/modules/find/FindCommon.cmake b/modules/find/FindCommon.cmake new file mode 100644 index 0000000000000000000000000000000000000000..95d8c1f5404c0d7ea2384d84bd12c2e4a3cc3418 --- /dev/null +++ b/modules/find/FindCommon.cmake @@ -0,0 +1,47 @@ +### +# +# @copyright (c) 2018 Inria. All rights reserved. +# +### +# +# @file FindCommon.cmake +# +# @project MORSE +# MORSE is a software package provided by: +# Inria Bordeaux - Sud-Ouest, +# Univ. of Tennessee, +# King Abdullah Univesity of Science and Technology +# Univ. of California Berkeley, +# Univ. of Colorado Denver. +# +# @version 1.0.0 +# @author Florent Pruvost +# @date 13-04-2018 +# +### + +# clean these variables before using them in CMAKE_REQUIRED_* variables in +# check_function_exists +macro(finds_remove_duplicates) + if (REQUIRED_DEFINITIONS) + list(REMOVE_DUPLICATES REQUIRED_DEFINITIONS) + endif() + if (REQUIRED_INCDIRS) + list(REMOVE_DUPLICATES REQUIRED_INCDIRS) + endif() + if (REQUIRED_FLAGS) + list(REMOVE_DUPLICATES REQUIRED_FLAGS) + endif() + if (REQUIRED_LDFLAGS) + list(REMOVE_DUPLICATES REQUIRED_LDFLAGS) + endif() + if (REQUIRED_LIBS) + list(REVERSE REQUIRED_LIBS) + list(REMOVE_DUPLICATES REQUIRED_LIBS) + list(REVERSE REQUIRED_LIBS) + endif() +endmacro() + +## +## @end file FindCommon +## diff --git a/modules/find/FindEZTRACE.cmake b/modules/find/FindEZTRACE.cmake index e85b543b2a8890c04e947ddba5f929d35f785dc4..f6115fea98f0879c54c9b09a2ddf94e991eb7737 100644 --- a/modules/find/FindEZTRACE.cmake +++ b/modules/find/FindEZTRACE.cmake @@ -63,6 +63,9 @@ # (To distribute this file outside of Morse, substitute the full # License text for the above reference.) +# Common macros to use in finds +include(FindInit) + if (NOT EZTRACE_FOUND) set(EZTRACE_DIR "" CACHE PATH "Installation directory of EZTRACE library") if (NOT EZTRACE_FIND_QUIETLY) @@ -330,6 +333,7 @@ if(EZTRACE_LIBRARIES) list(APPEND REQUIRED_FLAGS "${_flag}") endforeach() endif() + finds_remove_duplicates() set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) diff --git a/modules/find/FindFABULOUS.cmake b/modules/find/FindFABULOUS.cmake index 265d4f8b4355a0141c6fe2fe27a290e6330cef69..a4df2d975c3fe451867756a787fb9eb2191364fe 100644 --- a/modules/find/FindFABULOUS.cmake +++ b/modules/find/FindFABULOUS.cmake @@ -64,6 +64,9 @@ # (To distribute this file outside of Morse, substitute the full # License text for the above reference.) +# Common macros to use in finds +include(FindInit) + if (NOT FABULOUS_FOUND) set(FABULOUS_DIR "" CACHE PATH "Installation directory of FABULOUS library") if (NOT FABULOUS_FIND_QUIETLY) @@ -374,6 +377,7 @@ if(FABULOUS_LIBRARIES) list(APPEND REQUIRED_FLAGS "${_flag}") endforeach() endif() + finds_remove_duplicates() set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) @@ -394,9 +398,6 @@ if(FABULOUS_LIBRARIES) set(FABULOUS_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") set(FABULOUS_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}") set(FABULOUS_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}") - list(REMOVE_DUPLICATES FABULOUS_LIBRARY_DIRS_DEP) - list(REMOVE_DUPLICATES FABULOUS_CFLAGS_OTHER_DEP) - list(REMOVE_DUPLICATES FABULOUS_LDFLAGS_OTHER_DEP) else() if(NOT FABULOUS_FIND_QUIETLY) message(STATUS "Looking for fabulous : test of fabulous_topology_init with fabulous library fails") diff --git a/modules/find/FindFFTW.cmake b/modules/find/FindFFTW.cmake index 9f2e6ee768012872dad225ed7a110bca17791199..cb4e1d951d54a465edfe832261d97b4c00de109d 100644 --- a/modules/find/FindFFTW.cmake +++ b/modules/find/FindFFTW.cmake @@ -80,6 +80,8 @@ # (To distribute this file outside of Morse, substitute the full # License text for the above reference.) +# Common macros to use in finds +include(FindInit) if (NOT FFTW_FOUND) set(FFTW_DIR "" CACHE PATH "Installation directory of FFTW library given by user") @@ -767,6 +769,7 @@ if(FFTW_LIBRARIES) list(APPEND REQUIRED_FLAGS "${_flag}") endforeach() endif() + finds_remove_duplicates() set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) @@ -792,9 +795,6 @@ if(FFTW_LIBRARIES) set(FFTW_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") set(FFTW_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}") set(FFTW_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}") - list(REMOVE_DUPLICATES FFTW_LIBRARY_DIRS_DEP) - list(REMOVE_DUPLICATES FFTW_CFLAGS_OTHER_DEP) - list(REMOVE_DUPLICATES FFTW_LDFLAGS_OTHER_DEP) else() if(NOT FFTW_FIND_QUIETLY) message(STATUS "Looking for FFTW : test of ${FFTW_PREC_TESTFUNC}fftw_execute_ with fftw library fails") diff --git a/modules/find/FindFXT.cmake b/modules/find/FindFXT.cmake index 1e9ebd26118042b693592e00922e9f9ddd179313..d2eada5df0f88a9625b28c0b8adbafcc36c88bdc 100644 --- a/modules/find/FindFXT.cmake +++ b/modules/find/FindFXT.cmake @@ -59,6 +59,9 @@ # (To distribute this file outside of Morse, substitute the full # License text for the above reference.) +# Common macros to use in finds +include(FindInit) + if (NOT FXT_FOUND) set(FXT_DIR "" CACHE PATH "Installation directory of FXT library") if (NOT FXT_FIND_QUIETLY) @@ -289,6 +292,7 @@ if(FXT_LIBRARIES) list(APPEND REQUIRED_FLAGS "${_flag}") endforeach() endif() + finds_remove_duplicates() set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) diff --git a/modules/find/FindGTG.cmake b/modules/find/FindGTG.cmake index 673bf7d4be1607e750eefd106b39584bb82007d0..b3b7f0ff5493846d3a339c8ebbb619ad638b0e90 100644 --- a/modules/find/FindGTG.cmake +++ b/modules/find/FindGTG.cmake @@ -59,6 +59,9 @@ # (To distribute this file outside of Morse, substitute the full # License text for the above reference.) +# Common macros to use in finds +include(FindInit) + if (NOT GTG_FOUND) set(GTG_DIR "" CACHE PATH "Installation directory of GTG library") if (NOT GTG_FIND_QUIETLY) @@ -289,6 +292,7 @@ if(GTG_LIBRARIES) list(APPEND REQUIRED_FLAGS "${_flag}") endforeach() endif() + finds_remove_duplicates() set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) diff --git a/modules/find/FindHQR.cmake b/modules/find/FindHQR.cmake index e69c9a45888cf1106efa57e84968281d7e824923..3695d2601ba4bebeba28c8886dbee166354aed26 100644 --- a/modules/find/FindHQR.cmake +++ b/modules/find/FindHQR.cmake @@ -59,6 +59,9 @@ # (To distribute this file outside of Morse, substitute the full # License text for the above reference.) +# Common macros to use in finds +include(FindInit) + if (NOT HQR_FOUND) set(HQR_DIR "" CACHE PATH "Installation directory of HQR library") if (NOT HQR_FIND_QUIETLY) @@ -284,6 +287,7 @@ if(HQR_LIBRARIES) list(APPEND REQUIRED_FLAGS "${_flag}") endforeach() endif() + finds_remove_duplicates() set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) diff --git a/modules/find/FindHWLOC.cmake b/modules/find/FindHWLOC.cmake index fa53d6b8e47a68e7dc8e801aa28096fde228027d..a4dc4081354f988fcc9f2b5781a3a5fb0b118a5d 100644 --- a/modules/find/FindHWLOC.cmake +++ b/modules/find/FindHWLOC.cmake @@ -59,6 +59,9 @@ # (To distribute this file outside of Morse, substitute the full # License text for the above reference.) +# Common macros to use in finds +include(FindInit) + include(CheckStructHasMember) include(CheckCSourceCompiles) @@ -295,6 +298,7 @@ if(HWLOC_LIBRARIES) list(APPEND REQUIRED_FLAGS "${_flag}") endforeach() endif() + finds_remove_duplicates() set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) diff --git a/modules/find/FindHYPRE.cmake b/modules/find/FindHYPRE.cmake index 275ef4dafccc3cb9f2fdd08f38f6f70cef03e762..b83794fe8b713f1019155e7c01f8b5936f5de956 100644 --- a/modules/find/FindHYPRE.cmake +++ b/modules/find/FindHYPRE.cmake @@ -45,6 +45,9 @@ # (To distribute this file outside of Morse, substitute the full # License text for the above reference.) +# Common macros to use in finds +include(FindInit) + if (NOT HYPRE_FOUND) set(HYPRE_DIR "" CACHE PATH "Installation directory of HYPRE library") if (NOT HYPRE_FIND_QUIETLY) @@ -222,6 +225,7 @@ if(HYPRE_LIBRARIES) set(REQUIRED_LIBS "${HYPRE_LIBRARIES}") # set required libraries for link + finds_remove_duplicates() set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") set(CMAKE_REQUIRED_LIBRARIES) foreach(lib_dir ${REQUIRED_LIBDIRS}) diff --git a/modules/FindHeadersAndLibs.cmake b/modules/find/FindHeadersAndLibs.cmake similarity index 93% rename from modules/FindHeadersAndLibs.cmake rename to modules/find/FindHeadersAndLibs.cmake index 992b9fb58b2cd94cc9822027b5dcf5753d30da0a..64144bdbf8a35f966f1ac802e5765e6ad81abf7c 100644 --- a/modules/FindHeadersAndLibs.cmake +++ b/modules/find/FindHeadersAndLibs.cmake @@ -27,14 +27,9 @@ # ### -# Add the path where we handle our FindFOO.cmake to seek for liraries -list(APPEND CMAKE_MODULE_PATH ${MORSE_CMAKE_MODULE_PATH}/find) - # Some macros to print status when search for headers and libs -# PrintFindStatus.cmake is in cmake_modules/morse/find directory include(PrintFindStatus) - function(FindHeader _libname _header_to_find) # save _libname upper and lower case diff --git a/modules/find/FindInit.cmake b/modules/find/FindInit.cmake new file mode 100644 index 0000000000000000000000000000000000000000..e59d41a077848029e04065d5f46bba57bcf0277d --- /dev/null +++ b/modules/find/FindInit.cmake @@ -0,0 +1,45 @@ +### +# +# @copyright (c) 2018 Inria. All rights reserved. +# +### +# +# @file FindInit.cmake +# +# @project MORSE +# MORSE is a software package provided by: +# Inria Bordeaux - Sud-Ouest, +# Univ. of Tennessee, +# King Abdullah Univesity of Science and Technology +# Univ. of California Berkeley, +# Univ. of Colorado Denver. +# +# @version 1.0.0 +# @author Florent Pruvost +# @date 24-04-2018 +# +### + + +# This include is required to check symbols of libs +include(CheckFunctionExists) + +# This include is required to check defines in headers +include(CheckIncludeFiles) + +# Factorize some piece of code +include(FindCommon) + +# To find headers and libs +include(FindHeadersAndLibs) + +# To transform relative path into absolute for a list of libraries +include(LibrariesAbsolutePath) +include(FindPkgconfigLibrariesAbsolutePath) + +# Some macros to print status when search for headers and libs +include(PrintFindStatus) + +## +## @end file FindInit.cmake +## diff --git a/modules/find/FindLAPACK.cmake b/modules/find/FindLAPACK.cmake index b0bce5d9ee8c93cfd72108b0cebbec74dae3d0a4..3d73f26a26d6fbb3b5efa132426d09ad9d0e9dfd 100644 --- a/modules/find/FindLAPACK.cmake +++ b/modules/find/FindLAPACK.cmake @@ -76,44 +76,8 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) - -## Some macros to print status when search for headers and libs -# This macro informs why the _lib_to_find file has not been found -macro(Print_Find_Library_Blas_Status _libname _lib_to_find) - - # save _libname upper/lower case - string(TOUPPER ${_libname} LIBNAME) - string(TOLOWER ${_libname} libname) - - # print status - #message(" ") - if(${LIBNAME}_LIBDIR) - message("${Yellow}${LIBNAME}_LIBDIR is defined but ${_lib_to_find}" - "has not been found in ${ARGN}${ColourReset}") - else() - if(${LIBNAME}_DIR) - message("${Yellow}${LIBNAME}_DIR is defined but ${_lib_to_find}" - "has not been found in ${ARGN}${ColourReset}") - else() - message("${Yellow}${_lib_to_find} not found." - "Nor ${LIBNAME}_DIR neither ${LIBNAME}_LIBDIR" - "are defined so that we look for ${_lib_to_find} in" - "system paths (Linux: LD_LIBRARY_PATH, Windows: LIB," - "Mac: DYLD_LIBRARY_PATH," - "CMAKE_C_IMPLICIT_LINK_DIRECTORIES)${ColourReset}") - if(_lib_env) - message("${Yellow}${_lib_to_find} has not been found in" - "${_lib_env}${ColourReset}") - endif() - endif() - endif() - message("${BoldYellow}Please indicate where to find ${_lib_to_find}. You have three options:\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}") - -endmacro() +# Common macros to use in finds +include(FindInit) if (NOT LAPACK_FOUND) set(LAPACK_DIR "" CACHE PATH "Installation directory of LAPACK library") @@ -381,10 +345,11 @@ if(BLAS_FOUND) # if not lapack in blas libs, try to find lapack with pkg-config set(ENV_LAPACK_DIR "$ENV{LAPACK_DIR}") + set(ENV_MKL_DIR "$ENV{MKLROOT}") set(ENV_LAPACK_INCDIR "$ENV{LAPACK_INCDIR}") set(ENV_LAPACK_LIBDIR "$ENV{LAPACK_LIBDIR}") set(LAPACK_GIVEN_BY_USER "FALSE") - if ( LAPACK_DIR OR ( LAPACK_INCDIR AND LAPACK_LIBDIR) OR ENV_LAPACK_DIR OR (ENV_LAPACK_INCDIR AND ENV_LAPACK_LIBDIR) ) + if ( LAPACK_DIR OR ( LAPACK_INCDIR AND LAPACK_LIBDIR) OR ENV_LAPACK_DIR OR ENV_MKL_DIR OR (ENV_LAPACK_INCDIR AND ENV_LAPACK_LIBDIR) ) set(LAPACK_GIVEN_BY_USER "TRUE") endif() diff --git a/modules/find/FindLAPACKE.cmake b/modules/find/FindLAPACKE.cmake index 1f334b357d3e2d4cf0192e0e2c1d842cab3372cc..a024407e0832cfa43ec29f0eefdb2bbdffa42e82 100644 --- a/modules/find/FindLAPACKE.cmake +++ b/modules/find/FindLAPACKE.cmake @@ -83,6 +83,9 @@ # (To distribute this file outside of Morse, substitute the full # License text for the above reference.) +# Common macros to use in finds +include(FindInit) + if (NOT LAPACKE_FOUND) set(LAPACKE_DIR "" CACHE PATH "Installation directory of LAPACKE library") if (NOT LAPACKE_FIND_QUIETLY) @@ -100,7 +103,16 @@ if( LAPACKE_FIND_COMPONENTS ) endforeach() endif() -# LAPACKE depends on LAPACK anyway, try to find it +# LAPACKE may depend on TMG, try to find it +if (LAPACKE_WITH_TMG) + if(LAPACKE_FIND_REQUIRED) + find_package(TMG REQUIRED) + else() + find_package(TMG) + endif() +endif() + +# LAPACKE depends on LAPACK, try to find it if(LAPACKE_FIND_REQUIRED) find_package(LAPACK REQUIRED) else() @@ -139,10 +151,11 @@ if (LAPACK_FOUND) # try with pkg-config set(ENV_LAPACKE_DIR "$ENV{LAPACKE_DIR}") + set(ENV_MKL_DIR "$ENV{MKLROOT}") set(ENV_LAPACKE_INCDIR "$ENV{LAPACKE_INCDIR}") set(ENV_LAPACKE_LIBDIR "$ENV{LAPACKE_LIBDIR}") set(LAPACKE_GIVEN_BY_USER "FALSE") - if ( LAPACKE_DIR OR ( LAPACKE_INCDIR AND LAPACKE_LIBDIR) OR ENV_LAPACKE_DIR OR (ENV_LAPACKE_INCDIR AND ENV_LAPACKE_LIBDIR) ) + if ( LAPACKE_DIR OR ( LAPACKE_INCDIR AND LAPACKE_LIBDIR) OR ENV_LAPACKE_DIR OR ENV_MKL_DIR OR (ENV_LAPACKE_INCDIR AND ENV_LAPACKE_LIBDIR) ) set(LAPACKE_GIVEN_BY_USER "TRUE") endif() @@ -355,6 +368,22 @@ if (LAPACK_FOUND) set(REQUIRED_LIBDIRS "${LAPACKE_LIBRARY_DIRS}") endif() set(REQUIRED_LIBS "${LAPACKE_LIBRARIES}") + # TMG + if (LAPACKE_WITH_TMG) + if (TMG_INCLUDE_DIRS_DEP) + list(APPEND REQUIRED_INCDIRS "${TMG_INCLUDE_DIRS_DEP}") + endif() + if (TMG_CFLAGS_OTHER_DEP) + list(APPEND REQUIRED_FLAGS "${TMG_CFLAGS_OTHER_DEP}") + endif() + if (TMG_LDFLAGS_OTHER_DEP) + list(APPEND REQUIRED_LDFLAGS "${TMG_LDFLAGS_OTHER_DEP}") + endif() + if (TMG_LIBRARY_DIRS_DEP) + list(APPEND REQUIRED_LIBDIRS "${TMG_LIBRARY_DIRS_DEP}") + endif() + list(APPEND REQUIRED_LIBS "${TMG_LIBRARIES_DEP}") + endif() # LAPACK if (LAPACK_INCLUDE_DIRS_DEP) list(APPEND REQUIRED_INCDIRS "${LAPACK_INCLUDE_DIRS_DEP}") @@ -369,28 +398,6 @@ if (LAPACK_FOUND) list(APPEND REQUIRED_LIBDIRS "${LAPACK_LIBRARY_DIRS_DEP}") endif() list(APPEND REQUIRED_LIBS "${LAPACK_LIBRARIES_DEP}") - # Fortran - if (CMAKE_C_COMPILER_ID MATCHES "GNU") - find_library( - FORTRAN_gfortran_LIBRARY - NAMES gfortran - HINTS ${_lib_env} - ) - mark_as_advanced(FORTRAN_gfortran_LIBRARY) - if (FORTRAN_gfortran_LIBRARY) - list(APPEND REQUIRED_LIBS "${FORTRAN_gfortran_LIBRARY}") - endif() - elseif (CMAKE_C_COMPILER_ID MATCHES "Intel") - find_library( - FORTRAN_ifcore_LIBRARY - NAMES ifcore - HINTS ${_lib_env} - ) - mark_as_advanced(FORTRAN_ifcore_LIBRARY) - if (FORTRAN_ifcore_LIBRARY) - list(APPEND REQUIRED_LIBS "${FORTRAN_ifcore_LIBRARY}") - endif() - endif() # m find_library(M_LIBRARY NAMES m HINTS ${_lib_env}) mark_as_advanced(M_LIBRARY) @@ -411,6 +418,7 @@ if (LAPACK_FOUND) list(APPEND REQUIRED_FLAGS "${_flag}") endforeach() endif() + finds_remove_duplicates() set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) @@ -435,9 +443,6 @@ if (LAPACK_FOUND) set(LAPACKE_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") set(LAPACKE_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}") set(LAPACKE_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}") - list(REMOVE_DUPLICATES LAPACKE_LIBRARY_DIRS_DEP) - list(REMOVE_DUPLICATES LAPACKE_CFLAGS_OTHER_DEP) - list(REMOVE_DUPLICATES LAPACKE_LDFLAGS_OTHER_DEP) else() if(NOT LAPACKE_FIND_QUIETLY) message(STATUS "Looking for lapacke: test of LAPACKE_dgeqrf with lapacke and lapack libraries fails") diff --git a/modules/find/FindMAGMA.cmake b/modules/find/FindMAGMA.cmake index 057d566f38ad110fb1c184f72f15f9f5341e3891..95549c5a1e1503013aaa0a0d6554270974ca2148 100644 --- a/modules/find/FindMAGMA.cmake +++ b/modules/find/FindMAGMA.cmake @@ -63,6 +63,8 @@ # (To distribute this file outside of Morse, substitute the full # License text for the above reference.) +# Common macros to use in finds +include(FindInit) if(NOT MAGMA_FOUND) set(MAGMA_DIR "" CACHE PATH "Installation directory of MAGMA library") @@ -361,7 +363,7 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT MAGMA_FOUND) O list(APPEND REQUIRED_LIBDIRS "${CUDA_LIBRARY_DIRS}") endif() list(APPEND REQUIRED_LIBS "${CUDA_CUBLAS_LIBRARIES};${CUDA_LIBRARIES}") - + finds_remove_duplicates() # set required libraries for link set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") set(CMAKE_REQUIRED_LIBRARIES) @@ -384,9 +386,6 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT MAGMA_FOUND) O 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 diff --git a/modules/find/FindMETIS.cmake b/modules/find/FindMETIS.cmake index 9ce9ca6b62fc00397b4f132c401c9b8b44c9c0a0..860de60a9f4fcd04d31e739630d4cd62e9dfe7f4 100644 --- a/modules/find/FindMETIS.cmake +++ b/modules/find/FindMETIS.cmake @@ -47,6 +47,9 @@ # (To distribute this file outside of Morse, substitute the full # License text for the above reference.) +# Common macros to use in finds +include(FindInit) + if (NOT METIS_FOUND) set(METIS_DIR "" CACHE PATH "Installation directory of METIS library") if (NOT METIS_FIND_QUIETLY) @@ -210,7 +213,7 @@ if(METIS_LIBRARIES) if(M_LIBRARY) list(APPEND REQUIRED_LIBS "${M_LIBRARY}") endif() - + finds_remove_duplicates() # set required libraries for link set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") set(CMAKE_REQUIRED_LIBRARIES) diff --git a/modules/find/FindMUMPS.cmake b/modules/find/FindMUMPS.cmake index b1e9be54ebcaf7840fffd15d6f032a9c682846e4..a88c5702671a6248c36f8503bb5f13f1527c4f1a 100644 --- a/modules/find/FindMUMPS.cmake +++ b/modules/find/FindMUMPS.cmake @@ -69,6 +69,8 @@ # (To distribute this file outside of Morse, substitute the full # License text for the above reference.) +# Common macros to use in finds +include(FindInit) if (NOT MUMPS_FOUND) set(MUMPS_DIR "" CACHE PATH "Installation directory of MUMPS library") @@ -712,6 +714,7 @@ if(MUMPS_LIBRARIES) list(APPEND REQUIRED_FLAGS "${_flag}") endforeach() endif() + finds_remove_duplicates() set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) @@ -746,9 +749,6 @@ if(MUMPS_LIBRARIES) set(MUMPS_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") set(MUMPS_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}") set(MUMPS_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}") - list(REMOVE_DUPLICATES MUMPS_LIBRARY_DIRS_DEP) - list(REMOVE_DUPLICATES MUMPS_CFLAGS_OTHER_DEP) - list(REMOVE_DUPLICATES MUMPS_LDFLAGS_OTHER_DEP) else() if(NOT MUMPS_FIND_QUIETLY) message(STATUS "Looking for MUMPS : test of [sdcz]mumps() fails") diff --git a/modules/find/FindPAMPA.cmake b/modules/find/FindPAMPA.cmake index fba85f8a55e1675d4365ba9a58bd81ba67500861..e3f0ae01665b20492576d349727a7d11fc70a2a4 100644 --- a/modules/find/FindPAMPA.cmake +++ b/modules/find/FindPAMPA.cmake @@ -58,6 +58,9 @@ # (To distribute this file outside of Morse, substitute the full # License text for the above reference.) +# Common macros to use in finds +include(FindInit) + if (NOT PAMPA_FOUND) set(PAMPA_DIR "" CACHE PATH "Installation directory of PAMPA library") if (NOT PAMPA_FIND_QUIETLY) @@ -303,6 +306,7 @@ if(PAMPA_LIBRARIES) list(APPEND REQUIRED_FLAGS "${_flag}") endforeach() endif() + finds_remove_duplicates() set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) @@ -323,9 +327,6 @@ if(PAMPA_LIBRARIES) set(PAMPA_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") set(PAMPA_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}") set(PAMPA_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}") - list(REMOVE_DUPLICATES PAMPA_LIBRARY_DIRS_DEP) - list(REMOVE_DUPLICATES PAMPA_CFLAGS_OTHER_DEP) - list(REMOVE_DUPLICATES PAMPA_LDFLAGS_OTHER_DEP) else() if(NOT PAMPA_FIND_QUIETLY) message(STATUS "Looking for PAMPA : test of PAMPA_dmeshInit with PAMPA library fails") diff --git a/modules/find/FindPAPI.cmake b/modules/find/FindPAPI.cmake index add232d24be3ca9956005970e61d9bd84cb40982..4445a1f9f9e105b71cec5f4269ec9e37cda538fd 100644 --- a/modules/find/FindPAPI.cmake +++ b/modules/find/FindPAPI.cmake @@ -59,6 +59,9 @@ # (To distribute this file outside of Morse, substitute the full # License text for the above reference.) +# Common macros to use in finds +include(FindInit) + if (NOT PAPI_FOUND) set(PAPI_DIR "" CACHE PATH "Installation directory of PAPI library") if (NOT PAPI_FIND_QUIETLY) @@ -289,6 +292,7 @@ if(PAPI_LIBRARIES) list(APPEND REQUIRED_FLAGS "${_flag}") endforeach() endif() + finds_remove_duplicates() set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) diff --git a/modules/find/FindPARMETIS.cmake b/modules/find/FindPARMETIS.cmake index 8033659291f55d8d60e87c69bf4f27b502f38722..19202dda5d9cd5e60391fe31f30bf83fe5c64854 100644 --- a/modules/find/FindPARMETIS.cmake +++ b/modules/find/FindPARMETIS.cmake @@ -57,6 +57,9 @@ # (To distribute this file outside of Morse, substitute the full # License text for the above reference.) +# Common macros to use in finds +include(FindInit) + if (NOT PARMETIS_FOUND) set(PARMETIS_DIR "" CACHE PATH "Installation directory of PARMETIS library") if (NOT PARMETIS_FIND_QUIETLY) @@ -275,6 +278,7 @@ if(PARMETIS_LIBRARIES) list(APPEND REQUIRED_FLAGS "${_flag}") endforeach() endif() + finds_remove_duplicates() set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) @@ -295,9 +299,6 @@ if(PARMETIS_LIBRARIES) set(PARMETIS_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") set(PARMETIS_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}") set(PARMETIS_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}") - list(REMOVE_DUPLICATES PARMETIS_LIBRARY_DIRS_DEP) - list(REMOVE_DUPLICATES PARMETIS_CFLAGS_OTHER_DEP) - list(REMOVE_DUPLICATES PARMETIS_LDFLAGS_OTHER_DEP) else() if(NOT PARMETIS_FIND_QUIETLY) message(STATUS "Looking for PARMETIS : test of ParMETIS_V3_NodeND with PARMETIS library fails") diff --git a/modules/find/FindPARSEC.cmake b/modules/find/FindPARSEC.cmake index c3ff3e992e5cb22d0728dfd64ab41a1088e22823..d8f5786bf5cd07e84720bf9be23106622313f835 100644 --- a/modules/find/FindPARSEC.cmake +++ b/modules/find/FindPARSEC.cmake @@ -79,6 +79,9 @@ # (To distribute this file outside of Morse, substitute the full # License text for the above reference.) +# Common macros to use in finds +include(FindInit) + include(CheckSymbolExists) if (NOT PARSEC_FOUND) @@ -563,28 +566,6 @@ if(PARSEC_LIBRARIES) endif() list(APPEND REQUIRED_LIBS "${CUDA_CUBLAS_LIBRARIES};${CUDA_CUDART_LIBRARY};${CUDA_CUDA_LIBRARY}") endif() - # Fortran - if (CMAKE_C_COMPILER_ID MATCHES "GNU") - find_library( - FORTRAN_gfortran_LIBRARY - NAMES gfortran - HINTS ${_lib_env} - ) - mark_as_advanced(FORTRAN_gfortran_LIBRARY) - if (FORTRAN_gfortran_LIBRARY) - list(APPEND REQUIRED_LIBS "${FORTRAN_gfortran_LIBRARY}") - endif() - elseif (CMAKE_C_COMPILER_ID MATCHES "Intel") - find_library( - FORTRAN_ifcore_LIBRARY - NAMES ifcore - HINTS ${_lib_env} - ) - mark_as_advanced(FORTRAN_ifcore_LIBRARY) - if (FORTRAN_ifcore_LIBRARY) - list(APPEND REQUIRED_LIBS "${FORTRAN_ifcore_LIBRARY}") - endif() - endif() # EXTRA LIBS such that pthread, m, rt, dl list(APPEND REQUIRED_LIBS ${PARSEC_EXTRA_LIBRARIES}) @@ -602,6 +583,7 @@ if(PARSEC_LIBRARIES) list(APPEND REQUIRED_FLAGS "${_flag}") endforeach() endif() + finds_remove_duplicates() set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) @@ -622,9 +604,6 @@ if(PARSEC_LIBRARIES) set(PARSEC_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") set(PARSEC_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}") set(PARSEC_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}") - list(REMOVE_DUPLICATES PARSEC_LIBRARY_DIRS_DEP) - list(REMOVE_DUPLICATES PARSEC_CFLAGS_OTHER_DEP) - list(REMOVE_DUPLICATES PARSEC_LDFLAGS_OTHER_DEP) else() if(NOT PARSEC_FIND_QUIETLY) message(STATUS "Looking for parsec : test of parsec_init fails") diff --git a/modules/find/FindPASTIX.cmake b/modules/find/FindPASTIX.cmake index 06d46047ed9f590b280bc3f70a5c4bcd3cd2c231..66d1e45f40f32a4cd4100f7e4148f66ce0ecea2d 100644 --- a/modules/find/FindPASTIX.cmake +++ b/modules/find/FindPASTIX.cmake @@ -94,6 +94,8 @@ # (To distribute this file outside of Morse, substitute the full # License text for the above reference.) +# Common macros to use in finds +include(FindInit) if (NOT PASTIX_FOUND) set(PASTIX_DIR "" CACHE PATH "Installation directory of PASTIX library") @@ -738,28 +740,6 @@ if(PASTIX_LIBRARIES) endforeach() list(APPEND REQUIRED_LIBS "${METIS_LIBRARIES}") endif() - # Fortran - if (CMAKE_C_COMPILER_ID MATCHES "GNU") - find_library( - FORTRAN_gfortran_LIBRARY - NAMES gfortran - HINTS ${_lib_env} - ) - mark_as_advanced(FORTRAN_gfortran_LIBRARY) - if (FORTRAN_gfortran_LIBRARY) - list(APPEND REQUIRED_LIBS "${FORTRAN_gfortran_LIBRARY}") - endif() - elseif (CMAKE_C_COMPILER_ID MATCHES "Intel") - find_library( - FORTRAN_ifcore_LIBRARY - NAMES ifcore - HINTS ${_lib_env} - ) - mark_as_advanced(FORTRAN_ifcore_LIBRARY) - if (FORTRAN_ifcore_LIBRARY) - list(APPEND REQUIRED_LIBS "${FORTRAN_ifcore_LIBRARY}") - endif() - endif() # EXTRA LIBS such that pthread, m, rt list(APPEND REQUIRED_LIBS ${PASTIX_EXTRA_LIBRARIES}) @@ -777,6 +757,7 @@ if(PASTIX_LIBRARIES) list(APPEND REQUIRED_FLAGS "${_flag}") endforeach() endif() + finds_remove_duplicates() set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) @@ -797,9 +778,6 @@ if(PASTIX_LIBRARIES) set(PASTIX_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") set(PASTIX_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}") set(PASTIX_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}") - list(REMOVE_DUPLICATES PASTIX_LIBRARY_DIRS_DEP) - list(REMOVE_DUPLICATES PASTIX_CFLAGS_OTHER_DEP) - list(REMOVE_DUPLICATES PASTIX_LDFLAGS_OTHER_DEP) else() if(NOT PASTIX_FIND_QUIETLY) message(STATUS "Looking for PASTIX : test of pastix() fails") diff --git a/modules/find/FindPTSCOTCH.cmake b/modules/find/FindPTSCOTCH.cmake index bc10873f3c0acd74cbff7319522ee96ada8a3c5e..b0f983b8d87ef1fa20cd3835b479466f68d3dd78 100644 --- a/modules/find/FindPTSCOTCH.cmake +++ b/modules/find/FindPTSCOTCH.cmake @@ -62,6 +62,9 @@ # (To distribute this file outside of Morse, substitute the full # License text for the above reference.) +# Common macros to use in finds +include(FindInit) + if (NOT PTSCOTCH_FOUND) set(PTSCOTCH_DIR "" CACHE PATH "Installation directory of PTSCOTCH library") if (NOT PTSCOTCH_FIND_QUIETLY) @@ -333,6 +336,7 @@ if(PTSCOTCH_LIBRARIES) list(APPEND REQUIRED_FLAGS "${_flag}") endforeach() endif() + finds_remove_duplicates() set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) @@ -353,9 +357,6 @@ if(PTSCOTCH_LIBRARIES) set(PTSCOTCH_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") set(PTSCOTCH_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}") set(PTSCOTCH_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}") - list(REMOVE_DUPLICATES PTSCOTCH_LIBRARY_DIRS_DEP) - list(REMOVE_DUPLICATES PTSCOTCH_CFLAGS_OTHER_DEP) - list(REMOVE_DUPLICATES PTSCOTCH_LDFLAGS_OTHER_DEP) else() if(NOT PTSCOTCH_FIND_QUIETLY) message(STATUS "Looking for PTSCOTCH : test of SCOTCH_dgraphInit with PTSCOTCH library fails") diff --git a/modules/FindPkgconfigLibrariesAbsolutePath.cmake b/modules/find/FindPkgconfigLibrariesAbsolutePath.cmake similarity index 100% rename from modules/FindPkgconfigLibrariesAbsolutePath.cmake rename to modules/find/FindPkgconfigLibrariesAbsolutePath.cmake diff --git a/modules/find/FindQUARK.cmake b/modules/find/FindQUARK.cmake index 6431029e990d9189cb13b2003bfec823e04c66b0..78f76cf621e6322eaab8459fe568f51f92810e78 100644 --- a/modules/find/FindQUARK.cmake +++ b/modules/find/FindQUARK.cmake @@ -62,6 +62,8 @@ # (To distribute this file outside of Morse, substitute the full # License text for the above reference.) +# Common macros to use in finds +include(FindInit) if (NOT QUARK_FOUND) set(QUARK_DIR "" CACHE PATH "Installation directory of QUARK library") @@ -286,6 +288,7 @@ if(QUARK_LIBRARIES) list(APPEND REQUIRED_FLAGS "${_flag}") endforeach() endif() + finds_remove_duplicates() set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) @@ -306,9 +309,6 @@ if(QUARK_LIBRARIES) set(QUARK_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") set(QUARK_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}") set(QUARK_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}") - list(REMOVE_DUPLICATES QUARK_LIBRARY_DIRS_DEP) - list(REMOVE_DUPLICATES QUARK_CFLAGS_OTHER_DEP) - list(REMOVE_DUPLICATES QUARK_LDFLAGS_OTHER_DEP) else() if(NOT QUARK_FIND_QUIETLY) message(STATUS "Looking for QUARK : test of QUARK_New with QUARK library fails") diff --git a/modules/find/FindSCALAPACK.cmake b/modules/find/FindSCALAPACK.cmake index 9d0514d607219a1117cd2ac05c7d013fbb4ab641..1d7d19c28d624dda5c8263edf7b5fd9d610c24d8 100644 --- a/modules/find/FindSCALAPACK.cmake +++ b/modules/find/FindSCALAPACK.cmake @@ -58,44 +58,8 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) - -## Some macros to print status when search for headers and libs -# This macro informs why the _lib_to_find file has not been found -macro(Print_Find_Library_Blas_Status _libname _lib_to_find) - - # save _libname upper/lower case - string(TOUPPER ${_libname} LIBNAME) - string(TOLOWER ${_libname} libname) - - # print status - #message(" ") - if(${LIBNAME}_LIBDIR) - message("${Yellow}${LIBNAME}_LIBDIR is defined but ${_lib_to_find}" - "has not been found in ${ARGN}${ColourReset}") - else() - if(${LIBNAME}_DIR) - message("${Yellow}${LIBNAME}_DIR is defined but ${_lib_to_find}" - "has not been found in ${ARGN}${ColourReset}") - else() - message("${Yellow}${_lib_to_find} not found." - "Nor ${LIBNAME}_DIR neither ${LIBNAME}_LIBDIR" - "are defined so that we look for ${_lib_to_find} in" - "system paths (Linux: LD_LIBRARY_PATH, Windows: LIB," - "Mac: DYLD_LIBRARY_PATH," - "CMAKE_C_IMPLICIT_LINK_DIRECTORIES)${ColourReset}") - if(_lib_env) - message("${Yellow}${_lib_to_find} has not been found in" - "${_lib_env}${ColourReset}") - endif() - endif() - endif() - message("${BoldYellow}Please indicate where to find ${_lib_to_find}. You have three options:\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}") - -endmacro() +# Common macros to use in finds +include(FindInit) if (NOT SCALAPACK_FOUND) set(SCALAPACK_DIR "" CACHE PATH "Installation directory of SCALAPACK library") diff --git a/modules/find/FindSCOTCH.cmake b/modules/find/FindSCOTCH.cmake index f86f03855e65240f543ef6c45f8f441f82aba515..ddf258d3d37e3900c294c745cea207f9fec6ca93 100644 --- a/modules/find/FindSCOTCH.cmake +++ b/modules/find/FindSCOTCH.cmake @@ -51,6 +51,9 @@ # (To distribute this file outside of Morse, substitute the full # License text for the above reference.) +# Common macros to use in finds +include(FindInit) + if (NOT SCOTCH_FOUND) set(SCOTCH_DIR "" CACHE PATH "Installation directory of SCOTCH library") if (NOT SCOTCH_FIND_QUIETLY) @@ -270,7 +273,7 @@ if(SCOTCH_LIBRARIES) if(RT_LIBRARY) list(APPEND REQUIRED_LIBS "${RT_LIBRARY}") endif() - + finds_remove_duplicates() # set required libraries for link set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") set(CMAKE_REQUIRED_LIBRARIES) diff --git a/modules/find/FindSIMGRID.cmake b/modules/find/FindSIMGRID.cmake index 53789647d2705f7af2610915e4171230b8eaa0ea..691c2c5ea57efbfeabc07c35af14f625742b8147 100644 --- a/modules/find/FindSIMGRID.cmake +++ b/modules/find/FindSIMGRID.cmake @@ -59,6 +59,9 @@ # (To distribute this file outside of Morse, substitute the full # License text for the above reference.) +# Common macros to use in finds +include(FindInit) + if (NOT SIMGRID_FOUND) set(SIMGRID_DIR "" CACHE PATH "Installation directory of SIMGRID library") if (NOT SIMGRID_FIND_QUIETLY) @@ -299,6 +302,7 @@ if(SIMGRID_LIBRARIES) list(APPEND REQUIRED_FLAGS "${_flag}") endforeach() endif() + finds_remove_duplicates() set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) diff --git a/modules/find/FindSTARPU.cmake b/modules/find/FindSTARPU.cmake index 90d3837eb59d362d60b0e1790f814510f7013b50..a8fede95009f61cba1312110352117c9c01ba1ab 100644 --- a/modules/find/FindSTARPU.cmake +++ b/modules/find/FindSTARPU.cmake @@ -82,6 +82,9 @@ # (To distribute this file outside of Morse, substitute the full # License text for the above reference.) +# Common macros to use in finds +include(FindInit) + if (NOT STARPU_FOUND) set(STARPU_DIR "" CACHE PATH "Installation directory of STARPU library") if (NOT STARPU_FIND_QUIETLY) @@ -774,28 +777,6 @@ if(STARPU_LIBRARIES) endif() list(APPEND REQUIRED_LIBS "${BLAS_LIBRARIES}") endif() - # Fortran - if (CMAKE_C_COMPILER_ID MATCHES "GNU") - find_library( - FORTRAN_gfortran_LIBRARY - NAMES gfortran - HINTS ${_lib_env} - ) - mark_as_advanced(FORTRAN_gfortran_LIBRARY) - if (FORTRAN_gfortran_LIBRARY AND CMAKE_C_COMPILER_ID STREQUAL "GNU") - list(APPEND REQUIRED_LIBS "${FORTRAN_gfortran_LIBRARY}") - endif() - elseif (CMAKE_C_COMPILER_ID MATCHES "Intel") - find_library( - FORTRAN_ifcore_LIBRARY - NAMES ifcore - HINTS ${_lib_env} - ) - mark_as_advanced(FORTRAN_ifcore_LIBRARY) - if (FORTRAN_ifcore_LIBRARY) - list(APPEND REQUIRED_LIBS "${FORTRAN_ifcore_LIBRARY}") - endif() - endif() # EXTRA LIBS such that pthread, m, rt list(APPEND REQUIRED_LIBS ${STARPU_EXTRA_LIBRARIES}) @@ -813,6 +794,7 @@ if(STARPU_LIBRARIES) list(APPEND REQUIRED_FLAGS "${_flag}") endforeach() endif() + finds_remove_duplicates() set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) @@ -833,9 +815,6 @@ if(STARPU_LIBRARIES) set(STARPU_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") set(STARPU_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}") set(STARPU_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}") - list(REMOVE_DUPLICATES STARPU_LIBRARY_DIRS_DEP) - list(REMOVE_DUPLICATES STARPU_CFLAGS_OTHER_DEP) - list(REMOVE_DUPLICATES STARPU_LDFLAGS_OTHER_DEP) else() if(NOT STARPU_FIND_QUIETLY) message(STATUS "Looking for starpu : test of starpu_init fails") diff --git a/modules/find/FindSUITESPARSE.cmake b/modules/find/FindSUITESPARSE.cmake index 8a9eff8e2d49503cd13598007fe0d2fef11b6d0a..91245989f487659cbfba0d5836479292d399e91f 100644 --- a/modules/find/FindSUITESPARSE.cmake +++ b/modules/find/FindSUITESPARSE.cmake @@ -56,6 +56,8 @@ # (To distribute this file outside of Morse, substitute the full # License text for the above reference.) +# Common macros to use in finds +include(FindInit) if (NOT SUITESPARSE_FOUND) set(SUITESPARSE_DIR "" CACHE PATH "Installation directory of SUITESPARSE library") @@ -358,6 +360,7 @@ if(SUITESPARSE_LIBRARIES) list(APPEND REQUIRED_FLAGS "${_flag}") endforeach() endif() + finds_remove_duplicates() set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) @@ -378,9 +381,6 @@ if(SUITESPARSE_LIBRARIES) set(SUITESPARSE_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") set(SUITESPARSE_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}") set(SUITESPARSE_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}") - list(REMOVE_DUPLICATES SUITESPARSE_LIBRARY_DIRS_DEP) - list(REMOVE_DUPLICATES SUITESPARSE_CFLAGS_OTHER_DEP) - list(REMOVE_DUPLICATES SUITESPARSE_LDFLAGS_OTHER_DEP) else() if(NOT SUITESPARSE_FIND_QUIETLY) message(STATUS "Looking for SUITESPARSE : test of symbol SuiteSparse_start fails") diff --git a/modules/find/FindTMG.cmake b/modules/find/FindTMG.cmake index 5721dab29815597b771b78342647a5e38a14f7d4..09992e882a71248dc3d1aedab30a649474e7ebb0 100644 --- a/modules/find/FindTMG.cmake +++ b/modules/find/FindTMG.cmake @@ -53,6 +53,8 @@ # (To distribute this file outside of Morse, substitute the full # License text for the above reference.) +# Common macros to use in finds +include(FindInit) if (NOT TMG_FOUND) set(TMG_DIR "" CACHE PATH "Installation directory of TMG library") @@ -243,6 +245,7 @@ if (LAPACK_FOUND) list(APPEND REQUIRED_FLAGS "${_flag}") endforeach() endif() + finds_remove_duplicates() set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) @@ -276,9 +279,6 @@ if (LAPACK_FOUND) set(TMG_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") set(TMG_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}") set(TMG_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}") - list(REMOVE_DUPLICATES TMG_LIBRARY_DIRS_DEP) - list(REMOVE_DUPLICATES TMG_CFLAGS_OTHER_DEP) - list(REMOVE_DUPLICATES TMG_LDFLAGS_OTHER_DEP) else() if(NOT TMG_FIND_QUIETLY) message(STATUS "Looking for tmg: test of dlarnv and dlagsy with tmg and lapack libraries fails") diff --git a/modules/LibrariesAbsolutePath.cmake b/modules/find/LibrariesAbsolutePath.cmake similarity index 100% rename from modules/LibrariesAbsolutePath.cmake rename to modules/find/LibrariesAbsolutePath.cmake diff --git a/modules/PrintFindStatus.cmake b/modules/find/PrintFindStatus.cmake similarity index 100% rename from modules/PrintFindStatus.cmake rename to modules/find/PrintFindStatus.cmake diff --git a/modules/find/tests/CMakeLists.txt b/modules/find/tests/CMakeLists.txt index c664e716f61b63a138728eff9b0147e83d263cac..abccab8a1dd65d098c825d4c600ddf12634ee5d0 100644 --- a/modules/find/tests/CMakeLists.txt +++ b/modules/find/tests/CMakeLists.txt @@ -2,10 +2,8 @@ cmake_minimum_required(VERSION 2.8) project(TEST_MORSE_CMAKE_MODULES_FIND Fortran C CXX) # location of Morse modules to get some specific macros -list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../../") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../") include(MorseInit) -# location of find package modules -list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../") # main variable: control the list of libraries to find thanks to find_package # pay attention that package names must be given with capital letters