diff --git a/CMakeModules/morse/AuxilaryFlags.cmake b/CMakeModules/morse/AuxilaryFlags.cmake index 9b15b0f33ddf639a35d1a25fefab722f7f056534..9744d578b6eada54ef12355b27d1ff3000da2fb9 100644 --- a/CMakeModules/morse/AuxilaryFlags.cmake +++ b/CMakeModules/morse/AuxilaryFlags.cmake @@ -3,7 +3,7 @@ # @copyright (c) 2009-2014 The University of Tennessee and The University # of Tennessee Research Foundation. # All rights reserved. -# @copyright (c) 2012-2014 Inria. All rights reserved. +# @copyright (c) 2012-2016 Inria. All rights reserved. # @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. # ### @@ -20,20 +20,72 @@ # # @version 0.9.0 # @author Xavier Lacoste +# @author Florent Pruvost # @date 30-01-2015 # -# Define auxilary variables: +# Update CMAKE auxilary variables: +# - CMAKE_C_FLAGS: C compiler flags +# - CMAKE_CXX_FLAGS: CXX compiler flags +# - CMAKE_Fortran_FLAGS: Fortran compiler flags # - CMAKE_Fortran_PREPROCESS_FLAGS : force C preprocessor. # - CMAKE_Fortran_FREEFORM_FLAG : Force free format. -# - CMAKE_Fortran ### +if (MORSE_ENABLE_WARNING) -IF(CMAKE_Fortran_COMPILER_ID MATCHES GNU) + if(CMAKE_C_COMPILER_ID MATCHES GNU) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") + elseif(CMAKE_C_COMPILER_ID MATCHES Intel) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w3 -diag-disable:remark") + endif() + + if(CMAKE_CXX_COMPILER_ID MATCHES GNU) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") + elseif(CMAKE_CXX_COMPILER_ID MATCHES Intel) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w3 -diag-disable:remark") + endif() + + if(CMAKE_Fortran_COMPILER_ID MATCHES GNU) + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Wall") + elseif(CMAKE_Fortran_COMPILER_ID MATCHES Intel) + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -warn all -diag-disable:remark") + endif() + +endif(MORSE_ENABLE_WARNING) + +if (MORSE_ENABLE_COVERAGE) + + if(CMAKE_C_COMPILER_ID MATCHES GNU) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage") + else() + message(FATAL_ERROR "Code coverage is only available with the GNU C (gcc)" + "\n compiler, please turn MORSE_ENABLE_COVERAGE OFF\n.") + endif() + + if(CMAKE_CXX_COMPILER_ID MATCHES GNU) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") + else() + message(FATAL_ERROR "Code coverage is only available with the GNU CXX" + "\n (g++) compiler, please turn MORSE_ENABLE_COVERAGE OFF\n.") + endif() + + if(CMAKE_Fortran_COMPILER_ID MATCHES GNU) + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} --coverage") + else() + message(FATAL_ERROR "Code coverage is only available with the GNU" + "\n Fortran (gfortran) compiler, please turn MORSE_ENABLE_COVERAGE" + "\n OFF\n.") + endif() + + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage") + +endif(MORSE_ENABLE_COVERAGE) + + +if(CMAKE_Fortran_COMPILER_ID MATCHES GNU) list(APPEND CMAKE_Fortran_PREPROCESS_FLAGS "-cpp") list(APPEND CMAKE_Fortran_FREEFORM_FLAG "-ffree-form") - -ELSEIF(CMAKE_Fortran_COMPILER_ID MATCHES Intel) +elseif(CMAKE_Fortran_COMPILER_ID MATCHES Intel) list(APPEND CMAKE_Fortran_PREPROCESS_FLAG "-fpp") list(APPEND CMAKE_Fortran_FREEFORM_FLAG "") -ENDIF() +endif() diff --git a/CMakeModules/morse/FindHeadersAndLibs.cmake b/CMakeModules/morse/FindHeadersAndLibs.cmake index 0f5eadde7b0618cc20e65feab12de5982b2fe3cc..d0919dcb001d66f04f9691f7a826037c7cec2e88 100644 --- a/CMakeModules/morse/FindHeadersAndLibs.cmake +++ b/CMakeModules/morse/FindHeadersAndLibs.cmake @@ -37,60 +37,60 @@ include(PrintFindStatus) function(FindHeader _libname _header_to_find) - # save _libname upper and lower case - string(TOUPPER ${_libname} LIBNAME) - string(TOLOWER ${_libname} libname) + # save _libname upper and lower case + string(TOUPPER ${_libname} LIBNAME) + string(TOLOWER ${_libname} libname) - # Looking for include - # ------------------- + # Looking for include + # ------------------- - # Add system include paths to search include - # ------------------------------------------ - unset(_inc_env) - if(WIN32) - string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") - else() - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{CPATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - endif() - list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") - list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") - list(REMOVE_DUPLICATES _inc_env) + # Add system include paths to search include + # ------------------------------------------ + unset(_inc_env) + if(WIN32) + string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") + else() + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{CPATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + endif() + list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") + list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") + list(REMOVE_DUPLICATES _inc_env) - # Try to find the _header_to_find in the given paths - # -------------------------------------------------- - # call cmake macro to find the header path - if(${LIBNAME}_INCDIR) - set(${LIBNAME}_${_header_to_find}_DIRS "${LIBNAME}_${_header_to_find}_DIRS-NOTFOUND") - find_path(${LIBNAME}_${_header_to_find}_DIRS - NAMES ${_header_to_find} - HINTS ${${LIBNAME}_INCDIR}) - elseif(${LIBNAME}_DIR) - set(${LIBNAME}_${_header_to_find}_DIRS "${LIBNAME}_${_header_to_find}_DIRS-NOTFOUND") - find_path(${LIBNAME}_${_header_to_find}_DIRS - NAMES ${_header_to_find} - HINTS ${${LIBNAME}_DIR} - PATH_SUFFIXES include) - else() - set(${LIBNAME}_${_header_to_find}_DIRS "${LIBNAME}_${_header_to_find}_DIRS-NOTFOUND") - find_path(${LIBNAME}_${_header_to_find}_DIRS - NAMES ${_header_to_find} - HINTS ${_inc_env}) - endif() - mark_as_advanced(${LIBNAME}_${_header_to_find}_DIRS) + # Try to find the _header_to_find in the given paths + # -------------------------------------------------- + # call cmake macro to find the header path + if(${LIBNAME}_INCDIR) + set(${LIBNAME}_${_header_to_find}_DIRS "${LIBNAME}_${_header_to_find}_DIRS-NOTFOUND") + find_path(${LIBNAME}_${_header_to_find}_DIRS + NAMES ${_header_to_find} + HINTS ${${LIBNAME}_INCDIR}) + elseif(${LIBNAME}_DIR) + set(${LIBNAME}_${_header_to_find}_DIRS "${LIBNAME}_${_header_to_find}_DIRS-NOTFOUND") + find_path(${LIBNAME}_${_header_to_find}_DIRS + NAMES ${_header_to_find} + HINTS ${${LIBNAME}_DIR} + PATH_SUFFIXES include) + else() + set(${LIBNAME}_${_header_to_find}_DIRS "${LIBNAME}_${_header_to_find}_DIRS-NOTFOUND") + find_path(${LIBNAME}_${_header_to_find}_DIRS + NAMES ${_header_to_find} + HINTS ${_inc_env}) + endif() + mark_as_advanced(${LIBNAME}_${_header_to_find}_DIRS) - # Print status if not found - # ------------------------- - if (NOT ${LIBNAME}_${_header_to_find}_DIRS) - Print_Find_Header_Status(${libname} ${_header_to_find}) - endif () + # Print status if not found + # ------------------------- + if (NOT ${LIBNAME}_${_header_to_find}_DIRS) + Print_Find_Header_Status(${libname} ${_header_to_find}) + endif () endfunction(FindHeader) diff --git a/CMakeModules/morse/MorseInit.cmake b/CMakeModules/morse/MorseInit.cmake index c4ed4fd337f4f8ec9e9e7773f34ba2648c84d710..1fd1794f67369ddbb0e04e6b5ff5c6a092b113cc 100644 --- a/CMakeModules/morse/MorseInit.cmake +++ b/CMakeModules/morse/MorseInit.cmake @@ -3,7 +3,7 @@ # @copyright (c) 2009-2014 The University of Tennessee and The University # of Tennessee Research Foundation. # All rights reserved. -# @copyright (c) 2012-2014 Inria. All rights reserved. +# @copyright (c) 2012-2016 Inria. All rights reserved. # @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. # ### @@ -31,7 +31,7 @@ include(CheckFunctionExists) # To colorize messages -include(ColorizeMessage) +#include(ColorizeMessage) # To find headers and libs include(FindHeadersAndLibs) @@ -49,9 +49,11 @@ 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) -option(MORSE_VERBOSE_FIND_PACKAGE "Add additional messages concerning no found packages" OFF) -#message("-- ${BoldGreen}MORSE_VERBOSE_FIND_PACKAGE is set to OFF, turn it ON to get" -# "information about packages not found${ColourReset}") +option(MORSE_ENABLE_WARNING "Enable warning messages" OFF) +option(MORSE_ENABLE_COVERAGE "Enable flags for coverage test" OFF) +#option(MORSE_VERBOSE_FIND_PACKAGE "Add additional messages concerning packages not found" OFF) +#message(STATUS "MORSE_VERBOSE_FIND_PACKAGE is set to OFF, turn it ON to get" +# " information about packages not found") ## ## @end file MorseInit.cmake diff --git a/CMakeModules/morse/ParseArguments.cmake b/CMakeModules/morse/ParseArguments.cmake index 1407ded47d3d57d3f7ac8e5048188988e1e9bcb6..23a5ce6ddfb2e2085b1f2b46fc4563307938736c 100644 --- a/CMakeModules/morse/ParseArguments.cmake +++ b/CMakeModules/morse/ParseArguments.cmake @@ -16,7 +16,7 @@ # Univ. of Tennessee, # King Abdullah Univesity of Science and Technology # Univ. of California Berkeley, -# Univ. of Colorado Denver. +# Univ. of Colorado Denver. # # @version 0.9.0 # @author Cedric Castagnede @@ -27,43 +27,43 @@ ### MACRO(PARSE_ARGUMENTS prefix arg_names option_names) - set(DEFAULT_ARGS) - foreach(arg_name ${arg_names}) - set(${prefix}_${arg_name}) - endforeach(arg_name) - foreach(option ${option_names}) - set(${prefix}_${option} FALSE) - endforeach(option) + set(DEFAULT_ARGS) + foreach(arg_name ${arg_names}) + set(${prefix}_${arg_name}) + endforeach(arg_name) + foreach(option ${option_names}) + set(${prefix}_${option} FALSE) + endforeach(option) - set(current_arg_name DEFAULT_ARGS) - set(current_arg_list) - foreach(arg ${ARGN}) - set(larg_names ${arg_names}) - list(FIND larg_names "${arg}" is_arg_name) - if(is_arg_name GREATER -1) - set(${prefix}_${current_arg_name} ${current_arg_list}) - set(current_arg_name ${arg}) - set(current_arg_list) - else(is_arg_name GREATER -1) - set(loption_names ${option_names}) - list(FIND loption_names "${arg}" is_option) - if(is_option GREATER -1) - set(${prefix}_${arg} TRUE) - else(is_option GREATER -1) - set(current_arg_list ${current_arg_list} ${arg}) - endif(is_option GREATER -1) - endif(is_arg_name GREATER -1) - endforeach(arg) - set(${prefix}_${current_arg_name} ${current_arg_list}) + set(current_arg_name DEFAULT_ARGS) + set(current_arg_list) + foreach(arg ${ARGN}) + set(larg_names ${arg_names}) + list(FIND larg_names "${arg}" is_arg_name) + if(is_arg_name GREATER -1) + set(${prefix}_${current_arg_name} ${current_arg_list}) + set(current_arg_name ${arg}) + set(current_arg_list) + else(is_arg_name GREATER -1) + set(loption_names ${option_names}) + list(FIND loption_names "${arg}" is_option) + if(is_option GREATER -1) + set(${prefix}_${arg} TRUE) + else(is_option GREATER -1) + set(current_arg_list ${current_arg_list} ${arg}) + endif(is_option GREATER -1) + endif(is_arg_name GREATER -1) + endforeach(arg) + set(${prefix}_${current_arg_name} ${current_arg_list}) ENDMACRO(PARSE_ARGUMENTS) MACRO(CAR var) - set(${var} ${ARGV1}) + set(${var} ${ARGV1}) ENDMACRO(CAR) MACRO(CDR var junk) - set(${var} ${ARGN}) + set(${var} ${ARGN}) ENDMACRO(CDR) ## diff --git a/CMakeModules/morse/PrintFindStatus.cmake b/CMakeModules/morse/PrintFindStatus.cmake index 1ea56edb0b856fe1bbd482a5aef2c65a195f12d0..54e33a7d7f1718bde020cb05eff833f97cefa035 100644 --- a/CMakeModules/morse/PrintFindStatus.cmake +++ b/CMakeModules/morse/PrintFindStatus.cmake @@ -60,133 +60,133 @@ # This macro informs why the _header_to_find file has not been found macro(Print_Find_Header_Status _libname _header_to_find) - # save _libname upper and lower case - string(TOUPPER ${_libname} LIBNAME) - string(TOLOWER ${_libname} libname) - - # print status - #message(" ") - if(${LIBNAME}_INCDIR) - message("${Blue}${LIBNAME}_INCDIR is defined but ${_header_to_find}" - "has not been found in ${${LIBNAME}_INCDIR}${ColourReset}") + # save _libname upper and lower case + string(TOUPPER ${_libname} LIBNAME) + string(TOLOWER ${_libname} libname) + + # print status + #message(" ") + if(${LIBNAME}_INCDIR) + message("${Blue}${LIBNAME}_INCDIR is defined but ${_header_to_find}" + "has not been found in ${${LIBNAME}_INCDIR}${ColourReset}") + else() + if(${LIBNAME}_DIR) + message("${Blue}${LIBNAME}_DIR is defined but" + "${_header_to_find} has not been found in" + "${${LIBNAME}_DIR}/include${ColourReset}") else() - if(${LIBNAME}_DIR) - message("${Blue}${LIBNAME}_DIR is defined but" - "${_header_to_find} has not been found in" - "${${LIBNAME}_DIR}/include${ColourReset}") - else() - message("${Blue}${_header_to_find} not found." - "Nor ${LIBNAME}_DIR neither ${LIBNAME}_INCDIR" - "are defined so that we looked for ${_header_to_find} in" - "system paths (INCLUDE, CPATH, C_INCLUDE_PATH," - "INCLUDE_PATH, CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES" - ", CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES)${ColourReset}") - if(_inc_env) - message("${Blue}${_header_to_find} has not been found in" - "${_inc_env}${ColourReset}") - endif() - endif() + message("${Blue}${_header_to_find} not found." + "Nor ${LIBNAME}_DIR neither ${LIBNAME}_INCDIR" + "are defined so that we looked for ${_header_to_find} in" + "system paths (INCLUDE, CPATH, C_INCLUDE_PATH," + "INCLUDE_PATH, CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES" + ", CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES)${ColourReset}") + if(_inc_env) + message("${Blue}${_header_to_find} has not been found in" + "${_inc_env}${ColourReset}") + endif() endif() - message("${BoldBlue}Please indicate where to find ${_header_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 2: Provide the directory where to find the headers with cmake option: -D${LIBNAME}_INCDIR=your/path/to/${libname}/include/\n" - "- Option 3: Update your environment variable (INCLUDE or CPATH)\n" - "- Option 4: If your library provides a PkgConfig file, make sure pkg-config finds your library${ColourReset}") - #message(" ") + endif() + message("${BoldBlue}Please indicate where to find ${_header_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 2: Provide the directory where to find the headers with cmake option: -D${LIBNAME}_INCDIR=your/path/to/${libname}/include/\n" + "- Option 3: Update your environment variable (INCLUDE or CPATH)\n" + "- Option 4: If your library provides a PkgConfig file, make sure pkg-config finds your library${ColourReset}") + #message(" ") endmacro() # This macro informs why the _lib_to_find file has not been found macro(Print_Find_Library_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 ${${LIBNAME}_LIBDIR}${ColourReset}") + # 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 ${${LIBNAME}_LIBDIR}${ColourReset}") + else() + if(${LIBNAME}_DIR) + message("${Yellow}${LIBNAME}_DIR is defined but ${_lib_to_find}" + "has not been found in ${${LIBNAME}_DIR}/lib(or /lib32 or" + "/lib64)${ColourReset}") else() - if(${LIBNAME}_DIR) - message("${Yellow}${LIBNAME}_DIR is defined but ${_lib_to_find}" - "has not been found in ${${LIBNAME}_DIR}/lib(or /lib32 or" - "/lib64)${ColourReset}") - else() - message("${Yellow}${_lib_to_find} not found." - "Nor ${LIBNAME}_DIR neither ${LIBNAME}_LIBDIR" - "are defined so that we looked for ${_lib_to_find} in" - "system paths (Linux: LD_LIBRARY_PATH, Windows: LIB," - "Mac: DYLD_LIBRARY_PATH," - "CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES," - "CMAKE_C_IMPLICIT_LINK_DIRECTORIES)${ColourReset}") - if(_lib_env) - message("${Yellow}${_lib_to_find} has not been found in" - "${_lib_env}${ColourReset}") - endif() - endif() + message("${Yellow}${_lib_to_find} not found." + "Nor ${LIBNAME}_DIR neither ${LIBNAME}_LIBDIR" + "are defined so that we looked for ${_lib_to_find} in" + "system paths (Linux: LD_LIBRARY_PATH, Windows: LIB," + "Mac: DYLD_LIBRARY_PATH," + "CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES," + "CMAKE_C_IMPLICIT_LINK_DIRECTORIES)${ColourReset}") + if(_lib_env) + message("${Yellow}${_lib_to_find} has not been found in" + "${_lib_env}${ColourReset}") + 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 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}") + 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 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_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}") + # 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() - 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_PLATFORM_IMPLICIT_LINK_DIRECTORIES," - "CMAKE_C_IMPLICIT_LINK_DIRECTORIES)${ColourReset}") - if(_lib_env) - message("${Yellow}${_lib_to_find} has not been found in" - "${_lib_env}${ColourReset}") - endif() - endif() + 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_PLATFORM_IMPLICIT_LINK_DIRECTORIES," + "CMAKE_C_IMPLICIT_LINK_DIRECTORIES)${ColourReset}") + if(_lib_env) + message("${Yellow}${_lib_to_find} has not been found in" + "${_lib_env}${ColourReset}") + 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 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}") + 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 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) + # 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(" ") + # 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() @@ -195,16 +195,16 @@ endmacro() # ex: Print_Find_Pkgconfig_Status(foo foo.pc ${PATHLIST} macro(Print_Find_Pkgconfig_Status _libname _pc_to_find) - # save _libname lower case - string(TOLOWER ${_libname} libname) - - # print status - #message(" ") - message("${Magenta}${_pc_to_find} has not been found in" - "${ARGN}${ColourReset}") - message("${BoldMagenta}If you really want to use the pkg-config file of" - "${libname}, please update your PKG_CONFIG_PATH with the path" - "where ${_pc_to_find} states${ColourReset}") - #message(" ") + # save _libname lower case + string(TOLOWER ${_libname} libname) + + # print status + #message(" ") + message("${Magenta}${_pc_to_find} has not been found in" + "${ARGN}${ColourReset}") + message("${BoldMagenta}If you really want to use the pkg-config file of" + "${libname}, please update your PKG_CONFIG_PATH with the path" + "where ${_pc_to_find} states${ColourReset}") + #message(" ") endmacro() diff --git a/CMakeModules/morse/Ressources.cmake b/CMakeModules/morse/Ressources.cmake index 15b7a35d11cd2cd2ddb5ff358bb3139bbe92cfa0..cd5e2a1eeb4af93710b53745505d3ffa1dac69e2 100644 --- a/CMakeModules/morse/Ressources.cmake +++ b/CMakeModules/morse/Ressources.cmake @@ -29,28 +29,28 @@ if(NOT DEFINED PROCESSOR_COUNT) - # Unknown: - set(NUMBER_OF_CPU 0) + # Unknown: + set(NUMBER_OF_CPU 0) - # Linux: - set(cpuinfo_file "/proc/cpuinfo") - if(EXISTS "${cpuinfo_file}") - file(STRINGS "${cpuinfo_file}" procs REGEX "^processor.: [0-9]+$") - list(LENGTH procs NUMBER_OF_CPU) - endif() + # Linux: + set(cpuinfo_file "/proc/cpuinfo") + if(EXISTS "${cpuinfo_file}") + file(STRINGS "${cpuinfo_file}" procs REGEX "^processor.: [0-9]+$") + list(LENGTH procs NUMBER_OF_CPU) + endif() - # Mac: - if(APPLE) - find_program(cmd_sys_pro "system_profiler") - if(cmd_sys_pro) - execute_process(COMMAND ${cmd_sys_pro} SPHardwareDataType OUTPUT_VARIABLE info) - string(REGEX REPLACE "^.*Total Number of Cores: ([0-9]+).*$" "\\1" - NUMBER_OF_CPU "${info}") - endif() + # Mac: + if(APPLE) + find_program(cmd_sys_pro "system_profiler") + if(cmd_sys_pro) + execute_process(COMMAND ${cmd_sys_pro} SPHardwareDataType OUTPUT_VARIABLE info) + string(REGEX REPLACE "^.*Total Number of Cores: ([0-9]+).*$" "\\1" + NUMBER_OF_CPU "${info}") endif() + endif() - # Windows: - if(WIN32) + # Windows: + if(WIN32) set(NUMBER_OF_CPU "$ENV{NUMBER_OF_PROCESSORS}") - endif() + endif() endif() diff --git a/CMakeModules/morse/RulesPrecisions.cmake b/CMakeModules/morse/RulesPrecisions.cmake index bef0c4418aa0aba574c03309df6dd921f7446998..7e100c35f4da37069c0deb6de3094b3fdbda377a 100644 --- a/CMakeModules/morse/RulesPrecisions.cmake +++ b/CMakeModules/morse/RulesPrecisions.cmake @@ -70,25 +70,25 @@ set( _prec_C OFF ) set( _prec_Z OFF ) set( _prec_ZC OFF ) foreach(_prec ${RP_${CMAKE_PROJECT_NAME}_PRECISIONS}) - if ( ${_prec} STREQUAL "zc" ) + if ( ${_prec} STREQUAL zc ) set( _prec_S ON ) set( _prec_D ON ) set( _prec_C ON ) set( _prec_Z ON ) set( _prec_ZC ON ) - elseif( ${_prec} STREQUAL "z" ) + elseif( ${_prec} STREQUAL z ) set( _prec_D ON ) set( _prec_Z ON ) - elseif( ${_prec} STREQUAL "c" ) + elseif( ${_prec} STREQUAL c ) set( _prec_S ON ) set( _prec_C ON ) - elseif( ${_prec} STREQUAL "ds" ) + elseif( ${_prec} STREQUAL ds ) set( _prec_S ON ) set( _prec_D ON ) set( _prec_DS ON ) - elseif( ${_prec} STREQUAL "d" ) + elseif( ${_prec} STREQUAL d ) set( _prec_S ON ) - elseif( ${_prec} STREQUAL "s" ) + elseif( ${_prec} STREQUAL s ) set( _prec_S ON ) endif() endforeach() @@ -223,27 +223,27 @@ MACRO(precisions_rules_py) # Force the copy of the original files in the binary_dir # for VPATH compilation if( NOT ${CMAKE_PROJECT_NAME}_COMPILE_INPLACE ) - set(generate_out 1) + set(generate_out 1) else( NOT ${CMAKE_PROJECT_NAME}_COMPILE_INPLACE ) - string(COMPARE NOTEQUAL "${_dependency_OUTPUT}" "${_dependency_INPUT}" generate_out ) + string(COMPARE NOTEQUAL "${_dependency_OUTPUT}" "${_dependency_INPUT}" generate_out ) endif() # We generate a dependency only if a file will be generated if( got_file ) - if( generate_out ) - # the custom command is executed in CMAKE_CURRENT_BINARY_DIR - ADD_CUSTOM_COMMAND( - OUTPUT ${_dependency_OUTPUT} - COMMAND ${CMAKE_COMMAND} -E remove -f ${_dependency_OUTPUT} && ${pythoncmd} && chmod a-w ${_dependency_OUTPUT} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_dependency_INPUT} ${RP_CODEGEN} ${RP_${CMAKE_PROJECT_NAME}_DICTIONNARY}) + if( generate_out ) + # the custom command is executed in CMAKE_CURRENT_BINARY_DIR + ADD_CUSTOM_COMMAND( + OUTPUT ${_dependency_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E remove -f ${_dependency_OUTPUT} && ${pythoncmd} && chmod a-w ${_dependency_OUTPUT} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_dependency_INPUT} ${RP_CODEGEN} ${RP_${CMAKE_PROJECT_NAME}_DICTIONNARY}) - set_SOURCE_FILES_PROPERTIES(${_dependency_OUTPUT} PROPERTIES COMPILE_FLAGS "-DPRECISION_${_dependency_PREC}" GENERATED 1 IS_IN_BINARY_DIR 1 ) + set_SOURCE_FILES_PROPERTIES(${_dependency_OUTPUT} PROPERTIES COMPILE_FLAGS "-DPRECISION_${_dependency_PREC}" GENERATED 1 IS_IN_BINARY_DIR 1 ) - else( generate_out ) - set_SOURCE_FILES_PROPERTIES(${_dependency_OUTPUT} PROPERTIES COMPILE_FLAGS "-DPRECISION_${_dependency_PREC}" GENERATED 0 ) - endif( generate_out ) + else( generate_out ) + set_SOURCE_FILES_PROPERTIES(${_dependency_OUTPUT} PROPERTIES COMPILE_FLAGS "-DPRECISION_${_dependency_PREC}" GENERATED 0 ) + endif( generate_out ) - list(APPEND ${OUTPUTLIST} ${_dependency_OUTPUT}) + list(APPEND ${OUTPUTLIST} ${_dependency_OUTPUT}) endif( got_file ) endif() endforeach() diff --git a/CMakeModules/morse/find/FindBLAS.cmake b/CMakeModules/morse/find/FindBLAS.cmake index 0fd4feafc46b44eb9ec13dcf2f1ab97c88259d89..43132541ddcc0653822926aae4932ac84508a80a 100644 --- a/CMakeModules/morse/find/FindBLAS.cmake +++ b/CMakeModules/morse/find/FindBLAS.cmake @@ -82,63 +82,63 @@ # 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}") + # 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() - 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_PLATFORM_IMPLICIT_LINK_DIRECTORIES," - "CMAKE_C_IMPLICIT_LINK_DIRECTORIES)${ColourReset}") - if(_lib_env) - message("${Yellow}${_lib_to_find} has not been found in" - "${_lib_env}${ColourReset}") - endif() - endif() + 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_PLATFORM_IMPLICIT_LINK_DIRECTORIES," + "CMAKE_C_IMPLICIT_LINK_DIRECTORIES)${ColourReset}") + if(_lib_env) + message("${Yellow}${_lib_to_find} has not been found in" + "${_lib_env}${ColourReset}") + 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}") + 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) + # 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(" ") + # 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() if (NOT BLAS_FOUND) - 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() + 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) @@ -152,166 +152,166 @@ set(_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) # Check the language being used get_property( _LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES ) if( _LANGUAGES_ MATCHES Fortran ) - set( _CHECK_FORTRAN TRUE ) + set( _CHECK_FORTRAN TRUE ) elseif( (_LANGUAGES_ MATCHES C) OR (_LANGUAGES_ MATCHES CXX) ) - set( _CHECK_FORTRAN FALSE ) + set( _CHECK_FORTRAN FALSE ) else() - if(BLAS_FIND_REQUIRED) - message(FATAL_ERROR "FindBLAS requires Fortran, C, or C++ to be enabled.") - else() - message(STATUS "Looking for BLAS... - NOT found (Unsupported languages)") - return() - endif() + if(BLAS_FIND_REQUIRED) + message(FATAL_ERROR "FindBLAS requires Fortran, C, or C++ to be enabled.") + else() + message(STATUS "Looking for BLAS... - NOT found (Unsupported languages)") + return() + endif() endif() macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _thread) -# This macro checks for the existence of the combination of fortran libraries -# given by _list. If the combination is found, this macro checks (using the -# Check_Fortran_Function_Exists macro) whether can link against that library -# combination using the name of a routine given by _name using the linker -# flags given by _flags. If the combination of libraries is found and passes -# the link test, LIBRARIES is set to the list of complete library paths that -# have been found. Otherwise, LIBRARIES is set to FALSE. - -# N.B. _prefix is the prefix applied to the names of all cached variables that -# are generated internally and marked advanced by this macro. - - set(_libdir ${ARGN}) - - set(_libraries_work TRUE) - set(${LIBRARIES}) - set(_combined_name) - set(ENV_MKLROOT "$ENV{MKLROOT}") - set(ENV_BLAS_DIR "$ENV{BLAS_DIR}") - set(ENV_BLAS_LIBDIR "$ENV{BLAS_LIBDIR}") - if (NOT _libdir) - if (BLAS_LIBDIR) - list(APPEND _libdir "${BLAS_LIBDIR}") - elseif (BLAS_DIR) - list(APPEND _libdir "${BLAS_DIR}") - list(APPEND _libdir "${BLAS_DIR}/lib") - if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") - list(APPEND _libdir "${BLAS_DIR}/lib64") - list(APPEND _libdir "${BLAS_DIR}/lib/intel64") - else() - list(APPEND _libdir "${BLAS_DIR}/lib32") - list(APPEND _libdir "${BLAS_DIR}/lib/ia32") - endif() - elseif(ENV_BLAS_LIBDIR) - list(APPEND _libdir "${ENV_BLAS_LIBDIR}") - elseif(ENV_BLAS_DIR) - list(APPEND _libdir "${ENV_BLAS_DIR}") - list(APPEND _libdir "${ENV_BLAS_DIR}/lib") - if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") - list(APPEND _libdir "${ENV_BLAS_DIR}/lib64") - list(APPEND _libdir "${ENV_BLAS_DIR}/lib/intel64") - else() - list(APPEND _libdir "${ENV_BLAS_DIR}/lib32") - list(APPEND _libdir "${ENV_BLAS_DIR}/lib/ia32") - endif() - else() - if (ENV_MKLROOT) - list(APPEND _libdir "${ENV_MKLROOT}/lib") - if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") - list(APPEND _libdir "${ENV_MKLROOT}/lib64") - list(APPEND _libdir "${ENV_MKLROOT}/lib/intel64") - else() - list(APPEND _libdir "${ENV_MKLROOT}/lib32") - list(APPEND _libdir "${ENV_MKLROOT}/lib/ia32") - endif() - endif() - if (WIN32) - string(REPLACE ":" ";" _libdir2 "$ENV{LIB}") - elseif (APPLE) - 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 () + # This macro checks for the existence of the combination of fortran libraries + # given by _list. If the combination is found, this macro checks (using the + # Check_Fortran_Function_Exists macro) whether can link against that library + # combination using the name of a routine given by _name using the linker + # flags given by _flags. If the combination of libraries is found and passes + # the link test, LIBRARIES is set to the list of complete library paths that + # have been found. Otherwise, LIBRARIES is set to FALSE. + + # N.B. _prefix is the prefix applied to the names of all cached variables that + # are generated internally and marked advanced by this macro. + + set(_libdir ${ARGN}) + + set(_libraries_work TRUE) + set(${LIBRARIES}) + set(_combined_name) + set(ENV_MKLROOT "$ENV{MKLROOT}") + set(ENV_BLAS_DIR "$ENV{BLAS_DIR}") + set(ENV_BLAS_LIBDIR "$ENV{BLAS_LIBDIR}") + if (NOT _libdir) + if (BLAS_LIBDIR) + list(APPEND _libdir "${BLAS_LIBDIR}") + elseif (BLAS_DIR) + list(APPEND _libdir "${BLAS_DIR}") + list(APPEND _libdir "${BLAS_DIR}/lib") + if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") + list(APPEND _libdir "${BLAS_DIR}/lib64") + list(APPEND _libdir "${BLAS_DIR}/lib/intel64") + else() + list(APPEND _libdir "${BLAS_DIR}/lib32") + list(APPEND _libdir "${BLAS_DIR}/lib/ia32") + endif() + elseif(ENV_BLAS_LIBDIR) + list(APPEND _libdir "${ENV_BLAS_LIBDIR}") + elseif(ENV_BLAS_DIR) + list(APPEND _libdir "${ENV_BLAS_DIR}") + list(APPEND _libdir "${ENV_BLAS_DIR}/lib") + if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") + list(APPEND _libdir "${ENV_BLAS_DIR}/lib64") + list(APPEND _libdir "${ENV_BLAS_DIR}/lib/intel64") + else() + list(APPEND _libdir "${ENV_BLAS_DIR}/lib32") + list(APPEND _libdir "${ENV_BLAS_DIR}/lib/ia32") + endif() + else() + if (ENV_MKLROOT) + list(APPEND _libdir "${ENV_MKLROOT}/lib") + if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") + list(APPEND _libdir "${ENV_MKLROOT}/lib64") + list(APPEND _libdir "${ENV_MKLROOT}/lib/intel64") + else() + list(APPEND _libdir "${ENV_MKLROOT}/lib32") + list(APPEND _libdir "${ENV_MKLROOT}/lib/ia32") + endif() + endif() + if (WIN32) + string(REPLACE ":" ";" _libdir2 "$ENV{LIB}") + elseif (APPLE) + 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) - message("${Cyan}Try to find BLAS libraries: ${_list}") - endif () + if (BLAS_VERBOSE) + message("${Cyan}Try to find BLAS libraries: ${_list}") + endif () - foreach(_library ${_list}) - set(_combined_name ${_combined_name}_${_library}) - - if(_libraries_work) - if (BLA_STATIC) - if (WIN32) - set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) - endif () - if (APPLE) - set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) - else () - set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) - endif () - else () - if (CMAKE_SYSTEM_NAME STREQUAL "Linux") - # for ubuntu's libblas3gf and liblapack3gf packages - set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf) - endif () - endif () - find_library(${_prefix}_${_library}_LIBRARY - NAMES ${_library} - HINTS ${_libdir} - NO_DEFAULT_PATH - ) - mark_as_advanced(${_prefix}_${_library}_LIBRARY) - # Print status if not found - # ------------------------- - if (NOT ${_prefix}_${_library}_LIBRARY AND NOT BLAS_FIND_QUIETLY AND BLAS_VERBOSE) - Print_Find_Library_Blas_Status(blas ${_library} ${_libdir}) - endif () - set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) - set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) - endif(_libraries_work) - endforeach(_library ${_list}) + foreach(_library ${_list}) + set(_combined_name ${_combined_name}_${_library}) if(_libraries_work) - # Test this combination of libraries. - if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND BLA_STATIC) - list(INSERT ${LIBRARIES} 0 "-Wl,--start-group") - list(APPEND ${LIBRARIES} "-Wl,--end-group") - endif() - set(CMAKE_REQUIRED_LIBRARIES "${_flags};${${LIBRARIES}};${_thread}") - set(CMAKE_REQUIRED_FLAGS "${BLAS_COMPILER_FLAGS}") - if (BLAS_VERBOSE) - message("${Cyan}BLAS libs found for BLA_VENDOR ${BLA_VENDOR}." - "Try to compile symbol ${_name} with following libraries:" - "${CMAKE_REQUIRED_LIBRARIES}") - endif () - if(NOT BLAS_FOUND) - unset(${_prefix}${_combined_name}_WORKS CACHE) - endif() - if (_CHECK_FORTRAN) - if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") - string(REPLACE "mkl_intel_lp64" "mkl_gf_lp64" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - string(REPLACE "mkl_intel_ilp64" "mkl_gf_ilp64" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - endif() - check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS) - else() - check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS) - endif() - mark_as_advanced(${_prefix}${_combined_name}_WORKS) - set(_libraries_work ${${_prefix}${_combined_name}_WORKS}) - # Print status if not found - # ------------------------- - if (NOT _libraries_work AND NOT BLAS_FIND_QUIETLY AND BLAS_VERBOSE) - Print_Find_Library_Blas_CheckFunc_Status(${_name} ${CMAKE_REQUIRED_LIBRARIES}) - endif () - set(CMAKE_REQUIRED_LIBRARIES) + if (BLA_STATIC) + if (WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) + endif () + if (APPLE) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) + else () + set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + endif () + else () + if (CMAKE_SYSTEM_NAME STREQUAL "Linux") + # for ubuntu's libblas3gf and liblapack3gf packages + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf) + endif () + endif () + find_library(${_prefix}_${_library}_LIBRARY + NAMES ${_library} + HINTS ${_libdir} + NO_DEFAULT_PATH + ) + mark_as_advanced(${_prefix}_${_library}_LIBRARY) + # Print status if not found + # ------------------------- + if (NOT ${_prefix}_${_library}_LIBRARY AND NOT BLAS_FIND_QUIETLY AND BLAS_VERBOSE) + Print_Find_Library_Blas_Status(blas ${_library} ${_libdir}) + endif () + set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) + set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) + endif(_libraries_work) + endforeach(_library ${_list}) + + if(_libraries_work) + # Test this combination of libraries. + if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND BLA_STATIC) + list(INSERT ${LIBRARIES} 0 "-Wl,--start-group") + list(APPEND ${LIBRARIES} "-Wl,--end-group") + endif() + set(CMAKE_REQUIRED_LIBRARIES "${_flags};${${LIBRARIES}};${_thread}") + set(CMAKE_REQUIRED_FLAGS "${BLAS_COMPILER_FLAGS}") + if (BLAS_VERBOSE) + message("${Cyan}BLAS libs found for BLA_VENDOR ${BLA_VENDOR}." + "Try to compile symbol ${_name} with following libraries:" + "${CMAKE_REQUIRED_LIBRARIES}") + endif () + if(NOT BLAS_FOUND) + unset(${_prefix}${_combined_name}_WORKS CACHE) endif() + if (_CHECK_FORTRAN) + if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") + string(REPLACE "mkl_intel_lp64" "mkl_gf_lp64" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + string(REPLACE "mkl_intel_ilp64" "mkl_gf_ilp64" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + endif() + check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS) + else() + check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS) + endif() + mark_as_advanced(${_prefix}${_combined_name}_WORKS) + set(_libraries_work ${${_prefix}${_combined_name}_WORKS}) + # Print status if not found + # ------------------------- + if (NOT _libraries_work AND NOT BLAS_FIND_QUIETLY AND BLAS_VERBOSE) + Print_Find_Library_Blas_CheckFunc_Status(${_name} ${CMAKE_REQUIRED_LIBRARIES}) + endif () + set(CMAKE_REQUIRED_LIBRARIES) + endif() - if(_libraries_work) - set(${LIBRARIES} ${${LIBRARIES}} ${_thread}) - else(_libraries_work) - set(${LIBRARIES} FALSE) - endif(_libraries_work) + if(_libraries_work) + set(${LIBRARIES} ${${LIBRARIES}} ${_thread}) + else(_libraries_work) + set(${LIBRARIES} FALSE) + endif(_libraries_work) endmacro(Check_Fortran_Libraries) @@ -320,408 +320,408 @@ set(BLAS_LINKER_FLAGS) set(BLAS_LIBRARIES) set(BLAS95_LIBRARIES) if ($ENV{BLA_VENDOR} MATCHES ".+") - set(BLA_VENDOR $ENV{BLA_VENDOR}) + set(BLA_VENDOR $ENV{BLA_VENDOR}) else () - if(NOT BLA_VENDOR) - set(BLA_VENDOR "All") - endif() + if(NOT BLA_VENDOR) + set(BLA_VENDOR "All") + endif() endif () #BLAS in intel mkl 10 library? (em64t 64bit) if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All") - if(NOT BLAS_LIBRARIES OR BLA_VENDOR MATCHES "Intel*") - # Looking for include - # ------------------- - - # Add system include paths to search include - # ------------------------------------------ - unset(_inc_env) - set(ENV_MKLROOT "$ENV{MKLROOT}") - set(ENV_BLAS_DIR "$ENV{BLAS_DIR}") - set(ENV_BLAS_INCDIR "$ENV{BLAS_INCDIR}") - if(ENV_BLAS_INCDIR) - list(APPEND _inc_env "${ENV_BLAS_INCDIR}") - elseif(ENV_BLAS_DIR) - list(APPEND _inc_env "${ENV_BLAS_DIR}") - list(APPEND _inc_env "${ENV_BLAS_DIR}/include") - else() - if (ENV_MKLROOT) - list(APPEND _inc_env "${ENV_MKLROOT}/include") - endif() - # system variables - if(WIN32) - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") - list(APPEND _inc_env "${_path_env}") - else() - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{CPATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - endif() - endif() - list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") - list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") - list(REMOVE_DUPLICATES _inc_env) - - # set paths where to look for - set(PATH_TO_LOOK_FOR "${_inc_env}") - - # Try to find the fftw header in the given paths - # ------------------------------------------------- - # call cmake macro to find the header path - if(BLAS_INCDIR) - set(BLAS_mkl.h_DIRS "BLAS_mkl.h_DIRS-NOTFOUND") - find_path(BLAS_mkl.h_DIRS - NAMES mkl.h - HINTS ${BLAS_INCDIR}) - else() - if(BLAS_DIR) - set(BLAS_mkl.h_DIRS "BLAS_mkl.h_DIRS-NOTFOUND") - find_path(BLAS_mkl.h_DIRS - NAMES mkl.h - HINTS ${BLAS_DIR} - PATH_SUFFIXES "include") - else() - set(BLAS_mkl.h_DIRS "BLAS_mkl.h_DIRS-NOTFOUND") - find_path(BLAS_mkl.h_DIRS - NAMES mkl.h - HINTS ${PATH_TO_LOOK_FOR}) - endif() - endif() - mark_as_advanced(BLAS_mkl.h_DIRS) - - # If found, add path to cmake variable - # ------------------------------------ - if (BLAS_mkl.h_DIRS) - set(BLAS_INCLUDE_DIRS "${BLAS_mkl.h_DIRS}") - else () - set(BLAS_INCLUDE_DIRS "BLAS_INCLUDE_DIRS-NOTFOUND") - if(NOT BLAS_FIND_QUIETLY) - message(STATUS "Looking for BLAS -- mkl.h not found") - endif() - endif() - - if (WIN32) - string(REPLACE ":" ";" _libdir "$ENV{LIB}") - elseif (APPLE) - string(REPLACE ":" ";" _libdir "$ENV{DYLD_LIBRARY_PATH}") - else () - string(REPLACE ":" ";" _libdir "$ENV{LD_LIBRARY_PATH}") - endif () - list(APPEND _libdir "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") - list(APPEND _libdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - # libiomp5 - # -------- - set(OMP_iomp5_LIBRARY "OMP_iomp5_LIBRARY-NOTFOUND") - find_library(OMP_iomp5_LIBRARY - NAMES iomp5 - HINTS ${_libdir} - ) - mark_as_advanced(OMP_iomp5_LIBRARY) - set(OMP_LIB "") - # libgomp - # ------- - set(OMP_gomp_LIBRARY "OMP_gomp_LIBRARY-NOTFOUND") - find_library(OMP_gomp_LIBRARY - NAMES gomp - HINTS ${_libdir} - ) - mark_as_advanced(OMP_gomp_LIBRARY) - # choose one or another depending on the compilo - if (CMAKE_C_COMPILER_ID STREQUAL "GNU") - if (OMP_gomp_LIBRARY) - set(OMP_LIB "${OMP_gomp_LIBRARY}") - endif() - else(CMAKE_C_COMPILER_ID STREQUAL "Intel") - if (OMP_iomp5_LIBRARY) - set(OMP_LIB "${OMP_iomp5_LIBRARY}") - endif() - endif() - - if (UNIX AND NOT WIN32) - # m - find_library(M_LIBRARY - NAMES m - HINTS ${_libdir}) - mark_as_advanced(M_LIBRARY) - if(M_LIBRARY) - set(LM "-lm") - else() - set(LM "") - endif() - # Fortran - set(LGFORTRAN "") - if (CMAKE_C_COMPILER_ID MATCHES "GNU") - find_library( - FORTRAN_gfortran_LIBRARY - NAMES gfortran - HINTS ${_libdir} - ) - mark_as_advanced(FORTRAN_gfortran_LIBRARY) - if (FORTRAN_gfortran_LIBRARY) - set(LGFORTRAN "${FORTRAN_gfortran_LIBRARY}") - endif() - elseif (CMAKE_C_COMPILER_ID MATCHES "Intel") - find_library( - FORTRAN_ifcore_LIBRARY - NAMES ifcore - HINTS ${_libdir} - ) - mark_as_advanced(FORTRAN_ifcore_LIBRARY) - if (FORTRAN_ifcore_LIBRARY) - set(LGFORTRAN "{FORTRAN_ifcore_LIBRARY}") - endif() - endif() - set(BLAS_COMPILER_FLAGS "") - if (NOT BLA_VENDOR STREQUAL "Intel10_64lp_seq") - if (CMAKE_C_COMPILER_ID STREQUAL "Intel") - list(APPEND BLAS_COMPILER_FLAGS "-openmp") - endif() - if (CMAKE_C_COMPILER_ID STREQUAL "GNU") - list(APPEND BLAS_COMPILER_FLAGS "-fopenmp") - endif() - endif() - if (CMAKE_C_COMPILER_ID STREQUAL "GNU") - if (BLA_VENDOR STREQUAL "Intel10_32") - list(APPEND BLAS_COMPILER_FLAGS "-m32") - else() - list(APPEND BLAS_COMPILER_FLAGS "-m64") - endif() - if (NOT BLA_VENDOR STREQUAL "Intel10_64lp_seq") - list(APPEND OMP_LIB "-ldl") - endif() - if (ENV_MKLROOT) - list(APPEND BLAS_COMPILER_FLAGS "-I${ENV_MKLROOT}/include") - endif() - endif() - - set(additional_flags "") - if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_SYSTEM_NAME STREQUAL "Linux") - set(additional_flags "-Wl,--no-as-needed") - endif() - endif () - - if (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX) - if(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED) - find_package(Threads) - else() - find_package(Threads REQUIRED) - endif() - - set(BLAS_SEARCH_LIBS "") - - if(BLA_F95) - - set(BLAS_mkl_SEARCH_SYMBOL SGEMM) - set(_LIBRARIES BLAS95_LIBRARIES) - if (WIN32) - if (BLA_STATIC) - set(BLAS_mkl_DLL_SUFFIX "") - else() - set(BLAS_mkl_DLL_SUFFIX "_dll") - endif() - - # Find the main file (32-bit or 64-bit) - set(BLAS_SEARCH_LIBS_WIN_MAIN "") - if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN - "mkl_blas95${BLAS_mkl_DLL_SUFFIX} mkl_intel_c${BLAS_mkl_DLL_SUFFIX}") - endif() - if (BLA_VENDOR STREQUAL "Intel10_64lp*" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN - "mkl_blas95_lp64${BLAS_mkl_DLL_SUFFIX} mkl_intel_lp64${BLAS_mkl_DLL_SUFFIX}") - endif () - - # Add threading/sequential libs - set(BLAS_SEARCH_LIBS_WIN_THREAD "") - if (BLA_VENDOR STREQUAL "*_seq" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD - "mkl_sequential${BLAS_mkl_DLL_SUFFIX}") - endif() - if (NOT BLA_VENDOR STREQUAL "*_seq" OR BLA_VENDOR STREQUAL "All") - # old version - list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD - "libguide40 mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") - # mkl >= 10.3 - list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD - "libiomp5md mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") - endif() - - # Cartesian product of the above - foreach (MAIN ${BLAS_SEARCH_LIBS_WIN_MAIN}) - foreach (THREAD ${BLAS_SEARCH_LIBS_WIN_THREAD}) - list(APPEND BLAS_SEARCH_LIBS - "${MAIN} ${THREAD} mkl_core${BLAS_mkl_DLL_SUFFIX}") - endforeach() - endforeach() - else (WIN32) - if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS - "mkl_blas95 mkl_intel mkl_intel_thread mkl_core guide") - endif () - if (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All") - # old version - list(APPEND BLAS_SEARCH_LIBS - "mkl_blas95 mkl_intel_lp64 mkl_intel_thread mkl_core guide") - # mkl >= 10.3 - if (CMAKE_C_COMPILER_ID STREQUAL "Intel") - list(APPEND BLAS_SEARCH_LIBS - "mkl_blas95_lp64 mkl_intel_lp64 mkl_intel_thread mkl_core") - endif() - if (CMAKE_C_COMPILER_ID STREQUAL "GNU") - list(APPEND BLAS_SEARCH_LIBS - "mkl_blas95_lp64 mkl_intel_lp64 mkl_gnu_thread mkl_core") - endif() - endif () - if (BLA_VENDOR STREQUAL "Intel10_64lp_seq" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS - "mkl_intel_lp64 mkl_sequential mkl_core") - if (BLA_VENDOR STREQUAL "Intel10_64lp_seq") - set(OMP_LIB "") - endif() - endif () - endif (WIN32) - - else (BLA_F95) - - set(BLAS_mkl_SEARCH_SYMBOL sgemm) - set(_LIBRARIES BLAS_LIBRARIES) - if (WIN32) - if (BLA_STATIC) - set(BLAS_mkl_DLL_SUFFIX "") - else() - set(BLAS_mkl_DLL_SUFFIX "_dll") - endif() - - # Find the main file (32-bit or 64-bit) - set(BLAS_SEARCH_LIBS_WIN_MAIN "") - if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN - "mkl_intel_c${BLAS_mkl_DLL_SUFFIX}") - endif() - if (BLA_VENDOR STREQUAL "Intel10_64lp*" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN - "mkl_intel_lp64${BLAS_mkl_DLL_SUFFIX}") - endif () - - # Add threading/sequential libs - set(BLAS_SEARCH_LIBS_WIN_THREAD "") - if (NOT BLA_VENDOR STREQUAL "*_seq" OR BLA_VENDOR STREQUAL "All") - # old version - list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD - "libguide40 mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") - # mkl >= 10.3 - list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD - "libiomp5md mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") - endif() - if (BLA_VENDOR STREQUAL "*_seq" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD - "mkl_sequential${BLAS_mkl_DLL_SUFFIX}") - endif() - - # Cartesian product of the above - foreach (MAIN ${BLAS_SEARCH_LIBS_WIN_MAIN}) - foreach (THREAD ${BLAS_SEARCH_LIBS_WIN_THREAD}) - list(APPEND BLAS_SEARCH_LIBS - "${MAIN} ${THREAD} mkl_core${BLAS_mkl_DLL_SUFFIX}") - endforeach() - endforeach() - else (WIN32) - if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS - "mkl_intel mkl_intel_thread mkl_core guide") - endif () - if (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All") - # old version - list(APPEND BLAS_SEARCH_LIBS - "mkl_intel_lp64 mkl_intel_thread mkl_core guide") - # mkl >= 10.3 - if (CMAKE_C_COMPILER_ID STREQUAL "Intel") - list(APPEND BLAS_SEARCH_LIBS - "mkl_intel_lp64 mkl_intel_thread mkl_core") - endif() - if (CMAKE_C_COMPILER_ID STREQUAL "GNU") - list(APPEND BLAS_SEARCH_LIBS - "mkl_intel_lp64 mkl_gnu_thread mkl_core") - endif() - endif () - if (BLA_VENDOR STREQUAL "Intel10_64lp_seq" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS - "mkl_intel_lp64 mkl_sequential mkl_core") - if (BLA_VENDOR STREQUAL "Intel10_64lp_seq") - set(OMP_LIB "") - endif() - endif () - #older vesions of intel mkl libs - if (BLA_VENDOR STREQUAL "Intel" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS - "mkl") - list(APPEND BLAS_SEARCH_LIBS - "mkl_ia32") - list(APPEND BLAS_SEARCH_LIBS - "mkl_em64t") - endif () - endif (WIN32) - - endif (BLA_F95) - - foreach (IT ${BLAS_SEARCH_LIBS}) - string(REPLACE " " ";" SEARCH_LIBS ${IT}) - if (${_LIBRARIES}) - else () - check_fortran_libraries( - ${_LIBRARIES} - BLAS - ${BLAS_mkl_SEARCH_SYMBOL} - "${additional_flags}" - "${SEARCH_LIBS}" - "${OMP_LIB};${CMAKE_THREAD_LIBS_INIT};${LM}" - ) - if(_LIBRARIES) - set(BLAS_LINKER_FLAGS "${additional_flags}") - endif() - endif() - endforeach () - - endif (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX) - endif(NOT BLAS_LIBRARIES OR BLA_VENDOR MATCHES "Intel*") + if(NOT BLAS_LIBRARIES OR BLA_VENDOR MATCHES "Intel*") + # Looking for include + # ------------------- - if(NOT BLAS_FIND_QUIETLY) - if(${_LIBRARIES}) - message(STATUS "Looking for MKL BLAS: found") - else() - message(STATUS "Looking for MKL BLAS: not found") - endif() + # Add system include paths to search include + # ------------------------------------------ + unset(_inc_env) + set(ENV_MKLROOT "$ENV{MKLROOT}") + set(ENV_BLAS_DIR "$ENV{BLAS_DIR}") + set(ENV_BLAS_INCDIR "$ENV{BLAS_INCDIR}") + if(ENV_BLAS_INCDIR) + list(APPEND _inc_env "${ENV_BLAS_INCDIR}") + elseif(ENV_BLAS_DIR) + list(APPEND _inc_env "${ENV_BLAS_DIR}") + list(APPEND _inc_env "${ENV_BLAS_DIR}/include") + else() + if (ENV_MKLROOT) + list(APPEND _inc_env "${ENV_MKLROOT}/include") + endif() + # system variables + if(WIN32) + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") + list(APPEND _inc_env "${_path_env}") + else() + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{CPATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + endif() + endif() + list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") + list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") + list(REMOVE_DUPLICATES _inc_env) + + # set paths where to look for + set(PATH_TO_LOOK_FOR "${_inc_env}") + + # Try to find the fftw header in the given paths + # ------------------------------------------------- + # call cmake macro to find the header path + if(BLAS_INCDIR) + set(BLAS_mkl.h_DIRS "BLAS_mkl.h_DIRS-NOTFOUND") + find_path(BLAS_mkl.h_DIRS + NAMES mkl.h + HINTS ${BLAS_INCDIR}) + else() + if(BLAS_DIR) + set(BLAS_mkl.h_DIRS "BLAS_mkl.h_DIRS-NOTFOUND") + find_path(BLAS_mkl.h_DIRS + NAMES mkl.h + HINTS ${BLAS_DIR} + PATH_SUFFIXES "include") + else() + set(BLAS_mkl.h_DIRS "BLAS_mkl.h_DIRS-NOTFOUND") + find_path(BLAS_mkl.h_DIRS + NAMES mkl.h + HINTS ${PATH_TO_LOOK_FOR}) + endif() + endif() + mark_as_advanced(BLAS_mkl.h_DIRS) + + # If found, add path to cmake variable + # ------------------------------------ + if (BLAS_mkl.h_DIRS) + set(BLAS_INCLUDE_DIRS "${BLAS_mkl.h_DIRS}") + else () + set(BLAS_INCLUDE_DIRS "BLAS_INCLUDE_DIRS-NOTFOUND") + if(NOT BLAS_FIND_QUIETLY) + message(STATUS "Looking for BLAS -- mkl.h not found") + endif() + endif() + + if (WIN32) + string(REPLACE ":" ";" _libdir "$ENV{LIB}") + elseif (APPLE) + string(REPLACE ":" ";" _libdir "$ENV{DYLD_LIBRARY_PATH}") + else () + string(REPLACE ":" ";" _libdir "$ENV{LD_LIBRARY_PATH}") + endif () + list(APPEND _libdir "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") + list(APPEND _libdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + # libiomp5 + # -------- + set(OMP_iomp5_LIBRARY "OMP_iomp5_LIBRARY-NOTFOUND") + find_library(OMP_iomp5_LIBRARY + NAMES iomp5 + HINTS ${_libdir} + ) + mark_as_advanced(OMP_iomp5_LIBRARY) + set(OMP_LIB "") + # libgomp + # ------- + set(OMP_gomp_LIBRARY "OMP_gomp_LIBRARY-NOTFOUND") + find_library(OMP_gomp_LIBRARY + NAMES gomp + HINTS ${_libdir} + ) + mark_as_advanced(OMP_gomp_LIBRARY) + # choose one or another depending on the compilo + if (CMAKE_C_COMPILER_ID STREQUAL "GNU") + if (OMP_gomp_LIBRARY) + set(OMP_LIB "${OMP_gomp_LIBRARY}") + endif() + else(CMAKE_C_COMPILER_ID STREQUAL "Intel") + if (OMP_iomp5_LIBRARY) + set(OMP_LIB "${OMP_iomp5_LIBRARY}") + endif() + endif() + + if (UNIX AND NOT WIN32) + # m + find_library(M_LIBRARY + NAMES m + HINTS ${_libdir}) + mark_as_advanced(M_LIBRARY) + if(M_LIBRARY) + set(LM "-lm") + else() + set(LM "") + endif() + # Fortran + set(LGFORTRAN "") + if (CMAKE_C_COMPILER_ID MATCHES "GNU") + find_library( + FORTRAN_gfortran_LIBRARY + NAMES gfortran + HINTS ${_libdir} + ) + mark_as_advanced(FORTRAN_gfortran_LIBRARY) + if (FORTRAN_gfortran_LIBRARY) + set(LGFORTRAN "${FORTRAN_gfortran_LIBRARY}") + endif() + elseif (CMAKE_C_COMPILER_ID MATCHES "Intel") + find_library( + FORTRAN_ifcore_LIBRARY + NAMES ifcore + HINTS ${_libdir} + ) + mark_as_advanced(FORTRAN_ifcore_LIBRARY) + if (FORTRAN_ifcore_LIBRARY) + set(LGFORTRAN "{FORTRAN_ifcore_LIBRARY}") + endif() + endif() + set(BLAS_COMPILER_FLAGS "") + if (NOT BLA_VENDOR STREQUAL "Intel10_64lp_seq") + if (CMAKE_C_COMPILER_ID STREQUAL "Intel") + list(APPEND BLAS_COMPILER_FLAGS "-openmp") + endif() + if (CMAKE_C_COMPILER_ID STREQUAL "GNU") + list(APPEND BLAS_COMPILER_FLAGS "-fopenmp") + endif() + endif() + if (CMAKE_C_COMPILER_ID STREQUAL "GNU") + if (BLA_VENDOR STREQUAL "Intel10_32") + list(APPEND BLAS_COMPILER_FLAGS "-m32") + else() + list(APPEND BLAS_COMPILER_FLAGS "-m64") + endif() + if (NOT BLA_VENDOR STREQUAL "Intel10_64lp_seq") + list(APPEND OMP_LIB "-ldl") + endif() + if (ENV_MKLROOT) + list(APPEND BLAS_COMPILER_FLAGS "-I${ENV_MKLROOT}/include") + endif() + endif() + + set(additional_flags "") + if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(additional_flags "-Wl,--no-as-needed") + endif() + endif () + + if (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX) + if(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED) + find_package(Threads) + else() + find_package(Threads REQUIRED) + endif() + + set(BLAS_SEARCH_LIBS "") + + if(BLA_F95) + + set(BLAS_mkl_SEARCH_SYMBOL SGEMM) + set(_LIBRARIES BLAS95_LIBRARIES) + if (WIN32) + if (BLA_STATIC) + set(BLAS_mkl_DLL_SUFFIX "") + else() + set(BLAS_mkl_DLL_SUFFIX "_dll") + endif() + + # Find the main file (32-bit or 64-bit) + set(BLAS_SEARCH_LIBS_WIN_MAIN "") + if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN + "mkl_blas95${BLAS_mkl_DLL_SUFFIX} mkl_intel_c${BLAS_mkl_DLL_SUFFIX}") + endif() + if (BLA_VENDOR STREQUAL "Intel10_64lp*" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN + "mkl_blas95_lp64${BLAS_mkl_DLL_SUFFIX} mkl_intel_lp64${BLAS_mkl_DLL_SUFFIX}") + endif () + + # Add threading/sequential libs + set(BLAS_SEARCH_LIBS_WIN_THREAD "") + if (BLA_VENDOR STREQUAL "*_seq" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD + "mkl_sequential${BLAS_mkl_DLL_SUFFIX}") + endif() + if (NOT BLA_VENDOR STREQUAL "*_seq" OR BLA_VENDOR STREQUAL "All") + # old version + list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD + "libguide40 mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") + # mkl >= 10.3 + list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD + "libiomp5md mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") + endif() + + # Cartesian product of the above + foreach (MAIN ${BLAS_SEARCH_LIBS_WIN_MAIN}) + foreach (THREAD ${BLAS_SEARCH_LIBS_WIN_THREAD}) + list(APPEND BLAS_SEARCH_LIBS + "${MAIN} ${THREAD} mkl_core${BLAS_mkl_DLL_SUFFIX}") + endforeach() + endforeach() + else (WIN32) + if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS + "mkl_blas95 mkl_intel mkl_intel_thread mkl_core guide") + endif () + if (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All") + # old version + list(APPEND BLAS_SEARCH_LIBS + "mkl_blas95 mkl_intel_lp64 mkl_intel_thread mkl_core guide") + # mkl >= 10.3 + if (CMAKE_C_COMPILER_ID STREQUAL "Intel") + list(APPEND BLAS_SEARCH_LIBS + "mkl_blas95_lp64 mkl_intel_lp64 mkl_intel_thread mkl_core") + endif() + if (CMAKE_C_COMPILER_ID STREQUAL "GNU") + list(APPEND BLAS_SEARCH_LIBS + "mkl_blas95_lp64 mkl_intel_lp64 mkl_gnu_thread mkl_core") + endif() + endif () + if (BLA_VENDOR STREQUAL "Intel10_64lp_seq" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS + "mkl_intel_lp64 mkl_sequential mkl_core") + if (BLA_VENDOR STREQUAL "Intel10_64lp_seq") + set(OMP_LIB "") + endif() + endif () + endif (WIN32) + + else (BLA_F95) + + set(BLAS_mkl_SEARCH_SYMBOL sgemm) + set(_LIBRARIES BLAS_LIBRARIES) + if (WIN32) + if (BLA_STATIC) + set(BLAS_mkl_DLL_SUFFIX "") + else() + set(BLAS_mkl_DLL_SUFFIX "_dll") + endif() + + # Find the main file (32-bit or 64-bit) + set(BLAS_SEARCH_LIBS_WIN_MAIN "") + if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN + "mkl_intel_c${BLAS_mkl_DLL_SUFFIX}") + endif() + if (BLA_VENDOR STREQUAL "Intel10_64lp*" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN + "mkl_intel_lp64${BLAS_mkl_DLL_SUFFIX}") + endif () + + # Add threading/sequential libs + set(BLAS_SEARCH_LIBS_WIN_THREAD "") + if (NOT BLA_VENDOR STREQUAL "*_seq" OR BLA_VENDOR STREQUAL "All") + # old version + list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD + "libguide40 mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") + # mkl >= 10.3 + list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD + "libiomp5md mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") + endif() + if (BLA_VENDOR STREQUAL "*_seq" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD + "mkl_sequential${BLAS_mkl_DLL_SUFFIX}") + endif() + + # Cartesian product of the above + foreach (MAIN ${BLAS_SEARCH_LIBS_WIN_MAIN}) + foreach (THREAD ${BLAS_SEARCH_LIBS_WIN_THREAD}) + list(APPEND BLAS_SEARCH_LIBS + "${MAIN} ${THREAD} mkl_core${BLAS_mkl_DLL_SUFFIX}") + endforeach() + endforeach() + else (WIN32) + if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS + "mkl_intel mkl_intel_thread mkl_core guide") + endif () + if (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All") + # old version + list(APPEND BLAS_SEARCH_LIBS + "mkl_intel_lp64 mkl_intel_thread mkl_core guide") + # mkl >= 10.3 + if (CMAKE_C_COMPILER_ID STREQUAL "Intel") + list(APPEND BLAS_SEARCH_LIBS + "mkl_intel_lp64 mkl_intel_thread mkl_core") + endif() + if (CMAKE_C_COMPILER_ID STREQUAL "GNU") + list(APPEND BLAS_SEARCH_LIBS + "mkl_intel_lp64 mkl_gnu_thread mkl_core") + endif() + endif () + if (BLA_VENDOR STREQUAL "Intel10_64lp_seq" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS + "mkl_intel_lp64 mkl_sequential mkl_core") + if (BLA_VENDOR STREQUAL "Intel10_64lp_seq") + set(OMP_LIB "") + endif() + endif () + #older vesions of intel mkl libs + if (BLA_VENDOR STREQUAL "Intel" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS + "mkl") + list(APPEND BLAS_SEARCH_LIBS + "mkl_ia32") + list(APPEND BLAS_SEARCH_LIBS + "mkl_em64t") + endif () + endif (WIN32) + + endif (BLA_F95) + + foreach (IT ${BLAS_SEARCH_LIBS}) + string(REPLACE " " ";" SEARCH_LIBS ${IT}) + if (${_LIBRARIES}) + else () + check_fortran_libraries( + ${_LIBRARIES} + BLAS + ${BLAS_mkl_SEARCH_SYMBOL} + "${additional_flags}" + "${SEARCH_LIBS}" + "${OMP_LIB};${CMAKE_THREAD_LIBS_INIT};${LM}" + ) + if(_LIBRARIES) + set(BLAS_LINKER_FLAGS "${additional_flags}") + endif() + endif() + endforeach () + + endif (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX) + endif(NOT BLAS_LIBRARIES OR BLA_VENDOR MATCHES "Intel*") + + if(NOT BLAS_FIND_QUIETLY) + if(${_LIBRARIES}) + message(STATUS "Looking for MKL BLAS: found") + else() + message(STATUS "Looking for MKL BLAS: not found") endif() + endif() endif (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All") if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") - if(NOT BLAS_LIBRARIES) - # gotoblas (http://www.tacc.utexas.edu/tacc-projects/gotoblas2) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "goto2" - "" - ) - if(NOT BLAS_FIND_QUIETLY) - if(BLAS_LIBRARIES) - message(STATUS "Looking for Goto BLAS: found") - else() - message(STATUS "Looking for Goto BLAS: not found") - endif() - endif() + if(NOT BLAS_LIBRARIES) + # gotoblas (http://www.tacc.utexas.edu/tacc-projects/gotoblas2) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "goto2" + "" + ) + if(NOT BLAS_FIND_QUIETLY) + if(BLAS_LIBRARIES) + message(STATUS "Looking for Goto BLAS: found") + else() + message(STATUS "Looking for Goto BLAS: not found") + endif() endif() + endif() endif (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") @@ -729,24 +729,24 @@ endif (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") # OpenBlas if (BLA_VENDOR STREQUAL "Open" OR BLA_VENDOR STREQUAL "All") - if(NOT BLAS_LIBRARIES) - # openblas (http://www.openblas.net/) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "openblas" - "" - ) - if(NOT BLAS_FIND_QUIETLY) - if(BLAS_LIBRARIES) - message(STATUS "Looking for Open BLAS: found") - else() - message(STATUS "Looking for Open BLAS: not found") - endif() - endif() + if(NOT BLAS_LIBRARIES) + # openblas (http://www.openblas.net/) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "openblas" + "" + ) + if(NOT BLAS_FIND_QUIETLY) + if(BLAS_LIBRARIES) + message(STATUS "Looking for Open BLAS: found") + else() + message(STATUS "Looking for Open BLAS: not found") + endif() endif() + endif() endif (BLA_VENDOR STREQUAL "Open" OR BLA_VENDOR STREQUAL "All") @@ -754,67 +754,67 @@ endif (BLA_VENDOR STREQUAL "Open" OR BLA_VENDOR STREQUAL "All") # EigenBlas if (BLA_VENDOR STREQUAL "Eigen" OR BLA_VENDOR STREQUAL "All") - if(NOT BLAS_LIBRARIES) - # eigenblas (http://eigen.tuxfamily.org/index.php?title=Main_Page) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "eigen_blas" - "" - ) - if(NOT BLAS_FIND_QUIETLY) - if(BLAS_LIBRARIES) - message(STATUS "Looking for Eigen BLAS: found") - else() - message(STATUS "Looking for Eigen BLAS: not found") - endif() - endif() + if(NOT BLAS_LIBRARIES) + # eigenblas (http://eigen.tuxfamily.org/index.php?title=Main_Page) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "eigen_blas" + "" + ) + if(NOT BLAS_FIND_QUIETLY) + if(BLAS_LIBRARIES) + message(STATUS "Looking for Eigen BLAS: found") + else() + message(STATUS "Looking for Eigen BLAS: not found") + endif() endif() - - if(NOT BLAS_LIBRARIES) - # eigenblas (http://eigen.tuxfamily.org/index.php?title=Main_Page) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "eigen_blas_static" - "" - ) - if(NOT BLAS_FIND_QUIETLY) - if(BLAS_LIBRARIES) - message(STATUS "Looking for Eigen BLAS: found") - else() - message(STATUS "Looking for Eigen BLAS: not found") - endif() - endif() + endif() + + if(NOT BLAS_LIBRARIES) + # eigenblas (http://eigen.tuxfamily.org/index.php?title=Main_Page) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "eigen_blas_static" + "" + ) + if(NOT BLAS_FIND_QUIETLY) + if(BLAS_LIBRARIES) + message(STATUS "Looking for Eigen BLAS: found") + else() + message(STATUS "Looking for Eigen BLAS: not found") + endif() endif() + endif() endif (BLA_VENDOR STREQUAL "Eigen" OR BLA_VENDOR STREQUAL "All") if (BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All") - if(NOT BLAS_LIBRARIES) - # BLAS in ATLAS library? (http://math-atlas.sourceforge.net/) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - dgemm - "" - "f77blas;atlas" - "" - ) - if(NOT BLAS_FIND_QUIETLY) - if(BLAS_LIBRARIES) - message(STATUS "Looking for Atlas BLAS: found") - else() - message(STATUS "Looking for Atlas BLAS: not found") - endif() - endif() + if(NOT BLAS_LIBRARIES) + # BLAS in ATLAS library? (http://math-atlas.sourceforge.net/) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + dgemm + "" + "f77blas;atlas" + "" + ) + if(NOT BLAS_FIND_QUIETLY) + if(BLAS_LIBRARIES) + message(STATUS "Looking for Atlas BLAS: found") + else() + message(STATUS "Looking for Atlas BLAS: not found") + endif() endif() + endif() endif (BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All") @@ -822,23 +822,23 @@ endif (BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All") # BLAS in PhiPACK libraries? (requires generic BLAS lib, too) if (BLA_VENDOR STREQUAL "PhiPACK" OR BLA_VENDOR STREQUAL "All") - if(NOT BLAS_LIBRARIES) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "sgemm;dgemm;blas" - "" - ) - if(NOT BLAS_FIND_QUIETLY) - if(BLAS_LIBRARIES) - message(STATUS "Looking for PhiPACK BLAS: found") - else() - message(STATUS "Looking for PhiPACK BLAS: not found") - endif() - endif() + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "sgemm;dgemm;blas" + "" + ) + if(NOT BLAS_FIND_QUIETLY) + if(BLAS_LIBRARIES) + message(STATUS "Looking for PhiPACK BLAS: found") + else() + message(STATUS "Looking for PhiPACK BLAS: not found") + endif() endif() + endif() endif (BLA_VENDOR STREQUAL "PhiPACK" OR BLA_VENDOR STREQUAL "All") @@ -846,23 +846,23 @@ endif (BLA_VENDOR STREQUAL "PhiPACK" OR BLA_VENDOR STREQUAL "All") # BLAS in Alpha CXML library? if (BLA_VENDOR STREQUAL "CXML" OR BLA_VENDOR STREQUAL "All") - if(NOT BLAS_LIBRARIES) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "cxml" - "" - ) - if(NOT BLAS_FIND_QUIETLY) - if(BLAS_LIBRARIES) - message(STATUS "Looking for CXML BLAS: found") - else() - message(STATUS "Looking for CXML BLAS: not found") - endif() - endif() + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "cxml" + "" + ) + if(NOT BLAS_FIND_QUIETLY) + if(BLAS_LIBRARIES) + message(STATUS "Looking for CXML BLAS: found") + else() + message(STATUS "Looking for CXML BLAS: not found") + endif() endif() + endif() endif (BLA_VENDOR STREQUAL "CXML" OR BLA_VENDOR STREQUAL "All") @@ -870,23 +870,23 @@ endif (BLA_VENDOR STREQUAL "CXML" OR BLA_VENDOR STREQUAL "All") # BLAS in Alpha DXML library? (now called CXML, see above) if (BLA_VENDOR STREQUAL "DXML" OR BLA_VENDOR STREQUAL "All") - if(NOT BLAS_LIBRARIES) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "dxml" - "" - ) - if(NOT BLAS_FIND_QUIETLY) - if(BLAS_LIBRARIES) - message(STATUS "Looking for DXML BLAS: found") - else() - message(STATUS "Looking for DXML BLAS: not found") - endif() - endif() + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "dxml" + "" + ) + if(NOT BLAS_FIND_QUIETLY) + if(BLAS_LIBRARIES) + message(STATUS "Looking for DXML BLAS: found") + else() + message(STATUS "Looking for DXML BLAS: not found") + endif() endif() + endif() endif (BLA_VENDOR STREQUAL "DXML" OR BLA_VENDOR STREQUAL "All") @@ -894,26 +894,26 @@ endif (BLA_VENDOR STREQUAL "DXML" OR BLA_VENDOR STREQUAL "All") # BLAS in Sun Performance library? if (BLA_VENDOR STREQUAL "SunPerf" OR BLA_VENDOR STREQUAL "All") - if(NOT BLAS_LIBRARIES) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "-xlic_lib=sunperf" - "sunperf;sunmath" - "" - ) - if(BLAS_LIBRARIES) - set(BLAS_LINKER_FLAGS "-xlic_lib=sunperf") - endif() - if(NOT BLAS_FIND_QUIETLY) - if(BLAS_LIBRARIES) - message(STATUS "Looking for SunPerf BLAS: found") - else() - message(STATUS "Looking for SunPerf BLAS: not found") - endif() - endif() + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "-xlic_lib=sunperf" + "sunperf;sunmath" + "" + ) + if(BLAS_LIBRARIES) + set(BLAS_LINKER_FLAGS "-xlic_lib=sunperf") + endif() + if(NOT BLAS_FIND_QUIETLY) + if(BLAS_LIBRARIES) + message(STATUS "Looking for SunPerf BLAS: found") + else() + message(STATUS "Looking for SunPerf BLAS: not found") + endif() endif() + endif() endif () @@ -921,23 +921,23 @@ endif () # BLAS in SCSL library? (SGI/Cray Scientific Library) if (BLA_VENDOR STREQUAL "SCSL" OR BLA_VENDOR STREQUAL "All") - if(NOT BLAS_LIBRARIES) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "scsl" - "" - ) - if(NOT BLAS_FIND_QUIETLY) - if(BLAS_LIBRARIES) - message(STATUS "Looking for SCSL BLAS: found") - else() - message(STATUS "Looking for SCSL BLAS: not found") - endif() - endif() + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "scsl" + "" + ) + if(NOT BLAS_FIND_QUIETLY) + if(BLAS_LIBRARIES) + message(STATUS "Looking for SCSL BLAS: found") + else() + message(STATUS "Looking for SCSL BLAS: not found") + endif() endif() + endif() endif () @@ -945,23 +945,23 @@ endif () # BLAS in SGIMATH library? if (BLA_VENDOR STREQUAL "SGIMATH" OR BLA_VENDOR STREQUAL "All") - if(NOT BLAS_LIBRARIES) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "complib.sgimath" - "" - ) - if(NOT BLAS_FIND_QUIETLY) - if(BLAS_LIBRARIES) - message(STATUS "Looking for SGIMATH BLAS: found") - else() - message(STATUS "Looking for SGIMATH BLAS: not found") - endif() - endif() + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "complib.sgimath" + "" + ) + if(NOT BLAS_FIND_QUIETLY) + if(BLAS_LIBRARIES) + message(STATUS "Looking for SGIMATH BLAS: found") + else() + message(STATUS "Looking for SGIMATH BLAS: not found") + endif() endif() + endif() endif () @@ -969,46 +969,46 @@ endif () # BLAS in IBM ESSL library (requires generic BLAS lib, too) if (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All") - if(NOT BLAS_LIBRARIES) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "essl;xlfmath;xlf90_r;blas" - "" - ) - if(NOT BLAS_FIND_QUIETLY) - if(BLAS_LIBRARIES) - message(STATUS "Looking for IBM ESSL BLAS: found") - else() - message(STATUS "Looking for IBM ESSL BLAS: not found") - endif() - endif() + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "essl;xlfmath;xlf90_r;blas" + "" + ) + if(NOT BLAS_FIND_QUIETLY) + if(BLAS_LIBRARIES) + message(STATUS "Looking for IBM ESSL BLAS: found") + else() + message(STATUS "Looking for IBM ESSL BLAS: not found") + endif() endif() + endif() endif () # BLAS in IBM ESSL_MT library (requires generic BLAS lib, too) if (BLA_VENDOR STREQUAL "IBMESSLMT" OR BLA_VENDOR STREQUAL "All") - if(NOT BLAS_LIBRARIES) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "esslsmp;xlsmp;xlfmath;xlf90_r;blas" - "" - ) - if(NOT BLAS_FIND_QUIETLY) - if(BLAS_LIBRARIES) - message(STATUS "Looking for IBM ESSL MT BLAS: found") - else() - message(STATUS "Looking for IBM ESSL MT BLAS: not found") - endif() - endif() + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "esslsmp;xlsmp;xlfmath;xlf90_r;blas" + "" + ) + if(NOT BLAS_FIND_QUIETLY) + if(BLAS_LIBRARIES) + message(STATUS "Looking for IBM ESSL MT BLAS: found") + else() + message(STATUS "Looking for IBM ESSL MT BLAS: not found") + endif() endif() + endif() endif () @@ -1016,168 +1016,168 @@ endif () #BLAS in acml library? if (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All") - if( ((BLA_VENDOR STREQUAL "ACML") AND (NOT BLAS_ACML_LIB_DIRS)) OR - ((BLA_VENDOR STREQUAL "ACML_MP") AND (NOT BLAS_ACML_MP_LIB_DIRS)) OR - ((BLA_VENDOR STREQUAL "ACML_GPU") AND (NOT BLAS_ACML_GPU_LIB_DIRS))) - - # try to find acml in "standard" paths - if( WIN32 ) - file( GLOB _ACML_ROOT "C:/AMD/acml*/ACML-EULA.txt" ) - else() - file( GLOB _ACML_ROOT "/opt/acml*/ACML-EULA.txt" ) - endif() - if( WIN32 ) - file( GLOB _ACML_GPU_ROOT "C:/AMD/acml*/GPGPUexamples" ) - else() - file( GLOB _ACML_GPU_ROOT "/opt/acml*/GPGPUexamples" ) - endif() - list(GET _ACML_ROOT 0 _ACML_ROOT) - list(GET _ACML_GPU_ROOT 0 _ACML_GPU_ROOT) - - if( _ACML_ROOT ) - - get_filename_component( _ACML_ROOT ${_ACML_ROOT} PATH ) - if( SIZEOF_INTEGER EQUAL 8 ) - set( _ACML_PATH_SUFFIX "_int64" ) - else() - set( _ACML_PATH_SUFFIX "" ) - endif() - if( CMAKE_Fortran_COMPILER_ID STREQUAL "Intel" ) - set( _ACML_COMPILER32 "ifort32" ) - set( _ACML_COMPILER64 "ifort64" ) - elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "SunPro" ) - set( _ACML_COMPILER32 "sun32" ) - set( _ACML_COMPILER64 "sun64" ) - elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "PGI" ) - set( _ACML_COMPILER32 "pgi32" ) - if( WIN32 ) - set( _ACML_COMPILER64 "win64" ) - else() - set( _ACML_COMPILER64 "pgi64" ) - endif() - elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "Open64" ) - # 32 bit builds not supported on Open64 but for code simplicity - # We'll just use the same directory twice - set( _ACML_COMPILER32 "open64_64" ) - set( _ACML_COMPILER64 "open64_64" ) - elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "NAG" ) - set( _ACML_COMPILER32 "nag32" ) - set( _ACML_COMPILER64 "nag64" ) - else() - set( _ACML_COMPILER32 "gfortran32" ) - set( _ACML_COMPILER64 "gfortran64" ) - endif() - - if( BLA_VENDOR STREQUAL "ACML_MP" ) - set(_ACML_MP_LIB_DIRS - "${_ACML_ROOT}/${_ACML_COMPILER32}_mp${_ACML_PATH_SUFFIX}/lib" - "${_ACML_ROOT}/${_ACML_COMPILER64}_mp${_ACML_PATH_SUFFIX}/lib" ) - else() - set(_ACML_LIB_DIRS - "${_ACML_ROOT}/${_ACML_COMPILER32}${_ACML_PATH_SUFFIX}/lib" - "${_ACML_ROOT}/${_ACML_COMPILER64}${_ACML_PATH_SUFFIX}/lib" ) - endif() - - endif(_ACML_ROOT) - - elseif(BLAS_${BLA_VENDOR}_LIB_DIRS) - - set(_${BLA_VENDOR}_LIB_DIRS ${BLAS_${BLA_VENDOR}_LIB_DIRS}) + if( ((BLA_VENDOR STREQUAL "ACML") AND (NOT BLAS_ACML_LIB_DIRS)) OR + ((BLA_VENDOR STREQUAL "ACML_MP") AND (NOT BLAS_ACML_MP_LIB_DIRS)) OR + ((BLA_VENDOR STREQUAL "ACML_GPU") AND (NOT BLAS_ACML_GPU_LIB_DIRS))) + # try to find acml in "standard" paths + if( WIN32 ) + file( GLOB _ACML_ROOT "C:/AMD/acml*/ACML-EULA.txt" ) + else() + file( GLOB _ACML_ROOT "/opt/acml*/ACML-EULA.txt" ) endif() - - if( BLA_VENDOR STREQUAL "ACML_MP" ) - foreach( BLAS_ACML_MP_LIB_DIRS ${_ACML_MP_LIB_DIRS}) - check_fortran_libraries ( - BLAS_LIBRARIES - BLAS - sgemm - "" "acml_mp;acml_mv" "" ${BLAS_ACML_MP_LIB_DIRS} - ) - if( BLAS_LIBRARIES ) - break() - endif() - endforeach() - elseif( BLA_VENDOR STREQUAL "ACML_GPU" ) - foreach( BLAS_ACML_GPU_LIB_DIRS ${_ACML_GPU_LIB_DIRS}) - check_fortran_libraries ( - BLAS_LIBRARIES - BLAS - sgemm - "" "acml;acml_mv;CALBLAS" "" ${BLAS_ACML_GPU_LIB_DIRS} - ) - if( BLAS_LIBRARIES ) - break() - endif() - endforeach() + if( WIN32 ) + file( GLOB _ACML_GPU_ROOT "C:/AMD/acml*/GPGPUexamples" ) else() - foreach( BLAS_ACML_LIB_DIRS ${_ACML_LIB_DIRS} ) - check_fortran_libraries ( - BLAS_LIBRARIES - BLAS - sgemm - "" "acml;acml_mv" "" ${BLAS_ACML_LIB_DIRS} - ) - if( BLAS_LIBRARIES ) - break() - endif() - endforeach() + file( GLOB _ACML_GPU_ROOT "/opt/acml*/GPGPUexamples" ) endif() - - # Either acml or acml_mp should be in LD_LIBRARY_PATH but not both - if(NOT BLAS_LIBRARIES) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "acml;acml_mv" - "" - ) - if(NOT BLAS_FIND_QUIETLY) - if(BLAS_LIBRARIES) - message(STATUS "Looking for ACML BLAS: found") - else() - message(STATUS "Looking for ACML BLAS: not found") - endif() - endif() + list(GET _ACML_ROOT 0 _ACML_ROOT) + list(GET _ACML_GPU_ROOT 0 _ACML_GPU_ROOT) + + if( _ACML_ROOT ) + + get_filename_component( _ACML_ROOT ${_ACML_ROOT} PATH ) + if( SIZEOF_INTEGER EQUAL 8 ) + set( _ACML_PATH_SUFFIX "_int64" ) + else() + set( _ACML_PATH_SUFFIX "" ) + endif() + if( CMAKE_Fortran_COMPILER_ID STREQUAL "Intel" ) + set( _ACML_COMPILER32 "ifort32" ) + set( _ACML_COMPILER64 "ifort64" ) + elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "SunPro" ) + set( _ACML_COMPILER32 "sun32" ) + set( _ACML_COMPILER64 "sun64" ) + elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "PGI" ) + set( _ACML_COMPILER32 "pgi32" ) + if( WIN32 ) + set( _ACML_COMPILER64 "win64" ) + else() + set( _ACML_COMPILER64 "pgi64" ) + endif() + elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "Open64" ) + # 32 bit builds not supported on Open64 but for code simplicity + # We'll just use the same directory twice + set( _ACML_COMPILER32 "open64_64" ) + set( _ACML_COMPILER64 "open64_64" ) + elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "NAG" ) + set( _ACML_COMPILER32 "nag32" ) + set( _ACML_COMPILER64 "nag64" ) + else() + set( _ACML_COMPILER32 "gfortran32" ) + set( _ACML_COMPILER64 "gfortran64" ) + endif() + + if( BLA_VENDOR STREQUAL "ACML_MP" ) + set(_ACML_MP_LIB_DIRS + "${_ACML_ROOT}/${_ACML_COMPILER32}_mp${_ACML_PATH_SUFFIX}/lib" + "${_ACML_ROOT}/${_ACML_COMPILER64}_mp${_ACML_PATH_SUFFIX}/lib" ) + else() + set(_ACML_LIB_DIRS + "${_ACML_ROOT}/${_ACML_COMPILER32}${_ACML_PATH_SUFFIX}/lib" + "${_ACML_ROOT}/${_ACML_COMPILER64}${_ACML_PATH_SUFFIX}/lib" ) + endif() + + endif(_ACML_ROOT) + + elseif(BLAS_${BLA_VENDOR}_LIB_DIRS) + + set(_${BLA_VENDOR}_LIB_DIRS ${BLAS_${BLA_VENDOR}_LIB_DIRS}) + + endif() + + if( BLA_VENDOR STREQUAL "ACML_MP" ) + foreach( BLAS_ACML_MP_LIB_DIRS ${_ACML_MP_LIB_DIRS}) + check_fortran_libraries ( + BLAS_LIBRARIES + BLAS + sgemm + "" "acml_mp;acml_mv" "" ${BLAS_ACML_MP_LIB_DIRS} + ) + if( BLAS_LIBRARIES ) + break() + endif() + endforeach() + elseif( BLA_VENDOR STREQUAL "ACML_GPU" ) + foreach( BLAS_ACML_GPU_LIB_DIRS ${_ACML_GPU_LIB_DIRS}) + check_fortran_libraries ( + BLAS_LIBRARIES + BLAS + sgemm + "" "acml;acml_mv;CALBLAS" "" ${BLAS_ACML_GPU_LIB_DIRS} + ) + if( BLAS_LIBRARIES ) + break() + endif() + endforeach() + else() + foreach( BLAS_ACML_LIB_DIRS ${_ACML_LIB_DIRS} ) + check_fortran_libraries ( + BLAS_LIBRARIES + BLAS + sgemm + "" "acml;acml_mv" "" ${BLAS_ACML_LIB_DIRS} + ) + if( BLAS_LIBRARIES ) + break() + endif() + endforeach() + endif() + + # Either acml or acml_mp should be in LD_LIBRARY_PATH but not both + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "acml;acml_mv" + "" + ) + if(NOT BLAS_FIND_QUIETLY) + if(BLAS_LIBRARIES) + message(STATUS "Looking for ACML BLAS: found") + else() + message(STATUS "Looking for ACML BLAS: not found") + endif() endif() - - if(NOT BLAS_LIBRARIES) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "acml_mp;acml_mv" - "" - ) - if(NOT BLAS_FIND_QUIETLY) - if(BLAS_LIBRARIES) - message(STATUS "Looking for ACML BLAS: found") - else() - message(STATUS "Looking for ACML BLAS: not found") - endif() - endif() + endif() + + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "acml_mp;acml_mv" + "" + ) + if(NOT BLAS_FIND_QUIETLY) + if(BLAS_LIBRARIES) + message(STATUS "Looking for ACML BLAS: found") + else() + message(STATUS "Looking for ACML BLAS: not found") + endif() endif() - - if(NOT BLAS_LIBRARIES) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "acml;acml_mv;CALBLAS" - "" - ) - if(NOT BLAS_FIND_QUIETLY) - if(BLAS_LIBRARIES) - message(STATUS "Looking for ACML BLAS: found") - else() - message(STATUS "Looking for ACML BLAS: not found") - endif() - endif() + endif() + + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "acml;acml_mv;CALBLAS" + "" + ) + if(NOT BLAS_FIND_QUIETLY) + if(BLAS_LIBRARIES) + message(STATUS "Looking for ACML BLAS: found") + else() + message(STATUS "Looking for ACML BLAS: not found") + endif() endif() + endif() endif (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All") # ACML @@ -1185,46 +1185,46 @@ endif (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All") # ACML # Apple BLAS library? if (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") - if(NOT BLAS_LIBRARIES) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - dgemm - "" - "Accelerate" - "" - ) - if(NOT BLAS_FIND_QUIETLY) - if(BLAS_LIBRARIES) - message(STATUS "Looking for Apple BLAS: found") - else() - message(STATUS "Looking for Apple BLAS: not found") - endif() - endif() + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + dgemm + "" + "Accelerate" + "" + ) + if(NOT BLAS_FIND_QUIETLY) + if(BLAS_LIBRARIES) + message(STATUS "Looking for Apple BLAS: found") + else() + message(STATUS "Looking for Apple BLAS: not found") + endif() endif() + endif() endif (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") - if ( NOT BLAS_LIBRARIES ) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - dgemm - "" - "vecLib" - "" - ) - if(NOT BLAS_FIND_QUIETLY) - if(BLAS_LIBRARIES) - message(STATUS "Looking for NAS BLAS: found") - else() - message(STATUS "Looking for NAS BLAS: not found") - endif() - endif() - endif () + if ( NOT BLAS_LIBRARIES ) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + dgemm + "" + "vecLib" + "" + ) + if(NOT BLAS_FIND_QUIETLY) + if(BLAS_LIBRARIES) + message(STATUS "Looking for NAS BLAS: found") + else() + message(STATUS "Looking for NAS BLAS: not found") + endif() + endif() + endif () endif (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") @@ -1233,116 +1233,116 @@ endif (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") # Generic BLAS library? if (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All") - set(BLAS_SEARCH_LIBS "blas;blas_LINUX;blas_MAC;blas_WINDOWS;refblas") - foreach (SEARCH_LIB ${BLAS_SEARCH_LIBS}) - if (BLAS_LIBRARIES) - else () - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "${SEARCH_LIB}" - "${LGFORTRAN}" - ) - if(NOT BLAS_FIND_QUIETLY) - if(BLAS_LIBRARIES) - message(STATUS "Looking for Generic BLAS: found") - else() - message(STATUS "Looking for Generic BLAS: not found") - endif() - endif() - endif() - endforeach () + set(BLAS_SEARCH_LIBS "blas;blas_LINUX;blas_MAC;blas_WINDOWS;refblas") + foreach (SEARCH_LIB ${BLAS_SEARCH_LIBS}) + if (BLAS_LIBRARIES) + else () + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "${SEARCH_LIB}" + "${LGFORTRAN}" + ) + if(NOT BLAS_FIND_QUIETLY) + if(BLAS_LIBRARIES) + message(STATUS "Looking for Generic BLAS: found") + else() + message(STATUS "Looking for Generic BLAS: not found") + endif() + endif() + endif() + endforeach () endif (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All") if(BLA_F95) - if(BLAS95_LIBRARIES) - set(BLAS95_FOUND TRUE) - else() - set(BLAS95_FOUND FALSE) - endif() - - if(NOT BLAS_FIND_QUIETLY) - if(BLAS95_FOUND) - message(STATUS "A library with BLAS95 API found.") - message(STATUS "BLAS_LIBRARIES ${BLAS_LIBRARIES}") - 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 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." - "\nYou could also specify a BLAS vendor to look for by setting -DBLA_VENDOR=blas_vendor_name." - "\nList of possible BLAS vendor: Goto, ATLAS PhiPACK, CXML, DXML, SunPerf, SCSL, SGIMATH, IBMESSL, Intel10_32 (intel mkl v10 32 bit)," - "Intel10_64lp (intel mkl v10 64 bit, lp thread model, lp64 model), Intel10_64lp_seq (intel mkl v10 64 bit, sequential code, lp64 model)," - "Intel( older versions of mkl 32 and 64 bit), ACML, ACML_MP, ACML_GPU, Apple, NAS, Generic") - if(BLAS_FIND_REQUIRED) - message(FATAL_ERROR - "A required library with BLAS95 API not found. Please specify library location.") - else() - message(STATUS - "A library with BLAS95 API not found. Please specify library location.") - endif() - endif(BLAS95_FOUND) - endif(NOT BLAS_FIND_QUIETLY) - - set(BLAS_FOUND TRUE) - set(BLAS_LIBRARIES "${BLAS95_LIBRARIES}") - if (NOT BLAS_LIBRARIES_DEP) - set(BLAS_LIBRARIES_DEP "${BLAS95_LIBRARIES}") - endif() + if(BLAS95_LIBRARIES) + set(BLAS95_FOUND TRUE) + else() + set(BLAS95_FOUND FALSE) + endif() + + if(NOT BLAS_FIND_QUIETLY) + if(BLAS95_FOUND) + message(STATUS "A library with BLAS95 API found.") + message(STATUS "BLAS_LIBRARIES ${BLAS_LIBRARIES}") + 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 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." + "\nYou could also specify a BLAS vendor to look for by setting -DBLA_VENDOR=blas_vendor_name." + "\nList of possible BLAS vendor: Goto, ATLAS PhiPACK, CXML, DXML, SunPerf, SCSL, SGIMATH, IBMESSL, Intel10_32 (intel mkl v10 32 bit)," + "Intel10_64lp (intel mkl v10 64 bit, lp thread model, lp64 model), Intel10_64lp_seq (intel mkl v10 64 bit, sequential code, lp64 model)," + "Intel( older versions of mkl 32 and 64 bit), ACML, ACML_MP, ACML_GPU, Apple, NAS, Generic") + if(BLAS_FIND_REQUIRED) + message(FATAL_ERROR + "A required library with BLAS95 API not found. Please specify library location.") + else() + message(STATUS + "A library with BLAS95 API not found. Please specify library location.") + endif() + endif(BLAS95_FOUND) + endif(NOT BLAS_FIND_QUIETLY) + + set(BLAS_FOUND TRUE) + set(BLAS_LIBRARIES "${BLAS95_LIBRARIES}") + if (NOT BLAS_LIBRARIES_DEP) + set(BLAS_LIBRARIES_DEP "${BLAS95_LIBRARIES}") + endif() else(BLA_F95) - if(BLAS_LIBRARIES) - set(BLAS_FOUND TRUE) - else() - set(BLAS_FOUND FALSE) - endif() - - if(NOT BLAS_FIND_QUIETLY) - if(BLAS_FOUND) - message(STATUS "A library with BLAS API found.") - message(STATUS "BLAS_LIBRARIES ${BLAS_LIBRARIES}") - 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 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." - "\nYou could also specify a BLAS vendor to look for by setting -DBLA_VENDOR=blas_vendor_name." - "\nList of possible BLAS vendor: Goto, ATLAS PhiPACK, CXML, DXML, SunPerf, SCSL, SGIMATH, IBMESSL, Intel10_32 (intel mkl v10 32 bit)," - "Intel10_64lp (intel mkl v10 64 bit, lp thread model, lp64 model), Intel10_64lp_seq (intel mkl v10 64 bit, sequential code, lp64 model)," - "Intel( older versions of mkl 32 and 64 bit), ACML, ACML_MP, ACML_GPU, Apple, NAS, Generic") - if(BLAS_FIND_REQUIRED) - message(FATAL_ERROR - "A required library with BLAS API not found. Please specify library location.") - else() - message(STATUS - "A library with BLAS API not found. Please specify library location.") - endif() - endif(BLAS_FOUND) - endif(NOT BLAS_FIND_QUIETLY) + if(BLAS_LIBRARIES) + set(BLAS_FOUND TRUE) + else() + set(BLAS_FOUND FALSE) + endif() + + if(NOT BLAS_FIND_QUIETLY) + if(BLAS_FOUND) + message(STATUS "A library with BLAS API found.") + message(STATUS "BLAS_LIBRARIES ${BLAS_LIBRARIES}") + 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 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." + "\nYou could also specify a BLAS vendor to look for by setting -DBLA_VENDOR=blas_vendor_name." + "\nList of possible BLAS vendor: Goto, ATLAS PhiPACK, CXML, DXML, SunPerf, SCSL, SGIMATH, IBMESSL, Intel10_32 (intel mkl v10 32 bit)," + "Intel10_64lp (intel mkl v10 64 bit, lp thread model, lp64 model), Intel10_64lp_seq (intel mkl v10 64 bit, sequential code, lp64 model)," + "Intel( older versions of mkl 32 and 64 bit), ACML, ACML_MP, ACML_GPU, Apple, NAS, Generic") + if(BLAS_FIND_REQUIRED) + message(FATAL_ERROR + "A required library with BLAS API not found. Please specify library location.") + else() + message(STATUS + "A library with BLAS API not found. Please specify library location.") + endif() + endif(BLAS_FOUND) + endif(NOT BLAS_FIND_QUIETLY) endif(BLA_F95) set(CMAKE_FIND_LIBRARY_SUFFIXES ${_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) if (BLAS_FOUND) - list(GET BLAS_LIBRARIES 0 first_lib) - get_filename_component(first_lib_path "${first_lib}" PATH) - if (${first_lib_path} MATCHES "(/lib(32|64)?$)|(/lib/intel64$|/lib/ia32$)") - string(REGEX REPLACE "(/lib(32|64)?$)|(/lib/intel64$|/lib/ia32$)" "" not_cached_dir "${first_lib_path}") - set(BLAS_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of BLAS library" FORCE) - else() - set(BLAS_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of BLAS library" FORCE) - endif() + 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_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of BLAS library" FORCE) + else() + set(BLAS_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of BLAS library" FORCE) + endif() endif() mark_as_advanced(BLAS_DIR) mark_as_advanced(BLAS_DIR_FOUND) diff --git a/CMakeModules/morse/find/FindBLASEXT.cmake b/CMakeModules/morse/find/FindBLASEXT.cmake index a4af62ad22bac6f043abef03c10ec1b20e66f96a..0fe7fb84931bacf4f7879be412c6abf37c44d175 100644 --- a/CMakeModules/morse/find/FindBLASEXT.cmake +++ b/CMakeModules/morse/find/FindBLASEXT.cmake @@ -42,19 +42,19 @@ # macro to factorize this call macro(find_package_blas) - if(BLASEXT_FIND_REQUIRED) - if(BLASEXT_FIND_QUIETLY) - find_package(BLAS REQUIRED QUIET) - else() - find_package(BLAS REQUIRED) - endif() + if(BLASEXT_FIND_REQUIRED) + if(BLASEXT_FIND_QUIETLY) + find_package(BLAS REQUIRED QUIET) else() - if(BLASEXT_FIND_QUIETLY) - find_package(BLAS QUIET) - else() - find_package(BLAS) - endif() - endif() + find_package(BLAS REQUIRED) + endif() + else() + if(BLASEXT_FIND_QUIETLY) + find_package(BLAS QUIET) + else() + find_package(BLAS) + endif() + endif() endmacro() # add a cache variable to let the user specify the BLAS vendor @@ -67,218 +67,218 @@ set(BLA_VENDOR "" CACHE STRING "list of possible BLAS vendor: ACML, ACML_MP, ACML_GPU, Apple, NAS, Generic") if(NOT BLASEXT_FIND_QUIETLY) - message(STATUS "In FindBLASEXT") - message(STATUS "If you want to force the use of one specific library, " - "\n please specify the BLAS vendor by setting -DBLA_VENDOR=blas_vendor_name" - "\n at cmake configure.") - message(STATUS "List of possible BLAS vendor: Goto, ATLAS PhiPACK, CXML, " - "\n DXML, SunPerf, SCSL, SGIMATH, IBMESSL, IBMESSLMT, Intel10_32 (intel mkl v10 32 bit)," - "\n Intel10_64lp (intel mkl v10 64 bit, lp thread model, lp64 model)," - "\n Intel10_64lp_seq (intel mkl v10 64 bit, sequential code, lp64 model)," - "\n Intel( older versions of mkl 32 and 64 bit)," - "\n ACML, ACML_MP, ACML_GPU, Apple, NAS, Generic") + message(STATUS "In FindBLASEXT") + message(STATUS "If you want to force the use of one specific library, " + "\n please specify the BLAS vendor by setting -DBLA_VENDOR=blas_vendor_name" + "\n at cmake configure.") + message(STATUS "List of possible BLAS vendor: Goto, ATLAS PhiPACK, CXML, " + "\n DXML, SunPerf, SCSL, SGIMATH, IBMESSL, IBMESSLMT, Intel10_32 (intel mkl v10 32 bit)," + "\n Intel10_64lp (intel mkl v10 64 bit, lp thread model, lp64 model)," + "\n Intel10_64lp_seq (intel mkl v10 64 bit, sequential code, lp64 model)," + "\n Intel( older versions of mkl 32 and 64 bit)," + "\n ACML, ACML_MP, ACML_GPU, Apple, NAS, Generic") endif() if (NOT BLAS_FOUND) - # First try to detect two cases: - # 1: only SEQ libs are handled - # 2: both SEQ and PAR libs are handled - find_package_blas() + # First try to detect two cases: + # 1: only SEQ libs are handled + # 2: both SEQ and PAR libs are handled + find_package_blas() endif () # detect the cases where SEQ and PAR libs are handled if(BLA_VENDOR STREQUAL "All" AND - (BLAS_mkl_core_LIBRARY OR BLAS_mkl_core_dll_LIBRARY) - ) - set(BLA_VENDOR "Intel") - if(BLAS_mkl_intel_LIBRARY) - set(BLA_VENDOR "Intel10_32") - endif() - if(BLAS_mkl_intel_lp64_LIBRARY) - set(BLA_VENDOR "Intel10_64lp") - endif() - if(NOT BLASEXT_FIND_QUIETLY) - message(STATUS "A BLAS library has been found (${BLAS_LIBRARIES}) but we" - "\n have also potentially detected some multithreaded BLAS libraries from the MKL." - "\n We try to find both libraries lists (Sequential/Multithreaded).") - endif() - set(BLAS_FOUND "") + (BLAS_mkl_core_LIBRARY OR BLAS_mkl_core_dll_LIBRARY) + ) + set(BLA_VENDOR "Intel") + if(BLAS_mkl_intel_LIBRARY) + set(BLA_VENDOR "Intel10_32") + endif() + if(BLAS_mkl_intel_lp64_LIBRARY) + set(BLA_VENDOR "Intel10_64lp") + endif() + if(NOT BLASEXT_FIND_QUIETLY) + message(STATUS "A BLAS library has been found (${BLAS_LIBRARIES}) but we" + "\n have also potentially detected some multithreaded BLAS libraries from the MKL." + "\n We try to find both libraries lists (Sequential/Multithreaded).") + endif() + set(BLAS_FOUND "") elseif(BLA_VENDOR STREQUAL "All" AND BLAS_acml_LIBRARY) - set(BLA_VENDOR "ACML") - if(NOT BLASEXT_FIND_QUIETLY) - message(STATUS "A BLAS library has been found (${BLAS_LIBRARIES}) but we" - "\n have also potentially detected some multithreaded BLAS libraries from the ACML." - "\n We try to find both libraries lists (Sequential/Multithreaded).") - endif() - set(BLAS_FOUND "") + set(BLA_VENDOR "ACML") + if(NOT BLASEXT_FIND_QUIETLY) + message(STATUS "A BLAS library has been found (${BLAS_LIBRARIES}) but we" + "\n have also potentially detected some multithreaded BLAS libraries from the ACML." + "\n We try to find both libraries lists (Sequential/Multithreaded).") + endif() + set(BLAS_FOUND "") elseif(BLA_VENDOR STREQUAL "All" AND BLAS_essl_LIBRARY) - set(BLA_VENDOR "IBMESSL") - if(NOT BLASEXT_FIND_QUIETLY) - message(STATUS "A BLAS library has been found (${BLAS_LIBRARIES}) but we" - "\n have also potentially detected some multithreaded BLAS libraries from the ESSL." - "\n We try to find both libraries lists (Sequential/Multithreaded).") - endif() - set(BLAS_FOUND "") + set(BLA_VENDOR "IBMESSL") + if(NOT BLASEXT_FIND_QUIETLY) + message(STATUS "A BLAS library has been found (${BLAS_LIBRARIES}) but we" + "\n have also potentially detected some multithreaded BLAS libraries from the ESSL." + "\n We try to find both libraries lists (Sequential/Multithreaded).") + endif() + set(BLAS_FOUND "") endif() # Intel case if(BLA_VENDOR MATCHES "Intel*") - ### - # look for include path if the BLAS vendor is Intel - ### + ### + # look for include path if the BLAS vendor is Intel + ### - # gather system include paths - unset(_inc_env) - if(WIN32) - string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") - else() - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{CPATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - endif() - list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") - list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") - set(ENV_MKLROOT "$ENV{MKLROOT}") - if (ENV_MKLROOT) - list(APPEND _inc_env "${ENV_MKLROOT}/include") - endif() - list(REMOVE_DUPLICATES _inc_env) + # gather system include paths + unset(_inc_env) + if(WIN32) + string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") + else() + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{CPATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + endif() + list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") + list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") + set(ENV_MKLROOT "$ENV{MKLROOT}") + if (ENV_MKLROOT) + list(APPEND _inc_env "${ENV_MKLROOT}/include") + endif() + list(REMOVE_DUPLICATES _inc_env) - # find mkl.h inside known include paths + # find mkl.h inside known include paths + set(BLAS_mkl.h_INCLUDE_DIRS "BLAS_mkl.h_INCLUDE_DIRS-NOTFOUND") + if(BLAS_INCDIR) set(BLAS_mkl.h_INCLUDE_DIRS "BLAS_mkl.h_INCLUDE_DIRS-NOTFOUND") - if(BLAS_INCDIR) - set(BLAS_mkl.h_INCLUDE_DIRS "BLAS_mkl.h_INCLUDE_DIRS-NOTFOUND") - find_path(BLAS_mkl.h_INCLUDE_DIRS - NAMES mkl.h - HINTS ${BLAS_INCDIR}) + find_path(BLAS_mkl.h_INCLUDE_DIRS + NAMES mkl.h + HINTS ${BLAS_INCDIR}) + else() + if(BLAS_DIR) + set(BLAS_mkl.h_INCLUDE_DIRS "BLAS_mkl.h_INCLUDE_DIRS-NOTFOUND") + find_path(BLAS_mkl.h_INCLUDE_DIRS + NAMES mkl.h + HINTS ${BLAS_DIR} + PATH_SUFFIXES include) else() - if(BLAS_DIR) - set(BLAS_mkl.h_INCLUDE_DIRS "BLAS_mkl.h_INCLUDE_DIRS-NOTFOUND") - find_path(BLAS_mkl.h_INCLUDE_DIRS - NAMES mkl.h - HINTS ${BLAS_DIR} - PATH_SUFFIXES include) - else() - set(BLAS_mkl.h_INCLUDE_DIRS "BLAS_mkl.h_INCLUDE_DIRS-NOTFOUND") - find_path(BLAS_mkl.h_INCLUDE_DIRS - NAMES mkl.h - HINTS ${_inc_env}) - endif() - endif() - mark_as_advanced(BLAS_mkl.h_INCLUDE_DIRS) - ## Print status if not found - ## ------------------------- - #if (NOT BLAS_mkl.h_INCLUDE_DIRS AND MORSE_VERBOSE) - # Print_Find_Header_Status(blas mkl.h) - #endif () - set(BLAS_INCLUDE_DIRS "") - if(BLAS_mkl.h_INCLUDE_DIRS) - list(APPEND BLAS_INCLUDE_DIRS "${BLAS_mkl.h_INCLUDE_DIRS}" ) + set(BLAS_mkl.h_INCLUDE_DIRS "BLAS_mkl.h_INCLUDE_DIRS-NOTFOUND") + find_path(BLAS_mkl.h_INCLUDE_DIRS + NAMES mkl.h + HINTS ${_inc_env}) endif() + endif() + mark_as_advanced(BLAS_mkl.h_INCLUDE_DIRS) + ## Print status if not found + ## ------------------------- + #if (NOT BLAS_mkl.h_INCLUDE_DIRS AND MORSE_VERBOSE) + # Print_Find_Header_Status(blas mkl.h) + #endif () + set(BLAS_INCLUDE_DIRS "") + if(BLAS_mkl.h_INCLUDE_DIRS) + list(APPEND BLAS_INCLUDE_DIRS "${BLAS_mkl.h_INCLUDE_DIRS}" ) + endif() - ### - # look for libs - ### - # if Intel 10 64 bit -> look for sequential and multithreaded versions - if(BLA_VENDOR MATCHES "Intel10_64lp*") - - ## look for the sequential version - set(BLA_VENDOR "Intel10_64lp_seq") - if(NOT BLASEXT_FIND_QUIETLY) - message(STATUS "Look for the sequential version Intel10_64lp_seq") - endif() - find_package_blas() - if(BLAS_FOUND) - set(BLAS_SEQ_LIBRARIES "${BLAS_LIBRARIES}") - else() - set(BLAS_SEQ_LIBRARIES "${BLAS_SEQ_LIBRARIES-NOTFOUND}") - endif() - - ## look for the multithreaded version - set(BLA_VENDOR "Intel10_64lp") - if(NOT BLASEXT_FIND_QUIETLY) - message(STATUS "Look for the multithreaded version Intel10_64lp") - endif() - find_package_blas() - if(BLAS_FOUND) - set(BLAS_PAR_LIBRARIES "${BLAS_LIBRARIES}") - else() - set(BLAS_PAR_LIBRARIES "${BLAS_PAR_LIBRARIES-NOTFOUND}") - endif() - - else() - - if(BLAS_FOUND) - set(BLAS_SEQ_LIBRARIES "${BLAS_LIBRARIES}") - else() - set(BLAS_SEQ_LIBRARIES "${BLAS_SEQ_LIBRARIES-NOTFOUND}") - endif() - - endif() - -# ACML case -elseif(BLA_VENDOR MATCHES "ACML*") + ### + # look for libs + ### + # if Intel 10 64 bit -> look for sequential and multithreaded versions + if(BLA_VENDOR MATCHES "Intel10_64lp*") ## look for the sequential version - set(BLA_VENDOR "ACML") + set(BLA_VENDOR "Intel10_64lp_seq") + if(NOT BLASEXT_FIND_QUIETLY) + message(STATUS "Look for the sequential version Intel10_64lp_seq") + endif() find_package_blas() if(BLAS_FOUND) - set(BLAS_SEQ_LIBRARIES "${BLAS_LIBRARIES}") + set(BLAS_SEQ_LIBRARIES "${BLAS_LIBRARIES}") else() - set(BLAS_SEQ_LIBRARIES "${BLAS_SEQ_LIBRARIES-NOTFOUND}") + set(BLAS_SEQ_LIBRARIES "${BLAS_SEQ_LIBRARIES-NOTFOUND}") endif() ## look for the multithreaded version - set(BLA_VENDOR "ACML_MP") + set(BLA_VENDOR "Intel10_64lp") + if(NOT BLASEXT_FIND_QUIETLY) + message(STATUS "Look for the multithreaded version Intel10_64lp") + endif() find_package_blas() if(BLAS_FOUND) - set(BLAS_PAR_LIBRARIES "${BLAS_LIBRARIES}") + set(BLAS_PAR_LIBRARIES "${BLAS_LIBRARIES}") else() - set(BLAS_PAR_LIBRARIES "${BLAS_PAR_LIBRARIES-NOTFOUND}") + set(BLAS_PAR_LIBRARIES "${BLAS_PAR_LIBRARIES-NOTFOUND}") endif() -# IBMESSL case -elseif(BLA_VENDOR MATCHES "IBMESSL*") + else() - ## look for the sequential version - set(BLA_VENDOR "IBMESSL") - find_package_blas() if(BLAS_FOUND) - set(BLAS_SEQ_LIBRARIES "${BLAS_LIBRARIES}") + set(BLAS_SEQ_LIBRARIES "${BLAS_LIBRARIES}") else() - set(BLAS_SEQ_LIBRARIES "${BLAS_SEQ_LIBRARIES-NOTFOUND}") + set(BLAS_SEQ_LIBRARIES "${BLAS_SEQ_LIBRARIES-NOTFOUND}") endif() - ## look for the multithreaded version - set(BLA_VENDOR "IBMESSLMT") - find_package_blas() - if(BLAS_FOUND) - set(BLAS_PAR_LIBRARIES "${BLAS_LIBRARIES}") - else() - set(BLAS_PAR_LIBRARIES "${BLAS_PAR_LIBRARIES-NOTFOUND}") - endif() + endif() -else() + # ACML case +elseif(BLA_VENDOR MATCHES "ACML*") - if(BLAS_FOUND) - # define the SEQ libs as the BLAS_LIBRARIES - set(BLAS_SEQ_LIBRARIES "${BLAS_LIBRARIES}") - else() - set(BLAS_SEQ_LIBRARIES "${BLAS_SEQ_LIBRARIES-NOTFOUND}") - endif() + ## look for the sequential version + set(BLA_VENDOR "ACML") + find_package_blas() + if(BLAS_FOUND) + set(BLAS_SEQ_LIBRARIES "${BLAS_LIBRARIES}") + else() + set(BLAS_SEQ_LIBRARIES "${BLAS_SEQ_LIBRARIES-NOTFOUND}") + endif() + + ## look for the multithreaded version + set(BLA_VENDOR "ACML_MP") + find_package_blas() + if(BLAS_FOUND) + set(BLAS_PAR_LIBRARIES "${BLAS_LIBRARIES}") + else() set(BLAS_PAR_LIBRARIES "${BLAS_PAR_LIBRARIES-NOTFOUND}") + endif() + + # IBMESSL case +elseif(BLA_VENDOR MATCHES "IBMESSL*") + + ## look for the sequential version + set(BLA_VENDOR "IBMESSL") + find_package_blas() + if(BLAS_FOUND) + set(BLAS_SEQ_LIBRARIES "${BLAS_LIBRARIES}") + else() + set(BLAS_SEQ_LIBRARIES "${BLAS_SEQ_LIBRARIES-NOTFOUND}") + endif() + + ## look for the multithreaded version + set(BLA_VENDOR "IBMESSLMT") + find_package_blas() + if(BLAS_FOUND) + set(BLAS_PAR_LIBRARIES "${BLAS_LIBRARIES}") + else() + set(BLAS_PAR_LIBRARIES "${BLAS_PAR_LIBRARIES-NOTFOUND}") + endif() + +else() + + if(BLAS_FOUND) + # define the SEQ libs as the BLAS_LIBRARIES + set(BLAS_SEQ_LIBRARIES "${BLAS_LIBRARIES}") + else() + set(BLAS_SEQ_LIBRARIES "${BLAS_SEQ_LIBRARIES-NOTFOUND}") + endif() + set(BLAS_PAR_LIBRARIES "${BLAS_PAR_LIBRARIES-NOTFOUND}") endif() if(BLAS_SEQ_LIBRARIES) - set(BLAS_LIBRARIES "${BLAS_SEQ_LIBRARIES}") + set(BLAS_LIBRARIES "${BLAS_SEQ_LIBRARIES}") endif() # extract libs paths @@ -286,95 +286,95 @@ endif() set(BLAS_LIBRARY_DIRS "") string(REPLACE " " ";" BLAS_LIBRARIES "${BLAS_LIBRARIES}") foreach(blas_lib ${BLAS_LIBRARIES}) + if (EXISTS "${blas_lib}") + get_filename_component(a_blas_lib_dir "${blas_lib}" PATH) + list(APPEND BLAS_LIBRARY_DIRS "${a_blas_lib_dir}" ) + else() + string(REPLACE "-L" "" blas_lib "${blas_lib}") if (EXISTS "${blas_lib}") - get_filename_component(a_blas_lib_dir "${blas_lib}" PATH) - list(APPEND BLAS_LIBRARY_DIRS "${a_blas_lib_dir}" ) + list(APPEND BLAS_LIBRARY_DIRS "${blas_lib}" ) else() - string(REPLACE "-L" "" blas_lib "${blas_lib}") - if (EXISTS "${blas_lib}") - list(APPEND BLAS_LIBRARY_DIRS "${blas_lib}" ) - else() - get_filename_component(a_blas_lib_dir "${blas_lib}" PATH) - if (EXISTS "${a_blas_lib_dir}") - list(APPEND BLAS_LIBRARY_DIRS "${a_blas_lib_dir}" ) - endif() - endif() + get_filename_component(a_blas_lib_dir "${blas_lib}" PATH) + if (EXISTS "${a_blas_lib_dir}") + list(APPEND BLAS_LIBRARY_DIRS "${a_blas_lib_dir}" ) + endif() endif() + endif() endforeach() if (BLAS_LIBRARY_DIRS) - list(REMOVE_DUPLICATES BLAS_LIBRARY_DIRS) + list(REMOVE_DUPLICATES BLAS_LIBRARY_DIRS) endif () # check that BLAS has been found # --------------------------------- include(FindPackageHandleStandardArgs) if(BLA_VENDOR MATCHES "Intel*") - if(BLA_VENDOR MATCHES "Intel10_64lp*") - if(NOT BLASEXT_FIND_QUIETLY) - message(STATUS "BLAS found is Intel MKL:" - "\n we manage two lists of libs, one sequential and one parallel if found" - "\n (see BLAS_SEQ_LIBRARIES and BLAS_PAR_LIBRARIES)") - message(STATUS "BLAS sequential libraries stored in BLAS_SEQ_LIBRARIES") - endif() - find_package_handle_standard_args(BLAS DEFAULT_MSG - BLAS_SEQ_LIBRARIES - BLAS_LIBRARY_DIRS - BLAS_INCLUDE_DIRS) - if(BLAS_PAR_LIBRARIES) - if(NOT BLASEXT_FIND_QUIETLY) - message(STATUS "BLAS parallel libraries stored in BLAS_PAR_LIBRARIES") - endif() - find_package_handle_standard_args(BLAS DEFAULT_MSG - BLAS_PAR_LIBRARIES) - endif() - else() - if(NOT BLASEXT_FIND_QUIETLY) - message(STATUS "BLAS sequential libraries stored in BLAS_SEQ_LIBRARIES") - endif() - find_package_handle_standard_args(BLAS DEFAULT_MSG - BLAS_SEQ_LIBRARIES - BLAS_LIBRARY_DIRS - BLAS_INCLUDE_DIRS) - endif() -elseif(BLA_VENDOR MATCHES "ACML*") + if(BLA_VENDOR MATCHES "Intel10_64lp*") if(NOT BLASEXT_FIND_QUIETLY) - message(STATUS "BLAS found is ACML:" - "\n we manage two lists of libs, one sequential and one parallel if found" - "\n (see BLAS_SEQ_LIBRARIES and BLAS_PAR_LIBRARIES)") - message(STATUS "BLAS sequential libraries stored in BLAS_SEQ_LIBRARIES") + message(STATUS "BLAS found is Intel MKL:" + "\n we manage two lists of libs, one sequential and one parallel if found" + "\n (see BLAS_SEQ_LIBRARIES and BLAS_PAR_LIBRARIES)") + message(STATUS "BLAS sequential libraries stored in BLAS_SEQ_LIBRARIES") endif() find_package_handle_standard_args(BLAS DEFAULT_MSG - BLAS_SEQ_LIBRARIES - BLAS_LIBRARY_DIRS) + BLAS_SEQ_LIBRARIES + BLAS_LIBRARY_DIRS + BLAS_INCLUDE_DIRS) if(BLAS_PAR_LIBRARIES) - if(NOT BLASEXT_FIND_QUIETLY) - message(STATUS "BLAS parallel libraries stored in BLAS_PAR_LIBRARIES") - endif() - find_package_handle_standard_args(BLAS DEFAULT_MSG - BLAS_PAR_LIBRARIES) + if(NOT BLASEXT_FIND_QUIETLY) + message(STATUS "BLAS parallel libraries stored in BLAS_PAR_LIBRARIES") + endif() + find_package_handle_standard_args(BLAS DEFAULT_MSG + BLAS_PAR_LIBRARIES) endif() -elseif(BLA_VENDOR MATCHES "IBMESSL*") + else() if(NOT BLASEXT_FIND_QUIETLY) - message(STATUS "BLAS found is ESSL:" - "\n we manage two lists of libs, one sequential and one parallel if found" - "\n (see BLAS_SEQ_LIBRARIES and BLAS_PAR_LIBRARIES)") - message(STATUS "BLAS sequential libraries stored in BLAS_SEQ_LIBRARIES") + message(STATUS "BLAS sequential libraries stored in BLAS_SEQ_LIBRARIES") endif() find_package_handle_standard_args(BLAS DEFAULT_MSG - BLAS_SEQ_LIBRARIES - BLAS_LIBRARY_DIRS) - if(BLAS_PAR_LIBRARIES) - if(NOT BLASEXT_FIND_QUIETLY) - message(STATUS "BLAS parallel libraries stored in BLAS_PAR_LIBRARIES") - endif() - find_package_handle_standard_args(BLAS DEFAULT_MSG - BLAS_PAR_LIBRARIES) + BLAS_SEQ_LIBRARIES + BLAS_LIBRARY_DIRS + BLAS_INCLUDE_DIRS) + endif() +elseif(BLA_VENDOR MATCHES "ACML*") + if(NOT BLASEXT_FIND_QUIETLY) + message(STATUS "BLAS found is ACML:" + "\n we manage two lists of libs, one sequential and one parallel if found" + "\n (see BLAS_SEQ_LIBRARIES and BLAS_PAR_LIBRARIES)") + message(STATUS "BLAS sequential libraries stored in BLAS_SEQ_LIBRARIES") + endif() + find_package_handle_standard_args(BLAS DEFAULT_MSG + BLAS_SEQ_LIBRARIES + BLAS_LIBRARY_DIRS) + if(BLAS_PAR_LIBRARIES) + if(NOT BLASEXT_FIND_QUIETLY) + message(STATUS "BLAS parallel libraries stored in BLAS_PAR_LIBRARIES") endif() -else() + find_package_handle_standard_args(BLAS DEFAULT_MSG + BLAS_PAR_LIBRARIES) + endif() +elseif(BLA_VENDOR MATCHES "IBMESSL*") + if(NOT BLASEXT_FIND_QUIETLY) + message(STATUS "BLAS found is ESSL:" + "\n we manage two lists of libs, one sequential and one parallel if found" + "\n (see BLAS_SEQ_LIBRARIES and BLAS_PAR_LIBRARIES)") + message(STATUS "BLAS sequential libraries stored in BLAS_SEQ_LIBRARIES") + endif() + find_package_handle_standard_args(BLAS DEFAULT_MSG + BLAS_SEQ_LIBRARIES + BLAS_LIBRARY_DIRS) + if(BLAS_PAR_LIBRARIES) if(NOT BLASEXT_FIND_QUIETLY) - message(STATUS "BLAS sequential libraries stored in BLAS_SEQ_LIBRARIES") + message(STATUS "BLAS parallel libraries stored in BLAS_PAR_LIBRARIES") endif() find_package_handle_standard_args(BLAS DEFAULT_MSG - BLAS_SEQ_LIBRARIES - BLAS_LIBRARY_DIRS) + BLAS_PAR_LIBRARIES) + endif() +else() + if(NOT BLASEXT_FIND_QUIETLY) + message(STATUS "BLAS sequential libraries stored in BLAS_SEQ_LIBRARIES") + endif() + find_package_handle_standard_args(BLAS DEFAULT_MSG + BLAS_SEQ_LIBRARIES + BLAS_LIBRARY_DIRS) endif() diff --git a/CMakeModules/morse/find/FindCBLAS.cmake b/CMakeModules/morse/find/FindCBLAS.cmake index ebd269c8d833fe9e60ec8f416e64fcae7aff9b5c..eb10586376230fd464c57ad49944d422ef8adcc8 100644 --- a/CMakeModules/morse/find/FindCBLAS.cmake +++ b/CMakeModules/morse/find/FindCBLAS.cmake @@ -77,305 +77,305 @@ if (NOT CBLAS_FOUND) - 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() + 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() endif() # CBLAS depends on BLAS anyway, try to find it if (NOT BLAS_FOUND) - if(CBLAS_FIND_REQUIRED) - find_package(BLASEXT REQUIRED) - else() - find_package(BLASEXT) - endif() + if(CBLAS_FIND_REQUIRED) + find_package(BLASEXT REQUIRED) + else() + find_package(BLASEXT) + 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_LINKER_FLAGS};${BLAS_LIBRARIES}") - set(CMAKE_REQUIRED_FLAGS "${BLAS_COMPILER_FLAGS}") - unset(CBLAS_WORKS CACHE) - check_function_exists(cblas_dscal CBLAS_WORKS) - check_function_exists(cblas_zgemm3m CBLAS_ZGEMM3M_FOUND) - mark_as_advanced(CBLAS_WORKS) - set(CMAKE_REQUIRED_LIBRARIES) - - if(CBLAS_WORKS) - - # Check for faster complex GEMM routine - # (only C/Z, no S/D version) - if ( CBLAS_ZGEMM3M_FOUND ) - add_definitions(-DCBLAS_HAS_ZGEMM3M -DCBLAS_HAS_CGEMM3M) - endif() - - if(NOT CBLAS_FIND_QUIETLY) - message(STATUS "Looking for cblas: test with blas succeeds") - endif() - # test succeeds: CBLAS is in BLAS - set(CBLAS_LIBRARIES "${BLAS_LIBRARIES}") - 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) - - if (CBLAS_STANDALONE OR NOT CBLAS_WORKS) - - if(NOT CBLAS_WORKS AND NOT CBLAS_FIND_QUIETLY) - message(STATUS "Looking for cblas : test with blas fails") - endif() - # test fails: try to find CBLAS lib exterior to BLAS - - # Try to find CBLAS lib - ####################### - - # Looking for include - # ------------------- - - # Add system include paths to search include - # ------------------------------------------ - unset(_inc_env) - set(ENV_CBLAS_DIR "$ENV{CBLAS_DIR}") - set(ENV_CBLAS_INCDIR "$ENV{CBLAS_INCDIR}") - if(ENV_CBLAS_INCDIR) - list(APPEND _inc_env "${ENV_CBLAS_INCDIR}") - elseif(ENV_CBLAS_DIR) - list(APPEND _inc_env "${ENV_CBLAS_DIR}") - list(APPEND _inc_env "${ENV_CBLAS_DIR}/include") - list(APPEND _inc_env "${ENV_CBLAS_DIR}/include/cblas") - else() - if(WIN32) - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") - list(APPEND _inc_env "${_path_env}") - else() - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{CPATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - endif() - endif() - list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") - list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") - list(REMOVE_DUPLICATES _inc_env) - - - # Try to find the cblas header in the given paths - # ------------------------------------------------- - # call cmake macro to find the header path - if(CBLAS_INCDIR) - set(CBLAS_cblas.h_DIRS "CBLAS_cblas.h_DIRS-NOTFOUND") - find_path(CBLAS_cblas.h_DIRS - NAMES cblas.h - HINTS ${CBLAS_INCDIR}) - else() - if(CBLAS_DIR) - set(CBLAS_cblas.h_DIRS "CBLAS_cblas.h_DIRS-NOTFOUND") - find_path(CBLAS_cblas.h_DIRS - NAMES cblas.h - HINTS ${CBLAS_DIR} - PATH_SUFFIXES "include" "include/cblas") - else() - set(CBLAS_cblas.h_DIRS "CBLAS_cblas.h_DIRS-NOTFOUND") - find_path(CBLAS_cblas.h_DIRS - NAMES cblas.h - HINTS ${_inc_env} - PATH_SUFFIXES "cblas") - endif() - endif() - mark_as_advanced(CBLAS_cblas.h_DIRS) - - # If found, add path to cmake variable - # ------------------------------------ - if (CBLAS_cblas.h_DIRS) - set(CBLAS_INCLUDE_DIRS "${CBLAS_cblas.h_DIRS}") - else () - set(CBLAS_INCLUDE_DIRS "CBLAS_INCLUDE_DIRS-NOTFOUND") - if(NOT CBLAS_FIND_QUIETLY) - message(STATUS "Looking for cblas -- cblas.h not found") - endif() - endif() - - - # Looking for lib - # --------------- - - # Add system library paths to search lib - # -------------------------------------- - unset(_lib_env) - set(ENV_CBLAS_LIBDIR "$ENV{CBLAS_LIBDIR}") - if(ENV_CBLAS_LIBDIR) - list(APPEND _lib_env "${ENV_CBLAS_LIBDIR}") - elseif(ENV_CBLAS_DIR) - list(APPEND _lib_env "${ENV_CBLAS_DIR}") - list(APPEND _lib_env "${ENV_CBLAS_DIR}/lib") - else() - if(WIN32) - string(REPLACE ":" ";" _lib_env "$ENV{LIB}") - else() - if(APPLE) - string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - endif() - endif() - list(REMOVE_DUPLICATES _lib_env) - - # Try to find the cblas lib in the given paths - # ---------------------------------------------- - - # call cmake macro to find the lib path - if(CBLAS_LIBDIR) - set(CBLAS_cblas_LIBRARY "CBLAS_cblas_LIBRARY-NOTFOUND") - find_library(CBLAS_cblas_LIBRARY - NAMES cblas - HINTS ${CBLAS_LIBDIR}) - else() - if(CBLAS_DIR) - set(CBLAS_cblas_LIBRARY "CBLAS_cblas_LIBRARY-NOTFOUND") - find_library(CBLAS_cblas_LIBRARY - NAMES cblas - HINTS ${CBLAS_DIR} - PATH_SUFFIXES lib lib32 lib64) - else() - set(CBLAS_cblas_LIBRARY "CBLAS_cblas_LIBRARY-NOTFOUND") - find_library(CBLAS_cblas_LIBRARY - NAMES cblas - HINTS ${_lib_env}) - endif() - endif() - mark_as_advanced(CBLAS_cblas_LIBRARY) - - # If found, add path to cmake variable - # ------------------------------------ - if (CBLAS_cblas_LIBRARY) - get_filename_component(cblas_lib_path "${CBLAS_cblas_LIBRARY}" PATH) - # set cmake variables - set(CBLAS_LIBRARIES "${CBLAS_cblas_LIBRARY}") - set(CBLAS_LIBRARY_DIRS "${cblas_lib_path}") - else () - set(CBLAS_LIBRARIES "CBLAS_LIBRARIES-NOTFOUND") - set(CBLAS_LIBRARY_DIRS "CBLAS_LIBRARY_DIRS-NOTFOUND") - if (NOT CBLAS_FIND_QUIETLY) - message(STATUS "Looking for cblas -- lib cblas not found") - endif() - endif () - - # check a function to validate the find - if(CBLAS_LIBRARIES) - - set(REQUIRED_INCDIRS) - set(REQUIRED_LDFLAGS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) - - # CBLAS - if (CBLAS_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${CBLAS_INCLUDE_DIRS}") - endif() - if (CBLAS_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${CBLAS_LIBRARY_DIRS}") - endif() - set(REQUIRED_LIBS "${CBLAS_LIBRARIES}") - # BLAS - if (BLAS_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${BLAS_INCLUDE_DIRS}") - endif() - if (BLAS_LIBRARY_DIRS) - 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() - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - - # test link - unset(CBLAS_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(cblas_dscal CBLAS_WORKS) - mark_as_advanced(CBLAS_WORKS) - - if(CBLAS_WORKS) - - # Check for faster complex GEMM routine - # (only C/Z, no S/D version) - check_function_exists(cblas_zgemm3m CBLAS_ZGEMM3M_FOUND) - if ( CBLAS_ZGEMM3M_FOUND ) - add_definitions(-DCBLAS_HAS_ZGEMM3M -DCBLAS_HAS_CGEMM3M) - endif() - - # save link with dependencies - 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") - message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") - message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") - message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") - endif() - endif() - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_LIBRARIES) - endif(CBLAS_LIBRARIES) - - endif (CBLAS_STANDALONE OR NOT CBLAS_WORKS) + 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_LINKER_FLAGS};${BLAS_LIBRARIES}") + set(CMAKE_REQUIRED_FLAGS "${BLAS_COMPILER_FLAGS}") + unset(CBLAS_WORKS CACHE) + check_function_exists(cblas_dscal CBLAS_WORKS) + check_function_exists(cblas_zgemm3m CBLAS_ZGEMM3M_FOUND) + mark_as_advanced(CBLAS_WORKS) + set(CMAKE_REQUIRED_LIBRARIES) + + if(CBLAS_WORKS) + + # Check for faster complex GEMM routine + # (only C/Z, no S/D version) + if ( CBLAS_ZGEMM3M_FOUND ) + add_definitions(-DCBLAS_HAS_ZGEMM3M -DCBLAS_HAS_CGEMM3M) + endif() + + if(NOT CBLAS_FIND_QUIETLY) + message(STATUS "Looking for cblas: test with blas succeeds") + endif() + # test succeeds: CBLAS is in BLAS + set(CBLAS_LIBRARIES "${BLAS_LIBRARIES}") + 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) -else(BLAS_FOUND) + if (CBLAS_STANDALONE OR NOT CBLAS_WORKS) - if (NOT CBLAS_FIND_QUIETLY) - message(STATUS "CBLAS requires BLAS but BLAS has not been found." - "Please look for BLAS first.") + if(NOT CBLAS_WORKS AND NOT CBLAS_FIND_QUIETLY) + message(STATUS "Looking for cblas : test with blas fails") + endif() + # test fails: try to find CBLAS lib exterior to BLAS + + # Try to find CBLAS lib + ####################### + + # Looking for include + # ------------------- + + # Add system include paths to search include + # ------------------------------------------ + unset(_inc_env) + set(ENV_CBLAS_DIR "$ENV{CBLAS_DIR}") + set(ENV_CBLAS_INCDIR "$ENV{CBLAS_INCDIR}") + if(ENV_CBLAS_INCDIR) + list(APPEND _inc_env "${ENV_CBLAS_INCDIR}") + elseif(ENV_CBLAS_DIR) + list(APPEND _inc_env "${ENV_CBLAS_DIR}") + list(APPEND _inc_env "${ENV_CBLAS_DIR}/include") + list(APPEND _inc_env "${ENV_CBLAS_DIR}/include/cblas") + else() + if(WIN32) + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") + list(APPEND _inc_env "${_path_env}") + else() + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{CPATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + endif() + endif() + list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") + list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") + list(REMOVE_DUPLICATES _inc_env) + + + # Try to find the cblas header in the given paths + # ------------------------------------------------- + # call cmake macro to find the header path + if(CBLAS_INCDIR) + set(CBLAS_cblas.h_DIRS "CBLAS_cblas.h_DIRS-NOTFOUND") + find_path(CBLAS_cblas.h_DIRS + NAMES cblas.h + HINTS ${CBLAS_INCDIR}) + else() + if(CBLAS_DIR) + set(CBLAS_cblas.h_DIRS "CBLAS_cblas.h_DIRS-NOTFOUND") + find_path(CBLAS_cblas.h_DIRS + NAMES cblas.h + HINTS ${CBLAS_DIR} + PATH_SUFFIXES "include" "include/cblas") + else() + set(CBLAS_cblas.h_DIRS "CBLAS_cblas.h_DIRS-NOTFOUND") + find_path(CBLAS_cblas.h_DIRS + NAMES cblas.h + HINTS ${_inc_env} + PATH_SUFFIXES "cblas") + endif() + endif() + mark_as_advanced(CBLAS_cblas.h_DIRS) + + # If found, add path to cmake variable + # ------------------------------------ + if (CBLAS_cblas.h_DIRS) + set(CBLAS_INCLUDE_DIRS "${CBLAS_cblas.h_DIRS}") + else () + set(CBLAS_INCLUDE_DIRS "CBLAS_INCLUDE_DIRS-NOTFOUND") + if(NOT CBLAS_FIND_QUIETLY) + message(STATUS "Looking for cblas -- cblas.h not found") + endif() endif() -endif(BLAS_FOUND) -if (CBLAS_LIBRARIES) - list(GET CBLAS_LIBRARIES 0 first_lib) - get_filename_component(first_lib_path "${first_lib}" PATH) - if (${first_lib_path} MATCHES "(/lib(32|64)?$)|(/lib/intel64$|/lib/ia32$)") - string(REGEX REPLACE "(/lib(32|64)?$)|(/lib/intel64$|/lib/ia32$)" "" not_cached_dir "${first_lib_path}") - set(CBLAS_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of CBLAS library" FORCE) + # Looking for lib + # --------------- + + # Add system library paths to search lib + # -------------------------------------- + unset(_lib_env) + set(ENV_CBLAS_LIBDIR "$ENV{CBLAS_LIBDIR}") + if(ENV_CBLAS_LIBDIR) + list(APPEND _lib_env "${ENV_CBLAS_LIBDIR}") + elseif(ENV_CBLAS_DIR) + list(APPEND _lib_env "${ENV_CBLAS_DIR}") + list(APPEND _lib_env "${ENV_CBLAS_DIR}/lib") + else() + if(WIN32) + string(REPLACE ":" ";" _lib_env "$ENV{LIB}") + else() + if(APPLE) + string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") + else() + string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") + endif() + list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") + list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + endif() + endif() + list(REMOVE_DUPLICATES _lib_env) + + # Try to find the cblas lib in the given paths + # ---------------------------------------------- + + # call cmake macro to find the lib path + if(CBLAS_LIBDIR) + set(CBLAS_cblas_LIBRARY "CBLAS_cblas_LIBRARY-NOTFOUND") + find_library(CBLAS_cblas_LIBRARY + NAMES cblas + HINTS ${CBLAS_LIBDIR}) else() - set(CBLAS_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of CBLAS library" FORCE) + if(CBLAS_DIR) + set(CBLAS_cblas_LIBRARY "CBLAS_cblas_LIBRARY-NOTFOUND") + find_library(CBLAS_cblas_LIBRARY + NAMES cblas + HINTS ${CBLAS_DIR} + PATH_SUFFIXES lib lib32 lib64) + else() + set(CBLAS_cblas_LIBRARY "CBLAS_cblas_LIBRARY-NOTFOUND") + find_library(CBLAS_cblas_LIBRARY + NAMES cblas + HINTS ${_lib_env}) + endif() endif() + mark_as_advanced(CBLAS_cblas_LIBRARY) + + # If found, add path to cmake variable + # ------------------------------------ + if (CBLAS_cblas_LIBRARY) + get_filename_component(cblas_lib_path "${CBLAS_cblas_LIBRARY}" PATH) + # set cmake variables + set(CBLAS_LIBRARIES "${CBLAS_cblas_LIBRARY}") + set(CBLAS_LIBRARY_DIRS "${cblas_lib_path}") + else () + set(CBLAS_LIBRARIES "CBLAS_LIBRARIES-NOTFOUND") + set(CBLAS_LIBRARY_DIRS "CBLAS_LIBRARY_DIRS-NOTFOUND") + if (NOT CBLAS_FIND_QUIETLY) + message(STATUS "Looking for cblas -- lib cblas not found") + endif() + endif () + + # check a function to validate the find + if(CBLAS_LIBRARIES) + + set(REQUIRED_INCDIRS) + set(REQUIRED_LDFLAGS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) + + # CBLAS + if (CBLAS_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${CBLAS_INCLUDE_DIRS}") + endif() + if (CBLAS_LIBRARY_DIRS) + set(REQUIRED_LIBDIRS "${CBLAS_LIBRARY_DIRS}") + endif() + set(REQUIRED_LIBS "${CBLAS_LIBRARIES}") + # BLAS + if (BLAS_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${BLAS_INCLUDE_DIRS}") + endif() + if (BLAS_LIBRARY_DIRS) + 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() + list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") + string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + + # test link + unset(CBLAS_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(cblas_dscal CBLAS_WORKS) + mark_as_advanced(CBLAS_WORKS) + + if(CBLAS_WORKS) + + # Check for faster complex GEMM routine + # (only C/Z, no S/D version) + check_function_exists(cblas_zgemm3m CBLAS_ZGEMM3M_FOUND) + if ( CBLAS_ZGEMM3M_FOUND ) + add_definitions(-DCBLAS_HAS_ZGEMM3M -DCBLAS_HAS_CGEMM3M) + endif() + + # save link with dependencies + 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") + message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") + message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") + message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") + 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) + message(STATUS "CBLAS requires BLAS but BLAS has not been found." + "Please look for BLAS first.") + endif() + +endif(BLAS_FOUND) + +if (CBLAS_LIBRARIES) + list(GET CBLAS_LIBRARIES 0 first_lib) + get_filename_component(first_lib_path "${first_lib}" PATH) + if (${first_lib_path} MATCHES "(/lib(32|64)?$)|(/lib/intel64$|/lib/ia32$)") + string(REGEX REPLACE "(/lib(32|64)?$)|(/lib/intel64$|/lib/ia32$)" "" not_cached_dir "${first_lib_path}") + set(CBLAS_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of CBLAS library" FORCE) + else() + set(CBLAS_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of CBLAS library" FORCE) + endif() endif() mark_as_advanced(CBLAS_DIR) mark_as_advanced(CBLAS_DIR_FOUND) @@ -384,5 +384,5 @@ mark_as_advanced(CBLAS_DIR_FOUND) # ------------------------------- include(FindPackageHandleStandardArgs) find_package_handle_standard_args(CBLAS DEFAULT_MSG - CBLAS_LIBRARIES - CBLAS_WORKS) + CBLAS_LIBRARIES + CBLAS_WORKS) diff --git a/CMakeModules/morse/find/FindCHAMELEON.cmake b/CMakeModules/morse/find/FindCHAMELEON.cmake index 4ca172a63aa7244d997697e668d1b54b197e7f43..9b581f5b908b590d612dbf5f235ae22e6977f4cc 100644 --- a/CMakeModules/morse/find/FindCHAMELEON.cmake +++ b/CMakeModules/morse/find/FindCHAMELEON.cmake @@ -70,10 +70,10 @@ if (NOT CHAMELEON_FOUND) - 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() + 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() endif() # Try to find CHAMELEON dependencies if specified as COMPONENTS during the call @@ -85,34 +85,34 @@ set(CHAMELEON_LOOK_FOR_MPI OFF) set(CHAMELEON_LOOK_FOR_FXT OFF) if( CHAMELEON_FIND_COMPONENTS ) - foreach( component ${CHAMELEON_FIND_COMPONENTS} ) - if (${component} STREQUAL "STARPU") - # means we look for Chameleon with StarPU - set(CHAMELEON_LOOK_FOR_STARPU ON) - set(CHAMELEON_LOOK_FOR_QUARK OFF) - endif() - if (${component} STREQUAL "QUARK") - # means we look for Chameleon with QUARK - set(CHAMELEON_LOOK_FOR_QUARK ON) - set(CHAMELEON_LOOK_FOR_STARPU OFF) - endif() - if (${component} STREQUAL "CUDA") - # means we look for Chameleon with CUDA - set(CHAMELEON_LOOK_FOR_CUDA ON) - endif() - if (${component} STREQUAL "MAGMA") - # means we look for Chameleon with MAGMA - set(CHAMELEON_LOOK_FOR_MAGMA ON) - endif() - if (${component} STREQUAL "MPI") - # means we look for Chameleon with MPI - set(CHAMELEON_LOOK_FOR_MPI ON) - endif() - if (${component} STREQUAL "FXT") - # means we look for Chameleon with FXT - set(CHAMELEON_LOOK_FOR_FXT ON) - endif() - endforeach() + foreach( component ${CHAMELEON_FIND_COMPONENTS} ) + if (${component} STREQUAL "STARPU") + # means we look for Chameleon with StarPU + set(CHAMELEON_LOOK_FOR_STARPU ON) + set(CHAMELEON_LOOK_FOR_QUARK OFF) + endif() + if (${component} STREQUAL "QUARK") + # means we look for Chameleon with QUARK + set(CHAMELEON_LOOK_FOR_QUARK ON) + set(CHAMELEON_LOOK_FOR_STARPU OFF) + endif() + if (${component} STREQUAL "CUDA") + # means we look for Chameleon with CUDA + set(CHAMELEON_LOOK_FOR_CUDA ON) + endif() + if (${component} STREQUAL "MAGMA") + # means we look for Chameleon with MAGMA + set(CHAMELEON_LOOK_FOR_MAGMA ON) + endif() + if (${component} STREQUAL "MPI") + # means we look for Chameleon with MPI + set(CHAMELEON_LOOK_FOR_MPI ON) + endif() + if (${component} STREQUAL "FXT") + # means we look for Chameleon with FXT + set(CHAMELEON_LOOK_FOR_FXT ON) + endif() + endforeach() endif() set(ENV_CHAMELEON_DIR "$ENV{CHAMELEON_DIR}") @@ -120,7 +120,7 @@ set(ENV_CHAMELEON_INCDIR "$ENV{CHAMELEON_INCDIR}") set(ENV_CHAMELEON_LIBDIR "$ENV{CHAMELEON_LIBDIR}") set(CHAMELEON_GIVEN_BY_USER "FALSE") if ( CHAMELEON_DIR OR ( CHAMELEON_INCDIR AND CHAMELEON_LIBDIR) OR ENV_CHAMELEON_DIR OR (ENV_CHAMELEON_INCDIR AND ENV_CHAMELEON_LIBDIR) ) - set(CHAMELEON_GIVEN_BY_USER "TRUE") + set(CHAMELEON_GIVEN_BY_USER "TRUE") endif() # Optionally use pkg-config to detect include/library dirs (if pkg-config is available) @@ -129,660 +129,660 @@ include(FindPkgConfig) find_package(PkgConfig QUIET) if(PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_GIVEN_BY_USER) - pkg_search_module(CHAMELEON chameleon) - if (NOT CHAMELEON_FIND_QUIETLY) - if (CHAMELEON_FOUND AND CHAMELEON_LIBRARIES) - message(STATUS "Looking for CHAMELEON - found using PkgConfig") - #if(NOT CHAMELEON_INCLUDE_DIRS) - # message("${Magenta}CHAMELEON_INCLUDE_DIRS is empty using PkgConfig." - # "Perhaps the path to chameleon headers is already present in your" - # "C(PLUS)_INCLUDE_PATH environment variable.${ColourReset}") - #endif() - else() - message(STATUS "${Magenta}Looking for CHAMELEON - not found using PkgConfig." - "\n Perhaps you should add the directory containing chameleon.pc" - "\n to the PKG_CONFIG_PATH environment variable.${ColourReset}") - endif() - endif() - - if (CHAMELEON_FIND_VERSION_EXACT) - if( NOT (CHAMELEON_FIND_VERSION_MAJOR STREQUAL CHAMELEON_VERSION_MAJOR) OR - NOT (CHAMELEON_FIND_VERSION_MINOR STREQUAL CHAMELEON_VERSION_MINOR) ) - if(NOT CHAMELEON_FIND_QUIETLY) - message(FATAL_ERROR - "CHAMELEON version found is ${CHAMELEON_VERSION_STRING}" - "when required is ${CHAMELEON_FIND_VERSION}") - endif() - endif() + pkg_search_module(CHAMELEON chameleon) + if (NOT CHAMELEON_FIND_QUIETLY) + if (CHAMELEON_FOUND AND CHAMELEON_LIBRARIES) + message(STATUS "Looking for CHAMELEON - found using PkgConfig") + #if(NOT CHAMELEON_INCLUDE_DIRS) + # message("${Magenta}CHAMELEON_INCLUDE_DIRS is empty using PkgConfig." + # "Perhaps the path to chameleon headers is already present in your" + # "C(PLUS)_INCLUDE_PATH environment variable.${ColourReset}") + #endif() else() - # if the version found is older than the required then error - if( (CHAMELEON_FIND_VERSION_MAJOR STRGREATER CHAMELEON_VERSION_MAJOR) OR - (CHAMELEON_FIND_VERSION_MINOR STRGREATER CHAMELEON_VERSION_MINOR) ) - if(NOT CHAMELEON_FIND_QUIETLY) - message(FATAL_ERROR - "CHAMELEON version found is ${CHAMELEON_VERSION_STRING}" - "when required is ${CHAMELEON_FIND_VERSION} or newer") - endif() - endif() + message(STATUS "${Magenta}Looking for CHAMELEON - not found using PkgConfig." + "\n Perhaps you should add the directory containing chameleon.pc" + "\n to the PKG_CONFIG_PATH environment variable.${ColourReset}") endif() + endif() + + if (CHAMELEON_FIND_VERSION_EXACT) + if( NOT (CHAMELEON_FIND_VERSION_MAJOR STREQUAL CHAMELEON_VERSION_MAJOR) OR + NOT (CHAMELEON_FIND_VERSION_MINOR STREQUAL CHAMELEON_VERSION_MINOR) ) + if(NOT CHAMELEON_FIND_QUIETLY) + message(FATAL_ERROR + "CHAMELEON version found is ${CHAMELEON_VERSION_STRING}" + "when required is ${CHAMELEON_FIND_VERSION}") + endif() + endif() + else() + # if the version found is older than the required then error + if( (CHAMELEON_FIND_VERSION_MAJOR STRGREATER CHAMELEON_VERSION_MAJOR) OR + (CHAMELEON_FIND_VERSION_MINOR STRGREATER CHAMELEON_VERSION_MINOR) ) + if(NOT CHAMELEON_FIND_QUIETLY) + message(FATAL_ERROR + "CHAMELEON version found is ${CHAMELEON_VERSION_STRING}" + "when required is ${CHAMELEON_FIND_VERSION} or newer") + endif() + endif() + endif() - set(CHAMELEON_INCLUDE_DIRS_DEP "${CHAMELEON_INCLUDE_DIRS}") - set(CHAMELEON_LIBRARY_DIRS_DEP "${CHAMELEON_LIBRARY_DIRS}") - set(CHAMELEON_LIBRARIES_DEP "${CHAMELEON_LIBRARIES}") + set(CHAMELEON_INCLUDE_DIRS_DEP "${CHAMELEON_INCLUDE_DIRS}") + set(CHAMELEON_LIBRARY_DIRS_DEP "${CHAMELEON_LIBRARY_DIRS}") + set(CHAMELEON_LIBRARIES_DEP "${CHAMELEON_LIBRARIES}") endif(PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_GIVEN_BY_USER) if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR (CHAMELEON_GIVEN_BY_USER) ) - if (NOT CHAMELEON_FIND_QUIETLY) - message(STATUS "Looking for CHAMELEON - PkgConfig not used") + if (NOT CHAMELEON_FIND_QUIETLY) + message(STATUS "Looking for CHAMELEON - PkgConfig not used") + endif() + + # Dependencies detection + # ---------------------- + + if (NOT CHAMELEON_FIND_QUIETLY) + message(STATUS "Looking for CHAMELEON - Try to detect pthread") + endif() + if (CHAMELEON_FIND_REQUIRED) + find_package(Threads REQUIRED) + else() + find_package(Threads) + endif() + set(CHAMELEON_EXTRA_LIBRARIES "") + if( THREADS_FOUND ) + list(APPEND CHAMELEON_EXTRA_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) + endif () + + # Add math library to the list of extra + # it normally exists on all common systems provided with a C compiler + if (NOT CHAMELEON_FIND_QUIETLY) + message(STATUS "Looking for CHAMELEON - Try to detect libm") + endif() + set(CHAMELEON_M_LIBRARIES "") + if(UNIX OR WIN32) + find_library( + CHAMELEON_M_m_LIBRARY + NAMES m + ) + mark_as_advanced(CHAMELEON_M_m_LIBRARY) + if (CHAMELEON_M_m_LIBRARY) + list(APPEND CHAMELEON_M_LIBRARIES "${CHAMELEON_M_m_LIBRARY}") + list(APPEND CHAMELEON_EXTRA_LIBRARIES "${CHAMELEON_M_m_LIBRARY}") + else() + if (CHAMELEON_FIND_REQUIRED) + message(FATAL_ERROR "Could NOT find libm on your system." + "Are you sure to a have a C compiler installed?") + endif() endif() - - # Dependencies detection - # ---------------------- - - if (NOT CHAMELEON_FIND_QUIETLY) - message(STATUS "Looking for CHAMELEON - Try to detect pthread") + endif() + + # Try to find librt (libposix4 - POSIX.1b Realtime Extensions library) + # on Unix systems except Apple ones because it does not exist on it + if (NOT CHAMELEON_FIND_QUIETLY) + message(STATUS "Looking for CHAMELEON - Try to detect librt") + endif() + set(CHAMELEON_RT_LIBRARIES "") + if(UNIX AND NOT APPLE) + find_library( + CHAMELEON_RT_rt_LIBRARY + NAMES rt + ) + mark_as_advanced(CHAMELEON_RT_rt_LIBRARY) + if (CHAMELEON_RT_rt_LIBRARY) + list(APPEND CHAMELEON_RT_LIBRARIES "${CHAMELEON_RT_rt_LIBRARY}") + list(APPEND CHAMELEON_EXTRA_LIBRARIES "${CHAMELEON_RT_rt_LIBRARY}") + else() + if (CHAMELEON_FIND_REQUIRED) + message(FATAL_ERROR "Could NOT find librt on your system") + endif() endif() - if (CHAMELEON_FIND_REQUIRED) - find_package(Threads REQUIRED) + endif() + + # CHAMELEON depends on CBLAS + #--------------------------- + if (NOT CHAMELEON_FIND_QUIETLY) + message(STATUS "Looking for CHAMELEON - Try to detect CBLAS (depends on BLAS)") + endif() + if (CHAMELEON_FIND_REQUIRED) + find_package(CBLAS REQUIRED) + else() + find_package(CBLAS) + endif() + + # CHAMELEON depends on LAPACKE + #----------------------------- + + # standalone version of lapacke seems useless for now + # let the comment in case we meet some problems of non existing lapacke + # functions in lapack library such as mkl, acml, ... + #set(LAPACKE_STANDALONE TRUE) + if (NOT CHAMELEON_FIND_QUIETLY) + message(STATUS "Looking for CHAMELEON - Try to detect LAPACKE (depends on LAPACK)") + endif() + if (CHAMELEON_FIND_REQUIRED) + find_package(LAPACKE REQUIRED) + else() + find_package(LAPACKE) + endif() + + # CHAMELEON depends on TMG + #------------------------- + if (NOT CHAMELEON_FIND_QUIETLY) + message(STATUS "Looking for CHAMELEON - Try to detect TMG (depends on LAPACK)") + endif() + if (CHAMELEON_FIND_REQUIRED) + find_package(TMG REQUIRED) + else() + find_package(TMG) + endif() + + # CHAMELEON may depend on CUDA/CUBLAS + #------------------------------------ + if (NOT CUDA_FOUND AND CHAMELEON_LOOK_FOR_CUDA) + if (CHAMELEON_FIND_REQUIRED AND CHAMELEON_FIND_REQUIRED_CUDA) + find_package(CUDA REQUIRED) else() - find_package(Threads) - endif() - set(CHAMELEON_EXTRA_LIBRARIES "") - if( THREADS_FOUND ) - list(APPEND CHAMELEON_EXTRA_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) - endif () - - # Add math library to the list of extra - # it normally exists on all common systems provided with a C compiler - if (NOT CHAMELEON_FIND_QUIETLY) - message(STATUS "Looking for CHAMELEON - Try to detect libm") - endif() - set(CHAMELEON_M_LIBRARIES "") - if(UNIX OR WIN32) - find_library( - CHAMELEON_M_m_LIBRARY - NAMES m - ) - mark_as_advanced(CHAMELEON_M_m_LIBRARY) - if (CHAMELEON_M_m_LIBRARY) - list(APPEND CHAMELEON_M_LIBRARIES "${CHAMELEON_M_m_LIBRARY}") - list(APPEND CHAMELEON_EXTRA_LIBRARIES "${CHAMELEON_M_m_LIBRARY}") - else() - if (CHAMELEON_FIND_REQUIRED) - message(FATAL_ERROR "Could NOT find libm on your system." - "Are you sure to a have a C compiler installed?") - endif() - endif() - endif() - - # Try to find librt (libposix4 - POSIX.1b Realtime Extensions library) - # on Unix systems except Apple ones because it does not exist on it - if (NOT CHAMELEON_FIND_QUIETLY) - message(STATUS "Looking for CHAMELEON - Try to detect librt") - endif() - set(CHAMELEON_RT_LIBRARIES "") - if(UNIX AND NOT APPLE) - find_library( - CHAMELEON_RT_rt_LIBRARY - NAMES rt - ) - mark_as_advanced(CHAMELEON_RT_rt_LIBRARY) - if (CHAMELEON_RT_rt_LIBRARY) - list(APPEND CHAMELEON_RT_LIBRARIES "${CHAMELEON_RT_rt_LIBRARY}") - list(APPEND CHAMELEON_EXTRA_LIBRARIES "${CHAMELEON_RT_rt_LIBRARY}") - else() - if (CHAMELEON_FIND_REQUIRED) - message(FATAL_ERROR "Could NOT find librt on your system") - endif() - endif() - endif() - - # CHAMELEON depends on CBLAS - #--------------------------- - if (NOT CHAMELEON_FIND_QUIETLY) - message(STATUS "Looking for CHAMELEON - Try to detect CBLAS (depends on BLAS)") - endif() - if (CHAMELEON_FIND_REQUIRED) - find_package(CBLAS REQUIRED) + find_package(CUDA) + endif() + if (CUDA_FOUND) + mark_as_advanced(CUDA_BUILD_CUBIN) + mark_as_advanced(CUDA_BUILD_EMULATION) + mark_as_advanced(CUDA_SDK_ROOT_DIR) + mark_as_advanced(CUDA_TOOLKIT_ROOT_DIR) + mark_as_advanced(CUDA_VERBOSE_BUILD) + endif() + endif() + + # CHAMELEON may depend on MAGMA gpu kernels + # call our cmake module to test (in cmake_modules) + # change this call position if not appropriated + #------------------------------------------------- + if( CUDA_FOUND AND CHAMELEON_LOOK_FOR_MAGMA ) + set(CHAMELEON_MAGMA_VERSION "1.4" CACHE STRING "oldest MAGMA version desired") + if (CHAMELEON_FIND_REQUIRED AND CHAMELEON_FIND_REQUIRED_MAGMA) + find_package(MAGMA ${CHAMELEON_MAGMA_VERSION} REQUIRED) else() - find_package(CBLAS) + find_package(MAGMA ${CHAMELEON_MAGMA_VERSION}) endif() + endif() - # CHAMELEON depends on LAPACKE - #----------------------------- + # CHAMELEON depends on MPI + #------------------------- + if( NOT MPI_FOUND AND CHAMELEON_LOOK_FOR_MPI ) - # standalone version of lapacke seems useless for now - # let the comment in case we meet some problems of non existing lapacke - # functions in lapack library such as mkl, acml, ... - #set(LAPACKE_STANDALONE TRUE) - if (NOT CHAMELEON_FIND_QUIETLY) - message(STATUS "Looking for CHAMELEON - Try to detect LAPACKE (depends on LAPACK)") + # allows to use an external mpi compilation by setting compilers with + # -DMPI_C_COMPILER=path/to/mpicc -DMPI_Fortran_COMPILER=path/to/mpif90 + # at cmake configure + if(NOT MPI_C_COMPILER) + set(MPI_C_COMPILER mpicc) endif() - if (CHAMELEON_FIND_REQUIRED) - find_package(LAPACKE REQUIRED) + if (CHAMELEON_FIND_REQUIRED AND CHAMELEON_FIND_REQUIRED_MPI) + find_package(MPI REQUIRED) else() - find_package(LAPACKE) + find_package(MPI) endif() + if (MPI_FOUND) + mark_as_advanced(MPI_LIBRARY) + mark_as_advanced(MPI_EXTRA_LIBRARY) + endif() + + endif() + + if( NOT STARPU_FOUND AND CHAMELEON_LOOK_FOR_STARPU ) + + set(CHAMELEON_STARPU_VERSION "1.1" CACHE STRING "oldest STARPU version desired") - # CHAMELEON depends on TMG - #------------------------- - if (NOT CHAMELEON_FIND_QUIETLY) - message(STATUS "Looking for CHAMELEON - Try to detect TMG (depends on LAPACK)") + # create list of components in order to make a single call to find_package(starpu...) + # we explicitly need a StarPU version built with hwloc + set(STARPU_COMPONENT_LIST "HWLOC") + + # StarPU may depend on MPI + # allows to use an external mpi compilation by setting compilers with + # -DMPI_C_COMPILER=path/to/mpicc -DMPI_Fortran_COMPILER=path/to/mpif90 + # at cmake configure + if (CHAMELEON_LOOK_FOR_MPI) + if(NOT MPI_C_COMPILER) + set(MPI_C_COMPILER mpicc) + endif() + list(APPEND STARPU_COMPONENT_LIST "MPI") + endif() + if (CHAMELEON_LOOK_FOR_CUDA) + list(APPEND STARPU_COMPONENT_LIST "CUDA") endif() - if (CHAMELEON_FIND_REQUIRED) - find_package(TMG REQUIRED) + if (CHAMELEON_LOOK_FOR_FXT) + list(APPEND STARPU_COMPONENT_LIST "FXT") + endif() + if (CHAMELEON_FIND_REQUIRED AND CHAMELEON_FIND_REQUIRED_STARPU) + find_package(STARPU ${CHAMELEON_STARPU_VERSION} REQUIRED + COMPONENTS ${STARPU_COMPONENT_LIST}) else() - find_package(TMG) - endif() - - # CHAMELEON may depend on CUDA/CUBLAS - #------------------------------------ - if (NOT CUDA_FOUND AND CHAMELEON_LOOK_FOR_CUDA) - if (CHAMELEON_FIND_REQUIRED AND CHAMELEON_FIND_REQUIRED_CUDA) - find_package(CUDA REQUIRED) - else() - find_package(CUDA) - endif() - if (CUDA_FOUND) - mark_as_advanced(CUDA_BUILD_CUBIN) - mark_as_advanced(CUDA_BUILD_EMULATION) - mark_as_advanced(CUDA_SDK_ROOT_DIR) - mark_as_advanced(CUDA_TOOLKIT_ROOT_DIR) - mark_as_advanced(CUDA_VERBOSE_BUILD) - endif() - endif() - - # CHAMELEON may depend on MAGMA gpu kernels - # call our cmake module to test (in cmake_modules) - # change this call position if not appropriated - #------------------------------------------------- - if( CUDA_FOUND AND CHAMELEON_LOOK_FOR_MAGMA ) - set(CHAMELEON_MAGMA_VERSION "1.4" CACHE STRING "oldest MAGMA version desired") - if (CHAMELEON_FIND_REQUIRED AND CHAMELEON_FIND_REQUIRED_MAGMA) - find_package(MAGMA ${CHAMELEON_MAGMA_VERSION} REQUIRED) - else() - find_package(MAGMA ${CHAMELEON_MAGMA_VERSION}) - endif() - endif() - - # CHAMELEON depends on MPI - #------------------------- - if( NOT MPI_FOUND AND CHAMELEON_LOOK_FOR_MPI ) - - # allows to use an external mpi compilation by setting compilers with - # -DMPI_C_COMPILER=path/to/mpicc -DMPI_Fortran_COMPILER=path/to/mpif90 - # at cmake configure - if(NOT MPI_C_COMPILER) - set(MPI_C_COMPILER mpicc) - endif() - if (CHAMELEON_FIND_REQUIRED AND CHAMELEON_FIND_REQUIRED_MPI) - find_package(MPI REQUIRED) - else() - find_package(MPI) - endif() - if (MPI_FOUND) - mark_as_advanced(MPI_LIBRARY) - mark_as_advanced(MPI_EXTRA_LIBRARY) - endif() - - endif() - - if( NOT STARPU_FOUND AND CHAMELEON_LOOK_FOR_STARPU ) - - set(CHAMELEON_STARPU_VERSION "1.1" CACHE STRING "oldest STARPU version desired") - - # create list of components in order to make a single call to find_package(starpu...) - # we explicitly need a StarPU version built with hwloc - set(STARPU_COMPONENT_LIST "HWLOC") - - # StarPU may depend on MPI - # allows to use an external mpi compilation by setting compilers with - # -DMPI_C_COMPILER=path/to/mpicc -DMPI_Fortran_COMPILER=path/to/mpif90 - # at cmake configure - if (CHAMELEON_LOOK_FOR_MPI) - if(NOT MPI_C_COMPILER) - set(MPI_C_COMPILER mpicc) - endif() - list(APPEND STARPU_COMPONENT_LIST "MPI") - endif() - if (CHAMELEON_LOOK_FOR_CUDA) - list(APPEND STARPU_COMPONENT_LIST "CUDA") - endif() - if (CHAMELEON_LOOK_FOR_FXT) - list(APPEND STARPU_COMPONENT_LIST "FXT") - endif() - if (CHAMELEON_FIND_REQUIRED AND CHAMELEON_FIND_REQUIRED_STARPU) - find_package(STARPU ${CHAMELEON_STARPU_VERSION} REQUIRED - COMPONENTS ${STARPU_COMPONENT_LIST}) - else() - find_package(STARPU ${CHAMELEON_STARPU_VERSION} - COMPONENTS ${STARPU_COMPONENT_LIST}) - endif() - - endif() - - if( NOT QUARK_FOUND AND CHAMELEON_LOOK_FOR_QUARK ) - - # try to find quark runtime - if (CHAMELEON_FIND_REQUIRED AND CHAMELEON_FIND_REQUIRED_QUARK) - find_package(QUARK REQUIRED COMPONENTS HWLOC) - else() - find_package(QUARK COMPONENTS HWLOC) - endif() - - endif() - - # Looking for include - # ------------------- - - # Add system include paths to search include - # ------------------------------------------ - unset(_inc_env) - set(ENV_CHAMELEON_DIR "$ENV{CHAMELEON_DIR}") - set(ENV_CHAMELEON_INCDIR "$ENV{CHAMELEON_INCDIR}") - if(ENV_CHAMELEON_INCDIR) - list(APPEND _inc_env "${ENV_CHAMELEON_INCDIR}") - elseif(ENV_CHAMELEON_DIR) - list(APPEND _inc_env "${ENV_CHAMELEON_DIR}") - list(APPEND _inc_env "${ENV_CHAMELEON_DIR}/include") - list(APPEND _inc_env "${ENV_CHAMELEON_DIR}/include/chameleon") + find_package(STARPU ${CHAMELEON_STARPU_VERSION} + COMPONENTS ${STARPU_COMPONENT_LIST}) + endif() + + endif() + + if( NOT QUARK_FOUND AND CHAMELEON_LOOK_FOR_QUARK ) + + # try to find quark runtime + if (CHAMELEON_FIND_REQUIRED AND CHAMELEON_FIND_REQUIRED_QUARK) + find_package(QUARK REQUIRED COMPONENTS HWLOC) else() - if(WIN32) - string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") - else() - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{CPATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - endif() - endif() - list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") - list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") - list(REMOVE_DUPLICATES _inc_env) - - - # Try to find the chameleon header in the given paths - # --------------------------------------------------- - # call cmake macro to find the header path - if(CHAMELEON_INCDIR) - set(CHAMELEON_morse.h_DIRS "CHAMELEON_morse.h_DIRS-NOTFOUND") - find_path(CHAMELEON_morse.h_DIRS - NAMES morse.h - HINTS ${CHAMELEON_INCDIR}) + find_package(QUARK COMPONENTS HWLOC) + endif() + + endif() + + # Looking for include + # ------------------- + + # Add system include paths to search include + # ------------------------------------------ + unset(_inc_env) + set(ENV_CHAMELEON_DIR "$ENV{CHAMELEON_DIR}") + set(ENV_CHAMELEON_INCDIR "$ENV{CHAMELEON_INCDIR}") + if(ENV_CHAMELEON_INCDIR) + list(APPEND _inc_env "${ENV_CHAMELEON_INCDIR}") + elseif(ENV_CHAMELEON_DIR) + list(APPEND _inc_env "${ENV_CHAMELEON_DIR}") + list(APPEND _inc_env "${ENV_CHAMELEON_DIR}/include") + list(APPEND _inc_env "${ENV_CHAMELEON_DIR}/include/chameleon") + else() + if(WIN32) + string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") else() - if(CHAMELEON_DIR) - set(CHAMELEON_morse.h_DIRS "CHAMELEON_morse.h_DIRS-NOTFOUND") - find_path(CHAMELEON_morse.h_DIRS - NAMES morse.h - HINTS ${CHAMELEON_DIR} - PATH_SUFFIXES "include" "include/chameleon") - else() - set(CHAMELEON_morse.h_DIRS "CHAMELEON_morse.h_DIRS-NOTFOUND") - find_path(CHAMELEON_morse.h_DIRS - NAMES morse.h - HINTS ${_inc_env} - PATH_SUFFIXES "chameleon") - endif() - endif() - mark_as_advanced(CHAMELEON_morse.h_DIRS) - - # If found, add path to cmake variable - # ------------------------------------ - if (CHAMELEON_morse.h_DIRS) - set(CHAMELEON_INCLUDE_DIRS "${CHAMELEON_morse.h_DIRS}") - else () - set(CHAMELEON_INCLUDE_DIRS "CHAMELEON_INCLUDE_DIRS-NOTFOUND") - if(NOT CHAMELEON_FIND_QUIETLY) - message(STATUS "Looking for chameleon -- morse.h not found") - endif() - endif() - - - # Looking for lib - # --------------- - - # Add system library paths to search lib - # -------------------------------------- - unset(_lib_env) - set(ENV_CHAMELEON_LIBDIR "$ENV{CHAMELEON_LIBDIR}") - if(ENV_CHAMELEON_LIBDIR) - list(APPEND _lib_env "${ENV_CHAMELEON_LIBDIR}") - elseif(ENV_CHAMELEON_DIR) - list(APPEND _lib_env "${ENV_CHAMELEON_DIR}") - list(APPEND _lib_env "${ENV_CHAMELEON_DIR}/lib") + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{CPATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + endif() + endif() + list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") + list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") + list(REMOVE_DUPLICATES _inc_env) + + + # Try to find the chameleon header in the given paths + # --------------------------------------------------- + # call cmake macro to find the header path + if(CHAMELEON_INCDIR) + set(CHAMELEON_morse.h_DIRS "CHAMELEON_morse.h_DIRS-NOTFOUND") + find_path(CHAMELEON_morse.h_DIRS + NAMES morse.h + HINTS ${CHAMELEON_INCDIR}) + else() + if(CHAMELEON_DIR) + set(CHAMELEON_morse.h_DIRS "CHAMELEON_morse.h_DIRS-NOTFOUND") + find_path(CHAMELEON_morse.h_DIRS + NAMES morse.h + HINTS ${CHAMELEON_DIR} + PATH_SUFFIXES "include" "include/chameleon") else() - if(WIN32) - string(REPLACE ":" ";" _lib_env "$ENV{LIB}") - else() - if(APPLE) - string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - endif() - endif() - list(REMOVE_DUPLICATES _lib_env) - - # Try to find the chameleon lib in the given paths - # ------------------------------------------------ - - # create list of libs to find - set(CHAMELEON_libs_to_find "chameleon") - if (STARPU_FOUND) - list(APPEND CHAMELEON_libs_to_find "chameleon_starpu") - elseif (QUARK_FOUND) - list(APPEND CHAMELEON_libs_to_find "chameleon_quark") - endif() - list(APPEND CHAMELEON_libs_to_find "coreblas") - - # call cmake macro to find the lib path - if(CHAMELEON_LIBDIR) - foreach(chameleon_lib ${CHAMELEON_libs_to_find}) - set(CHAMELEON_${chameleon_lib}_LIBRARY "CHAMELEON_${chameleon_lib}_LIBRARY-NOTFOUND") - find_library(CHAMELEON_${chameleon_lib}_LIBRARY - NAMES ${chameleon_lib} - HINTS ${CHAMELEON_LIBDIR}) - endforeach() + set(CHAMELEON_morse.h_DIRS "CHAMELEON_morse.h_DIRS-NOTFOUND") + find_path(CHAMELEON_morse.h_DIRS + NAMES morse.h + HINTS ${_inc_env} + PATH_SUFFIXES "chameleon") + endif() + endif() + mark_as_advanced(CHAMELEON_morse.h_DIRS) + + # If found, add path to cmake variable + # ------------------------------------ + if (CHAMELEON_morse.h_DIRS) + set(CHAMELEON_INCLUDE_DIRS "${CHAMELEON_morse.h_DIRS}") + else () + set(CHAMELEON_INCLUDE_DIRS "CHAMELEON_INCLUDE_DIRS-NOTFOUND") + if(NOT CHAMELEON_FIND_QUIETLY) + message(STATUS "Looking for chameleon -- morse.h not found") + endif() + endif() + + + # Looking for lib + # --------------- + + # Add system library paths to search lib + # -------------------------------------- + unset(_lib_env) + set(ENV_CHAMELEON_LIBDIR "$ENV{CHAMELEON_LIBDIR}") + if(ENV_CHAMELEON_LIBDIR) + list(APPEND _lib_env "${ENV_CHAMELEON_LIBDIR}") + elseif(ENV_CHAMELEON_DIR) + list(APPEND _lib_env "${ENV_CHAMELEON_DIR}") + list(APPEND _lib_env "${ENV_CHAMELEON_DIR}/lib") + else() + if(WIN32) + string(REPLACE ":" ";" _lib_env "$ENV{LIB}") else() - if(CHAMELEON_DIR) - foreach(chameleon_lib ${CHAMELEON_libs_to_find}) - set(CHAMELEON_${chameleon_lib}_LIBRARY "CHAMELEON_${chameleon_lib}_LIBRARY-NOTFOUND") - find_library(CHAMELEON_${chameleon_lib}_LIBRARY - NAMES ${chameleon_lib} - HINTS ${CHAMELEON_DIR} - PATH_SUFFIXES lib lib32 lib64) - endforeach() - else() - foreach(chameleon_lib ${CHAMELEON_libs_to_find}) - set(CHAMELEON_${chameleon_lib}_LIBRARY "CHAMELEON_${chameleon_lib}_LIBRARY-NOTFOUND") - find_library(CHAMELEON_${chameleon_lib}_LIBRARY - NAMES ${chameleon_lib} - HINTS ${_lib_env}) - endforeach() - endif() - endif() - - # If found, add path to cmake variable - # ------------------------------------ + if(APPLE) + string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") + else() + string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") + endif() + list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") + list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + endif() + endif() + list(REMOVE_DUPLICATES _lib_env) + + # Try to find the chameleon lib in the given paths + # ------------------------------------------------ + + # create list of libs to find + set(CHAMELEON_libs_to_find "chameleon") + if (STARPU_FOUND) + list(APPEND CHAMELEON_libs_to_find "chameleon_starpu") + elseif (QUARK_FOUND) + list(APPEND CHAMELEON_libs_to_find "chameleon_quark") + endif() + list(APPEND CHAMELEON_libs_to_find "coreblas") + + # call cmake macro to find the lib path + if(CHAMELEON_LIBDIR) foreach(chameleon_lib ${CHAMELEON_libs_to_find}) + set(CHAMELEON_${chameleon_lib}_LIBRARY "CHAMELEON_${chameleon_lib}_LIBRARY-NOTFOUND") + find_library(CHAMELEON_${chameleon_lib}_LIBRARY + NAMES ${chameleon_lib} + HINTS ${CHAMELEON_LIBDIR}) + endforeach() + else() + if(CHAMELEON_DIR) + foreach(chameleon_lib ${CHAMELEON_libs_to_find}) + set(CHAMELEON_${chameleon_lib}_LIBRARY "CHAMELEON_${chameleon_lib}_LIBRARY-NOTFOUND") + find_library(CHAMELEON_${chameleon_lib}_LIBRARY + NAMES ${chameleon_lib} + HINTS ${CHAMELEON_DIR} + PATH_SUFFIXES lib lib32 lib64) + endforeach() + else() + foreach(chameleon_lib ${CHAMELEON_libs_to_find}) + set(CHAMELEON_${chameleon_lib}_LIBRARY "CHAMELEON_${chameleon_lib}_LIBRARY-NOTFOUND") + find_library(CHAMELEON_${chameleon_lib}_LIBRARY + NAMES ${chameleon_lib} + HINTS ${_lib_env}) + endforeach() + endif() + endif() - get_filename_component(${chameleon_lib}_lib_path ${CHAMELEON_${chameleon_lib}_LIBRARY} PATH) - # set cmake variables (respects naming convention) - if (CHAMELEON_LIBRARIES) - list(APPEND CHAMELEON_LIBRARIES "${CHAMELEON_${chameleon_lib}_LIBRARY}") - else() - set(CHAMELEON_LIBRARIES "${CHAMELEON_${chameleon_lib}_LIBRARY}") - endif() - if (CHAMELEON_LIBRARY_DIRS) - list(APPEND CHAMELEON_LIBRARY_DIRS "${${chameleon_lib}_lib_path}") - else() - set(CHAMELEON_LIBRARY_DIRS "${${chameleon_lib}_lib_path}") - endif() - mark_as_advanced(CHAMELEON_${chameleon_lib}_LIBRARY) - - endforeach(chameleon_lib ${CHAMELEON_libs_to_find}) - - # check a function to validate the find - if(CHAMELEON_LIBRARIES) - - set(REQUIRED_LDFLAGS) - set(REQUIRED_INCDIRS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) - - # CHAMELEON - if (CHAMELEON_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${CHAMELEON_INCLUDE_DIRS}") - endif() - foreach(libdir ${CHAMELEON_LIBRARY_DIRS}) - if (libdir) - list(APPEND REQUIRED_LIBDIRS "${libdir}") - endif() - endforeach() - set(REQUIRED_LIBS "${CHAMELEON_LIBRARIES}") - # STARPU - if (STARPU_FOUND AND CHAMELEON_LOOK_FOR_STARPU) - if (STARPU_INCLUDE_DIRS_DEP) - list(APPEND REQUIRED_INCDIRS "${STARPU_INCLUDE_DIRS_DEP}") - elseif (STARPU_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${STARPU_INCLUDE_DIRS}") - endif() - if(STARPU_LIBRARY_DIRS_DEP) - list(APPEND REQUIRED_LIBDIRS "${STARPU_LIBRARY_DIRS_DEP}") - elseif(STARPU_LIBRARY_DIRS) - list(APPEND REQUIRED_LIBDIRS "${STARPU_LIBRARY_DIRS}") - endif() - if (STARPU_LIBRARIES_DEP) - list(APPEND REQUIRED_LIBS "${STARPU_LIBRARIES_DEP}") - elseif (STARPU_LIBRARIES) - foreach(lib ${STARPU_LIBRARIES}) - if (EXISTS ${lib} OR ${lib} MATCHES "^-") - list(APPEND REQUIRED_LIBS "${lib}") - else() - list(APPEND REQUIRED_LIBS "-l${lib}") - endif() - endforeach() - endif() - endif() - # QUARK - if (QUARK_FOUND AND CHAMELEON_LOOK_FOR_QUARK) - if (QUARK_INCLUDE_DIRS_DEP) - list(APPEND REQUIRED_INCDIRS "${QUARK_INCLUDE_DIRS_DEP}") - elseif(QUARK_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${QUARK_INCLUDE_DIRS}") - endif() - if(QUARK_LIBRARY_DIRS_DEP) - list(APPEND REQUIRED_LIBDIRS "${QUARK_LIBRARY_DIRS_DEP}") - elseif(QUARK_LIBRARY_DIRS) - list(APPEND REQUIRED_LIBDIRS "${QUARK_LIBRARY_DIRS}") - endif() - if (QUARK_LIBRARY_DIRS_DEP) - list(APPEND REQUIRED_LIBS "${QUARK_LIBRARIES_DEP}") - elseif (QUARK_LIBRARY_DIRS_DEP) - list(APPEND REQUIRED_LIBS "${QUARK_LIBRARIES}") - endif() - endif() - # CUDA - if (CUDA_FOUND AND CHAMELEON_LOOK_FOR_CUDA) - if (CUDA_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${CUDA_INCLUDE_DIRS}") - endif() - foreach(libdir ${CUDA_LIBRARY_DIRS}) - if (libdir) - list(APPEND REQUIRED_LIBDIRS "${libdir}") - endif() - endforeach() - list(APPEND REQUIRED_LIBS "${CUDA_CUBLAS_LIBRARIES};${CUDA_LIBRARIES}") - endif() - # MAGMA - if (MAGMA_FOUND AND CHAMELEON_LOOK_FOR_MAGMA) - if (MAGMA_INCLUDE_DIRS_DEP) - list(APPEND REQUIRED_INCDIRS "${MAGMA_INCLUDE_DIRS_DEP}") - elseif(MAGMA_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${MAGMA_INCLUDE_DIRS}") - endif() - if (MAGMA_LIBRARY_DIRS_DEP) - list(APPEND REQUIRED_LIBDIRS "${MAGMA_LIBRARY_DIRS_DEP}") - elseif(MAGMA_LIBRARY_DIRS) - list(APPEND REQUIRED_LIBDIRS "${MAGMA_LIBRARY_DIRS}") - endif() - if (MAGMA_LIBRARIES_DEP) - list(APPEND REQUIRED_LIBS "${MAGMA_LIBRARIES_DEP}") - elseif(MAGMA_LIBRARIES) - foreach(lib ${MAGMA_LIBRARIES}) - if (EXISTS ${lib} OR ${lib} MATCHES "^-") - list(APPEND REQUIRED_LIBS "${lib}") - else() - list(APPEND REQUIRED_LIBS "-l${lib}") - endif() - endforeach() - endif() - endif() - # MPI - if (MPI_FOUND AND CHAMELEON_LOOK_FOR_MPI) - if (MPI_C_INCLUDE_PATH) - list(APPEND REQUIRED_INCDIRS "${MPI_C_INCLUDE_PATH}") - endif() - if (MPI_C_LINK_FLAGS) - if (${MPI_C_LINK_FLAGS} MATCHES " -") - string(REGEX REPLACE " -" "-" MPI_C_LINK_FLAGS ${MPI_C_LINK_FLAGS}) - endif() - list(APPEND REQUIRED_LDFLAGS "${MPI_C_LINK_FLAGS}") - endif() - list(APPEND REQUIRED_LIBS "${MPI_C_LIBRARIES}") - endif() - # HWLOC - if (HWLOC_FOUND) - if (HWLOC_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${HWLOC_INCLUDE_DIRS}") - endif() - foreach(libdir ${HWLOC_LIBRARY_DIRS}) - if (libdir) - list(APPEND REQUIRED_LIBDIRS "${libdir}") - endif() - endforeach() - foreach(lib ${HWLOC_LIBRARIES}) - if (EXISTS ${lib} OR ${lib} MATCHES "^-") - list(APPEND REQUIRED_LIBS "${lib}") - else() - list(APPEND REQUIRED_LIBS "-l${lib}") - endif() - endforeach() - endif() - # TMG - if (TMG_FOUND) - if (TMG_INCLUDE_DIRS_DEP) - list(APPEND REQUIRED_INCDIRS "${TMG_INCLUDE_DIRS_DEP}") - elseif (TMG_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${TMG_INCLUDE_DIRS}") - endif() - if(TMG_LIBRARY_DIRS_DEP) - list(APPEND REQUIRED_LIBDIRS "${TMG_LIBRARY_DIRS_DEP}") - elseif(TMG_LIBRARY_DIRS) - list(APPEND REQUIRED_LIBDIRS "${TMG_LIBRARY_DIRS}") - endif() - if (TMG_LIBRARIES_DEP) - list(APPEND REQUIRED_LIBS "${TMG_LIBRARIES_DEP}") - 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) - if (LAPACKE_INCLUDE_DIRS_DEP) - list(APPEND REQUIRED_INCDIRS "${LAPACKE_INCLUDE_DIRS_DEP}") - elseif (LAPACKE_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${LAPACKE_INCLUDE_DIRS}") - endif() - if(LAPACKE_LIBRARY_DIRS_DEP) - list(APPEND REQUIRED_LIBDIRS "${LAPACKE_LIBRARY_DIRS_DEP}") - elseif(LAPACKE_LIBRARY_DIRS) - list(APPEND REQUIRED_LIBDIRS "${LAPACKE_LIBRARY_DIRS}") - endif() - if (LAPACKE_LIBRARIES_DEP) - list(APPEND REQUIRED_LIBS "${LAPACKE_LIBRARIES_DEP}") - 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) - if (CBLAS_INCLUDE_DIRS_DEP) - list(APPEND REQUIRED_INCDIRS "${CBLAS_INCLUDE_DIRS_DEP}") - elseif (CBLAS_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${CBLAS_INCLUDE_DIRS}") - endif() - if(CBLAS_LIBRARY_DIRS_DEP) - list(APPEND REQUIRED_LIBDIRS "${CBLAS_LIBRARY_DIRS_DEP}") - elseif(CBLAS_LIBRARY_DIRS) - list(APPEND REQUIRED_LIBDIRS "${CBLAS_LIBRARY_DIRS}") - endif() - if (CBLAS_LIBRARIES_DEP) - list(APPEND REQUIRED_LIBS "${CBLAS_LIBRARIES_DEP}") - 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}) - - # 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}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - - # test link - unset(CHAMELEON_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(MORSE_Init CHAMELEON_WORKS) - mark_as_advanced(CHAMELEON_WORKS) - - if(CHAMELEON_WORKS) - # save link with dependencies - 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") - message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") - message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") - message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") - message(STATUS "Maybe CHAMELEON is linked with specific libraries. " - "Have you tried with COMPONENTS (STARPU/QUARK, CUDA, MAGMA, MPI, FXT)? " - "See the explanation in FindCHAMELEON.cmake.") - endif() - endif() - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_LIBRARIES) - endif(CHAMELEON_LIBRARIES) - -endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR (CHAMELEON_GIVEN_BY_USER) ) + # If found, add path to cmake variable + # ------------------------------------ + foreach(chameleon_lib ${CHAMELEON_libs_to_find}) -if (CHAMELEON_LIBRARIES) + get_filename_component(${chameleon_lib}_lib_path ${CHAMELEON_${chameleon_lib}_LIBRARY} PATH) + # set cmake variables (respects naming convention) + if (CHAMELEON_LIBRARIES) + list(APPEND CHAMELEON_LIBRARIES "${CHAMELEON_${chameleon_lib}_LIBRARY}") + else() + set(CHAMELEON_LIBRARIES "${CHAMELEON_${chameleon_lib}_LIBRARY}") + endif() if (CHAMELEON_LIBRARY_DIRS) - foreach(dir ${CHAMELEON_LIBRARY_DIRS}) - if ("${dir}" MATCHES "chameleon") - set(first_lib_path "${dir}") - endif() - endforeach() + list(APPEND CHAMELEON_LIBRARY_DIRS "${${chameleon_lib}_lib_path}") else() - list(GET CHAMELEON_LIBRARIES 0 first_lib) - get_filename_component(first_lib_path "${first_lib}" PATH) + set(CHAMELEON_LIBRARY_DIRS "${${chameleon_lib}_lib_path}") + endif() + mark_as_advanced(CHAMELEON_${chameleon_lib}_LIBRARY) + + endforeach(chameleon_lib ${CHAMELEON_libs_to_find}) + + # check a function to validate the find + if(CHAMELEON_LIBRARIES) + + set(REQUIRED_LDFLAGS) + set(REQUIRED_INCDIRS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) + + # CHAMELEON + if (CHAMELEON_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${CHAMELEON_INCLUDE_DIRS}") endif() - if (${first_lib_path} MATCHES "/lib(32|64)?$") - string(REGEX REPLACE "/lib(32|64)?$" "" not_cached_dir "${first_lib_path}") - set(CHAMELEON_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of CHAMELEON library" FORCE) + foreach(libdir ${CHAMELEON_LIBRARY_DIRS}) + if (libdir) + list(APPEND REQUIRED_LIBDIRS "${libdir}") + endif() + endforeach() + set(REQUIRED_LIBS "${CHAMELEON_LIBRARIES}") + # STARPU + if (STARPU_FOUND AND CHAMELEON_LOOK_FOR_STARPU) + if (STARPU_INCLUDE_DIRS_DEP) + list(APPEND REQUIRED_INCDIRS "${STARPU_INCLUDE_DIRS_DEP}") + elseif (STARPU_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${STARPU_INCLUDE_DIRS}") + endif() + if(STARPU_LIBRARY_DIRS_DEP) + list(APPEND REQUIRED_LIBDIRS "${STARPU_LIBRARY_DIRS_DEP}") + elseif(STARPU_LIBRARY_DIRS) + list(APPEND REQUIRED_LIBDIRS "${STARPU_LIBRARY_DIRS}") + endif() + if (STARPU_LIBRARIES_DEP) + list(APPEND REQUIRED_LIBS "${STARPU_LIBRARIES_DEP}") + elseif (STARPU_LIBRARIES) + foreach(lib ${STARPU_LIBRARIES}) + if (EXISTS ${lib} OR ${lib} MATCHES "^-") + list(APPEND REQUIRED_LIBS "${lib}") + else() + list(APPEND REQUIRED_LIBS "-l${lib}") + endif() + endforeach() + endif() + endif() + # QUARK + if (QUARK_FOUND AND CHAMELEON_LOOK_FOR_QUARK) + if (QUARK_INCLUDE_DIRS_DEP) + list(APPEND REQUIRED_INCDIRS "${QUARK_INCLUDE_DIRS_DEP}") + elseif(QUARK_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${QUARK_INCLUDE_DIRS}") + endif() + if(QUARK_LIBRARY_DIRS_DEP) + list(APPEND REQUIRED_LIBDIRS "${QUARK_LIBRARY_DIRS_DEP}") + elseif(QUARK_LIBRARY_DIRS) + list(APPEND REQUIRED_LIBDIRS "${QUARK_LIBRARY_DIRS}") + endif() + if (QUARK_LIBRARY_DIRS_DEP) + list(APPEND REQUIRED_LIBS "${QUARK_LIBRARIES_DEP}") + elseif (QUARK_LIBRARY_DIRS_DEP) + list(APPEND REQUIRED_LIBS "${QUARK_LIBRARIES}") + endif() + endif() + # CUDA + if (CUDA_FOUND AND CHAMELEON_LOOK_FOR_CUDA) + if (CUDA_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${CUDA_INCLUDE_DIRS}") + endif() + foreach(libdir ${CUDA_LIBRARY_DIRS}) + if (libdir) + list(APPEND REQUIRED_LIBDIRS "${libdir}") + endif() + endforeach() + list(APPEND REQUIRED_LIBS "${CUDA_CUBLAS_LIBRARIES};${CUDA_LIBRARIES}") + endif() + # MAGMA + if (MAGMA_FOUND AND CHAMELEON_LOOK_FOR_MAGMA) + if (MAGMA_INCLUDE_DIRS_DEP) + list(APPEND REQUIRED_INCDIRS "${MAGMA_INCLUDE_DIRS_DEP}") + elseif(MAGMA_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${MAGMA_INCLUDE_DIRS}") + endif() + if (MAGMA_LIBRARY_DIRS_DEP) + list(APPEND REQUIRED_LIBDIRS "${MAGMA_LIBRARY_DIRS_DEP}") + elseif(MAGMA_LIBRARY_DIRS) + list(APPEND REQUIRED_LIBDIRS "${MAGMA_LIBRARY_DIRS}") + endif() + if (MAGMA_LIBRARIES_DEP) + list(APPEND REQUIRED_LIBS "${MAGMA_LIBRARIES_DEP}") + elseif(MAGMA_LIBRARIES) + foreach(lib ${MAGMA_LIBRARIES}) + if (EXISTS ${lib} OR ${lib} MATCHES "^-") + list(APPEND REQUIRED_LIBS "${lib}") + else() + list(APPEND REQUIRED_LIBS "-l${lib}") + endif() + endforeach() + endif() + endif() + # MPI + if (MPI_FOUND AND CHAMELEON_LOOK_FOR_MPI) + if (MPI_C_INCLUDE_PATH) + list(APPEND REQUIRED_INCDIRS "${MPI_C_INCLUDE_PATH}") + endif() + if (MPI_C_LINK_FLAGS) + if (${MPI_C_LINK_FLAGS} MATCHES " -") + string(REGEX REPLACE " -" "-" MPI_C_LINK_FLAGS ${MPI_C_LINK_FLAGS}) + endif() + list(APPEND REQUIRED_LDFLAGS "${MPI_C_LINK_FLAGS}") + endif() + list(APPEND REQUIRED_LIBS "${MPI_C_LIBRARIES}") + endif() + # HWLOC + if (HWLOC_FOUND) + if (HWLOC_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${HWLOC_INCLUDE_DIRS}") + endif() + foreach(libdir ${HWLOC_LIBRARY_DIRS}) + if (libdir) + list(APPEND REQUIRED_LIBDIRS "${libdir}") + endif() + endforeach() + foreach(lib ${HWLOC_LIBRARIES}) + if (EXISTS ${lib} OR ${lib} MATCHES "^-") + list(APPEND REQUIRED_LIBS "${lib}") + else() + list(APPEND REQUIRED_LIBS "-l${lib}") + endif() + endforeach() + endif() + # TMG + if (TMG_FOUND) + if (TMG_INCLUDE_DIRS_DEP) + list(APPEND REQUIRED_INCDIRS "${TMG_INCLUDE_DIRS_DEP}") + elseif (TMG_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${TMG_INCLUDE_DIRS}") + endif() + if(TMG_LIBRARY_DIRS_DEP) + list(APPEND REQUIRED_LIBDIRS "${TMG_LIBRARY_DIRS_DEP}") + elseif(TMG_LIBRARY_DIRS) + list(APPEND REQUIRED_LIBDIRS "${TMG_LIBRARY_DIRS}") + endif() + if (TMG_LIBRARIES_DEP) + list(APPEND REQUIRED_LIBS "${TMG_LIBRARIES_DEP}") + 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) + if (LAPACKE_INCLUDE_DIRS_DEP) + list(APPEND REQUIRED_INCDIRS "${LAPACKE_INCLUDE_DIRS_DEP}") + elseif (LAPACKE_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${LAPACKE_INCLUDE_DIRS}") + endif() + if(LAPACKE_LIBRARY_DIRS_DEP) + list(APPEND REQUIRED_LIBDIRS "${LAPACKE_LIBRARY_DIRS_DEP}") + elseif(LAPACKE_LIBRARY_DIRS) + list(APPEND REQUIRED_LIBDIRS "${LAPACKE_LIBRARY_DIRS}") + endif() + if (LAPACKE_LIBRARIES_DEP) + list(APPEND REQUIRED_LIBS "${LAPACKE_LIBRARIES_DEP}") + 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) + if (CBLAS_INCLUDE_DIRS_DEP) + list(APPEND REQUIRED_INCDIRS "${CBLAS_INCLUDE_DIRS_DEP}") + elseif (CBLAS_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${CBLAS_INCLUDE_DIRS}") + endif() + if(CBLAS_LIBRARY_DIRS_DEP) + list(APPEND REQUIRED_LIBDIRS "${CBLAS_LIBRARY_DIRS_DEP}") + elseif(CBLAS_LIBRARY_DIRS) + list(APPEND REQUIRED_LIBDIRS "${CBLAS_LIBRARY_DIRS}") + endif() + if (CBLAS_LIBRARIES_DEP) + list(APPEND REQUIRED_LIBS "${CBLAS_LIBRARIES_DEP}") + 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}) + + # 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}") + string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + + # test link + unset(CHAMELEON_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(MORSE_Init CHAMELEON_WORKS) + mark_as_advanced(CHAMELEON_WORKS) + + if(CHAMELEON_WORKS) + # save link with dependencies + 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() - set(CHAMELEON_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of CHAMELEON library" FORCE) + if(NOT CHAMELEON_FIND_QUIETLY) + message(STATUS "Looking for chameleon : test of MORSE_Init fails") + message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") + message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") + message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") + message(STATUS "Maybe CHAMELEON is linked with specific libraries. " + "Have you tried with COMPONENTS (STARPU/QUARK, CUDA, MAGMA, MPI, FXT)? " + "See the explanation in FindCHAMELEON.cmake.") + endif() endif() + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) + endif(CHAMELEON_LIBRARIES) + +endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR (CHAMELEON_GIVEN_BY_USER) ) + +if (CHAMELEON_LIBRARIES) + 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_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of CHAMELEON library" FORCE) + else() + set(CHAMELEON_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of CHAMELEON library" FORCE) + endif() endif() mark_as_advanced(CHAMELEON_DIR) mark_as_advanced(CHAMELEON_DIR_FOUND) @@ -791,10 +791,10 @@ mark_as_advanced(CHAMELEON_DIR_FOUND) # --------------------------------- include(FindPackageHandleStandardArgs) if (PKG_CONFIG_EXECUTABLE AND CHAMELEON_FOUND) - find_package_handle_standard_args(CHAMELEON DEFAULT_MSG - CHAMELEON_LIBRARIES) + find_package_handle_standard_args(CHAMELEON DEFAULT_MSG + CHAMELEON_LIBRARIES) else() - find_package_handle_standard_args(CHAMELEON DEFAULT_MSG - CHAMELEON_LIBRARIES - CHAMELEON_WORKS) + find_package_handle_standard_args(CHAMELEON DEFAULT_MSG + CHAMELEON_LIBRARIES + CHAMELEON_WORKS) endif() diff --git a/CMakeModules/morse/find/FindEZTRACE.cmake b/CMakeModules/morse/find/FindEZTRACE.cmake index 663dceed33d4c942f37bfc29ad2dfe37177c1a59..7584c5e9f7f2d9ba42a272593134a1126c08d0f2 100644 --- a/CMakeModules/morse/find/FindEZTRACE.cmake +++ b/CMakeModules/morse/find/FindEZTRACE.cmake @@ -50,10 +50,10 @@ # License text for the above reference.) if (NOT EZTRACE_FOUND) - set(EZTRACE_DIR "" CACHE PATH "Installation directory of EZTRACE library") - if (NOT EZTRACE_FIND_QUIETLY) - message(STATUS "A cache variable, namely EZTRACE_DIR, has been set to specify the install directory of EZTRACE") - endif() + set(EZTRACE_DIR "" CACHE PATH "Installation directory of EZTRACE library") + if (NOT EZTRACE_FIND_QUIETLY) + message(STATUS "A cache variable, namely EZTRACE_DIR, has been set to specify the install directory of EZTRACE") + endif() endif() set(ENV_EZTRACE_DIR "$ENV{EZTRACE_DIR}") @@ -61,7 +61,7 @@ set(ENV_EZTRACE_INCDIR "$ENV{EZTRACE_INCDIR}") set(ENV_EZTRACE_LIBDIR "$ENV{EZTRACE_LIBDIR}") set(EZTRACE_GIVEN_BY_USER "FALSE") if ( EZTRACE_DIR OR ( EZTRACE_INCDIR AND EZTRACE_LIBDIR) OR ENV_EZTRACE_DIR OR (ENV_EZTRACE_INCDIR AND ENV_EZTRACE_LIBDIR) ) - set(EZTRACE_GIVEN_BY_USER "TRUE") + set(EZTRACE_GIVEN_BY_USER "TRUE") endif() # Optionally use pkg-config to detect include/library dirs (if pkg-config is available) @@ -70,274 +70,274 @@ include(FindPkgConfig) find_package(PkgConfig QUIET) if( PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_GIVEN_BY_USER ) - pkg_search_module(EZTRACE eztrace) - if (NOT EZTRACE_FIND_QUIETLY) - if (EZTRACE_FOUND AND EZTRACE_LIBRARIES) - message(STATUS "Looking for EZTRACE - found using PkgConfig") - #if(NOT EZTRACE_INCLUDE_DIRS) - # message("${Magenta}EZTRACE_INCLUDE_DIRS is empty using PkgConfig." - # "Perhaps the path to eztrace headers is already present in your" - # "C(PLUS)_INCLUDE_PATH environment variable.${ColourReset}") - #endif() - else() - message(STATUS "${Magenta}Looking for EZTRACE - not found using PkgConfig." - "\n Perhaps you should add the directory containing eztrace.pc to" - "\n the PKG_CONFIG_PATH environment variable.${ColourReset}") - endif() + pkg_search_module(EZTRACE eztrace) + if (NOT EZTRACE_FIND_QUIETLY) + if (EZTRACE_FOUND AND EZTRACE_LIBRARIES) + message(STATUS "Looking for EZTRACE - found using PkgConfig") + #if(NOT EZTRACE_INCLUDE_DIRS) + # message("${Magenta}EZTRACE_INCLUDE_DIRS is empty using PkgConfig." + # "Perhaps the path to eztrace headers is already present in your" + # "C(PLUS)_INCLUDE_PATH environment variable.${ColourReset}") + #endif() + else() + message(STATUS "${Magenta}Looking for EZTRACE - not found using PkgConfig." + "\n Perhaps you should add the directory containing eztrace.pc to" + "\n the PKG_CONFIG_PATH environment variable.${ColourReset}") endif() + endif() endif( PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_GIVEN_BY_USER ) if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_FOUND) OR (EZTRACE_GIVEN_BY_USER) ) - if (NOT EZTRACE_FIND_QUIETLY) - message(STATUS "Looking for EZTRACE - PkgConfig not used") + if (NOT EZTRACE_FIND_QUIETLY) + message(STATUS "Looking for EZTRACE - PkgConfig not used") + endif() + + # Looking for libbfd + # ------------------ + + # Add system library paths to search lib + # -------------------------------------- + unset(_lib_env) + if(WIN32) + string(REPLACE ":" ";" _lib_env "$ENV{LIB}") + else() + if(APPLE) + string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") + else() + string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") + endif() + list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") + list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + endif() + list(REMOVE_DUPLICATES _lib_env) + + # set paths where to look for + set(PATH_TO_LOOK_FOR "${_lib_env}") + + # Try to find the bfd lib in the given paths + # ------------------------------------------ + + # call cmake macro to find the lib path + set(EZTRACE_bfd_LIBRARY "EZTRACE_bfd_LIBRARY-NOTFOUND") + find_library(EZTRACE_bfd_LIBRARY + NAMES bfd + HINTS ${PATH_TO_LOOK_FOR}) + mark_as_advanced(EZTRACE_bfd_LIBRARY) + + if (NOT EZTRACE_bfd_LIBRARY) + if(NOT EZTRACE_FIND_QUIETLY) + message(STATUS "Looking for eztrace -- lib bfd not found") endif() + endif () + + # Looking for include + # ------------------- + + # Add system include paths to search include + # ------------------------------------------ + unset(_inc_env) + if(ENV_EZTRACE_INCDIR) + list(APPEND _inc_env "${ENV_EZTRACE_INCDIR}") + elseif(ENV_EZTRACE_DIR) + list(APPEND _inc_env "${ENV_EZTRACE_DIR}") + list(APPEND _inc_env "${ENV_EZTRACE_DIR}/include") + list(APPEND _inc_env "${ENV_EZTRACE_DIR}/include/eztrace") + else() + if(WIN32) + string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") + else() + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{CPATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + endif() + endif() + list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") + list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") + list(REMOVE_DUPLICATES _inc_env) + + # set paths where to look for + set(PATH_TO_LOOK_FOR "${_inc_env}") + + # Try to find the eztrace header in the given paths + # ------------------------------------------------- + # call cmake macro to find the header path + if(EZTRACE_INCDIR) + set(EZTRACE_eztrace.h_DIRS "EZTRACE_eztrace.h_DIRS-NOTFOUND") + find_path(EZTRACE_eztrace.h_DIRS + NAMES eztrace.h + HINTS ${EZTRACE_INCDIR}) + else() + if(EZTRACE_DIR) + set(EZTRACE_eztrace.h_DIRS "EZTRACE_eztrace.h_DIRS-NOTFOUND") + find_path(EZTRACE_eztrace.h_DIRS + NAMES eztrace.h + HINTS ${EZTRACE_DIR} + PATH_SUFFIXES "include" "include/eztrace") + else() + set(EZTRACE_eztrace.h_DIRS "EZTRACE_eztrace.h_DIRS-NOTFOUND") + find_path(EZTRACE_eztrace.h_DIRS + NAMES eztrace.h + HINTS ${PATH_TO_LOOK_FOR} + PATH_SUFFIXES "eztrace") + endif() + endif() + mark_as_advanced(EZTRACE_eztrace.h_DIRS) + + # Add path to cmake variable + # ------------------------------------ + if (EZTRACE_eztrace.h_DIRS) + set(EZTRACE_INCLUDE_DIRS "${EZTRACE_eztrace.h_DIRS}") + else () + set(EZTRACE_INCLUDE_DIRS "EZTRACE_INCLUDE_DIRS-NOTFOUND") + if(NOT EZTRACE_FIND_QUIETLY) + message(STATUS "Looking for eztrace -- eztrace.h not found") + endif() + endif () + + if (EZTRACE_INCLUDE_DIRS) + list(REMOVE_DUPLICATES EZTRACE_INCLUDE_DIRS) + endif () + - # Looking for libbfd - # ------------------ + # Looking for lib + # --------------- - # Add system library paths to search lib - # -------------------------------------- - unset(_lib_env) + # Add system library paths to search lib + # -------------------------------------- + unset(_lib_env) + if(ENV_EZTRACE_LIBDIR) + list(APPEND _lib_env "${ENV_EZTRACE_LIBDIR}") + elseif(ENV_EZTRACE_DIR) + list(APPEND _lib_env "${ENV_EZTRACE_DIR}") + list(APPEND _lib_env "${ENV_EZTRACE_DIR}/lib") + else() if(WIN32) string(REPLACE ":" ";" _lib_env "$ENV{LIB}") else() if(APPLE) - string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") + string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") else() - string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") + string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") endif() list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") endif() - list(REMOVE_DUPLICATES _lib_env) - - # set paths where to look for - set(PATH_TO_LOOK_FOR "${_lib_env}") - - # Try to find the bfd lib in the given paths - # ------------------------------------------ - - # call cmake macro to find the lib path - set(EZTRACE_bfd_LIBRARY "EZTRACE_bfd_LIBRARY-NOTFOUND") - find_library(EZTRACE_bfd_LIBRARY - NAMES bfd - HINTS ${PATH_TO_LOOK_FOR}) - mark_as_advanced(EZTRACE_bfd_LIBRARY) - - if (NOT EZTRACE_bfd_LIBRARY) - if(NOT EZTRACE_FIND_QUIETLY) - message(STATUS "Looking for eztrace -- lib bfd not found") - endif() - endif () - - # Looking for include - # ------------------- - - # Add system include paths to search include - # ------------------------------------------ - unset(_inc_env) - if(ENV_EZTRACE_INCDIR) - list(APPEND _inc_env "${ENV_EZTRACE_INCDIR}") - elseif(ENV_EZTRACE_DIR) - list(APPEND _inc_env "${ENV_EZTRACE_DIR}") - list(APPEND _inc_env "${ENV_EZTRACE_DIR}/include") - list(APPEND _inc_env "${ENV_EZTRACE_DIR}/include/eztrace") + endif() + list(REMOVE_DUPLICATES _lib_env) + + # set paths where to look for + set(PATH_TO_LOOK_FOR "${_lib_env}") + + # Try to find the eztrace lib in the given paths + # ---------------------------------------------- + + # call cmake macro to find the lib path + if(EZTRACE_LIBDIR) + set(EZTRACE_eztrace_LIBRARY "EZTRACE_eztrace_LIBRARY-NOTFOUND") + find_library(EZTRACE_eztrace_LIBRARY + NAMES eztrace + HINTS ${EZTRACE_LIBDIR}) + else() + if(EZTRACE_DIR) + set(EZTRACE_eztrace_LIBRARY "EZTRACE_eztrace_LIBRARY-NOTFOUND") + find_library(EZTRACE_eztrace_LIBRARY + NAMES eztrace + HINTS ${EZTRACE_DIR} + PATH_SUFFIXES lib lib32 lib64) else() - if(WIN32) - string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") - else() - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{CPATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - endif() + set(EZTRACE_eztrace_LIBRARY "EZTRACE_eztrace_LIBRARY-NOTFOUND") + find_library(EZTRACE_eztrace_LIBRARY + NAMES eztrace + HINTS ${PATH_TO_LOOK_FOR}) endif() - list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") - list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") - list(REMOVE_DUPLICATES _inc_env) - - # set paths where to look for - set(PATH_TO_LOOK_FOR "${_inc_env}") - - # Try to find the eztrace header in the given paths - # ------------------------------------------------- - # call cmake macro to find the header path - if(EZTRACE_INCDIR) - set(EZTRACE_eztrace.h_DIRS "EZTRACE_eztrace.h_DIRS-NOTFOUND") - find_path(EZTRACE_eztrace.h_DIRS - NAMES eztrace.h - HINTS ${EZTRACE_INCDIR}) - else() - if(EZTRACE_DIR) - set(EZTRACE_eztrace.h_DIRS "EZTRACE_eztrace.h_DIRS-NOTFOUND") - find_path(EZTRACE_eztrace.h_DIRS - NAMES eztrace.h - HINTS ${EZTRACE_DIR} - PATH_SUFFIXES "include" "include/eztrace") - else() - set(EZTRACE_eztrace.h_DIRS "EZTRACE_eztrace.h_DIRS-NOTFOUND") - find_path(EZTRACE_eztrace.h_DIRS - NAMES eztrace.h - HINTS ${PATH_TO_LOOK_FOR} - PATH_SUFFIXES "eztrace") - endif() + endif() + mark_as_advanced(EZTRACE_eztrace_LIBRARY) + + # If found, add path to cmake variable + # ------------------------------------ + if (EZTRACE_eztrace_LIBRARY) + get_filename_component(eztrace_lib_path ${EZTRACE_eztrace_LIBRARY} PATH) + # set cmake variables (respects naming convention) + set(EZTRACE_LIBRARIES "${EZTRACE_eztrace_LIBRARY}") + set(EZTRACE_LIBRARY_DIRS "${eztrace_lib_path}") + else () + set(EZTRACE_LIBRARIES "EZTRACE_LIBRARIES-NOTFOUND") + set(EZTRACE_LIBRARY_DIRS "EZTRACE_LIBRARY_DIRS-NOTFOUND") + if(NOT EZTRACE_FIND_QUIETLY) + message(STATUS "Looking for eztrace -- lib eztrace not found") endif() - mark_as_advanced(EZTRACE_eztrace.h_DIRS) - - # Add path to cmake variable - # ------------------------------------ - if (EZTRACE_eztrace.h_DIRS) - set(EZTRACE_INCLUDE_DIRS "${EZTRACE_eztrace.h_DIRS}") - else () - set(EZTRACE_INCLUDE_DIRS "EZTRACE_INCLUDE_DIRS-NOTFOUND") - if(NOT EZTRACE_FIND_QUIETLY) - message(STATUS "Looking for eztrace -- eztrace.h not found") - endif() - endif () - - if (EZTRACE_INCLUDE_DIRS) - list(REMOVE_DUPLICATES EZTRACE_INCLUDE_DIRS) - endif () + endif () + if (EZTRACE_LIBRARY_DIRS) + list(REMOVE_DUPLICATES EZTRACE_LIBRARY_DIRS) + endif () - # Looking for lib - # --------------- + # check a function to validate the find + if(EZTRACE_LIBRARIES) - # Add system library paths to search lib - # -------------------------------------- - unset(_lib_env) - if(ENV_EZTRACE_LIBDIR) - list(APPEND _lib_env "${ENV_EZTRACE_LIBDIR}") - elseif(ENV_EZTRACE_DIR) - list(APPEND _lib_env "${ENV_EZTRACE_DIR}") - list(APPEND _lib_env "${ENV_EZTRACE_DIR}/lib") - else() - if(WIN32) - string(REPLACE ":" ";" _lib_env "$ENV{LIB}") - else() - if(APPLE) - string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - endif() - endif() - list(REMOVE_DUPLICATES _lib_env) - - # set paths where to look for - set(PATH_TO_LOOK_FOR "${_lib_env}") - - # Try to find the eztrace lib in the given paths - # ---------------------------------------------- + set(REQUIRED_INCDIRS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) - # call cmake macro to find the lib path - if(EZTRACE_LIBDIR) - set(EZTRACE_eztrace_LIBRARY "EZTRACE_eztrace_LIBRARY-NOTFOUND") - find_library(EZTRACE_eztrace_LIBRARY - NAMES eztrace - HINTS ${EZTRACE_LIBDIR}) - else() - if(EZTRACE_DIR) - set(EZTRACE_eztrace_LIBRARY "EZTRACE_eztrace_LIBRARY-NOTFOUND") - find_library(EZTRACE_eztrace_LIBRARY - NAMES eztrace - HINTS ${EZTRACE_DIR} - PATH_SUFFIXES lib lib32 lib64) - else() - set(EZTRACE_eztrace_LIBRARY "EZTRACE_eztrace_LIBRARY-NOTFOUND") - find_library(EZTRACE_eztrace_LIBRARY - NAMES eztrace - HINTS ${PATH_TO_LOOK_FOR}) - endif() + # EZTRACE + if (EZTRACE_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${EZTRACE_INCLUDE_DIRS}") endif() - mark_as_advanced(EZTRACE_eztrace_LIBRARY) - - # If found, add path to cmake variable - # ------------------------------------ - if (EZTRACE_eztrace_LIBRARY) - get_filename_component(eztrace_lib_path ${EZTRACE_eztrace_LIBRARY} PATH) - # set cmake variables (respects naming convention) - set(EZTRACE_LIBRARIES "${EZTRACE_eztrace_LIBRARY}") - set(EZTRACE_LIBRARY_DIRS "${eztrace_lib_path}") - else () - set(EZTRACE_LIBRARIES "EZTRACE_LIBRARIES-NOTFOUND") - set(EZTRACE_LIBRARY_DIRS "EZTRACE_LIBRARY_DIRS-NOTFOUND") - if(NOT EZTRACE_FIND_QUIETLY) - message(STATUS "Looking for eztrace -- lib eztrace not found") - endif() - endif () - if (EZTRACE_LIBRARY_DIRS) - list(REMOVE_DUPLICATES EZTRACE_LIBRARY_DIRS) - endif () - - # check a function to validate the find - if(EZTRACE_LIBRARIES) - - set(REQUIRED_INCDIRS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) - - # EZTRACE - if (EZTRACE_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${EZTRACE_INCLUDE_DIRS}") - endif() - if (EZTRACE_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${EZTRACE_LIBRARY_DIRS}") - endif() - set(REQUIRED_LIBS "${EZTRACE_LIBRARIES}") - - # set required libraries for link - set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") - set(CMAKE_REQUIRED_LIBRARIES) - foreach(lib_dir ${REQUIRED_LIBDIRS}) - list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}") - endforeach() - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - - # test link - unset(EZTRACE_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(eztrace_start EZTRACE_WORKS) - mark_as_advanced(EZTRACE_WORKS) - - if(NOT EZTRACE_WORKS) - if(NOT EZTRACE_FIND_QUIETLY) - message(STATUS "Looking for eztrace : test of eztrace_topology_init with eztrace library fails") - message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") - message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") - message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") - endif() - endif() - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_LIBRARIES) - endif(EZTRACE_LIBRARIES) + set(REQUIRED_LIBDIRS "${EZTRACE_LIBRARY_DIRS}") + endif() + set(REQUIRED_LIBS "${EZTRACE_LIBRARIES}") + + # set required libraries for link + set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") + set(CMAKE_REQUIRED_LIBRARIES) + foreach(lib_dir ${REQUIRED_LIBDIRS}) + list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}") + endforeach() + list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") + string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + + # test link + unset(EZTRACE_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(eztrace_start EZTRACE_WORKS) + mark_as_advanced(EZTRACE_WORKS) + + if(NOT EZTRACE_WORKS) + if(NOT EZTRACE_FIND_QUIETLY) + message(STATUS "Looking for eztrace : test of eztrace_topology_init with eztrace library fails") + message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") + message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") + message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") + endif() + endif() + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) + endif(EZTRACE_LIBRARIES) endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_FOUND) OR (EZTRACE_GIVEN_BY_USER) ) if (EZTRACE_LIBRARIES) - if (EZTRACE_LIBRARY_DIRS) - list(GET EZTRACE_LIBRARY_DIRS 0 first_lib_path) - else() - list(GET EZTRACE_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(EZTRACE_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of EZTRACE library" FORCE) - else() - set(EZTRACE_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of EZTRACE library" FORCE) - endif() + if (EZTRACE_LIBRARY_DIRS) + list(GET EZTRACE_LIBRARY_DIRS 0 first_lib_path) + else() + list(GET EZTRACE_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(EZTRACE_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of EZTRACE library" FORCE) + else() + set(EZTRACE_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of EZTRACE library" FORCE) + endif() endif() mark_as_advanced(EZTRACE_DIR) mark_as_advanced(EZTRACE_DIR_FOUND) @@ -346,10 +346,10 @@ mark_as_advanced(EZTRACE_DIR_FOUND) # ------------------------------- include(FindPackageHandleStandardArgs) if (PKG_CONFIG_EXECUTABLE AND EZTRACE_FOUND) - find_package_handle_standard_args(EZTRACE DEFAULT_MSG - EZTRACE_LIBRARIES) + find_package_handle_standard_args(EZTRACE DEFAULT_MSG + EZTRACE_LIBRARIES) else() - find_package_handle_standard_args(EZTRACE DEFAULT_MSG - EZTRACE_LIBRARIES - EZTRACE_WORKS) + find_package_handle_standard_args(EZTRACE DEFAULT_MSG + EZTRACE_LIBRARIES + EZTRACE_WORKS) endif() diff --git a/CMakeModules/morse/find/FindFFTW.cmake b/CMakeModules/morse/find/FindFFTW.cmake index 47c428b9b773fb6effe6b74ccdc318d57ded1df4..a9d8b1918a5a3be1e66efa20fd0df8c8abfef68a 100644 --- a/CMakeModules/morse/find/FindFFTW.cmake +++ b/CMakeModules/morse/find/FindFFTW.cmake @@ -113,38 +113,38 @@ if( FFTW_FIND_COMPONENTS ) # means we look for the Intel MKL version of FFTW set(FFTW_LOOK_FOR_MKL ON) if (FFTW_LOOK_FOR_FFTW_LONG) - if (NOT FFTW_FIND_QUIETLY) - message(WARNING "Looking for FFTW -- long precision functions do not exist in MKL FFTW") - endif() - set(FFTW_LOOK_FOR_FFTW_LONG OFF) + if (NOT FFTW_FIND_QUIETLY) + message(WARNING "Looking for FFTW -- long precision functions do not exist in MKL FFTW") + endif() + set(FFTW_LOOK_FOR_FFTW_LONG OFF) endif() if (FFTW_LOOK_FOR_FFTW_QUAD) - if (NOT FFTW_FIND_QUIETLY) - message(WARNING "Looking for FFTW -- quadruple functions do not exist in MKL FFTW") - endif() - set(FFTW_LOOK_FOR_FFTW_QUAD OFF) + if (NOT FFTW_FIND_QUIETLY) + message(WARNING "Looking for FFTW -- quadruple functions do not exist in MKL FFTW") + endif() + set(FFTW_LOOK_FOR_FFTW_QUAD OFF) endif() endif() if (${component} STREQUAL "ESSL") # means we look for the Intel MKL version of FFTW set(FFTW_LOOK_FOR_ESSL ON) if (FFTW_LOOK_FOR_FFTW_LONG) - if (NOT FFTW_FIND_QUIETLY) - message(WARNING "Looking for FFTW -- long precision functions do not exist in FFTW_ESSL") - endif() - set(FFTW_LOOK_FOR_FFTW_LONG OFF) + if (NOT FFTW_FIND_QUIETLY) + message(WARNING "Looking for FFTW -- long precision functions do not exist in FFTW_ESSL") + endif() + set(FFTW_LOOK_FOR_FFTW_LONG OFF) endif() if (FFTW_LOOK_FOR_FFTW_QUAD) - if (NOT FFTW_FIND_QUIETLY) - message(WARNING "Looking for FFTW -- quadruple functions do not exist in FFTW_ESSL") - endif() - set(FFTW_LOOK_FOR_FFTW_QUAD OFF) + if (NOT FFTW_FIND_QUIETLY) + message(WARNING "Looking for FFTW -- quadruple functions do not exist in FFTW_ESSL") + endif() + set(FFTW_LOOK_FOR_FFTW_QUAD OFF) endif() if (FFTW_LOOK_FOR_OMP) - if (NOT FFTW_FIND_QUIETLY) - message(WARNING "Looking for FFTW -- FFTW_ESSL does not use OpenMP") - endif() - set(FFTW_LOOK_FOR_OMP OFF) + if (NOT FFTW_FIND_QUIETLY) + message(WARNING "Looking for FFTW -- FFTW_ESSL does not use OpenMP") + endif() + set(FFTW_LOOK_FOR_OMP OFF) endif() endif() endforeach() @@ -230,116 +230,116 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL) pkg_search_module(FFTW3F fftw3f) pkg_search_module(FFTW3 fftw3) if (FFTW3F_FOUND) - if (NOT FFTW_FIND_QUIETLY) - message(STATUS "Looking for FFTW3F - found using PkgConfig") - endif() - if (FFTW3F_LIBRARIES) - list(APPEND FFTW_LIBRARIES "${FFTW3F_LIBRARIES}") - endif() - if(FFTW3F_INCLUDE_DIRS) - list(APPEND FFTW_INCLUDE_DIRS "${FFTW3F_INCLUDE_DIRS}") - else() - if (NOT FFTW_FIND_QUIETLY) - message(WARNING "FFTW3F_INCLUDE_DIRS is empty using PkgConfig." - "Perhaps the path to fftw3f headers is already present in your" - "CPATH/C(PLUS)_INCLUDE_PATH environment variables.") - endif() - endif() - if(FFTW3F_LIBRARY_DIRS) - list(APPEND FFTW_LIBRARY_DIRS "${FFTW3F_LIBRARY_DIRS}") - endif() + if (NOT FFTW_FIND_QUIETLY) + message(STATUS "Looking for FFTW3F - found using PkgConfig") + endif() + if (FFTW3F_LIBRARIES) + list(APPEND FFTW_LIBRARIES "${FFTW3F_LIBRARIES}") + endif() + if(FFTW3F_INCLUDE_DIRS) + list(APPEND FFTW_INCLUDE_DIRS "${FFTW3F_INCLUDE_DIRS}") + else() + if (NOT FFTW_FIND_QUIETLY) + message(WARNING "FFTW3F_INCLUDE_DIRS is empty using PkgConfig." + "Perhaps the path to fftw3f headers is already present in your" + "CPATH/C(PLUS)_INCLUDE_PATH environment variables.") + endif() + endif() + if(FFTW3F_LIBRARY_DIRS) + list(APPEND FFTW_LIBRARY_DIRS "${FFTW3F_LIBRARY_DIRS}") + endif() else(FFTW3F_FOUND) - if (NOT FFTW_FIND_QUIETLY) - message(STATUS "Looking for FFTW3F - not found using PkgConfig." - "\n Perhaps you should add the directory containing fftw3f.pc to" - "\n the PKG_CONFIG_PATH environment variable.") - endif() + if (NOT FFTW_FIND_QUIETLY) + message(STATUS "Looking for FFTW3F - not found using PkgConfig." + "\n Perhaps you should add the directory containing fftw3f.pc to" + "\n the PKG_CONFIG_PATH environment variable.") + endif() endif(FFTW3F_FOUND) elseif(FFTW_LOOK_FOR_FFTW_LONG) pkg_search_module(FFTW3L fftw3l) pkg_search_module(FFTW3 fftw3) if (FFTW3L_FOUND) - if (NOT FFTW_FIND_QUIETLY) - message(STATUS "Looking for FFTW3L - found using PkgConfig") - endif() - if (FFTW3L_LIBRARIES) - list(APPEND FFTW_LIBRARIES "${FFTW3L_LIBRARIES}") - endif() - if(FFTW3L_INCLUDE_DIRS) - list(APPEND FFTW_INCLUDE_DIRS "${FFTW3L_INCLUDE_DIRS}") - else() - if (NOT FFTW_FIND_QUIETLY) - message(WARNING "FFTW3L_INCLUDE_DIRS is empty using PkgConfig." - "Perhaps the path to fftw3l headers is already present in your" - "CPATH/C(PLUS)_INCLUDE_PATH environment variables.") - endif() - endif() - if(FFTW3L_LIBRARY_DIRS) - list(APPEND FFTW_LIBRARY_DIRS "${FFTW3L_LIBRARY_DIRS}") - endif() + if (NOT FFTW_FIND_QUIETLY) + message(STATUS "Looking for FFTW3L - found using PkgConfig") + endif() + if (FFTW3L_LIBRARIES) + list(APPEND FFTW_LIBRARIES "${FFTW3L_LIBRARIES}") + endif() + if(FFTW3L_INCLUDE_DIRS) + list(APPEND FFTW_INCLUDE_DIRS "${FFTW3L_INCLUDE_DIRS}") + else() + if (NOT FFTW_FIND_QUIETLY) + message(WARNING "FFTW3L_INCLUDE_DIRS is empty using PkgConfig." + "Perhaps the path to fftw3l headers is already present in your" + "CPATH/C(PLUS)_INCLUDE_PATH environment variables.") + endif() + endif() + if(FFTW3L_LIBRARY_DIRS) + list(APPEND FFTW_LIBRARY_DIRS "${FFTW3L_LIBRARY_DIRS}") + endif() else(FFTW3L_FOUND) - if (NOT FFTW_FIND_QUIETLY) - message(STATUS "Looking for FFTW3L - not found using PkgConfig." - "\n Perhaps you should add the directory containing fftw3l.pc to" - "\n the PKG_CONFIG_PATH environment variable.") - endif() + if (NOT FFTW_FIND_QUIETLY) + message(STATUS "Looking for FFTW3L - not found using PkgConfig." + "\n Perhaps you should add the directory containing fftw3l.pc to" + "\n the PKG_CONFIG_PATH environment variable.") + endif() endif(FFTW3L_FOUND) elseif(FFTW_LOOK_FOR_FFTW_QUAD) pkg_search_module(FFTW3Q fftw3q) pkg_search_module(FFTW3 fftw3) if (FFTW3Q_FOUND) - if (NOT FFTW_FIND_QUIETLY) - message(STATUS "Looking for FFTW3Q - found using PkgConfig") - endif() - if (FFTW3Q_LIBRARIES) - list(APPEND FFTW_LIBRARIES "${FFTW3Q_LIBRARIES}") - endif() - if(FFTW3Q_INCLUDE_DIRS) - list(APPEND FFTW_INCLUDE_DIRS "${FFTW3Q_INCLUDE_DIRS}") - else() - if (NOT FFTW_FIND_QUIETLY) - message(WARNING "FFTW3Q_INCLUDE_DIRS is empty using PkgConfig." - "Perhaps the path to fftw3q headers is already present in your" - "CPATH/C(PLUS)_INCLUDE_PATH environment variables.") - endif() - endif() - if(FFTW3Q_LIBRARY_DIRS) - list(APPEND FFTW_LIBRARY_DIRS "${FFTW3Q_LIBRARY_DIRS}") - endif() + if (NOT FFTW_FIND_QUIETLY) + message(STATUS "Looking for FFTW3Q - found using PkgConfig") + endif() + if (FFTW3Q_LIBRARIES) + list(APPEND FFTW_LIBRARIES "${FFTW3Q_LIBRARIES}") + endif() + if(FFTW3Q_INCLUDE_DIRS) + list(APPEND FFTW_INCLUDE_DIRS "${FFTW3Q_INCLUDE_DIRS}") + else() + if (NOT FFTW_FIND_QUIETLY) + message(WARNING "FFTW3Q_INCLUDE_DIRS is empty using PkgConfig." + "Perhaps the path to fftw3q headers is already present in your" + "CPATH/C(PLUS)_INCLUDE_PATH environment variables.") + endif() + endif() + if(FFTW3Q_LIBRARY_DIRS) + list(APPEND FFTW_LIBRARY_DIRS "${FFTW3Q_LIBRARY_DIRS}") + endif() else(FFTW3Q_FOUND) - if (NOT FFTW_FIND_QUIETLY) - message(STATUS "Looking for FFTW3Q - not found using PkgConfig." - "\n Perhaps you should add the directory containing fftw3q.pc to" - "\n the PKG_CONFIG_PATH environment variable.") - endif() + if (NOT FFTW_FIND_QUIETLY) + message(STATUS "Looking for FFTW3Q - not found using PkgConfig." + "\n Perhaps you should add the directory containing fftw3q.pc to" + "\n the PKG_CONFIG_PATH environment variable.") + endif() endif(FFTW3Q_FOUND) else() pkg_search_module(FFTW3 fftw3) endif() if (FFTW3_FOUND) if (NOT FFTW_FIND_QUIETLY) - message(STATUS "Looking for FFTW3 - found using PkgConfig") + message(STATUS "Looking for FFTW3 - found using PkgConfig") endif() if (FFTW3_LIBRARIES) - list(APPEND FFTW_LIBRARIES "${FFTW3_LIBRARIES}") + list(APPEND FFTW_LIBRARIES "${FFTW3_LIBRARIES}") endif() if(FFTW3_INCLUDE_DIRS) - list(APPEND FFTW_INCLUDE_DIRS "${FFTW3_INCLUDE_DIRS}") + list(APPEND FFTW_INCLUDE_DIRS "${FFTW3_INCLUDE_DIRS}") else() - if (NOT FFTW_FIND_QUIETLY) - message(WARNING "FFTW3_INCLUDE_DIRS is empty using PkgConfig." - "Perhaps the path to fftw3 headers is already present in your" - "CPATH/C(PLUS)_INCLUDE_PATH environment variables.") - endif() + if (NOT FFTW_FIND_QUIETLY) + message(WARNING "FFTW3_INCLUDE_DIRS is empty using PkgConfig." + "Perhaps the path to fftw3 headers is already present in your" + "CPATH/C(PLUS)_INCLUDE_PATH environment variables.") + endif() endif() if(FFTW3_LIBRARY_DIRS) - list(APPEND FFTW_LIBRARY_DIRS "${FFTW3_LIBRARY_DIRS}") + list(APPEND FFTW_LIBRARY_DIRS "${FFTW3_LIBRARY_DIRS}") endif() else(FFTW3_FOUND) if (NOT FFTW_FIND_QUIETLY) - message(STATUS "Looking for FFTW3 - not found using PkgConfig." - "\n Perhaps you should add the directory containing fftw3.pc to" - "\n the PKG_CONFIG_PATH environment variable.") + message(STATUS "Looking for FFTW3 - not found using PkgConfig." + "\n Perhaps you should add the directory containing fftw3.pc to" + "\n the PKG_CONFIG_PATH environment variable.") endif() endif(FFTW3_FOUND) @@ -356,11 +356,11 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL) endif(NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL) if( (NOT PKG_CONFIG_EXECUTABLE) OR - (PKG_CONFIG_EXECUTABLE AND NOT FFTW_FOUND) OR - FFTW_GIVEN_BY_USER OR - FFTW_LOOK_FOR_MKL OR - FFTW_LOOK_FOR_ESSL - ) + (PKG_CONFIG_EXECUTABLE AND NOT FFTW_FOUND) OR + FFTW_GIVEN_BY_USER OR + FFTW_LOOK_FOR_MKL OR + FFTW_LOOK_FOR_ESSL + ) # Looking for include # ------------------- @@ -522,7 +522,7 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR endif() if (FFTW_LOOK_FOR_FFTW_QUAD) if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL) - list(APPEND FFTW_libs_to_find "quadmath") + list(APPEND FFTW_libs_to_find "quadmath") endif() endif() @@ -536,27 +536,27 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR # call cmake macro to find the lib path if(FFTW_LIBDIR) foreach(fftw_lib ${FFTW_libs_to_find}) - set(FFTW_${fftw_lib}_LIBRARY "FFTW_${fftw_lib}_LIBRARY-NOTFOUND") - find_library(FFTW_${fftw_lib}_LIBRARY - NAMES ${fftw_lib} - HINTS ${FFTW_LIBDIR}) + set(FFTW_${fftw_lib}_LIBRARY "FFTW_${fftw_lib}_LIBRARY-NOTFOUND") + find_library(FFTW_${fftw_lib}_LIBRARY + NAMES ${fftw_lib} + HINTS ${FFTW_LIBDIR}) endforeach() else() if(FFTW_DIR) - foreach(fftw_lib ${FFTW_libs_to_find}) - set(FFTW_${fftw_lib}_LIBRARY "FFTW_${fftw_lib}_LIBRARY-NOTFOUND") - find_library(FFTW_${fftw_lib}_LIBRARY - NAMES ${fftw_lib} - HINTS ${FFTW_DIR} - PATH_SUFFIXES lib lib32 lib64) - endforeach() + foreach(fftw_lib ${FFTW_libs_to_find}) + set(FFTW_${fftw_lib}_LIBRARY "FFTW_${fftw_lib}_LIBRARY-NOTFOUND") + find_library(FFTW_${fftw_lib}_LIBRARY + NAMES ${fftw_lib} + HINTS ${FFTW_DIR} + PATH_SUFFIXES lib lib32 lib64) + endforeach() else() - foreach(fftw_lib ${FFTW_libs_to_find}) - set(FFTW_${fftw_lib}_LIBRARY "FFTW_${fftw_lib}_LIBRARY-NOTFOUND") - find_library(FFTW_${fftw_lib}_LIBRARY - NAMES ${fftw_lib} - HINTS ${PATH_TO_LOOK_FOR}) - endforeach() + foreach(fftw_lib ${FFTW_libs_to_find}) + set(FFTW_${fftw_lib}_LIBRARY "FFTW_${fftw_lib}_LIBRARY-NOTFOUND") + find_library(FFTW_${fftw_lib}_LIBRARY + NAMES ${fftw_lib} + HINTS ${PATH_TO_LOOK_FOR}) + endforeach() endif() endif() @@ -565,15 +565,15 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR foreach(fftw_lib ${FFTW_libs_to_find}) if (FFTW_${fftw_lib}_LIBRARY) - get_filename_component(${fftw_lib}_lib_path "${FFTW_${fftw_lib}_LIBRARY}" PATH) - # set cmake variables - list(APPEND FFTW_LIBRARIES "${FFTW_${fftw_lib}_LIBRARY}") - list(APPEND FFTW_LIBRARY_DIRS "${${fftw_lib}_lib_path}") + get_filename_component(${fftw_lib}_lib_path "${FFTW_${fftw_lib}_LIBRARY}" PATH) + # set cmake variables + list(APPEND FFTW_LIBRARIES "${FFTW_${fftw_lib}_LIBRARY}") + list(APPEND FFTW_LIBRARY_DIRS "${${fftw_lib}_lib_path}") else () - list(APPEND FFTW_LIBRARIES "${FFTW_${fftw_lib}_LIBRARY}") - if (NOT FFTW_FIND_QUIETLY) - message(STATUS "Looking for FFTW -- lib ${fftw_lib} not found") - endif() + list(APPEND FFTW_LIBRARIES "${FFTW_${fftw_lib}_LIBRARY}") + if (NOT FFTW_FIND_QUIETLY) + message(STATUS "Looking for FFTW -- lib ${fftw_lib} not found") + endif() endif () mark_as_advanced(FFTW_${fftw_lib}_LIBRARY) @@ -581,9 +581,9 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR # check if one lib is NOTFOUND foreach(lib ${FFTW_LIBRARIES}) - if (NOT lib) - set(FFTW_LIBRARIES "FFTW_LIBRARIES-NOTFOUND") - endif() + if (NOT lib) + set(FFTW_LIBRARIES "FFTW_LIBRARIES-NOTFOUND") + endif() endforeach() endif(NOT FFTW_LOOK_FOR_MKL) @@ -593,67 +593,67 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR # FFTW relies on blas libs if (FFTW_LOOK_FOR_THREADS) if (FFTW_LOOK_FOR_MKL) - if (BLAS_PAR_LIBRARIES) - list(APPEND FFTW_LIBRARIES "${BLAS_PAR_LIBRARIES}") - if (NOT FFTW_FIND_QUIETLY) - message(STATUS "Multithreaded FFTW has been found: ${FFTW_LIBRARIES}") - endif() - else() - if (NOT FFTW_FIND_QUIETLY) - if (FFTW_FIND_REQUIRED AND FFTW_FIND_REQUIRED_MKL) - message(FATAL_ERROR "FFTW is required but not found.") - else() - message(STATUS "Multithreaded FFTW not found.") - endif() - endif() - endif(BLAS_PAR_LIBRARIES) + if (BLAS_PAR_LIBRARIES) + list(APPEND FFTW_LIBRARIES "${BLAS_PAR_LIBRARIES}") + if (NOT FFTW_FIND_QUIETLY) + message(STATUS "Multithreaded FFTW has been found: ${FFTW_LIBRARIES}") + endif() + else() + if (NOT FFTW_FIND_QUIETLY) + if (FFTW_FIND_REQUIRED AND FFTW_FIND_REQUIRED_MKL) + message(FATAL_ERROR "FFTW is required but not found.") + else() + message(STATUS "Multithreaded FFTW not found.") + endif() + endif() + endif(BLAS_PAR_LIBRARIES) elseif (FFTW_LOOK_FOR_ESSL) - if (FFTW_LIBRARIES AND BLAS_PAR_LIBRARIES) - list(APPEND FFTW_LIBRARIES "${BLAS_PAR_LIBRARIES}") - if (NOT FFTW_FIND_QUIETLY) - message(STATUS "Multithreaded FFTW has been found: ${FFTW_LIBRARIES}") - endif() - else() - if (NOT FFTW_FIND_QUIETLY) - if (FFTW_FIND_REQUIRED AND FFTW_FIND_REQUIRED_MKL) - message(FATAL_ERROR "FFTW is required but not found.") - else() - message(STATUS "Multithreaded FFTW not found.") - endif() - endif() - endif(FFTW_LIBRARIES AND BLAS_PAR_LIBRARIES) + if (FFTW_LIBRARIES AND BLAS_PAR_LIBRARIES) + list(APPEND FFTW_LIBRARIES "${BLAS_PAR_LIBRARIES}") + if (NOT FFTW_FIND_QUIETLY) + message(STATUS "Multithreaded FFTW has been found: ${FFTW_LIBRARIES}") + endif() + else() + if (NOT FFTW_FIND_QUIETLY) + if (FFTW_FIND_REQUIRED AND FFTW_FIND_REQUIRED_MKL) + message(FATAL_ERROR "FFTW is required but not found.") + else() + message(STATUS "Multithreaded FFTW not found.") + endif() + endif() + endif(FFTW_LIBRARIES AND BLAS_PAR_LIBRARIES) endif() else(FFTW_LOOK_FOR_THREADS) if (FFTW_LOOK_FOR_MKL) - if (BLAS_SEQ_LIBRARIES) - list(APPEND FFTW_LIBRARIES "${BLAS_SEQ_LIBRARIES}") - if (NOT FFTW_FIND_QUIETLY) - message(STATUS "FFTW has been found: ${FFTW_LIBRARIES}") - endif() - else() - if (NOT FFTW_FIND_QUIETLY) - if (FFTW_FIND_REQUIRED AND FFTW_FIND_REQUIRED_MKL) - message(FATAL_ERROR "FFTW is required but not found.") - else() - message(STATUS "FFTW not found.") - endif() - endif() - endif(BLAS_SEQ_LIBRARIES) + if (BLAS_SEQ_LIBRARIES) + list(APPEND FFTW_LIBRARIES "${BLAS_SEQ_LIBRARIES}") + if (NOT FFTW_FIND_QUIETLY) + message(STATUS "FFTW has been found: ${FFTW_LIBRARIES}") + endif() + else() + if (NOT FFTW_FIND_QUIETLY) + if (FFTW_FIND_REQUIRED AND FFTW_FIND_REQUIRED_MKL) + message(FATAL_ERROR "FFTW is required but not found.") + else() + message(STATUS "FFTW not found.") + endif() + endif() + endif(BLAS_SEQ_LIBRARIES) elseif (FFTW_LOOK_FOR_ESSL) - if (FFTW_LIBRARIES AND BLAS_SEQ_LIBRARIES) - list(APPEND FFTW_LIBRARIES "${BLAS_SEQ_LIBRARIES}") - if (NOT FFTW_FIND_QUIETLY) - message(STATUS "FFTW has been found: ${FFTW_LIBRARIES}") - endif() - else() - if (NOT FFTW_FIND_QUIETLY) - if (FFTW_FIND_REQUIRED AND FFTW_FIND_REQUIRED_MKL) - message(FATAL_ERROR "FFTW is required but not found.") - else() - message(STATUS "FFTW not found.") - endif() - endif() - endif(FFTW_LIBRARIES AND BLAS_SEQ_LIBRARIES) + if (FFTW_LIBRARIES AND BLAS_SEQ_LIBRARIES) + list(APPEND FFTW_LIBRARIES "${BLAS_SEQ_LIBRARIES}") + if (NOT FFTW_FIND_QUIETLY) + message(STATUS "FFTW has been found: ${FFTW_LIBRARIES}") + endif() + else() + if (NOT FFTW_FIND_QUIETLY) + if (FFTW_FIND_REQUIRED AND FFTW_FIND_REQUIRED_MKL) + message(FATAL_ERROR "FFTW is required but not found.") + else() + message(STATUS "FFTW not found.") + endif() + endif() + endif(FFTW_LIBRARIES AND BLAS_SEQ_LIBRARIES) endif() endif(FFTW_LOOK_FOR_THREADS) @@ -661,7 +661,7 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR list(APPEND FFTW_LIBRARY_DIRS "${BLAS_LIBRARY_DIRS}") else() if (NOT FFTW_FIND_QUIETLY) - message(WARNING "FFTW_LIBRARY_DIRS may not be complete because BLAS_LIBRARY_DIRS is empty.") + message(WARNING "FFTW_LIBRARY_DIRS may not be complete because BLAS_LIBRARY_DIRS is empty.") endif() endif() @@ -672,9 +672,9 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR # check if one lib is NOTFOUND foreach(lib ${FFTW_LIBRARIES}) - if (NOT lib) - set(FFTW_LIBRARIES "FFTW_LIBRARIES-NOTFOUND") - endif() + if (NOT lib) + set(FFTW_LIBRARIES "FFTW_LIBRARIES-NOTFOUND") + endif() endforeach() # check a function to validate the find @@ -714,7 +714,7 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR if(FFTW_LOOK_FOR_MKL) list(APPEND REQUIRED_LIBS "${CMAKE_THREAD_LIBS_INIT}") if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_SYSTEM_NAME STREQUAL "Linux") - list(APPEND REQUIRED_LDFLAGS "-Wl,--no-as-needed") + list(APPEND REQUIRED_LDFLAGS "-Wl,--no-as-needed") endif() endif() # m @@ -772,11 +772,11 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR endif(FFTW_LIBRARIES) endif( (NOT PKG_CONFIG_EXECUTABLE) OR - (PKG_CONFIG_EXECUTABLE AND NOT FFTW_FOUND) OR - FFTW_GIVEN_BY_USER OR - FFTW_LOOK_FOR_MKL OR - FFTW_LOOK_FOR_ESSL - ) + (PKG_CONFIG_EXECUTABLE AND NOT FFTW_FOUND) OR + FFTW_GIVEN_BY_USER OR + FFTW_LOOK_FOR_MKL OR + FFTW_LOOK_FOR_ESSL + ) if (FFTW_LIBRARIES) list(GET FFTW_LIBRARIES 0 first_lib) @@ -795,12 +795,12 @@ mark_as_advanced(FFTW_DIR_FOUND) # ------------------------------- include(FindPackageHandleStandardArgs) if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT FFTW_FOUND) OR (FFTW_GIVEN_BY_USER) ) -find_package_handle_standard_args(FFTW DEFAULT_MSG - FFTW_LIBRARIES - FFTW_INCLUDE_DIRS - FFTW_WORKS) + find_package_handle_standard_args(FFTW DEFAULT_MSG + FFTW_LIBRARIES + FFTW_INCLUDE_DIRS + FFTW_WORKS) else() -find_package_handle_standard_args(FFTW DEFAULT_MSG - FFTW_LIBRARIES - FFTW_WORKS) + find_package_handle_standard_args(FFTW DEFAULT_MSG + FFTW_LIBRARIES + FFTW_WORKS) endif() diff --git a/CMakeModules/morse/find/FindFXT.cmake b/CMakeModules/morse/find/FindFXT.cmake index 8aa816713cfcecc95962a0722235dd9f08217f03..3fd9a6eb2d461ce3e86a7a515b570e30f98b6820 100644 --- a/CMakeModules/morse/find/FindFXT.cmake +++ b/CMakeModules/morse/find/FindFXT.cmake @@ -46,10 +46,10 @@ # License text for the above reference.) if (NOT FXT_FOUND) - 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() + 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() endif() set(ENV_FXT_DIR "$ENV{FXT_DIR}") @@ -57,7 +57,7 @@ set(ENV_FXT_INCDIR "$ENV{FXT_INCDIR}") set(ENV_FXT_LIBDIR "$ENV{FXT_LIBDIR}") set(FXT_GIVEN_BY_USER "FALSE") if ( FXT_DIR OR ( FXT_INCDIR AND FXT_LIBDIR) OR ENV_FXT_DIR OR (ENV_FXT_INCDIR AND ENV_FXT_LIBDIR) ) - set(FXT_GIVEN_BY_USER "TRUE") + set(FXT_GIVEN_BY_USER "TRUE") endif() # Optionally use pkg-config to detect include/library dirs (if pkg-config is available) @@ -66,233 +66,233 @@ include(FindPkgConfig) find_package(PkgConfig QUIET) if(PKG_CONFIG_EXECUTABLE AND NOT FXT_GIVEN_BY_USER) - pkg_search_module(FXT fxt) - if (NOT FXT_FIND_QUIETLY) - if (FXT_FOUND AND FXT_LIBRARIES) - message(STATUS "Looking for FXT - found using PkgConfig") - #if(NOT FXT_INCLUDE_DIRS) - # message("${Magenta}FXT_INCLUDE_DIRS is empty using PkgConfig." - # "Perhaps the path to fxt headers is already present in your" - # "C(PLUS)_INCLUDE_PATH environment variable.${ColourReset}") - #endif() - else() - message(STATUS "${Magenta}Looking for FXT - not found using PkgConfig." - "\n Perhaps you should add the directory containing fxt.pc to the" - "\n PKG_CONFIG_PATH environment variable.${ColourReset}") - endif() + pkg_search_module(FXT fxt) + if (NOT FXT_FIND_QUIETLY) + if (FXT_FOUND AND FXT_LIBRARIES) + message(STATUS "Looking for FXT - found using PkgConfig") + #if(NOT FXT_INCLUDE_DIRS) + # message("${Magenta}FXT_INCLUDE_DIRS is empty using PkgConfig." + # "Perhaps the path to fxt headers is already present in your" + # "C(PLUS)_INCLUDE_PATH environment variable.${ColourReset}") + #endif() + else() + message(STATUS "${Magenta}Looking for FXT - not found using PkgConfig." + "\n Perhaps you should add the directory containing fxt.pc to the" + "\n PKG_CONFIG_PATH environment variable.${ColourReset}") endif() + endif() endif(PKG_CONFIG_EXECUTABLE AND NOT FXT_GIVEN_BY_USER) if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT FXT_FOUND) OR (FXT_GIVEN_BY_USER) ) - if (NOT FXT_FIND_QUIETLY) - message(STATUS "Looking for FXT - PkgConfig not used") - endif() + if (NOT FXT_FIND_QUIETLY) + message(STATUS "Looking for FXT - PkgConfig not used") + endif() - # Looking for include - # ------------------- + # Looking for include + # ------------------- - # Add system include paths to search include - # ------------------------------------------ - unset(_inc_env) - set(ENV_FXT_DIR "$ENV{FXT_DIR}") - set(ENV_FXT_INCDIR "$ENV{FXT_INCDIR}") - if(ENV_FXT_INCDIR) - list(APPEND _inc_env "${ENV_FXT_INCDIR}") - elseif(ENV_FXT_DIR) - list(APPEND _inc_env "${ENV_FXT_DIR}") - list(APPEND _inc_env "${ENV_FXT_DIR}/include") - list(APPEND _inc_env "${ENV_FXT_DIR}/include/fxt") + # Add system include paths to search include + # ------------------------------------------ + unset(_inc_env) + set(ENV_FXT_DIR "$ENV{FXT_DIR}") + set(ENV_FXT_INCDIR "$ENV{FXT_INCDIR}") + if(ENV_FXT_INCDIR) + list(APPEND _inc_env "${ENV_FXT_INCDIR}") + elseif(ENV_FXT_DIR) + list(APPEND _inc_env "${ENV_FXT_DIR}") + list(APPEND _inc_env "${ENV_FXT_DIR}/include") + list(APPEND _inc_env "${ENV_FXT_DIR}/include/fxt") + else() + if(WIN32) + string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") else() - if(WIN32) - string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") - else() - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{CPATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - endif() + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{CPATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") endif() - list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") - list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") - list(REMOVE_DUPLICATES _inc_env) + endif() + list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") + list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") + list(REMOVE_DUPLICATES _inc_env) - # Try to find the fxt header in the given paths - # ------------------------------------------------- - # call cmake macro to find the header path - if(FXT_INCDIR) - set(FXT_fxt.h_DIRS "FXT_fxt.h_DIRS-NOTFOUND") - find_path(FXT_fxt.h_DIRS - NAMES fxt.h - HINTS ${FXT_INCDIR}) + # Try to find the fxt header in the given paths + # ------------------------------------------------- + # call cmake macro to find the header path + if(FXT_INCDIR) + set(FXT_fxt.h_DIRS "FXT_fxt.h_DIRS-NOTFOUND") + find_path(FXT_fxt.h_DIRS + NAMES fxt.h + HINTS ${FXT_INCDIR}) + else() + if(FXT_DIR) + set(FXT_fxt.h_DIRS "FXT_fxt.h_DIRS-NOTFOUND") + find_path(FXT_fxt.h_DIRS + NAMES fxt.h + HINTS ${FXT_DIR} + PATH_SUFFIXES "include" "include/fxt") else() - if(FXT_DIR) - set(FXT_fxt.h_DIRS "FXT_fxt.h_DIRS-NOTFOUND") - find_path(FXT_fxt.h_DIRS - NAMES fxt.h - HINTS ${FXT_DIR} - PATH_SUFFIXES "include" "include/fxt") - else() - set(FXT_fxt.h_DIRS "FXT_fxt.h_DIRS-NOTFOUND") - find_path(FXT_fxt.h_DIRS - NAMES fxt.h - HINTS ${_inc_env} - PATH_SUFFIXES "fxt") - endif() + set(FXT_fxt.h_DIRS "FXT_fxt.h_DIRS-NOTFOUND") + find_path(FXT_fxt.h_DIRS + NAMES fxt.h + HINTS ${_inc_env} + PATH_SUFFIXES "fxt") endif() - mark_as_advanced(FXT_fxt.h_DIRS) + endif() + mark_as_advanced(FXT_fxt.h_DIRS) - # Add path to cmake variable - # ------------------------------------ - if (FXT_fxt.h_DIRS) - set(FXT_INCLUDE_DIRS "${FXT_fxt.h_DIRS}") - else () - set(FXT_INCLUDE_DIRS "FXT_INCLUDE_DIRS-NOTFOUND") - if(NOT FXT_FIND_QUIETLY) - message(STATUS "Looking for fxt -- fxt.h not found") - endif() - endif () + # Add path to cmake variable + # ------------------------------------ + if (FXT_fxt.h_DIRS) + set(FXT_INCLUDE_DIRS "${FXT_fxt.h_DIRS}") + else () + set(FXT_INCLUDE_DIRS "FXT_INCLUDE_DIRS-NOTFOUND") + if(NOT FXT_FIND_QUIETLY) + message(STATUS "Looking for fxt -- fxt.h not found") + endif() + endif () - if (FXT_INCLUDE_DIRS) - list(REMOVE_DUPLICATES FXT_INCLUDE_DIRS) - endif () + if (FXT_INCLUDE_DIRS) + list(REMOVE_DUPLICATES FXT_INCLUDE_DIRS) + endif () - # Looking for lib - # --------------- + # Looking for lib + # --------------- - # Add system library paths to search lib - # -------------------------------------- - unset(_lib_env) - set(ENV_FXT_LIBDIR "$ENV{FXT_LIBDIR}") - if(ENV_FXT_LIBDIR) - list(APPEND _lib_env "${ENV_FXT_LIBDIR}") - elseif(ENV_FXT_DIR) - list(APPEND _lib_env "${ENV_FXT_DIR}") - list(APPEND _lib_env "${ENV_FXT_DIR}/lib") + # Add system library paths to search lib + # -------------------------------------- + unset(_lib_env) + set(ENV_FXT_LIBDIR "$ENV{FXT_LIBDIR}") + if(ENV_FXT_LIBDIR) + list(APPEND _lib_env "${ENV_FXT_LIBDIR}") + elseif(ENV_FXT_DIR) + list(APPEND _lib_env "${ENV_FXT_DIR}") + list(APPEND _lib_env "${ENV_FXT_DIR}/lib") + else() + if(WIN32) + string(REPLACE ":" ";" _lib_env "$ENV{LIB}") else() - if(WIN32) - string(REPLACE ":" ";" _lib_env "$ENV{LIB}") - else() - if(APPLE) - string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - endif() + if(APPLE) + string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") + else() + string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") + endif() + list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") + list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") endif() - list(REMOVE_DUPLICATES _lib_env) + endif() + list(REMOVE_DUPLICATES _lib_env) - # Try to find the fxt lib in the given paths - # ---------------------------------------------- + # Try to find the fxt lib in the given paths + # ---------------------------------------------- - # call cmake macro to find the lib path - if(FXT_LIBDIR) - set(FXT_fxt_LIBRARY "FXT_fxt_LIBRARY-NOTFOUND") - find_library(FXT_fxt_LIBRARY - NAMES fxt - HINTS ${FXT_LIBDIR}) + # call cmake macro to find the lib path + if(FXT_LIBDIR) + set(FXT_fxt_LIBRARY "FXT_fxt_LIBRARY-NOTFOUND") + find_library(FXT_fxt_LIBRARY + NAMES fxt + HINTS ${FXT_LIBDIR}) + else() + if(FXT_DIR) + set(FXT_fxt_LIBRARY "FXT_fxt_LIBRARY-NOTFOUND") + find_library(FXT_fxt_LIBRARY + NAMES fxt + HINTS ${FXT_DIR} + PATH_SUFFIXES lib lib32 lib64) else() - if(FXT_DIR) - set(FXT_fxt_LIBRARY "FXT_fxt_LIBRARY-NOTFOUND") - find_library(FXT_fxt_LIBRARY - NAMES fxt - HINTS ${FXT_DIR} - PATH_SUFFIXES lib lib32 lib64) - else() - set(FXT_fxt_LIBRARY "FXT_fxt_LIBRARY-NOTFOUND") - find_library(FXT_fxt_LIBRARY - NAMES fxt - HINTS ${_lib_env}) - endif() + set(FXT_fxt_LIBRARY "FXT_fxt_LIBRARY-NOTFOUND") + find_library(FXT_fxt_LIBRARY + NAMES fxt + HINTS ${_lib_env}) endif() - mark_as_advanced(FXT_fxt_LIBRARY) + endif() + mark_as_advanced(FXT_fxt_LIBRARY) - # If found, add path to cmake variable - # ------------------------------------ - if (FXT_fxt_LIBRARY) - get_filename_component(fxt_lib_path ${FXT_fxt_LIBRARY} PATH) - # set cmake variables (respects naming convention) - set(FXT_LIBRARIES "${FXT_fxt_LIBRARY}") - set(FXT_LIBRARY_DIRS "${fxt_lib_path}") - else () - set(FXT_LIBRARIES "FXT_LIBRARIES-NOTFOUND") - set(FXT_LIBRARY_DIRS "FXT_LIBRARY_DIRS-NOTFOUND") - if(NOT FXT_FIND_QUIETLY) - message(STATUS "Looking for fxt -- lib fxt not found") - endif() - endif () + # If found, add path to cmake variable + # ------------------------------------ + if (FXT_fxt_LIBRARY) + get_filename_component(fxt_lib_path ${FXT_fxt_LIBRARY} PATH) + # set cmake variables (respects naming convention) + set(FXT_LIBRARIES "${FXT_fxt_LIBRARY}") + set(FXT_LIBRARY_DIRS "${fxt_lib_path}") + else () + set(FXT_LIBRARIES "FXT_LIBRARIES-NOTFOUND") + set(FXT_LIBRARY_DIRS "FXT_LIBRARY_DIRS-NOTFOUND") + if(NOT FXT_FIND_QUIETLY) + message(STATUS "Looking for fxt -- lib fxt not found") + endif() + endif () - if (FXT_LIBRARY_DIRS) - list(REMOVE_DUPLICATES FXT_LIBRARY_DIRS) - endif () + if (FXT_LIBRARY_DIRS) + list(REMOVE_DUPLICATES FXT_LIBRARY_DIRS) + endif () - # check a function to validate the find - if(FXT_LIBRARIES) + # check a function to validate the find + if(FXT_LIBRARIES) - set(REQUIRED_INCDIRS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) + set(REQUIRED_INCDIRS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) - # FXT - if (FXT_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${FXT_INCLUDE_DIRS}") - endif() - if (FXT_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${FXT_LIBRARY_DIRS}") - endif() - set(REQUIRED_LIBS "${FXT_LIBRARIES}") + # FXT + if (FXT_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${FXT_INCLUDE_DIRS}") + endif() + if (FXT_LIBRARY_DIRS) + set(REQUIRED_LIBDIRS "${FXT_LIBRARY_DIRS}") + endif() + set(REQUIRED_LIBS "${FXT_LIBRARIES}") - # set required libraries for link - set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") - set(CMAKE_REQUIRED_LIBRARIES) - foreach(lib_dir ${REQUIRED_LIBDIRS}) - list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}") - endforeach() - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + # set required libraries for link + set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") + set(CMAKE_REQUIRED_LIBRARIES) + foreach(lib_dir ${REQUIRED_LIBDIRS}) + list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}") + endforeach() + list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") + string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - # test link - unset(FXT_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(fut_keychange FXT_WORKS) - mark_as_advanced(FXT_WORKS) + # test link + unset(FXT_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(fut_keychange FXT_WORKS) + mark_as_advanced(FXT_WORKS) - if(NOT FXT_WORKS) - if(NOT FXT_FIND_QUIETLY) - message(STATUS "Looking for fxt : test of fut_keychange with fxt library fails") - message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") - message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") - message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") - endif() - endif() - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_LIBRARIES) - endif(FXT_LIBRARIES) + if(NOT FXT_WORKS) + if(NOT FXT_FIND_QUIETLY) + message(STATUS "Looking for fxt : test of fut_keychange with fxt library fails") + message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") + message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") + message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") + endif() + endif() + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) + endif(FXT_LIBRARIES) endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT FXT_FOUND) OR (FXT_GIVEN_BY_USER) ) if (FXT_LIBRARIES) - 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_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of FXT library" FORCE) - else() - set(FXT_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of FXT library" FORCE) - endif() + 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_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of FXT library" FORCE) + else() + set(FXT_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of FXT library" FORCE) + endif() endif() mark_as_advanced(FXT_DIR) mark_as_advanced(FXT_DIR_FOUND) @@ -301,10 +301,10 @@ mark_as_advanced(FXT_DIR_FOUND) # ------------------------------- include(FindPackageHandleStandardArgs) if (PKG_CONFIG_EXECUTABLE AND FXT_FOUND) - find_package_handle_standard_args(FXT DEFAULT_MSG - FXT_LIBRARIES) + find_package_handle_standard_args(FXT DEFAULT_MSG + FXT_LIBRARIES) else() - find_package_handle_standard_args(FXT DEFAULT_MSG - FXT_LIBRARIES - FXT_WORKS) + find_package_handle_standard_args(FXT DEFAULT_MSG + FXT_LIBRARIES + FXT_WORKS) endif() diff --git a/CMakeModules/morse/find/FindHWLOC.cmake b/CMakeModules/morse/find/FindHWLOC.cmake index 8e897cdd73c5a763e6df74cc26980b18357bef6b..a831b5c725acc0b88dfba169e3ed477dd5bf2910 100644 --- a/CMakeModules/morse/find/FindHWLOC.cmake +++ b/CMakeModules/morse/find/FindHWLOC.cmake @@ -49,10 +49,10 @@ include(CheckStructHasMember) include(CheckCSourceCompiles) if (NOT HWLOC_FOUND) - 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() + 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() endif() set(ENV_HWLOC_DIR "$ENV{HWLOC_DIR}") @@ -60,7 +60,7 @@ set(ENV_HWLOC_INCDIR "$ENV{HWLOC_INCDIR}") set(ENV_HWLOC_LIBDIR "$ENV{HWLOC_LIBDIR}") set(HWLOC_GIVEN_BY_USER "FALSE") if ( HWLOC_DIR OR ( HWLOC_INCDIR AND HWLOC_LIBDIR) OR ENV_HWLOC_DIR OR (ENV_HWLOC_INCDIR AND ENV_HWLOC_LIBDIR) ) - set(HWLOC_GIVEN_BY_USER "TRUE") + set(HWLOC_GIVEN_BY_USER "TRUE") endif() # Optionally use pkg-config to detect include/library dirs (if pkg-config is available) @@ -69,236 +69,236 @@ include(FindPkgConfig) find_package(PkgConfig QUIET) if( PKG_CONFIG_EXECUTABLE AND NOT HWLOC_GIVEN_BY_USER ) - pkg_search_module(HWLOC hwloc) - if (NOT HWLOC_FIND_QUIETLY) - if (HWLOC_FOUND AND HWLOC_LIBRARIES) - message(STATUS "Looking for HWLOC - found using PkgConfig") - #if(NOT HWLOC_INCLUDE_DIRS) - # message("${Magenta}HWLOC_INCLUDE_DIRS is empty using PkgConfig." - # "Perhaps the path to hwloc headers is already present in your" - # "C(PLUS)_INCLUDE_PATH environment variable.${ColourReset}") - #endif() - else() - message(STATUS "${Magenta}Looking for HWLOC - not found using PkgConfig." - "\n Perhaps you should add the directory containing hwloc.pc to" - "\n the PKG_CONFIG_PATH environment variable.${ColourReset}") - endif() + pkg_search_module(HWLOC hwloc) + if (NOT HWLOC_FIND_QUIETLY) + if (HWLOC_FOUND AND HWLOC_LIBRARIES) + message(STATUS "Looking for HWLOC - found using PkgConfig") + #if(NOT HWLOC_INCLUDE_DIRS) + # message("${Magenta}HWLOC_INCLUDE_DIRS is empty using PkgConfig." + # "Perhaps the path to hwloc headers is already present in your" + # "C(PLUS)_INCLUDE_PATH environment variable.${ColourReset}") + #endif() + else() + message(STATUS "${Magenta}Looking for HWLOC - not found using PkgConfig." + "\n Perhaps you should add the directory containing hwloc.pc to" + "\n the PKG_CONFIG_PATH environment variable.${ColourReset}") endif() + endif() endif( PKG_CONFIG_EXECUTABLE AND NOT HWLOC_GIVEN_BY_USER ) if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT HWLOC_FOUND) OR (HWLOC_GIVEN_BY_USER) ) - if (NOT HWLOC_FIND_QUIETLY) - message(STATUS "Looking for HWLOC - PkgConfig not used") + if (NOT HWLOC_FIND_QUIETLY) + message(STATUS "Looking for HWLOC - PkgConfig not used") + endif() + + # Looking for include + # ------------------- + + # Add system include paths to search include + # ------------------------------------------ + unset(_inc_env) + if(ENV_HWLOC_INCDIR) + list(APPEND _inc_env "${ENV_HWLOC_INCDIR}") + elseif(ENV_HWLOC_DIR) + list(APPEND _inc_env "${ENV_HWLOC_DIR}") + list(APPEND _inc_env "${ENV_HWLOC_DIR}/include") + list(APPEND _inc_env "${ENV_HWLOC_DIR}/include/hwloc") + else() + if(WIN32) + string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") + else() + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{CPATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") endif() - - # Looking for include - # ------------------- - - # Add system include paths to search include - # ------------------------------------------ - unset(_inc_env) - if(ENV_HWLOC_INCDIR) - list(APPEND _inc_env "${ENV_HWLOC_INCDIR}") - elseif(ENV_HWLOC_DIR) - list(APPEND _inc_env "${ENV_HWLOC_DIR}") - list(APPEND _inc_env "${ENV_HWLOC_DIR}/include") - list(APPEND _inc_env "${ENV_HWLOC_DIR}/include/hwloc") + endif() + list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") + list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") + list(REMOVE_DUPLICATES _inc_env) + + # set paths where to look for + set(PATH_TO_LOOK_FOR "${_inc_env}") + + # Try to find the hwloc header in the given paths + # ------------------------------------------------- + # call cmake macro to find the header path + if(HWLOC_INCDIR) + set(HWLOC_hwloc.h_DIRS "HWLOC_hwloc.h_DIRS-NOTFOUND") + find_path(HWLOC_hwloc.h_DIRS + NAMES hwloc.h + HINTS ${HWLOC_INCDIR}) + else() + if(HWLOC_DIR) + set(HWLOC_hwloc.h_DIRS "HWLOC_hwloc.h_DIRS-NOTFOUND") + find_path(HWLOC_hwloc.h_DIRS + NAMES hwloc.h + HINTS ${HWLOC_DIR} + PATH_SUFFIXES "include" "include/hwloc") else() - if(WIN32) - string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") - else() - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{CPATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - endif() + set(HWLOC_hwloc.h_DIRS "HWLOC_hwloc.h_DIRS-NOTFOUND") + find_path(HWLOC_hwloc.h_DIRS + NAMES hwloc.h + HINTS ${PATH_TO_LOOK_FOR} + PATH_SUFFIXES "hwloc") + endif() + endif() + mark_as_advanced(HWLOC_hwloc.h_DIRS) + + # Add path to cmake variable + # ------------------------------------ + if (HWLOC_hwloc.h_DIRS) + set(HWLOC_INCLUDE_DIRS "${HWLOC_hwloc.h_DIRS}") + else () + set(HWLOC_INCLUDE_DIRS "HWLOC_INCLUDE_DIRS-NOTFOUND") + if(NOT HWLOC_FIND_QUIETLY) + message(STATUS "Looking for hwloc -- hwloc.h not found") endif() - list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") - list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") - list(REMOVE_DUPLICATES _inc_env) - - # set paths where to look for - set(PATH_TO_LOOK_FOR "${_inc_env}") - - # Try to find the hwloc header in the given paths - # ------------------------------------------------- - # call cmake macro to find the header path - if(HWLOC_INCDIR) - set(HWLOC_hwloc.h_DIRS "HWLOC_hwloc.h_DIRS-NOTFOUND") - find_path(HWLOC_hwloc.h_DIRS - NAMES hwloc.h - HINTS ${HWLOC_INCDIR}) + endif () + + if (HWLOC_INCLUDE_DIRS) + list(REMOVE_DUPLICATES HWLOC_INCLUDE_DIRS) + endif () + + + # Looking for lib + # --------------- + + # Add system library paths to search lib + # -------------------------------------- + unset(_lib_env) + if(ENV_HWLOC_LIBDIR) + list(APPEND _lib_env "${ENV_HWLOC_LIBDIR}") + elseif(ENV_HWLOC_DIR) + list(APPEND _lib_env "${ENV_HWLOC_DIR}") + list(APPEND _lib_env "${ENV_HWLOC_DIR}/lib") + else() + if(WIN32) + string(REPLACE ":" ";" _lib_env "$ENV{LIB}") else() - if(HWLOC_DIR) - set(HWLOC_hwloc.h_DIRS "HWLOC_hwloc.h_DIRS-NOTFOUND") - find_path(HWLOC_hwloc.h_DIRS - NAMES hwloc.h - HINTS ${HWLOC_DIR} - PATH_SUFFIXES "include" "include/hwloc") - else() - set(HWLOC_hwloc.h_DIRS "HWLOC_hwloc.h_DIRS-NOTFOUND") - find_path(HWLOC_hwloc.h_DIRS - NAMES hwloc.h - HINTS ${PATH_TO_LOOK_FOR} - PATH_SUFFIXES "hwloc") - endif() + if(APPLE) + string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") + else() + string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") + endif() + list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") + list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") endif() - mark_as_advanced(HWLOC_hwloc.h_DIRS) - - # Add path to cmake variable - # ------------------------------------ - if (HWLOC_hwloc.h_DIRS) - set(HWLOC_INCLUDE_DIRS "${HWLOC_hwloc.h_DIRS}") - else () - set(HWLOC_INCLUDE_DIRS "HWLOC_INCLUDE_DIRS-NOTFOUND") - if(NOT HWLOC_FIND_QUIETLY) - message(STATUS "Looking for hwloc -- hwloc.h not found") - endif() - endif () - - if (HWLOC_INCLUDE_DIRS) - list(REMOVE_DUPLICATES HWLOC_INCLUDE_DIRS) - endif () - - - # Looking for lib - # --------------- - - # Add system library paths to search lib - # -------------------------------------- - unset(_lib_env) - if(ENV_HWLOC_LIBDIR) - list(APPEND _lib_env "${ENV_HWLOC_LIBDIR}") - elseif(ENV_HWLOC_DIR) - list(APPEND _lib_env "${ENV_HWLOC_DIR}") - list(APPEND _lib_env "${ENV_HWLOC_DIR}/lib") + endif() + list(REMOVE_DUPLICATES _lib_env) + + # set paths where to look for + set(PATH_TO_LOOK_FOR "${_lib_env}") + + # Try to find the hwloc lib in the given paths + # ---------------------------------------------- + + # call cmake macro to find the lib path + if(HWLOC_LIBDIR) + set(HWLOC_hwloc_LIBRARY "HWLOC_hwloc_LIBRARY-NOTFOUND") + find_library(HWLOC_hwloc_LIBRARY + NAMES hwloc + HINTS ${HWLOC_LIBDIR}) + else() + if(HWLOC_DIR) + set(HWLOC_hwloc_LIBRARY "HWLOC_hwloc_LIBRARY-NOTFOUND") + find_library(HWLOC_hwloc_LIBRARY + NAMES hwloc + HINTS ${HWLOC_DIR} + PATH_SUFFIXES lib lib32 lib64) else() - if(WIN32) - string(REPLACE ":" ";" _lib_env "$ENV{LIB}") - else() - if(APPLE) - string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - endif() + set(HWLOC_hwloc_LIBRARY "HWLOC_hwloc_LIBRARY-NOTFOUND") + find_library(HWLOC_hwloc_LIBRARY + NAMES hwloc + HINTS ${PATH_TO_LOOK_FOR}) + endif() + endif() + mark_as_advanced(HWLOC_hwloc_LIBRARY) + + # If found, add path to cmake variable + # ------------------------------------ + if (HWLOC_hwloc_LIBRARY) + get_filename_component(hwloc_lib_path ${HWLOC_hwloc_LIBRARY} PATH) + # set cmake variables (respects naming convention) + set(HWLOC_LIBRARIES "${HWLOC_hwloc_LIBRARY}") + set(HWLOC_LIBRARY_DIRS "${hwloc_lib_path}") + else () + set(HWLOC_LIBRARIES "HWLOC_LIBRARIES-NOTFOUND") + set(HWLOC_LIBRARY_DIRS "HWLOC_LIBRARY_DIRS-NOTFOUND") + if(NOT HWLOC_FIND_QUIETLY) + message(STATUS "Looking for hwloc -- lib hwloc not found") endif() - list(REMOVE_DUPLICATES _lib_env) + endif () - # set paths where to look for - set(PATH_TO_LOOK_FOR "${_lib_env}") + if (HWLOC_LIBRARY_DIRS) + list(REMOVE_DUPLICATES HWLOC_LIBRARY_DIRS) + endif () - # Try to find the hwloc lib in the given paths - # ---------------------------------------------- + # check a function to validate the find + if(HWLOC_LIBRARIES) - # call cmake macro to find the lib path - if(HWLOC_LIBDIR) - set(HWLOC_hwloc_LIBRARY "HWLOC_hwloc_LIBRARY-NOTFOUND") - find_library(HWLOC_hwloc_LIBRARY - NAMES hwloc - HINTS ${HWLOC_LIBDIR}) - else() - if(HWLOC_DIR) - set(HWLOC_hwloc_LIBRARY "HWLOC_hwloc_LIBRARY-NOTFOUND") - find_library(HWLOC_hwloc_LIBRARY - NAMES hwloc - HINTS ${HWLOC_DIR} - PATH_SUFFIXES lib lib32 lib64) - else() - set(HWLOC_hwloc_LIBRARY "HWLOC_hwloc_LIBRARY-NOTFOUND") - find_library(HWLOC_hwloc_LIBRARY - NAMES hwloc - HINTS ${PATH_TO_LOOK_FOR}) - endif() - endif() - mark_as_advanced(HWLOC_hwloc_LIBRARY) - - # If found, add path to cmake variable - # ------------------------------------ - if (HWLOC_hwloc_LIBRARY) - get_filename_component(hwloc_lib_path ${HWLOC_hwloc_LIBRARY} PATH) - # set cmake variables (respects naming convention) - set(HWLOC_LIBRARIES "${HWLOC_hwloc_LIBRARY}") - set(HWLOC_LIBRARY_DIRS "${hwloc_lib_path}") - else () - set(HWLOC_LIBRARIES "HWLOC_LIBRARIES-NOTFOUND") - set(HWLOC_LIBRARY_DIRS "HWLOC_LIBRARY_DIRS-NOTFOUND") - if(NOT HWLOC_FIND_QUIETLY) - message(STATUS "Looking for hwloc -- lib hwloc not found") - endif() - endif () + set(REQUIRED_INCDIRS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) + # HWLOC + if (HWLOC_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${HWLOC_INCLUDE_DIRS}") + endif() if (HWLOC_LIBRARY_DIRS) - list(REMOVE_DUPLICATES HWLOC_LIBRARY_DIRS) - endif () - - # check a function to validate the find - if(HWLOC_LIBRARIES) - - set(REQUIRED_INCDIRS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) - - # HWLOC - if (HWLOC_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${HWLOC_INCLUDE_DIRS}") - endif() - if (HWLOC_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${HWLOC_LIBRARY_DIRS}") - endif() - set(REQUIRED_LIBS "${HWLOC_LIBRARIES}") - - # set required libraries for link - set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") - set(CMAKE_REQUIRED_LIBRARIES) - foreach(lib_dir ${REQUIRED_LIBDIRS}) - list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}") - endforeach() - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - - # test link - unset(HWLOC_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(hwloc_topology_init HWLOC_WORKS) - mark_as_advanced(HWLOC_WORKS) - - if(NOT HWLOC_WORKS) - if(NOT HWLOC_FIND_QUIETLY) - message(STATUS "Looking for hwloc : test of hwloc_topology_init with hwloc library fails") - message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") - message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") - message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") - endif() - endif() - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_LIBRARIES) - endif(HWLOC_LIBRARIES) + set(REQUIRED_LIBDIRS "${HWLOC_LIBRARY_DIRS}") + endif() + set(REQUIRED_LIBS "${HWLOC_LIBRARIES}") + + # set required libraries for link + set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") + set(CMAKE_REQUIRED_LIBRARIES) + foreach(lib_dir ${REQUIRED_LIBDIRS}) + list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}") + endforeach() + list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") + string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + + # test link + unset(HWLOC_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(hwloc_topology_init HWLOC_WORKS) + mark_as_advanced(HWLOC_WORKS) + + if(NOT HWLOC_WORKS) + if(NOT HWLOC_FIND_QUIETLY) + message(STATUS "Looking for hwloc : test of hwloc_topology_init with hwloc library fails") + message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") + message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") + message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") + endif() + endif() + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) + endif(HWLOC_LIBRARIES) endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT HWLOC_FOUND) OR (HWLOC_GIVEN_BY_USER) ) if (HWLOC_LIBRARIES) - 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_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of HWLOC library" FORCE) - else() - set(HWLOC_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of HWLOC library" FORCE) - endif() + 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_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of HWLOC library" FORCE) + else() + set(HWLOC_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of HWLOC library" FORCE) + endif() endif() mark_as_advanced(HWLOC_DIR) mark_as_advanced(HWLOC_DIR_FOUND) @@ -307,26 +307,25 @@ mark_as_advanced(HWLOC_DIR_FOUND) # ------------------------------- include(FindPackageHandleStandardArgs) if (PKG_CONFIG_EXECUTABLE AND HWLOC_FOUND) - find_package_handle_standard_args(HWLOC DEFAULT_MSG - HWLOC_LIBRARIES) + find_package_handle_standard_args(HWLOC DEFAULT_MSG + HWLOC_LIBRARIES) else() - find_package_handle_standard_args(HWLOC DEFAULT_MSG - HWLOC_LIBRARIES - HWLOC_WORKS) + find_package_handle_standard_args(HWLOC DEFAULT_MSG + HWLOC_LIBRARIES + HWLOC_WORKS) endif() if (HWLOC_FOUND) - set(HWLOC_SAVE_CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES}) - list(APPEND CMAKE_REQUIRED_INCLUDES ${HWLOC_INCLUDE_DIRS}) - - # test headers to guess the version - check_struct_has_member( "struct hwloc_obj" parent hwloc.h HAVE_HWLOC_PARENT_MEMBER ) - check_struct_has_member( "struct hwloc_cache_attr_s" size hwloc.h HAVE_HWLOC_CACHE_ATTR ) - check_c_source_compiles( "#include <hwloc.h> - int main(void) { hwloc_obj_t o; o->type = HWLOC_OBJ_PU; return 0;}" HAVE_HWLOC_OBJ_PU) - include(CheckLibraryExists) - check_library_exists(${HWLOC_LIBRARIES} hwloc_bitmap_free "" HAVE_HWLOC_BITMAP) - - set(CMAKE_REQUIRED_INCLUDES ${HWLOC_SAVE_CMAKE_REQUIRED_INCLUDES}) + set(HWLOC_SAVE_CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES}) + list(APPEND CMAKE_REQUIRED_INCLUDES ${HWLOC_INCLUDE_DIRS}) + + # test headers to guess the version + check_struct_has_member( "struct hwloc_obj" parent hwloc.h HAVE_HWLOC_PARENT_MEMBER ) + check_struct_has_member( "struct hwloc_cache_attr_s" size hwloc.h HAVE_HWLOC_CACHE_ATTR ) + check_c_source_compiles( "#include <hwloc.h> + int main(void) { hwloc_obj_t o; o->type = HWLOC_OBJ_PU; return 0;}" HAVE_HWLOC_OBJ_PU) + include(CheckLibraryExists) + check_library_exists(${HWLOC_LIBRARIES} hwloc_bitmap_free "" HAVE_HWLOC_BITMAP) + + set(CMAKE_REQUIRED_INCLUDES ${HWLOC_SAVE_CMAKE_REQUIRED_INCLUDES}) endif() - diff --git a/CMakeModules/morse/find/FindHYPRE.cmake b/CMakeModules/morse/find/FindHYPRE.cmake index 0f74e37caf6f6aa4851fea2283091c95e76baffc..944b5ecbdb952d13a4b2e0bee15352cda500bc52 100644 --- a/CMakeModules/morse/find/FindHYPRE.cmake +++ b/CMakeModules/morse/find/FindHYPRE.cmake @@ -43,10 +43,10 @@ # License text for the above reference.) if (NOT HYPRE_FOUND) - set(HYPRE_DIR "" CACHE PATH "Installation directory of HYPRE library") - if (NOT HYPRE_FIND_QUIETLY) - message(STATUS "A cache variable, namely HYPRE_DIR, has been set to specify the install directory of HYPRE") - endif() + set(HYPRE_DIR "" CACHE PATH "Installation directory of HYPRE library") + if (NOT HYPRE_FIND_QUIETLY) + message(STATUS "A cache variable, namely HYPRE_DIR, has been set to specify the install directory of HYPRE") + endif() endif() set(ENV_HYPRE_DIR "$ENV{HYPRE_DIR}") @@ -54,7 +54,7 @@ set(ENV_HYPRE_INCDIR "$ENV{HYPRE_INCDIR}") set(ENV_HYPRE_LIBDIR "$ENV{HYPRE_LIBDIR}") set(HYPRE_GIVEN_BY_USER "FALSE") if ( HYPRE_DIR OR ( HYPRE_INCDIR AND HYPRE_LIBDIR) OR ENV_HYPRE_DIR OR (ENV_HYPRE_INCDIR AND ENV_HYPRE_LIBDIR) ) - set(HYPRE_GIVEN_BY_USER "TRUE") + set(HYPRE_GIVEN_BY_USER "TRUE") endif() # Looking for include @@ -64,24 +64,24 @@ endif() # ------------------------------------------ unset(_inc_env) if(ENV_HYPRE_INCDIR) - list(APPEND _inc_env "${ENV_HYPRE_INCDIR}") + list(APPEND _inc_env "${ENV_HYPRE_INCDIR}") elseif(ENV_HYPRE_DIR) - list(APPEND _inc_env "${ENV_HYPRE_DIR}") - list(APPEND _inc_env "${ENV_HYPRE_DIR}/include") - list(APPEND _inc_env "${ENV_HYPRE_DIR}/include/hypre") + list(APPEND _inc_env "${ENV_HYPRE_DIR}") + list(APPEND _inc_env "${ENV_HYPRE_DIR}/include") + list(APPEND _inc_env "${ENV_HYPRE_DIR}/include/hypre") else() - if(WIN32) - string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") - else() - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{CPATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - endif() + if(WIN32) + string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") + else() + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{CPATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + endif() endif() list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") @@ -94,40 +94,40 @@ set(PATH_TO_LOOK_FOR "${_inc_env}") # ------------------------------------------------- # call cmake macro to find the header path if(HYPRE_INCDIR) + set(HYPRE_HYPRE.h_DIRS "HYPRE_HYPRE.h_DIRS-NOTFOUND") + find_path(HYPRE_HYPRE.h_DIRS + NAMES HYPRE.h + HINTS ${HYPRE_INCDIR}) +else() + if(HYPRE_DIR) set(HYPRE_HYPRE.h_DIRS "HYPRE_HYPRE.h_DIRS-NOTFOUND") find_path(HYPRE_HYPRE.h_DIRS NAMES HYPRE.h - HINTS ${HYPRE_INCDIR}) -else() - if(HYPRE_DIR) - set(HYPRE_HYPRE.h_DIRS "HYPRE_HYPRE.h_DIRS-NOTFOUND") - find_path(HYPRE_HYPRE.h_DIRS - NAMES HYPRE.h - HINTS ${HYPRE_DIR} - PATH_SUFFIXES "include" "include/hypre") - else() - set(HYPRE_HYPRE.h_DIRS "HYPRE_HYPRE.h_DIRS-NOTFOUND") - find_path(HYPRE_HYPRE.h_DIRS - NAMES HYPRE.h - HINTS ${PATH_TO_LOOK_FOR} - PATH_SUFFIXES "hypre") - endif() + HINTS ${HYPRE_DIR} + PATH_SUFFIXES "include" "include/hypre") + else() + set(HYPRE_HYPRE.h_DIRS "HYPRE_HYPRE.h_DIRS-NOTFOUND") + find_path(HYPRE_HYPRE.h_DIRS + NAMES HYPRE.h + HINTS ${PATH_TO_LOOK_FOR} + PATH_SUFFIXES "hypre") + endif() endif() mark_as_advanced(HYPRE_HYPRE.h_DIRS) # Add path to cmake variable # ------------------------------------ if (HYPRE_HYPRE.h_DIRS) - set(HYPRE_INCLUDE_DIRS "${HYPRE_HYPRE.h_DIRS}") + set(HYPRE_INCLUDE_DIRS "${HYPRE_HYPRE.h_DIRS}") else () - set(HYPRE_INCLUDE_DIRS "HYPRE_INCLUDE_DIRS-NOTFOUND") - if(NOT HYPRE_FIND_QUIETLY) - message(STATUS "Looking for hypre -- HYPRE.h not found") - endif() + set(HYPRE_INCLUDE_DIRS "HYPRE_INCLUDE_DIRS-NOTFOUND") + if(NOT HYPRE_FIND_QUIETLY) + message(STATUS "Looking for hypre -- HYPRE.h not found") + endif() endif () if (HYPRE_INCLUDE_DIRS) - list(REMOVE_DUPLICATES HYPRE_INCLUDE_DIRS) + list(REMOVE_DUPLICATES HYPRE_INCLUDE_DIRS) endif () @@ -138,22 +138,22 @@ endif () # -------------------------------------- unset(_lib_env) if(ENV_HYPRE_LIBDIR) - list(APPEND _lib_env "${ENV_HYPRE_LIBDIR}") + list(APPEND _lib_env "${ENV_HYPRE_LIBDIR}") elseif(ENV_HYPRE_DIR) - list(APPEND _lib_env "${ENV_HYPRE_DIR}") - list(APPEND _lib_env "${ENV_HYPRE_DIR}/lib") + list(APPEND _lib_env "${ENV_HYPRE_DIR}") + list(APPEND _lib_env "${ENV_HYPRE_DIR}/lib") else() - if(WIN32) - string(REPLACE ":" ";" _lib_env "$ENV{LIB}") + if(WIN32) + string(REPLACE ":" ";" _lib_env "$ENV{LIB}") + else() + if(APPLE) + string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") else() - if(APPLE) - string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") endif() + list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") + list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + endif() endif() list(REMOVE_DUPLICATES _lib_env) @@ -165,102 +165,102 @@ set(PATH_TO_LOOK_FOR "${_lib_env}") # call cmake macro to find the lib path if(HYPRE_LIBDIR) + set(HYPRE_HYPRE_LIBRARY "HYPRE_HYPRE_LIBRARY-NOTFOUND") + find_library(HYPRE_HYPRE_LIBRARY + NAMES HYPRE + HINTS ${HYPRE_LIBDIR}) +else() + if(HYPRE_DIR) set(HYPRE_HYPRE_LIBRARY "HYPRE_HYPRE_LIBRARY-NOTFOUND") find_library(HYPRE_HYPRE_LIBRARY - NAMES HYPRE - HINTS ${HYPRE_LIBDIR}) -else() - if(HYPRE_DIR) - set(HYPRE_HYPRE_LIBRARY "HYPRE_HYPRE_LIBRARY-NOTFOUND") - find_library(HYPRE_HYPRE_LIBRARY - NAMES HYPRE - HINTS ${HYPRE_DIR} - PATH_SUFFIXES lib lib32 lib64) - else() - set(HYPRE_HYPRE_LIBRARY "HYPRE_HYPRE_LIBRARY-NOTFOUND") - find_library(HYPRE_HYPRE_LIBRARY - NAMES HYPRE - HINTS ${PATH_TO_LOOK_FOR}) - endif() + NAMES HYPRE + HINTS ${HYPRE_DIR} + PATH_SUFFIXES lib lib32 lib64) + else() + set(HYPRE_HYPRE_LIBRARY "HYPRE_HYPRE_LIBRARY-NOTFOUND") + find_library(HYPRE_HYPRE_LIBRARY + NAMES HYPRE + HINTS ${PATH_TO_LOOK_FOR}) + endif() endif() mark_as_advanced(HYPRE_HYPRE_LIBRARY) # If found, add path to cmake variable # ------------------------------------ if (HYPRE_HYPRE_LIBRARY) - get_filename_component(hypre_lib_path ${HYPRE_HYPRE_LIBRARY} PATH) - # set cmake variables (respects naming convention) - set(HYPRE_LIBRARIES "${HYPRE_HYPRE_LIBRARY}") - set(HYPRE_LIBRARY_DIRS "${hypre_lib_path}") + get_filename_component(hypre_lib_path ${HYPRE_HYPRE_LIBRARY} PATH) + # set cmake variables (respects naming convention) + set(HYPRE_LIBRARIES "${HYPRE_HYPRE_LIBRARY}") + set(HYPRE_LIBRARY_DIRS "${hypre_lib_path}") else () - set(HYPRE_LIBRARIES "HYPRE_LIBRARIES-NOTFOUND") - set(HYPRE_LIBRARY_DIRS "HYPRE_LIBRARY_DIRS-NOTFOUND") - if(NOT HYPRE_FIND_QUIETLY) - message(STATUS "Looking for hypre -- lib HYPRE not found") - endif() + set(HYPRE_LIBRARIES "HYPRE_LIBRARIES-NOTFOUND") + set(HYPRE_LIBRARY_DIRS "HYPRE_LIBRARY_DIRS-NOTFOUND") + if(NOT HYPRE_FIND_QUIETLY) + message(STATUS "Looking for hypre -- lib HYPRE not found") + endif() endif () if (HYPRE_LIBRARY_DIRS) - list(REMOVE_DUPLICATES HYPRE_LIBRARY_DIRS) + list(REMOVE_DUPLICATES HYPRE_LIBRARY_DIRS) endif () # check a function to validate the find if(HYPRE_LIBRARIES) - set(REQUIRED_INCDIRS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) + set(REQUIRED_INCDIRS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) - # HYPRE - if (HYPRE_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${HYPRE_INCLUDE_DIRS}") - endif() - if (HYPRE_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${HYPRE_LIBRARY_DIRS}") - endif() - set(REQUIRED_LIBS "${HYPRE_LIBRARIES}") + # HYPRE + if (HYPRE_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${HYPRE_INCLUDE_DIRS}") + endif() + if (HYPRE_LIBRARY_DIRS) + set(REQUIRED_LIBDIRS "${HYPRE_LIBRARY_DIRS}") + endif() + set(REQUIRED_LIBS "${HYPRE_LIBRARIES}") - # set required libraries for link - set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") - set(CMAKE_REQUIRED_LIBRARIES) - foreach(lib_dir ${REQUIRED_LIBDIRS}) - list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}") - endforeach() - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + # set required libraries for link + set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") + set(CMAKE_REQUIRED_LIBRARIES) + foreach(lib_dir ${REQUIRED_LIBDIRS}) + list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}") + endforeach() + list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") + string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - # test link - unset(HYPRE_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(HYPRE_StructGridCreate HYPRE_WORKS) - mark_as_advanced(HYPRE_WORKS) + # test link + unset(HYPRE_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(HYPRE_StructGridCreate HYPRE_WORKS) + mark_as_advanced(HYPRE_WORKS) - if(NOT HYPRE_WORKS) - if(NOT HYPRE_FIND_QUIETLY) - message(STATUS "Looking for HYPRE : test of HYPRE_StructGridCreate with HYPRE library fails") - message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") - message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") - message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") - endif() + if(NOT HYPRE_WORKS) + if(NOT HYPRE_FIND_QUIETLY) + message(STATUS "Looking for HYPRE : test of HYPRE_StructGridCreate with HYPRE library fails") + message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") + message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") + message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") endif() - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_LIBRARIES) + endif() + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) endif(HYPRE_LIBRARIES) if (HYPRE_LIBRARIES) - if (HYPRE_LIBRARY_DIRS) - list(GET HYPRE_LIBRARY_DIRS 0 first_lib_path) - else() - list(GET HYPRE_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(HYPRE_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of HYPRE library" FORCE) - else() - set(HYPRE_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of HYPRE library" FORCE) - endif() + if (HYPRE_LIBRARY_DIRS) + list(GET HYPRE_LIBRARY_DIRS 0 first_lib_path) + else() + list(GET HYPRE_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(HYPRE_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of HYPRE library" FORCE) + else() + set(HYPRE_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of HYPRE library" FORCE) + endif() endif() mark_as_advanced(HYPRE_DIR) mark_as_advanced(HYPRE_DIR_FOUND) @@ -269,5 +269,5 @@ mark_as_advanced(HYPRE_DIR_FOUND) # ------------------------------- include(FindPackageHandleStandardArgs) find_package_handle_standard_args(HYPRE DEFAULT_MSG - HYPRE_LIBRARIES - HYPRE_WORKS) + HYPRE_LIBRARIES + HYPRE_WORKS) diff --git a/CMakeModules/morse/find/FindLAPACK.cmake b/CMakeModules/morse/find/FindLAPACK.cmake index f6ad2c23b09193c649eecafc42191ec636b96f27..378a8fdb81c63b518bb11a7c29832b201a116fb8 100644 --- a/CMakeModules/morse/find/FindLAPACK.cmake +++ b/CMakeModules/morse/find/FindLAPACK.cmake @@ -61,61 +61,61 @@ # 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}") + # 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() - 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_PLATFORM_IMPLICIT_LINK_DIRECTORIES," - "CMAKE_C_IMPLICIT_LINK_DIRECTORIES)${ColourReset}") - if(_lib_env) - message("${Yellow}${_lib_to_find} has not been found in" - "${_lib_env}${ColourReset}") - endif() - endif() + 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_PLATFORM_IMPLICIT_LINK_DIRECTORIES," + "CMAKE_C_IMPLICIT_LINK_DIRECTORIES)${ColourReset}") + if(_lib_env) + message("${Yellow}${_lib_to_find} has not been found in" + "${_lib_env}${ColourReset}") + 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}") + 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() if (NOT LAPACK_FOUND) - 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() + 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() endif (NOT LAPACK_FOUND) option(LAPACK_VERBOSE "Print some additional information during LAPACK libraries detection" OFF) mark_as_advanced(LAPACK_VERBOSE) if (BLAS_VERBOSE) - set(LAPACK_VERBOSE ON) + set(LAPACK_VERBOSE ON) endif () set(_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) 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) set(LAPACK_FOUND FALSE) @@ -124,171 +124,171 @@ set(LAPACK95_FOUND FALSE) # TODO: move this stuff to separate module macro(Check_Lapack_Libraries LIBRARIES _prefix _name _flags _list _blas _threads) -# This macro checks for the existence of the combination of fortran libraries -# given by _list. If the combination is found, this macro checks (using the -# Check_Fortran_Function_Exists macro) whether can link against that library -# combination using the name of a routine given by _name using the linker -# flags given by _flags. If the combination of libraries is found and passes -# the link test, LIBRARIES is set to the list of complete library paths that -# have been found. Otherwise, LIBRARIES is set to FALSE. - -# N.B. _prefix is the prefix applied to the names of all cached variables that -# are generated internally and marked advanced by this macro. -set(_libdir ${ARGN}) -set(_libraries_work TRUE) -set(${LIBRARIES}) -set(_combined_name) -set(ENV_MKLROOT "$ENV{MKLROOT}") -set(ENV_BLAS_DIR "$ENV{BLAS_DIR}") -set(ENV_BLAS_LIBDIR "$ENV{BLAS_LIBDIR}") -set(ENV_LAPACK_DIR "$ENV{LAPACK_DIR}") -set(ENV_LAPACK_LIBDIR "$ENV{LAPACK_LIBDIR}") -if (NOT _libdir) - if (BLAS_LIBDIR) + # This macro checks for the existence of the combination of fortran libraries + # given by _list. If the combination is found, this macro checks (using the + # Check_Fortran_Function_Exists macro) whether can link against that library + # combination using the name of a routine given by _name using the linker + # flags given by _flags. If the combination of libraries is found and passes + # the link test, LIBRARIES is set to the list of complete library paths that + # have been found. Otherwise, LIBRARIES is set to FALSE. + + # N.B. _prefix is the prefix applied to the names of all cached variables that + # are generated internally and marked advanced by this macro. + set(_libdir ${ARGN}) + set(_libraries_work TRUE) + set(${LIBRARIES}) + set(_combined_name) + set(ENV_MKLROOT "$ENV{MKLROOT}") + set(ENV_BLAS_DIR "$ENV{BLAS_DIR}") + set(ENV_BLAS_LIBDIR "$ENV{BLAS_LIBDIR}") + set(ENV_LAPACK_DIR "$ENV{LAPACK_DIR}") + set(ENV_LAPACK_LIBDIR "$ENV{LAPACK_LIBDIR}") + if (NOT _libdir) + if (BLAS_LIBDIR) list(APPEND _libdir "${BLAS_LIBDIR}") - elseif (BLAS_DIR) + elseif (BLAS_DIR) list(APPEND _libdir "${BLAS_DIR}") list(APPEND _libdir "${BLAS_DIR}/lib") if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") - list(APPEND _libdir "${BLAS_DIR}/lib64") - list(APPEND _libdir "${BLAS_DIR}/lib/intel64") + list(APPEND _libdir "${BLAS_DIR}/lib64") + list(APPEND _libdir "${BLAS_DIR}/lib/intel64") else() - list(APPEND _libdir "${BLAS_DIR}/lib32") - list(APPEND _libdir "${BLAS_DIR}/lib/ia32") + list(APPEND _libdir "${BLAS_DIR}/lib32") + list(APPEND _libdir "${BLAS_DIR}/lib/ia32") endif() - elseif(ENV_BLAS_LIBDIR) + elseif(ENV_BLAS_LIBDIR) list(APPEND _libdir "${ENV_BLAS_LIBDIR}") - elseif(ENV_BLAS_DIR) + elseif(ENV_BLAS_DIR) list(APPEND _libdir "${ENV_BLAS_DIR}") list(APPEND _libdir "${ENV_BLAS_DIR}/lib") if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") - list(APPEND _libdir "${ENV_BLAS_DIR}/lib64") - list(APPEND _libdir "${ENV_BLAS_DIR}/lib/intel64") + list(APPEND _libdir "${ENV_BLAS_DIR}/lib64") + list(APPEND _libdir "${ENV_BLAS_DIR}/lib/intel64") else() - list(APPEND _libdir "${ENV_BLAS_DIR}/lib32") - list(APPEND _libdir "${ENV_BLAS_DIR}/lib/ia32") + list(APPEND _libdir "${ENV_BLAS_DIR}/lib32") + list(APPEND _libdir "${ENV_BLAS_DIR}/lib/ia32") endif() - endif() - if (LAPACK_LIBDIR) - list(APPEND _libdir "${LAPACK_LIBDIR}") - elseif (LAPACK_DIR) - list(APPEND _libdir "${LAPACK_DIR}") - list(APPEND _libdir "${LAPACK_DIR}/lib") - if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") - list(APPEND _libdir "${LAPACK_DIR}/lib64") - list(APPEND _libdir "${LAPACK_DIR}/lib/intel64") - else() - list(APPEND _libdir "${LAPACK_DIR}/lib32") - list(APPEND _libdir "${LAPACK_DIR}/lib/ia32") endif() - elseif(ENV_LAPACK_LIBDIR) + if (LAPACK_LIBDIR) + list(APPEND _libdir "${LAPACK_LIBDIR}") + elseif (LAPACK_DIR) + list(APPEND _libdir "${LAPACK_DIR}") + list(APPEND _libdir "${LAPACK_DIR}/lib") + if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") + list(APPEND _libdir "${LAPACK_DIR}/lib64") + list(APPEND _libdir "${LAPACK_DIR}/lib/intel64") + else() + list(APPEND _libdir "${LAPACK_DIR}/lib32") + list(APPEND _libdir "${LAPACK_DIR}/lib/ia32") + endif() + elseif(ENV_LAPACK_LIBDIR) list(APPEND _libdir "${ENV_LAPACK_LIBDIR}") - elseif(ENV_LAPACK_DIR) + elseif(ENV_LAPACK_DIR) list(APPEND _libdir "${ENV_LAPACK_DIR}") list(APPEND _libdir "${ENV_LAPACK_DIR}/lib") if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") - list(APPEND _libdir "${ENV_LAPACK_DIR}/lib64") - list(APPEND _libdir "${ENV_LAPACK_DIR}/lib/intel64") + list(APPEND _libdir "${ENV_LAPACK_DIR}/lib64") + list(APPEND _libdir "${ENV_LAPACK_DIR}/lib/intel64") else() - list(APPEND _libdir "${ENV_LAPACK_DIR}/lib32") - list(APPEND _libdir "${ENV_LAPACK_DIR}/lib/ia32") + list(APPEND _libdir "${ENV_LAPACK_DIR}/lib32") + list(APPEND _libdir "${ENV_LAPACK_DIR}/lib/ia32") endif() - else() - if (ENV_MKLROOT) - list(APPEND _libdir "${ENV_MKLROOT}/lib") - if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") - list(APPEND _libdir "${ENV_MKLROOT}/lib64") - list(APPEND _libdir "${ENV_MKLROOT}/lib/intel64") - else() - list(APPEND _libdir "${ENV_MKLROOT}/lib32") - list(APPEND _libdir "${ENV_MKLROOT}/lib/ia32") - endif() - endif() - if (WIN32) - string(REPLACE ":" ";" _libdir2 "$ENV{LIB}") - elseif (APPLE) - string(REPLACE ":" ";" _libdir2 "$ENV{DYLD_LIBRARY_PATH}") - else () - string(REPLACE ":" ";" _libdir2 "$ENV{LD_LIBRARY_PATH}") + else() + if (ENV_MKLROOT) + list(APPEND _libdir "${ENV_MKLROOT}/lib") + if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") + list(APPEND _libdir "${ENV_MKLROOT}/lib64") + list(APPEND _libdir "${ENV_MKLROOT}/lib/intel64") + else() + list(APPEND _libdir "${ENV_MKLROOT}/lib32") + list(APPEND _libdir "${ENV_MKLROOT}/lib/ia32") + endif() + endif() + if (WIN32) + string(REPLACE ":" ";" _libdir2 "$ENV{LIB}") + elseif (APPLE) + 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 () - list(APPEND _libdir "${_libdir2}") - list(APPEND _libdir "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") - list(APPEND _libdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") endif () -endif () -if (LAPACK_VERBOSE) + if (LAPACK_VERBOSE) message("${Cyan}Try to find LAPACK libraries: ${_list}") -endif () + endif () -foreach(_library ${_list}) - set(_combined_name ${_combined_name}_${_library}) + foreach(_library ${_list}) + set(_combined_name ${_combined_name}_${_library}) + + if(_libraries_work) + if (BLA_STATIC) + if (WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) + endif ( WIN32 ) + if (APPLE) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) + else (APPLE) + set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + endif (APPLE) + else (BLA_STATIC) + if (CMAKE_SYSTEM_NAME STREQUAL "Linux") + # for ubuntu's libblas3gf and liblapack3gf packages + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf) + endif () + endif (BLA_STATIC) + find_library(${_prefix}_${_library}_LIBRARY + NAMES ${_library} + HINTS ${_libdir} + NO_DEFAULT_PATH + ) + mark_as_advanced(${_prefix}_${_library}_LIBRARY) + # Print status if not found + # ------------------------- + if (NOT ${_prefix}_${_library}_LIBRARY AND NOT LAPACK_FIND_QUIETLY AND LAPACK_VERBOSE) + Print_Find_Library_Blas_Status(lapack ${_library} ${_libdir}) + endif () + set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) + set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) + endif(_libraries_work) + endforeach(_library ${_list}) if(_libraries_work) - if (BLA_STATIC) - if (WIN32) - set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) - endif ( WIN32 ) - if (APPLE) - set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) - else (APPLE) - set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) - endif (APPLE) - else (BLA_STATIC) - if (CMAKE_SYSTEM_NAME STREQUAL "Linux") - # for ubuntu's libblas3gf and liblapack3gf packages - set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf) - endif () - endif (BLA_STATIC) - find_library(${_prefix}_${_library}_LIBRARY - NAMES ${_library} - HINTS ${_libdir} - NO_DEFAULT_PATH - ) - mark_as_advanced(${_prefix}_${_library}_LIBRARY) - # Print status if not found - # ------------------------- - if (NOT ${_prefix}_${_library}_LIBRARY AND NOT LAPACK_FIND_QUIETLY AND LAPACK_VERBOSE) - Print_Find_Library_Blas_Status(lapack ${_library} ${_libdir}) + # Test this combination of libraries. + if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND BLA_STATIC) + list(INSERT ${LIBRARIES} 0 "-Wl,--start-group") + list(APPEND ${LIBRARIES} "-Wl,--end-group") + endif() + if(UNIX AND BLA_STATIC) + set(CMAKE_REQUIRED_LIBRARIES ${_flags} "-Wl,--start-group" ${${LIBRARIES}} ${_blas} "-Wl,--end-group" ${_threads}) + else(UNIX AND BLA_STATIC) + set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blas} ${_threads}) + endif(UNIX AND BLA_STATIC) + if (LAPACK_VERBOSE) + message("${Cyan}LAPACK libs found. Try to compile symbol ${_name} with" + "following libraries: ${CMAKE_REQUIRED_LIBRARIES}") endif () - set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) - set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) + if(NOT LAPACK_FOUND) + unset(${_prefix}${_combined_name}_WORKS CACHE) + endif() + if (NOT _LANGUAGES_ MATCHES Fortran) + check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS) + else (NOT _LANGUAGES_ MATCHES Fortran) + check_fortran_function_exists(${_name} ${_prefix}${_combined_name}_WORKS) + endif (NOT _LANGUAGES_ MATCHES Fortran) + set(CMAKE_REQUIRED_LIBRARIES) + mark_as_advanced(${_prefix}${_combined_name}_WORKS) + set(_libraries_work ${${_prefix}${_combined_name}_WORKS}) endif(_libraries_work) -endforeach(_library ${_list}) -if(_libraries_work) - # Test this combination of libraries. - if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND BLA_STATIC) - list(INSERT ${LIBRARIES} 0 "-Wl,--start-group") - list(APPEND ${LIBRARIES} "-Wl,--end-group") - endif() - if(UNIX AND BLA_STATIC) - set(CMAKE_REQUIRED_LIBRARIES ${_flags} "-Wl,--start-group" ${${LIBRARIES}} ${_blas} "-Wl,--end-group" ${_threads}) - else(UNIX AND BLA_STATIC) - set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blas} ${_threads}) - endif(UNIX AND BLA_STATIC) - if (LAPACK_VERBOSE) - message("${Cyan}LAPACK libs found. Try to compile symbol ${_name} with" - "following libraries: ${CMAKE_REQUIRED_LIBRARIES}") - endif () - if(NOT LAPACK_FOUND) - unset(${_prefix}${_combined_name}_WORKS CACHE) - endif() - if (NOT _LANGUAGES_ MATCHES Fortran) - check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS) - else (NOT _LANGUAGES_ MATCHES Fortran) - check_fortran_function_exists(${_name} ${_prefix}${_combined_name}_WORKS) - endif (NOT _LANGUAGES_ MATCHES Fortran) - set(CMAKE_REQUIRED_LIBRARIES) - mark_as_advanced(${_prefix}${_combined_name}_WORKS) - set(_libraries_work ${${_prefix}${_combined_name}_WORKS}) -endif(_libraries_work) - - if(_libraries_work) - set(${LIBRARIES} ${${LIBRARIES}} ${_blas} ${_threads}) - else(_libraries_work) + if(_libraries_work) + set(${LIBRARIES} ${${LIBRARIES}} ${_blas} ${_threads}) + else(_libraries_work) set(${LIBRARIES} FALSE) - endif(_libraries_work) + endif(_libraries_work) endmacro(Check_Lapack_Libraries) @@ -298,11 +298,11 @@ set(LAPACK_LIBRARIES) set(LAPACK95_LIBRARIES) if (NOT BLAS_FOUND) - if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED) - find_package(BLASEXT) - else(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED) - find_package(BLASEXT REQUIRED) - endif(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED) + if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED) + find_package(BLASEXT) + else(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED) + find_package(BLASEXT REQUIRED) + endif(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED) endif () if(BLAS_FOUND) @@ -315,354 +315,354 @@ if(BLAS_FOUND) endif(NOT BLA_VENDOR) endif ($ENV{BLA_VENDOR} MATCHES ".+") -if (UNIX AND NOT WIN32) - # m - find_library(M_LIBRARY NAMES m) - mark_as_advanced(M_LIBRARY) - if(M_LIBRARY) - set(LM "-lm") - else() - set(LM "") + if (UNIX AND NOT WIN32) + # m + find_library(M_LIBRARY NAMES m) + mark_as_advanced(M_LIBRARY) + if(M_LIBRARY) + set(LM "-lm") + else() + set(LM "") + endif() endif() -endif() -#intel lapack -if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") + #intel lapack + if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") - if (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX) - if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED) - find_PACKAGE(Threads) - else() - find_package(Threads REQUIRED) - endif() + if (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX) + if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED) + find_PACKAGE(Threads) + else() + find_package(Threads REQUIRED) + endif() - set(LAPACK_SEARCH_LIBS "") + set(LAPACK_SEARCH_LIBS "") - set(additional_flags "") - if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_SYSTEM_NAME STREQUAL "Linux") - set(additional_flags "-Wl,--no-as-needed") - endif() + set(additional_flags "") + if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(additional_flags "-Wl,--no-as-needed") + endif() - if (BLA_F95) - set(LAPACK_mkl_SEARCH_SYMBOL "CHEEV") - set(_LIBRARIES LAPACK95_LIBRARIES) - set(_BLAS_LIBRARIES ${BLAS95_LIBRARIES}) - - # old - list(APPEND LAPACK_SEARCH_LIBS - "mkl_lapack95") - # new >= 10.3 - list(APPEND LAPACK_SEARCH_LIBS - "mkl_intel_c") - list(APPEND LAPACK_SEARCH_LIBS - "mkl_intel_lp64") - else() - set(LAPACK_mkl_SEARCH_SYMBOL "cheev") - set(_LIBRARIES LAPACK_LIBRARIES) - set(_BLAS_LIBRARIES ${BLAS_LIBRARIES}) - - # old - list(APPEND LAPACK_SEARCH_LIBS - "mkl_lapack") - # new >= 10.3 - list(APPEND LAPACK_SEARCH_LIBS - "mkl_gf_lp64") - endif() + if (BLA_F95) + set(LAPACK_mkl_SEARCH_SYMBOL "CHEEV") + set(_LIBRARIES LAPACK95_LIBRARIES) + set(_BLAS_LIBRARIES ${BLAS95_LIBRARIES}) + + # old + list(APPEND LAPACK_SEARCH_LIBS + "mkl_lapack95") + # new >= 10.3 + list(APPEND LAPACK_SEARCH_LIBS + "mkl_intel_c") + list(APPEND LAPACK_SEARCH_LIBS + "mkl_intel_lp64") + else() + set(LAPACK_mkl_SEARCH_SYMBOL "cheev") + set(_LIBRARIES LAPACK_LIBRARIES) + set(_BLAS_LIBRARIES ${BLAS_LIBRARIES}) + + # old + list(APPEND LAPACK_SEARCH_LIBS + "mkl_lapack") + # new >= 10.3 + list(APPEND LAPACK_SEARCH_LIBS + "mkl_gf_lp64") + endif() - # First try empty lapack libs - if (NOT ${_LIBRARIES}) - check_lapack_libraries( - ${_LIBRARIES} - LAPACK - ${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}) + # First try empty lapack libs if (NOT ${_LIBRARIES}) - check_lapack_libraries( - ${_LIBRARIES} - LAPACK - ${LAPACK_mkl_SEARCH_SYMBOL} - "${additional_flags}" - "${IT}" - "${_BLAS_LIBRARIES}" - "${CMAKE_THREAD_LIBS_INIT};${LM}" - ) - if(_LIBRARIES) - set(LAPACK_LINKER_FLAGS "${additional_flags}") - endif() + check_lapack_libraries( + ${_LIBRARIES} + LAPACK + ${LAPACK_mkl_SEARCH_SYMBOL} + "${additional_flags}" + "" + "${_BLAS_LIBRARIES}" + "${CMAKE_THREAD_LIBS_INIT};${LM}" + ) + if(_LIBRARIES) + set(LAPACK_LINKER_FLAGS "${additional_flags}") + endif() endif () - endforeach () - if(NOT LAPACK_FIND_QUIETLY) - if(${_LIBRARIES}) - message(STATUS "Looking for MKL LAPACK: found") - else() - message(STATUS "Looking for MKL LAPACK: not found") - endif() + # Then try the search libs + foreach (IT ${LAPACK_SEARCH_LIBS}) + if (NOT ${_LIBRARIES}) + check_lapack_libraries( + ${_LIBRARIES} + LAPACK + ${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 () + if(NOT LAPACK_FIND_QUIETLY) + if(${_LIBRARIES}) + message(STATUS "Looking for MKL LAPACK: found") + else() + message(STATUS "Looking for MKL LAPACK: not found") + endif() + endif() + endif () + endif() + + #goto lapack + if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") + if(NOT LAPACK_LIBRARIES) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "goto2" + "${BLAS_LIBRARIES}" + "" + ) + if(NOT LAPACK_FIND_QUIETLY) + if(LAPACK_LIBRARIES) + message(STATUS "Looking for Goto LAPACK: found") + else() + message(STATUS "Looking for Goto LAPACK: not found") + endif() + endif() + endif(NOT LAPACK_LIBRARIES) + endif (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") + + #open lapack + if (BLA_VENDOR STREQUAL "Open" OR BLA_VENDOR STREQUAL "All") + if(NOT LAPACK_LIBRARIES) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "openblas" + "${BLAS_LIBRARIES}" + "" + ) + if(NOT LAPACK_FIND_QUIETLY) + if(LAPACK_LIBRARIES) + message(STATUS "Looking for Open LAPACK: found") + else() + message(STATUS "Looking for Open LAPACK: not found") + endif() + endif() + endif(NOT LAPACK_LIBRARIES) + endif (BLA_VENDOR STREQUAL "Open" OR BLA_VENDOR STREQUAL "All") + + # LAPACK in IBM ESSL library (requires generic lapack lib, too) + if (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All") + if(NOT LAPACK_LIBRARIES) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheevd + "" + "essl;lapack" + "${BLAS_LIBRARIES}" + "" + ) + if(NOT LAPACK_FIND_QUIETLY) + if(LAPACK_LIBRARIES) + message(STATUS "Looking for IBM ESSL LAPACK: found") + else() + message(STATUS "Looking for IBM ESSL LAPACK: not found") + endif() + endif() endif() endif () -endif() -#goto lapack -if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "goto2" - "${BLAS_LIBRARIES}" - "" - ) - if(NOT LAPACK_FIND_QUIETLY) - if(LAPACK_LIBRARIES) - message(STATUS "Looking for Goto LAPACK: found") - else() - message(STATUS "Looking for Goto LAPACK: not found") - endif() - endif() - endif(NOT LAPACK_LIBRARIES) -endif (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") - -#open lapack -if (BLA_VENDOR STREQUAL "Open" OR BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "openblas" - "${BLAS_LIBRARIES}" - "" - ) - if(NOT LAPACK_FIND_QUIETLY) - if(LAPACK_LIBRARIES) - message(STATUS "Looking for Open LAPACK: found") - else() - message(STATUS "Looking for Open LAPACK: not found") - endif() - endif() - endif(NOT LAPACK_LIBRARIES) -endif (BLA_VENDOR STREQUAL "Open" OR BLA_VENDOR STREQUAL "All") - -# LAPACK in IBM ESSL library (requires generic lapack lib, too) -if (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheevd - "" - "essl;lapack" - "${BLAS_LIBRARIES}" - "" - ) - if(NOT LAPACK_FIND_QUIETLY) - if(LAPACK_LIBRARIES) - message(STATUS "Looking for IBM ESSL LAPACK: found") - else() - message(STATUS "Looking for IBM ESSL LAPACK: not found") - endif() - endif() - endif() -endif () + # LAPACK in IBM ESSL_MT library (requires generic lapack lib, too) + if (BLA_VENDOR STREQUAL "IBMESSLMT" OR BLA_VENDOR STREQUAL "All") + if(NOT LAPACK_LIBRARIES) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheevd + "" + "esslsmp;lapack" + "${BLAS_PAR_LIBRARIES}" + "" + ) + if(NOT LAPACK_FIND_QUIETLY) + if(LAPACK_LIBRARIES) + message(STATUS "Looking for IBM ESSL MT LAPACK: found") + else() + message(STATUS "Looking for IBM ESSL MT LAPACK: not found") + endif() + endif() + endif() + endif () -# LAPACK in IBM ESSL_MT library (requires generic lapack lib, too) -if (BLA_VENDOR STREQUAL "IBMESSLMT" OR BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheevd - "" - "esslsmp;lapack" - "${BLAS_PAR_LIBRARIES}" - "" - ) - if(NOT LAPACK_FIND_QUIETLY) - if(LAPACK_LIBRARIES) - message(STATUS "Looking for IBM ESSL MT LAPACK: found") - else() - message(STATUS "Looking for IBM ESSL MT LAPACK: not found") - endif() - endif() - endif() -endif () + #acml lapack + if (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All") + if (BLAS_LIBRARIES MATCHES ".+acml.+") + set (LAPACK_LIBRARIES ${BLAS_LIBRARIES}) + if(NOT LAPACK_FIND_QUIETLY) + if(LAPACK_LIBRARIES) + message(STATUS "Looking for ACML LAPACK: found") + else() + message(STATUS "Looking for ACML LAPACK: not found") + endif() + endif() + endif () + endif () -#acml lapack -if (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All") - if (BLAS_LIBRARIES MATCHES ".+acml.+") - set (LAPACK_LIBRARIES ${BLAS_LIBRARIES}) - if(NOT LAPACK_FIND_QUIETLY) - if(LAPACK_LIBRARIES) - message(STATUS "Looking for ACML LAPACK: found") - else() - message(STATUS "Looking for ACML LAPACK: not found") - endif() - endif() - endif () -endif () + # Apple LAPACK library? + if (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") + if(NOT LAPACK_LIBRARIES) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "Accelerate" + "${BLAS_LIBRARIES}" + "" + ) + if(NOT LAPACK_FIND_QUIETLY) + if(LAPACK_LIBRARIES) + message(STATUS "Looking for Apple Accelerate LAPACK: found") + else() + message(STATUS "Looking for Apple Accelerate LAPACK: not found") + endif() + endif() + endif(NOT LAPACK_LIBRARIES) + endif (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") -# Apple LAPACK library? -if (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "Accelerate" - "${BLAS_LIBRARIES}" - "" - ) - if(NOT LAPACK_FIND_QUIETLY) - if(LAPACK_LIBRARIES) - message(STATUS "Looking for Apple Accelerate LAPACK: found") - else() - message(STATUS "Looking for Apple Accelerate LAPACK: not found") - endif() - endif() - endif(NOT LAPACK_LIBRARIES) -endif (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") - -if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") - if ( NOT LAPACK_LIBRARIES ) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "vecLib" - "${BLAS_LIBRARIES}" - "" - ) - if(NOT LAPACK_FIND_QUIETLY) - if(LAPACK_LIBRARIES) - message(STATUS "Looking for NAS LAPACK: found") - else() - message(STATUS "Looking for NAS LAPACK: not found") - endif() - endif() - endif ( NOT LAPACK_LIBRARIES ) -endif (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") - -# Generic LAPACK library? -if (BLA_VENDOR STREQUAL "Generic" OR - BLA_VENDOR STREQUAL "ATLAS" OR - BLA_VENDOR STREQUAL "All") - if ( NOT LAPACK_LIBRARIES ) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "lapack" - "${BLAS_LIBRARIES};${LM}" - "" - ) - if(NOT LAPACK_FIND_QUIETLY) - if(LAPACK_LIBRARIES) - message(STATUS "Looking for Generic LAPACK: found") - else() - message(STATUS "Looking for Generic LAPACK: not found") - endif() - endif() - endif ( NOT LAPACK_LIBRARIES ) -endif () + if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") + if ( NOT LAPACK_LIBRARIES ) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "vecLib" + "${BLAS_LIBRARIES}" + "" + ) + if(NOT LAPACK_FIND_QUIETLY) + if(LAPACK_LIBRARIES) + message(STATUS "Looking for NAS LAPACK: found") + else() + message(STATUS "Looking for NAS LAPACK: not found") + endif() + endif() + endif ( NOT LAPACK_LIBRARIES ) + endif (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") + + # Generic LAPACK library? + if (BLA_VENDOR STREQUAL "Generic" OR + BLA_VENDOR STREQUAL "ATLAS" OR + BLA_VENDOR STREQUAL "All") + if ( NOT LAPACK_LIBRARIES ) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "lapack" + "${BLAS_LIBRARIES};${LM}" + "" + ) + if(NOT LAPACK_FIND_QUIETLY) + if(LAPACK_LIBRARIES) + message(STATUS "Looking for Generic LAPACK: found") + else() + message(STATUS "Looking for Generic LAPACK: not found") + endif() + endif() + endif ( NOT LAPACK_LIBRARIES ) + endif () else(BLAS_FOUND) message(STATUS "LAPACK requires BLAS") endif(BLAS_FOUND) if(BLA_F95) - if(LAPACK95_LIBRARIES) - set(LAPACK95_FOUND TRUE) - else(LAPACK95_LIBRARIES) - set(LAPACK95_FOUND FALSE) - endif(LAPACK95_LIBRARIES) - if(NOT LAPACK_FIND_QUIETLY) - if(LAPACK95_FOUND) - message(STATUS "A library with LAPACK95 API found.") - message(STATUS "LAPACK_LIBRARIES ${LAPACK_LIBRARIES}") - 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 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." - "\nYou could also specify a BLAS vendor to look for by setting -DBLA_VENDOR=blas_vendor_name." - "\nList of possible BLAS vendor: Goto, ATLAS PhiPACK, CXML, DXML, SunPerf, SCSL, SGIMATH, IBMESSL, Intel10_32 (intel mkl v10 32 bit)," - "Intel10_64lp (intel mkl v10 64 bit, lp thread model, lp64 model), Intel10_64lp_seq (intel mkl v10 64 bit, sequential code, lp64 model)," - "Intel( older versions of mkl 32 and 64 bit), ACML, ACML_MP, ACML_GPU, Apple, NAS, Generic") - if(LAPACK_FIND_REQUIRED) - message(FATAL_ERROR - "A required library with LAPACK95 API not found. Please specify library location." - ) - else(LAPACK_FIND_REQUIRED) - message(STATUS - "A library with LAPACK95 API not found. Please specify library location." - ) - endif(LAPACK_FIND_REQUIRED) - endif(LAPACK95_FOUND) - endif(NOT LAPACK_FIND_QUIETLY) - set(LAPACK_FOUND "${LAPACK95_FOUND}") - set(LAPACK_LIBRARIES "${LAPACK95_LIBRARIES}") + if(LAPACK95_LIBRARIES) + set(LAPACK95_FOUND TRUE) + else(LAPACK95_LIBRARIES) + set(LAPACK95_FOUND FALSE) + endif(LAPACK95_LIBRARIES) + if(NOT LAPACK_FIND_QUIETLY) + if(LAPACK95_FOUND) + message(STATUS "A library with LAPACK95 API found.") + message(STATUS "LAPACK_LIBRARIES ${LAPACK_LIBRARIES}") + 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 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." + "\nYou could also specify a BLAS vendor to look for by setting -DBLA_VENDOR=blas_vendor_name." + "\nList of possible BLAS vendor: Goto, ATLAS PhiPACK, CXML, DXML, SunPerf, SCSL, SGIMATH, IBMESSL, Intel10_32 (intel mkl v10 32 bit)," + "Intel10_64lp (intel mkl v10 64 bit, lp thread model, lp64 model), Intel10_64lp_seq (intel mkl v10 64 bit, sequential code, lp64 model)," + "Intel( older versions of mkl 32 and 64 bit), ACML, ACML_MP, ACML_GPU, Apple, NAS, Generic") + if(LAPACK_FIND_REQUIRED) + message(FATAL_ERROR + "A required library with LAPACK95 API not found. Please specify library location." + ) + else(LAPACK_FIND_REQUIRED) + message(STATUS + "A library with LAPACK95 API not found. Please specify library location." + ) + endif(LAPACK_FIND_REQUIRED) + endif(LAPACK95_FOUND) + endif(NOT LAPACK_FIND_QUIETLY) + set(LAPACK_FOUND "${LAPACK95_FOUND}") + set(LAPACK_LIBRARIES "${LAPACK95_LIBRARIES}") else(BLA_F95) - if(LAPACK_LIBRARIES) - set(LAPACK_FOUND TRUE) - else(LAPACK_LIBRARIES) - set(LAPACK_FOUND FALSE) - endif(LAPACK_LIBRARIES) - - if(NOT LAPACK_FIND_QUIETLY) - if(LAPACK_FOUND) - message(STATUS "A library with LAPACK API found.") - message(STATUS "LAPACK_LIBRARIES ${LAPACK_LIBRARIES}") - 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 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." - "\nYou could also specify a BLAS vendor to look for by setting -DBLA_VENDOR=blas_vendor_name." - "\nList of possible BLAS vendor: Goto, ATLAS PhiPACK, CXML, DXML, SunPerf, SCSL, SGIMATH, IBMESSL, Intel10_32 (intel mkl v10 32 bit)," - "Intel10_64lp (intel mkl v10 64 bit, lp thread model, lp64 model), Intel10_64lp_seq (intel mkl v10 64 bit, sequential code, lp64 model)," - "Intel( older versions of mkl 32 and 64 bit), ACML, ACML_MP, ACML_GPU, Apple, NAS, Generic") - if(LAPACK_FIND_REQUIRED) - message(FATAL_ERROR - "A required library with LAPACK API not found. Please specify library location." - ) - else(LAPACK_FIND_REQUIRED) - message(STATUS - "A library with LAPACK API not found. Please specify library location." - ) - endif(LAPACK_FIND_REQUIRED) - endif(LAPACK_FOUND) - endif(NOT LAPACK_FIND_QUIETLY) + if(LAPACK_LIBRARIES) + set(LAPACK_FOUND TRUE) + else(LAPACK_LIBRARIES) + set(LAPACK_FOUND FALSE) + endif(LAPACK_LIBRARIES) + + if(NOT LAPACK_FIND_QUIETLY) + if(LAPACK_FOUND) + message(STATUS "A library with LAPACK API found.") + message(STATUS "LAPACK_LIBRARIES ${LAPACK_LIBRARIES}") + 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 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." + "\nYou could also specify a BLAS vendor to look for by setting -DBLA_VENDOR=blas_vendor_name." + "\nList of possible BLAS vendor: Goto, ATLAS PhiPACK, CXML, DXML, SunPerf, SCSL, SGIMATH, IBMESSL, Intel10_32 (intel mkl v10 32 bit)," + "Intel10_64lp (intel mkl v10 64 bit, lp thread model, lp64 model), Intel10_64lp_seq (intel mkl v10 64 bit, sequential code, lp64 model)," + "Intel( older versions of mkl 32 and 64 bit), ACML, ACML_MP, ACML_GPU, Apple, NAS, Generic") + if(LAPACK_FIND_REQUIRED) + message(FATAL_ERROR + "A required library with LAPACK API not found. Please specify library location." + ) + else(LAPACK_FIND_REQUIRED) + message(STATUS + "A library with LAPACK API not found. Please specify library location." + ) + endif(LAPACK_FIND_REQUIRED) + endif(LAPACK_FOUND) + endif(NOT LAPACK_FIND_QUIETLY) endif(BLA_F95) set(CMAKE_FIND_LIBRARY_SUFFIXES ${_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) if (LAPACK_FOUND) - 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_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of LAPACK library" FORCE) - else() - set(LAPACK_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of LAPACK library" FORCE) - endif() + 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_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of LAPACK library" FORCE) + else() + set(LAPACK_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of LAPACK library" FORCE) + endif() endif() mark_as_advanced(LAPACK_DIR) mark_as_advanced(LAPACK_DIR_FOUND) diff --git a/CMakeModules/morse/find/FindLAPACKE.cmake b/CMakeModules/morse/find/FindLAPACKE.cmake index aa6c43e66d3b83a9fb3c10eac8b777b97725385f..145f85e18c06d258be8797ddc6f6b40379223c35 100644 --- a/CMakeModules/morse/find/FindLAPACKE.cmake +++ b/CMakeModules/morse/find/FindLAPACKE.cmake @@ -62,310 +62,310 @@ # License text for the above reference.) if (NOT LAPACKE_FOUND) - 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() + 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() endif() # LAPACKE depends on LAPACK anyway, try to find it if (NOT LAPACK_FOUND) - if(LAPACKE_FIND_REQUIRED) - find_package(LAPACKEXT REQUIRED) - else() - find_package(LAPACKEXT) - endif() + if(LAPACKE_FIND_REQUIRED) + find_package(LAPACKEXT REQUIRED) + else() + find_package(LAPACKEXT) + endif() endif() # LAPACKE depends on LAPACK if (LAPACK_FOUND) - if (NOT LAPACKE_STANDALONE) - # check if a lapacke function exists in the LAPACK lib - include(CheckFunctionExists) - 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) - set(CMAKE_REQUIRED_LIBRARIES) + if (NOT LAPACKE_STANDALONE) + # check if a lapacke function exists in the LAPACK lib + include(CheckFunctionExists) + 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) + set(CMAKE_REQUIRED_LIBRARIES) - if(LAPACKE_WORKS) - if(NOT LAPACKE_FIND_QUIETLY) - message(STATUS "Looking for lapacke: test with lapack succeeds") - endif() - # test succeeds: LAPACKE is in LAPACK - set(LAPACKE_LIBRARIES "${LAPACK_LIBRARIES}") - 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) + if(LAPACKE_WORKS) + if(NOT LAPACKE_FIND_QUIETLY) + message(STATUS "Looking for lapacke: test with lapack succeeds") + endif() + # test succeeds: LAPACKE is in LAPACK + set(LAPACKE_LIBRARIES "${LAPACK_LIBRARIES}") + 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) - if (LAPACKE_STANDALONE OR NOT LAPACKE_WORKS) + if (LAPACKE_STANDALONE OR NOT LAPACKE_WORKS) - if(NOT LAPACKE_WORKS AND NOT LAPACKE_FIND_QUIETLY) - message(STATUS "Looking for lapacke : test with lapack fails") - endif() - # test fails: try to find LAPACKE lib exterior to LAPACK + if(NOT LAPACKE_WORKS AND NOT LAPACKE_FIND_QUIETLY) + message(STATUS "Looking for lapacke : test with lapack fails") + endif() + # test fails: try to find LAPACKE lib exterior to LAPACK - # Try to find LAPACKE lib - ####################### + # Try to find LAPACKE lib + ####################### - # Looking for include - # ------------------- + # Looking for include + # ------------------- - # Add system include paths to search include - # ------------------------------------------ - unset(_inc_env) - set(ENV_LAPACKE_DIR "$ENV{LAPACKE_DIR}") - set(ENV_LAPACKE_INCDIR "$ENV{LAPACKE_INCDIR}") - if(ENV_LAPACKE_INCDIR) - list(APPEND _inc_env "${ENV_LAPACKE_INCDIR}") - elseif(ENV_LAPACKE_DIR) - list(APPEND _inc_env "${ENV_LAPACKE_DIR}") - list(APPEND _inc_env "${ENV_LAPACKE_DIR}/include") - list(APPEND _inc_env "${ENV_LAPACKE_DIR}/include/lapacke") - else() - if(WIN32) - string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") - else() - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{CPATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - endif() - endif() - list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") - list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") - list(REMOVE_DUPLICATES _inc_env) + # Add system include paths to search include + # ------------------------------------------ + unset(_inc_env) + set(ENV_LAPACKE_DIR "$ENV{LAPACKE_DIR}") + set(ENV_LAPACKE_INCDIR "$ENV{LAPACKE_INCDIR}") + if(ENV_LAPACKE_INCDIR) + list(APPEND _inc_env "${ENV_LAPACKE_INCDIR}") + elseif(ENV_LAPACKE_DIR) + list(APPEND _inc_env "${ENV_LAPACKE_DIR}") + list(APPEND _inc_env "${ENV_LAPACKE_DIR}/include") + list(APPEND _inc_env "${ENV_LAPACKE_DIR}/include/lapacke") + else() + if(WIN32) + string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") + else() + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{CPATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + endif() + endif() + list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") + list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") + list(REMOVE_DUPLICATES _inc_env) - # Try to find the lapacke header in the given paths - # ------------------------------------------------- - # call cmake macro to find the header path - if(LAPACKE_INCDIR) - set(LAPACKE_lapacke.h_DIRS "LAPACKE_lapacke.h_DIRS-NOTFOUND") - find_path(LAPACKE_lapacke.h_DIRS - NAMES lapacke.h - HINTS ${LAPACKE_INCDIR}) - else() - if(LAPACKE_DIR) - set(LAPACKE_lapacke.h_DIRS "LAPACKE_lapacke.h_DIRS-NOTFOUND") - find_path(LAPACKE_lapacke.h_DIRS - NAMES lapacke.h - HINTS ${LAPACKE_DIR} - PATH_SUFFIXES "include" "include/lapacke") - else() - set(LAPACKE_lapacke.h_DIRS "LAPACKE_lapacke.h_DIRS-NOTFOUND") - find_path(LAPACKE_lapacke.h_DIRS - NAMES lapacke.h - HINTS ${_inc_env}) - endif() - endif() - mark_as_advanced(LAPACKE_lapacke.h_DIRS) + # Try to find the lapacke header in the given paths + # ------------------------------------------------- + # call cmake macro to find the header path + if(LAPACKE_INCDIR) + set(LAPACKE_lapacke.h_DIRS "LAPACKE_lapacke.h_DIRS-NOTFOUND") + find_path(LAPACKE_lapacke.h_DIRS + NAMES lapacke.h + HINTS ${LAPACKE_INCDIR}) + else() + if(LAPACKE_DIR) + set(LAPACKE_lapacke.h_DIRS "LAPACKE_lapacke.h_DIRS-NOTFOUND") + find_path(LAPACKE_lapacke.h_DIRS + NAMES lapacke.h + HINTS ${LAPACKE_DIR} + PATH_SUFFIXES "include" "include/lapacke") + else() + set(LAPACKE_lapacke.h_DIRS "LAPACKE_lapacke.h_DIRS-NOTFOUND") + find_path(LAPACKE_lapacke.h_DIRS + NAMES lapacke.h + HINTS ${_inc_env}) + endif() + endif() + mark_as_advanced(LAPACKE_lapacke.h_DIRS) - # If found, add path to cmake variable - # ------------------------------------ - if (LAPACKE_lapacke.h_DIRS) - set(LAPACKE_INCLUDE_DIRS "${LAPACKE_lapacke.h_DIRS}") - else () - set(LAPACKE_INCLUDE_DIRS "LAPACKE_INCLUDE_DIRS-NOTFOUND") - if(NOT LAPACKE_FIND_QUIETLY) - message(STATUS "Looking for lapacke -- lapacke.h not found") - endif() - endif() + # If found, add path to cmake variable + # ------------------------------------ + if (LAPACKE_lapacke.h_DIRS) + set(LAPACKE_INCLUDE_DIRS "${LAPACKE_lapacke.h_DIRS}") + else () + set(LAPACKE_INCLUDE_DIRS "LAPACKE_INCLUDE_DIRS-NOTFOUND") + if(NOT LAPACKE_FIND_QUIETLY) + message(STATUS "Looking for lapacke -- lapacke.h not found") + endif() + endif() - # Looking for lib - # --------------- + # Looking for lib + # --------------- - # Add system library paths to search lib - # -------------------------------------- - unset(_lib_env) - set(ENV_LAPACKE_LIBDIR "$ENV{LAPACKE_LIBDIR}") - if(ENV_LAPACKE_LIBDIR) - list(APPEND _lib_env "${ENV_LAPACKE_LIBDIR}") - elseif(ENV_LAPACKE_DIR) - list(APPEND _lib_env "${ENV_LAPACKE_DIR}") - list(APPEND _lib_env "${ENV_LAPACKE_DIR}/lib") - else() - if(WIN32) - string(REPLACE ":" ";" _lib_env "$ENV{LIB}") - else() - if(APPLE) - string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - endif() - endif() - list(REMOVE_DUPLICATES _lib_env) + # Add system library paths to search lib + # -------------------------------------- + unset(_lib_env) + set(ENV_LAPACKE_LIBDIR "$ENV{LAPACKE_LIBDIR}") + if(ENV_LAPACKE_LIBDIR) + list(APPEND _lib_env "${ENV_LAPACKE_LIBDIR}") + elseif(ENV_LAPACKE_DIR) + list(APPEND _lib_env "${ENV_LAPACKE_DIR}") + list(APPEND _lib_env "${ENV_LAPACKE_DIR}/lib") + else() + if(WIN32) + string(REPLACE ":" ";" _lib_env "$ENV{LIB}") + else() + if(APPLE) + string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") + else() + string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") + endif() + list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") + list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + endif() + endif() + list(REMOVE_DUPLICATES _lib_env) - # Try to find the lapacke lib in the given paths - # ---------------------------------------------- + # Try to find the lapacke lib in the given paths + # ---------------------------------------------- - # call cmake macro to find the lib path - if(LAPACKE_LIBDIR) - set(LAPACKE_lapacke_LIBRARY "LAPACKE_lapacke_LIBRARY-NOTFOUND") - find_library(LAPACKE_lapacke_LIBRARY - NAMES lapacke - HINTS ${LAPACKE_LIBDIR}) - else() - if(LAPACKE_DIR) - set(LAPACKE_lapacke_LIBRARY "LAPACKE_lapacke_LIBRARY-NOTFOUND") - find_library(LAPACKE_lapacke_LIBRARY - NAMES lapacke - HINTS ${LAPACKE_DIR} - PATH_SUFFIXES lib lib32 lib64) - else() - set(LAPACKE_lapacke_LIBRARY "LAPACKE_lapacke_LIBRARY-NOTFOUND") - find_library(LAPACKE_lapacke_LIBRARY - NAMES lapacke - HINTS ${_lib_env}) - endif() - endif() - mark_as_advanced(LAPACKE_lapacke_LIBRARY) + # call cmake macro to find the lib path + if(LAPACKE_LIBDIR) + set(LAPACKE_lapacke_LIBRARY "LAPACKE_lapacke_LIBRARY-NOTFOUND") + find_library(LAPACKE_lapacke_LIBRARY + NAMES lapacke + HINTS ${LAPACKE_LIBDIR}) + else() + if(LAPACKE_DIR) + set(LAPACKE_lapacke_LIBRARY "LAPACKE_lapacke_LIBRARY-NOTFOUND") + find_library(LAPACKE_lapacke_LIBRARY + NAMES lapacke + HINTS ${LAPACKE_DIR} + PATH_SUFFIXES lib lib32 lib64) + else() + set(LAPACKE_lapacke_LIBRARY "LAPACKE_lapacke_LIBRARY-NOTFOUND") + find_library(LAPACKE_lapacke_LIBRARY + NAMES lapacke + HINTS ${_lib_env}) + endif() + endif() + mark_as_advanced(LAPACKE_lapacke_LIBRARY) - # If found, add path to cmake variable - # ------------------------------------ - if (LAPACKE_lapacke_LIBRARY) - get_filename_component(lapacke_lib_path "${LAPACKE_lapacke_LIBRARY}" PATH) - # set cmake variables - set(LAPACKE_LIBRARIES "${LAPACKE_lapacke_LIBRARY}") - set(LAPACKE_LIBRARY_DIRS "${lapacke_lib_path}") - else () - set(LAPACKE_LIBRARIES "LAPACKE_LIBRARIES-NOTFOUND") - set(LAPACKE_LIBRARY_DIRS "LAPACKE_LIBRARY_DIRS-NOTFOUND") - if (NOT LAPACKE_FIND_QUIETLY) - message(STATUS "Looking for lapacke -- lib lapacke not found") - endif() - endif () + # If found, add path to cmake variable + # ------------------------------------ + if (LAPACKE_lapacke_LIBRARY) + get_filename_component(lapacke_lib_path "${LAPACKE_lapacke_LIBRARY}" PATH) + # set cmake variables + set(LAPACKE_LIBRARIES "${LAPACKE_lapacke_LIBRARY}") + set(LAPACKE_LIBRARY_DIRS "${lapacke_lib_path}") + else () + set(LAPACKE_LIBRARIES "LAPACKE_LIBRARIES-NOTFOUND") + set(LAPACKE_LIBRARY_DIRS "LAPACKE_LIBRARY_DIRS-NOTFOUND") + if (NOT LAPACKE_FIND_QUIETLY) + message(STATUS "Looking for lapacke -- lib lapacke not found") + endif() + endif () - # check a function to validate the find - if(LAPACKE_LIBRARIES) + # check a function to validate the find + if(LAPACKE_LIBRARIES) - set(REQUIRED_LDFLAGS) - set(REQUIRED_INCDIRS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) + set(REQUIRED_LDFLAGS) + set(REQUIRED_INCDIRS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) - # LAPACKE - if (LAPACKE_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${LAPACKE_INCLUDE_DIRS}") - endif() - if (LAPACKE_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${LAPACKE_LIBRARY_DIRS}") - endif() - set(REQUIRED_LIBS "${LAPACKE_LIBRARIES}") - # LAPACK - if (LAPACK_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${LAPACK_INCLUDE_DIRS}") - endif() - if (LAPACK_LIBRARY_DIRS) - 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_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) - if(M_LIBRARY) - list(APPEND REQUIRED_LIBS "-lm") - 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}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + # LAPACKE + if (LAPACKE_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${LAPACKE_INCLUDE_DIRS}") + endif() + if (LAPACKE_LIBRARY_DIRS) + set(REQUIRED_LIBDIRS "${LAPACKE_LIBRARY_DIRS}") + endif() + set(REQUIRED_LIBS "${LAPACKE_LIBRARIES}") + # LAPACK + if (LAPACK_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${LAPACK_INCLUDE_DIRS}") + endif() + if (LAPACK_LIBRARY_DIRS) + 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_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) + if(M_LIBRARY) + list(APPEND REQUIRED_LIBS "-lm") + 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}") + string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - # test link - unset(LAPACKE_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(LAPACKE_dgeqrf LAPACKE_WORKS) - mark_as_advanced(LAPACKE_WORKS) + # test link + unset(LAPACKE_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(LAPACKE_dgeqrf LAPACKE_WORKS) + mark_as_advanced(LAPACKE_WORKS) - if(LAPACKE_WORKS) - # save link with dependencies - 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") - message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") - message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") - message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") - endif() - endif() - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_LIBRARIES) - endif(LAPACKE_LIBRARIES) + if(LAPACKE_WORKS) + # save link with dependencies + 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") + message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") + message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") + message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") + endif() + endif() + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) + endif(LAPACKE_LIBRARIES) - endif (LAPACKE_STANDALONE OR NOT LAPACKE_WORKS) + endif (LAPACKE_STANDALONE OR NOT LAPACKE_WORKS) else(LAPACK_FOUND) - if (NOT LAPACKE_FIND_QUIETLY) - message(STATUS "LAPACKE requires LAPACK but LAPACK has not been found." - "Please look for LAPACK first.") - endif() + if (NOT LAPACKE_FIND_QUIETLY) + message(STATUS "LAPACKE requires LAPACK but LAPACK has not been found." + "Please look for LAPACK first.") + endif() endif(LAPACK_FOUND) if (LAPACKE_LIBRARIES) - 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_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of LAPACKE library" FORCE) - else() - set(LAPACKE_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of LAPACKE library" FORCE) - endif() + 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_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of LAPACKE library" FORCE) + else() + set(LAPACKE_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of LAPACKE library" FORCE) + endif() endif() mark_as_advanced(LAPACKE_DIR) mark_as_advanced(LAPACKE_DIR_FOUND) @@ -374,5 +374,5 @@ mark_as_advanced(LAPACKE_DIR_FOUND) # --------------------------------- include(FindPackageHandleStandardArgs) find_package_handle_standard_args(LAPACKE DEFAULT_MSG - LAPACKE_LIBRARIES - LAPACKE_WORKS) + LAPACKE_LIBRARIES + LAPACKE_WORKS) diff --git a/CMakeModules/morse/find/FindLAPACKEXT.cmake b/CMakeModules/morse/find/FindLAPACKEXT.cmake index 8b6b68f7c8832d10a4a05dcd3c9b63aad59c5d1e..bf62c3d7071cce623a64a78aa55c52935b0e5256 100644 --- a/CMakeModules/morse/find/FindLAPACKEXT.cmake +++ b/CMakeModules/morse/find/FindLAPACKEXT.cmake @@ -42,212 +42,212 @@ # macro to factorize this call macro(find_package_lapack) - if(LAPACKEXT_FIND_REQUIRED) - if(LAPACKEXT_FIND_QUIETLY) - find_package(LAPACK REQUIRED QUIET) - else() - find_package(LAPACK REQUIRED) - endif() + if(LAPACKEXT_FIND_REQUIRED) + if(LAPACKEXT_FIND_QUIETLY) + find_package(LAPACK REQUIRED QUIET) else() - if(LAPACKEXT_FIND_QUIETLY) - find_package(LAPACK QUIET) - else() - find_package(LAPACK) - endif() - endif() + find_package(LAPACK REQUIRED) + endif() + else() + if(LAPACKEXT_FIND_QUIETLY) + find_package(LAPACK QUIET) + else() + find_package(LAPACK) + endif() + endif() endmacro() # LAPACKEXT depends on BLASEXT # call our extended module for BLAS #---------------------------------- if (NOT BLAS_FOUND) - if(LAPACKEXT_FIND_REQUIRED) - if(LAPACKEXT_FIND_QUIETLY) - find_package(BLAS REQUIRED QUIET) - else() - find_package(BLAS REQUIRED) - endif() + if(LAPACKEXT_FIND_REQUIRED) + if(LAPACKEXT_FIND_QUIETLY) + find_package(BLAS REQUIRED QUIET) + else() + find_package(BLAS REQUIRED) + endif() + else() + if(LAPACKEXT_FIND_QUIETLY) + find_package(BLAS QUIET) else() - if(LAPACKEXT_FIND_QUIETLY) - find_package(BLAS QUIET) - else() - find_package(BLAS) - endif() + find_package(BLAS) endif() + endif() endif () if(NOT LAPACKEXT_FIND_QUIETLY) - message(STATUS "In FindLAPACKEXT") + message(STATUS "In FindLAPACKEXT") endif() if(BLA_VENDOR MATCHES "Intel*") - ### - # look for include path if the LAPACK vendor is Intel - ### + ### + # look for include path if the LAPACK vendor is Intel + ### - # gather system include paths - unset(_inc_env) - if(WIN32) - string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") - else() - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{CPATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - endif() - list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") - list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") - set(ENV_MKLROOT "$ENV{MKLROOT}") - if (ENV_MKLROOT) - list(APPEND _inc_env "${ENV_MKLROOT}/include") - endif() - list(REMOVE_DUPLICATES _inc_env) + # gather system include paths + unset(_inc_env) + if(WIN32) + string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") + else() + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{CPATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + endif() + list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") + list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") + set(ENV_MKLROOT "$ENV{MKLROOT}") + if (ENV_MKLROOT) + list(APPEND _inc_env "${ENV_MKLROOT}/include") + endif() + list(REMOVE_DUPLICATES _inc_env) - if (BLAS_DIR) - set(LAPACK_DIR ${BLAS_DIR}) - endif () - if (BLAS_INCDIR) - set(LAPACK_INCDIR ${BLAS_INCDIR}) - endif () - # find mkl.h inside known include paths - set(LAPACK_mkl_lapack.h_INCLUDE_DIRS "LAPACK_mkl_lapack.h_INCLUDE_DIRS-NOTFOUND") - if(LAPACK_INCDIR) - find_path(LAPACK_mkl_lapack.h_INCLUDE_DIRS - NAMES mkl_lapack.h - HINTS ${LAPACK_INCDIR}) + if (BLAS_DIR) + set(LAPACK_DIR ${BLAS_DIR}) + endif () + if (BLAS_INCDIR) + set(LAPACK_INCDIR ${BLAS_INCDIR}) + endif () + # find mkl.h inside known include paths + set(LAPACK_mkl_lapack.h_INCLUDE_DIRS "LAPACK_mkl_lapack.h_INCLUDE_DIRS-NOTFOUND") + if(LAPACK_INCDIR) + find_path(LAPACK_mkl_lapack.h_INCLUDE_DIRS + NAMES mkl_lapack.h + HINTS ${LAPACK_INCDIR}) + else() + if(LAPACK_DIR) + find_path(LAPACK_mkl_lapack.h_INCLUDE_DIRS + NAMES mkl_lapack.h + HINTS ${LAPACK_DIR} + PATH_SUFFIXES include) else() - if(LAPACK_DIR) - find_path(LAPACK_mkl_lapack.h_INCLUDE_DIRS - NAMES mkl_lapack.h - HINTS ${LAPACK_DIR} - PATH_SUFFIXES include) - else() - find_path(LAPACK_mkl_lapack.h_INCLUDE_DIRS - NAMES mkl_lapack.h - HINTS ${_inc_env}) - endif() - endif() - mark_as_advanced(LAPACK_mkl_lapack.h_INCLUDE_DIRS) - ## Print status if not found - ## ------------------------- - #if (NOT LAPACK_mkl_lapack.h_INCLUDE_DIRS) - # Print_Find_Header_Status(lapack mkl_lapack.h) - #endif () - set(LAPACK_INCLUDE_DIRS "") - if(LAPACK_mkl_lapack.h_INCLUDE_DIRS) - list(APPEND LAPACK_INCLUDE_DIRS "${LAPACK_mkl_lapack.h_INCLUDE_DIRS}" ) + find_path(LAPACK_mkl_lapack.h_INCLUDE_DIRS + NAMES mkl_lapack.h + HINTS ${_inc_env}) endif() + endif() + mark_as_advanced(LAPACK_mkl_lapack.h_INCLUDE_DIRS) + ## Print status if not found + ## ------------------------- + #if (NOT LAPACK_mkl_lapack.h_INCLUDE_DIRS) + # Print_Find_Header_Status(lapack mkl_lapack.h) + #endif () + set(LAPACK_INCLUDE_DIRS "") + if(LAPACK_mkl_lapack.h_INCLUDE_DIRS) + list(APPEND LAPACK_INCLUDE_DIRS "${LAPACK_mkl_lapack.h_INCLUDE_DIRS}" ) + endif() - ### - # look for libs - ### + ### + # look for libs + ### - if (BLA_VENDOR MATCHES "Intel10_64lp*") - ## look for the sequential version - set(BLA_VENDOR "Intel10_64lp_seq") - endif() - find_package_lapack() + if (BLA_VENDOR MATCHES "Intel10_64lp*") + ## look for the sequential version + set(BLA_VENDOR "Intel10_64lp_seq") + endif() + find_package_lapack() - if (LAPACK_FOUND) - if(BLAS_SEQ_LIBRARIES) - set(LAPACK_SEQ_LIBRARIES "${BLAS_SEQ_LIBRARIES}") - else() - set(LAPACK_SEQ_LIBRARIES "${LAPACK_SEQ_LIBRARIES-NOTFOUND}") - endif() - # if BLAS Intel 10 64 bit -> save sequential and multithreaded versions - if(BLA_VENDOR MATCHES "Intel10_64lp*") - if(BLAS_PAR_LIBRARIES) - set(LAPACK_PAR_LIBRARIES "${BLAS_PAR_LIBRARIES}") - else() - set(LAPACK_PAR_LIBRARIES "${LAPACK_PAR_LIBRARIES-NOTFOUND}") - endif() - endif() + if (LAPACK_FOUND) + if(BLAS_SEQ_LIBRARIES) + set(LAPACK_SEQ_LIBRARIES "${BLAS_SEQ_LIBRARIES}") + else() + set(LAPACK_SEQ_LIBRARIES "${LAPACK_SEQ_LIBRARIES-NOTFOUND}") + endif() + # if BLAS Intel 10 64 bit -> save sequential and multithreaded versions + if(BLA_VENDOR MATCHES "Intel10_64lp*") + if(BLAS_PAR_LIBRARIES) + set(LAPACK_PAR_LIBRARIES "${BLAS_PAR_LIBRARIES}") + else() + set(LAPACK_PAR_LIBRARIES "${LAPACK_PAR_LIBRARIES-NOTFOUND}") + endif() endif() + endif() elseif(BLA_VENDOR MATCHES "IBMESSL*") - ## look for the sequential version - set(BLA_VENDOR "IBMESSL") - find_package_lapack() + ## look for the sequential version + set(BLA_VENDOR "IBMESSL") + find_package_lapack() - if (LAPACK_FOUND) - if(LAPACK_LIBRARIES) - set(LAPACK_SEQ_LIBRARIES "${LAPACK_LIBRARIES}") - else() - set(LAPACK_SEQ_LIBRARIES "${LAPACK_SEQ_LIBRARIES-NOTFOUND}") - endif() + if (LAPACK_FOUND) + if(LAPACK_LIBRARIES) + set(LAPACK_SEQ_LIBRARIES "${LAPACK_LIBRARIES}") + else() + set(LAPACK_SEQ_LIBRARIES "${LAPACK_SEQ_LIBRARIES-NOTFOUND}") endif() + endif() - ## look for the multithreaded version - set(BLA_VENDOR "IBMESSLMT") - find_package_lapack() + ## look for the multithreaded version + set(BLA_VENDOR "IBMESSLMT") + find_package_lapack() - if (LAPACK_FOUND) - if(LAPACK_LIBRARIES) - set(LAPACK_PAR_LIBRARIES "${LAPACK_LIBRARIES}") - else() - set(LAPACK_PAR_LIBRARIES "${LAPACK_PAR_LIBRARIES-NOTFOUND}") - endif() + if (LAPACK_FOUND) + if(LAPACK_LIBRARIES) + set(LAPACK_PAR_LIBRARIES "${LAPACK_LIBRARIES}") + else() + set(LAPACK_PAR_LIBRARIES "${LAPACK_PAR_LIBRARIES-NOTFOUND}") endif() + endif() elseif(BLA_VENDOR MATCHES "ACML*") - ### - # look for libs - ### - find_package_lapack() + ### + # look for libs + ### + find_package_lapack() - if (LAPACK_FOUND) - if(BLAS_SEQ_LIBRARIES) - set(LAPACK_SEQ_LIBRARIES "${BLAS_SEQ_LIBRARIES}") - else() - set(LAPACK_SEQ_LIBRARIES "${LAPACK_SEQ_LIBRARIES-NOTFOUND}") - endif() - if(BLAS_PAR_LIBRARIES) - set(LAPACK_PAR_LIBRARIES "${BLAS_PAR_LIBRARIES}") - else() - set(LAPACK_PAR_LIBRARIES "${LAPACK_PAR_LIBRARIES-NOTFOUND}") - endif() + if (LAPACK_FOUND) + if(BLAS_SEQ_LIBRARIES) + set(LAPACK_SEQ_LIBRARIES "${BLAS_SEQ_LIBRARIES}") + else() + set(LAPACK_SEQ_LIBRARIES "${LAPACK_SEQ_LIBRARIES-NOTFOUND}") endif() + if(BLAS_PAR_LIBRARIES) + set(LAPACK_PAR_LIBRARIES "${BLAS_PAR_LIBRARIES}") + else() + set(LAPACK_PAR_LIBRARIES "${LAPACK_PAR_LIBRARIES-NOTFOUND}") + endif() + endif() else() - ## look for a sequential version - # call to the cmake official FindLAPACK module - # This module sets the following variables: - # LAPACK_FOUND - set to true if a library implementing the LAPACK interface - # is found - # LAPACK_LINKER_FLAGS - uncached list of required linker flags (excluding -l - # and -L). - # LAPACK_LIBRARIES - uncached list of libraries (using full path name) to - # link against to use LAPACK - # LAPACK95_LIBRARIES - uncached list of libraries (using full path name) - # to link against to use LAPACK95 interface - # LAPACK95_FOUND - set to true if a library implementing the LAPACK f95 interface - # is found - # BLA_STATIC if set on this determines what kind of linkage we do (static) - # BLA_VENDOR if set checks only the specified vendor, if not set checks - # all the possibilities - # BLA_F95 if set on tries to find the f95 interfaces for LAPACK/LAPACK - # Remark: it looks only into paths contained in the system environment variables - find_package_lapack() + ## look for a sequential version + # call to the cmake official FindLAPACK module + # This module sets the following variables: + # LAPACK_FOUND - set to true if a library implementing the LAPACK interface + # is found + # LAPACK_LINKER_FLAGS - uncached list of required linker flags (excluding -l + # and -L). + # LAPACK_LIBRARIES - uncached list of libraries (using full path name) to + # link against to use LAPACK + # LAPACK95_LIBRARIES - uncached list of libraries (using full path name) + # to link against to use LAPACK95 interface + # LAPACK95_FOUND - set to true if a library implementing the LAPACK f95 interface + # is found + # BLA_STATIC if set on this determines what kind of linkage we do (static) + # BLA_VENDOR if set checks only the specified vendor, if not set checks + # all the possibilities + # BLA_F95 if set on tries to find the f95 interfaces for LAPACK/LAPACK + # Remark: it looks only into paths contained in the system environment variables + find_package_lapack() - if(LAPACK_FOUND) - set(LAPACK_SEQ_LIBRARIES "${LAPACK_LIBRARIES}") - else() - set(LAPACK_SEQ_LIBRARIES "${LAPACK_SEQ_LIBRARIES-NOTFOUND}") - endif() - set(BLAS_PAR_LIBRARIES "${BLAS_PAR_LIBRARIES-NOTFOUND}") + if(LAPACK_FOUND) + set(LAPACK_SEQ_LIBRARIES "${LAPACK_LIBRARIES}") + else() + set(LAPACK_SEQ_LIBRARIES "${LAPACK_SEQ_LIBRARIES-NOTFOUND}") + endif() + set(BLAS_PAR_LIBRARIES "${BLAS_PAR_LIBRARIES-NOTFOUND}") endif() if (LAPACK_SEQ_LIBRARIES) - set(LAPACK_LIBRARIES "${LAPACK_SEQ_LIBRARIES}") + set(LAPACK_LIBRARIES "${LAPACK_SEQ_LIBRARIES}") endif() # extract libs paths @@ -255,96 +255,96 @@ endif() set(LAPACK_LIBRARY_DIRS "") string(REPLACE " " ";" LAPACK_LIBRARIES "${LAPACK_LIBRARIES}") foreach(lapack_lib ${LAPACK_LIBRARIES}) + if (EXISTS "${lapack_lib}") + get_filename_component(a_lapack_lib_dir "${lapack_lib}" PATH) + list(APPEND LAPACK_LIBRARY_DIRS "${a_lapack_lib_dir}" ) + else() + string(REPLACE "-L" "" lapack_lib "${lapack_lib}") if (EXISTS "${lapack_lib}") - get_filename_component(a_lapack_lib_dir "${lapack_lib}" PATH) - list(APPEND LAPACK_LIBRARY_DIRS "${a_lapack_lib_dir}" ) + list(APPEND LAPACK_LIBRARY_DIRS "${lapack_lib}" ) else() - string(REPLACE "-L" "" lapack_lib "${lapack_lib}") - if (EXISTS "${lapack_lib}") - list(APPEND LAPACK_LIBRARY_DIRS "${lapack_lib}" ) - else() - get_filename_component(a_lapack_lib_dir "${lapack_lib}" PATH) - if (EXISTS "${a_lapack_lib_dir}") - list(APPEND LAPACK_LIBRARY_DIRS "${a_lapack_lib_dir}" ) - endif() - endif() + get_filename_component(a_lapack_lib_dir "${lapack_lib}" PATH) + if (EXISTS "${a_lapack_lib_dir}") + list(APPEND LAPACK_LIBRARY_DIRS "${a_lapack_lib_dir}" ) + endif() endif() + endif() endforeach() if (LAPACK_LIBRARY_DIRS) - list(REMOVE_DUPLICATES LAPACK_LIBRARY_DIRS) + list(REMOVE_DUPLICATES LAPACK_LIBRARY_DIRS) endif () # check that LAPACK has been found # --------------------------------- include(FindPackageHandleStandardArgs) if(BLA_VENDOR MATCHES "Intel*") - if(BLA_VENDOR MATCHES "Intel10_64lp*") - if(NOT LAPACKEXT_FIND_QUIETLY) - message(STATUS "LAPACK found is Intel MKL:" - "\n we manage two lists of libs, one sequential and one parallel" - "\n (see LAPACK_SEQ_LIBRARIES and LAPACK_PAR_LIBRARIES)") - message(STATUS "LAPACK sequential libraries stored in LAPACK_SEQ_LIBRARIES") - endif() - find_package_handle_standard_args(LAPACK DEFAULT_MSG - LAPACK_SEQ_LIBRARIES - LAPACK_LIBRARY_DIRS - LAPACK_INCLUDE_DIRS) - if(LAPACK_PAR_LIBRARIES) - if(NOT LAPACKEXT_FIND_QUIETLY) - message(STATUS "LAPACK parallel libraries stored in LAPACK_PAR_LIBRARIES") - endif() - find_package_handle_standard_args(LAPACK DEFAULT_MSG - LAPACK_PAR_LIBRARIES) - endif() - - else() - if(NOT LAPACKEXT_FIND_QUIETLY) - message(STATUS "LAPACK sequential libraries stored in LAPACK_SEQ_LIBRARIES") - endif() - find_package_handle_standard_args(LAPACK DEFAULT_MSG - LAPACK_SEQ_LIBRARIES - LAPACK_LIBRARY_DIRS - LAPACK_INCLUDE_DIRS) - endif() -elseif(BLA_VENDOR MATCHES "ACML*") + if(BLA_VENDOR MATCHES "Intel10_64lp*") if(NOT LAPACKEXT_FIND_QUIETLY) - message(STATUS "LAPACK found is ACML:" - "\n we manage two lists of libs, one sequential and one parallel" - "\n (see LAPACK_SEQ_LIBRARIES and LAPACK_PAR_LIBRARIES)") - message(STATUS "LAPACK sequential libraries stored in LAPACK_SEQ_LIBRARIES") + message(STATUS "LAPACK found is Intel MKL:" + "\n we manage two lists of libs, one sequential and one parallel" + "\n (see LAPACK_SEQ_LIBRARIES and LAPACK_PAR_LIBRARIES)") + message(STATUS "LAPACK sequential libraries stored in LAPACK_SEQ_LIBRARIES") endif() find_package_handle_standard_args(LAPACK DEFAULT_MSG - LAPACK_SEQ_LIBRARIES - LAPACK_LIBRARY_DIRS) + LAPACK_SEQ_LIBRARIES + LAPACK_LIBRARY_DIRS + LAPACK_INCLUDE_DIRS) if(LAPACK_PAR_LIBRARIES) - if(NOT LAPACKEXT_FIND_QUIETLY) - message(STATUS "LAPACK parallel libraries stored in LAPACK_PAR_LIBRARIES") - endif() - find_package_handle_standard_args(LAPACK DEFAULT_MSG - LAPACK_PAR_LIBRARIES) + if(NOT LAPACKEXT_FIND_QUIETLY) + message(STATUS "LAPACK parallel libraries stored in LAPACK_PAR_LIBRARIES") + endif() + find_package_handle_standard_args(LAPACK DEFAULT_MSG + LAPACK_PAR_LIBRARIES) endif() -elseif(BLA_VENDOR MATCHES "IBMESSL*") + + else() if(NOT LAPACKEXT_FIND_QUIETLY) - message(STATUS "LAPACK found is IBMESSL:" - "\n we manage two lists of libs, one sequential and one parallel" - "\n (see LAPACK_SEQ_LIBRARIES and LAPACK_PAR_LIBRARIES)") - message(STATUS "LAPACK sequential libraries stored in LAPACK_SEQ_LIBRARIES") + message(STATUS "LAPACK sequential libraries stored in LAPACK_SEQ_LIBRARIES") endif() find_package_handle_standard_args(LAPACK DEFAULT_MSG - LAPACK_SEQ_LIBRARIES - LAPACK_LIBRARY_DIRS) - if(LAPACK_PAR_LIBRARIES) - if(NOT LAPACKEXT_FIND_QUIETLY) - message(STATUS "LAPACK parallel libraries stored in LAPACK_PAR_LIBRARIES") - endif() - find_package_handle_standard_args(LAPACK DEFAULT_MSG - LAPACK_PAR_LIBRARIES) + LAPACK_SEQ_LIBRARIES + LAPACK_LIBRARY_DIRS + LAPACK_INCLUDE_DIRS) + endif() +elseif(BLA_VENDOR MATCHES "ACML*") + if(NOT LAPACKEXT_FIND_QUIETLY) + message(STATUS "LAPACK found is ACML:" + "\n we manage two lists of libs, one sequential and one parallel" + "\n (see LAPACK_SEQ_LIBRARIES and LAPACK_PAR_LIBRARIES)") + message(STATUS "LAPACK sequential libraries stored in LAPACK_SEQ_LIBRARIES") + endif() + find_package_handle_standard_args(LAPACK DEFAULT_MSG + LAPACK_SEQ_LIBRARIES + LAPACK_LIBRARY_DIRS) + if(LAPACK_PAR_LIBRARIES) + if(NOT LAPACKEXT_FIND_QUIETLY) + message(STATUS "LAPACK parallel libraries stored in LAPACK_PAR_LIBRARIES") endif() -else() + find_package_handle_standard_args(LAPACK DEFAULT_MSG + LAPACK_PAR_LIBRARIES) + endif() +elseif(BLA_VENDOR MATCHES "IBMESSL*") + if(NOT LAPACKEXT_FIND_QUIETLY) + message(STATUS "LAPACK found is IBMESSL:" + "\n we manage two lists of libs, one sequential and one parallel" + "\n (see LAPACK_SEQ_LIBRARIES and LAPACK_PAR_LIBRARIES)") + message(STATUS "LAPACK sequential libraries stored in LAPACK_SEQ_LIBRARIES") + endif() + find_package_handle_standard_args(LAPACK DEFAULT_MSG + LAPACK_SEQ_LIBRARIES + LAPACK_LIBRARY_DIRS) + if(LAPACK_PAR_LIBRARIES) if(NOT LAPACKEXT_FIND_QUIETLY) - message(STATUS "LAPACK sequential libraries stored in LAPACK_SEQ_LIBRARIES") + message(STATUS "LAPACK parallel libraries stored in LAPACK_PAR_LIBRARIES") endif() find_package_handle_standard_args(LAPACK DEFAULT_MSG - LAPACK_SEQ_LIBRARIES - LAPACK_LIBRARY_DIRS) + LAPACK_PAR_LIBRARIES) + endif() +else() + if(NOT LAPACKEXT_FIND_QUIETLY) + message(STATUS "LAPACK sequential libraries stored in LAPACK_SEQ_LIBRARIES") + endif() + find_package_handle_standard_args(LAPACK DEFAULT_MSG + LAPACK_SEQ_LIBRARIES + LAPACK_LIBRARY_DIRS) endif() diff --git a/CMakeModules/morse/find/FindMAGMA.cmake b/CMakeModules/morse/find/FindMAGMA.cmake index 9c97501c1e4e0368ca04a53156fa2077d9d95d95..d3eda98d3ccd8036d2fcc5f42e9052ce03b573e6 100644 --- a/CMakeModules/morse/find/FindMAGMA.cmake +++ b/CMakeModules/morse/find/FindMAGMA.cmake @@ -62,42 +62,42 @@ if(NOT MAGMA_FOUND) - 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() + 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() endif(NOT MAGMA_FOUND) # 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() + 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() + 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(LAPACKEXT REQUIRED) - else() - find_package(LAPACKEXT) - endif() + if(MAGMA_FIND_REQUIRED) + find_package(LAPACKEXT REQUIRED) + else() + find_package(LAPACKEXT) + 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() + if(MAGMA_FIND_REQUIRED) + find_package(CBLAS REQUIRED) + else() + find_package(CBLAS) + endif() endif() set(ENV_MAGMA_DIR "$ENV{MAGMA_DIR}") @@ -105,7 +105,7 @@ set(ENV_MAGMA_INCDIR "$ENV{MAGMA_INCDIR}") set(ENV_MAGMA_LIBDIR "$ENV{MAGMA_LIBDIR}") set(MAGMA_GIVEN_BY_USER "FALSE") if ( MAGMA_DIR OR ( MAGMA_INCDIR AND MAGMA_LIBDIR) OR ENV_MAGMA_DIR OR (ENV_MAGMA_INCDIR AND ENV_MAGMA_LIBDIR) ) - set(MAGMA_GIVEN_BY_USER "TRUE") + set(MAGMA_GIVEN_BY_USER "TRUE") endif() # Optionally use pkg-config to detect include/library dirs (if pkg-config is available) @@ -114,313 +114,313 @@ include(FindPkgConfig) find_package(PkgConfig QUIET) if(PKG_CONFIG_EXECUTABLE AND NOT MAGMA_GIVEN_BY_USER) - pkg_search_module(MAGMA magma) - if (NOT MAGMA_FIND_QUIETLY) - if (MAGMA_FOUND AND MAGMA_LIBRARIES) - message(STATUS "Looking for MAGMA - found using PkgConfig") - #if(NOT MAGMA_INCLUDE_DIRS) - # message("${Magenta}MAGMA_INCLUDE_DIRS is empty using PkgConfig." - # "Perhaps the path to magma headers is already present in your" - # "C(PLUS)_INCLUDE_PATH environment variable.${ColourReset}") - #endif() - else() - message(STATUS "${Magenta}Looking for MAGMA - not found using PkgConfig. " - "\n Perhaps you should add the directory containing magma.pc " - "\n to the PKG_CONFIG_PATH environment variable.${ColourReset}") - endif() + pkg_search_module(MAGMA magma) + if (NOT MAGMA_FIND_QUIETLY) + if (MAGMA_FOUND AND MAGMA_LIBRARIES) + message(STATUS "Looking for MAGMA - found using PkgConfig") + #if(NOT MAGMA_INCLUDE_DIRS) + # message("${Magenta}MAGMA_INCLUDE_DIRS is empty using PkgConfig." + # "Perhaps the path to magma headers is already present in your" + # "C(PLUS)_INCLUDE_PATH environment variable.${ColourReset}") + #endif() + else() + message(STATUS "${Magenta}Looking for MAGMA - not found using PkgConfig. " + "\n Perhaps you should add the directory containing magma.pc " + "\n to the PKG_CONFIG_PATH environment variable.${ColourReset}") endif() + endif() - if (MAGMA_FIND_VERSION_EXACT) - if( NOT (MAGMA_FIND_VERSION_MAJOR STREQUAL MAGMA_VERSION_MAJOR) OR - NOT (MAGMA_FIND_VERSION_MINOR STREQUAL MAGMA_VERSION_MINOR) ) - if(NOT MAGMA_FIND_QUIETLY) - message(FATAL_ERROR - "MAGMA version found is ${MAGMA_VERSION_STRING} " - "when required is ${MAGMA_FIND_VERSION}") - endif() - endif() - else() - # if the version found is older than the required then error - if( (MAGMA_FIND_VERSION_MAJOR STRGREATER MAGMA_VERSION_MAJOR) OR - (MAGMA_FIND_VERSION_MINOR STRGREATER MAGMA_VERSION_MINOR) ) - if(NOT MAGMA_FIND_QUIETLY) - message(FATAL_ERROR - "MAGMA version found is ${MAGMA_VERSION_STRING} " - "when required is ${MAGMA_FIND_VERSION} or newer") - endif() - endif() + if (MAGMA_FIND_VERSION_EXACT) + if( NOT (MAGMA_FIND_VERSION_MAJOR STREQUAL MAGMA_VERSION_MAJOR) OR + NOT (MAGMA_FIND_VERSION_MINOR STREQUAL MAGMA_VERSION_MINOR) ) + if(NOT MAGMA_FIND_QUIETLY) + message(FATAL_ERROR + "MAGMA version found is ${MAGMA_VERSION_STRING} " + "when required is ${MAGMA_FIND_VERSION}") + endif() endif() + else() + # if the version found is older than the required then error + if( (MAGMA_FIND_VERSION_MAJOR STRGREATER MAGMA_VERSION_MAJOR) OR + (MAGMA_FIND_VERSION_MINOR STRGREATER MAGMA_VERSION_MINOR) ) + if(NOT MAGMA_FIND_QUIETLY) + message(FATAL_ERROR + "MAGMA version found is ${MAGMA_VERSION_STRING} " + "when required is ${MAGMA_FIND_VERSION} or newer") + endif() + endif() + endif() - # if pkg-config is used: these variables are empty - # the pkg_search_module call will set the following: - # MAGMA_LDFLAGS: all required linker flags - # MAGMA_CFLAGS: all required cflags - 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}") + # if pkg-config is used: these variables are empty + # the pkg_search_module call will set the following: + # MAGMA_LDFLAGS: all required linker flags + # MAGMA_CFLAGS: all required cflags + 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 AND NOT MAGMA_GIVEN_BY_USER) # if MAGMA is not found using pkg-config if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT MAGMA_FOUND) OR (MAGMA_GIVEN_BY_USER) ) - if (NOT MAGMA_FIND_QUIETLY) - message(STATUS "Looking for MAGMA - PkgConfig not used") - endif() + if (NOT MAGMA_FIND_QUIETLY) + message(STATUS "Looking for MAGMA - PkgConfig not used") + endif() - # Looking for include - # ------------------- + # Looking for include + # ------------------- - # Add system include paths to search include - # ------------------------------------------ - unset(_inc_env) - set(ENV_MAGMA_DIR "$ENV{MAGMA_DIR}") - set(ENV_MAGMA_INCDIR "$ENV{MAGMA_INCDIR}") - if(ENV_MAGMA_INCDIR) - list(APPEND _inc_env "${ENV_MAGMA_INCDIR}") - elseif(ENV_MAGMA_DIR) - list(APPEND _inc_env "${ENV_MAGMA_DIR}") - list(APPEND _inc_env "${ENV_MAGMA_DIR}/include") - list(APPEND _inc_env "${ENV_MAGMA_DIR}/include/magma") + # Add system include paths to search include + # ------------------------------------------ + unset(_inc_env) + set(ENV_MAGMA_DIR "$ENV{MAGMA_DIR}") + set(ENV_MAGMA_INCDIR "$ENV{MAGMA_INCDIR}") + if(ENV_MAGMA_INCDIR) + list(APPEND _inc_env "${ENV_MAGMA_INCDIR}") + elseif(ENV_MAGMA_DIR) + list(APPEND _inc_env "${ENV_MAGMA_DIR}") + list(APPEND _inc_env "${ENV_MAGMA_DIR}/include") + list(APPEND _inc_env "${ENV_MAGMA_DIR}/include/magma") + else() + if(WIN32) + string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") else() - if(WIN32) - string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") - else() - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{CPATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - endif() + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{CPATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") endif() - list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") - list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") - list(REMOVE_DUPLICATES _inc_env) + endif() + list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") + list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") + list(REMOVE_DUPLICATES _inc_env) - # Try to find the magma header in the given paths - # ------------------------------------------------- - # call cmake macro to find the header path - if(MAGMA_INCDIR) - set(MAGMA_magma.h_DIRS "MAGMA_magma.h_DIRS-NOTFOUND") - find_path(MAGMA_magma.h_DIRS - NAMES magma.h - HINTS ${MAGMA_INCDIR}) + # Try to find the magma header in the given paths + # ------------------------------------------------- + # call cmake macro to find the header path + if(MAGMA_INCDIR) + set(MAGMA_magma.h_DIRS "MAGMA_magma.h_DIRS-NOTFOUND") + find_path(MAGMA_magma.h_DIRS + NAMES magma.h + HINTS ${MAGMA_INCDIR}) + else() + if(MAGMA_DIR) + set(MAGMA_magma.h_DIRS "MAGMA_magma.h_DIRS-NOTFOUND") + find_path(MAGMA_magma.h_DIRS + NAMES magma.h + HINTS ${MAGMA_DIR} + PATH_SUFFIXES "include" "include/magma") else() - if(MAGMA_DIR) - set(MAGMA_magma.h_DIRS "MAGMA_magma.h_DIRS-NOTFOUND") - find_path(MAGMA_magma.h_DIRS - NAMES magma.h - HINTS ${MAGMA_DIR} - PATH_SUFFIXES "include" "include/magma") - else() - set(MAGMA_magma.h_DIRS "MAGMA_magma.h_DIRS-NOTFOUND") - find_path(MAGMA_magma.h_DIRS - NAMES magma.h - HINTS ${_inc_env}) - endif() + set(MAGMA_magma.h_DIRS "MAGMA_magma.h_DIRS-NOTFOUND") + find_path(MAGMA_magma.h_DIRS + NAMES magma.h + HINTS ${_inc_env}) endif() - mark_as_advanced(MAGMA_magma.h_DIRS) + endif() + mark_as_advanced(MAGMA_magma.h_DIRS) - # If found, add path to cmake variable - # ------------------------------------ - if (MAGMA_magma.h_DIRS) - set(MAGMA_INCLUDE_DIRS "${MAGMA_magma.h_DIRS}") - else () - set(MAGMA_INCLUDE_DIRS "MAGMA_INCLUDE_DIRS-NOTFOUND") - if(NOT MAGMA_FIND_QUIETLY) - message(STATUS "Looking for magma -- magma.h not found") - endif() + # If found, add path to cmake variable + # ------------------------------------ + if (MAGMA_magma.h_DIRS) + set(MAGMA_INCLUDE_DIRS "${MAGMA_magma.h_DIRS}") + else () + set(MAGMA_INCLUDE_DIRS "MAGMA_INCLUDE_DIRS-NOTFOUND") + if(NOT MAGMA_FIND_QUIETLY) + message(STATUS "Looking for magma -- magma.h not found") endif() + endif() - # Looking for lib - # --------------- + # Looking for lib + # --------------- - # Add system library paths to search lib - # -------------------------------------- - unset(_lib_env) - set(ENV_MAGMA_LIBDIR "$ENV{MAGMA_LIBDIR}") - if(ENV_MAGMA_LIBDIR) - list(APPEND _lib_env "${ENV_MAGMA_LIBDIR}") - elseif(ENV_MAGMA_DIR) - list(APPEND _lib_env "${ENV_MAGMA_DIR}") - list(APPEND _lib_env "${ENV_MAGMA_DIR}/lib") + # Add system library paths to search lib + # -------------------------------------- + unset(_lib_env) + set(ENV_MAGMA_LIBDIR "$ENV{MAGMA_LIBDIR}") + if(ENV_MAGMA_LIBDIR) + list(APPEND _lib_env "${ENV_MAGMA_LIBDIR}") + elseif(ENV_MAGMA_DIR) + list(APPEND _lib_env "${ENV_MAGMA_DIR}") + list(APPEND _lib_env "${ENV_MAGMA_DIR}/lib") + else() + if(WIN32) + string(REPLACE ":" ";" _lib_env "$ENV{LIB}") else() - if(WIN32) - string(REPLACE ":" ";" _lib_env "$ENV{LIB}") - else() - if(APPLE) - string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - endif() + if(APPLE) + string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") + else() + string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") + endif() + list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") + list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") endif() - list(REMOVE_DUPLICATES _lib_env) + endif() + list(REMOVE_DUPLICATES _lib_env) - # Try to find the magma lib in the given paths - # ---------------------------------------------- + # Try to find the magma lib in the given paths + # ---------------------------------------------- - # call cmake macro to find the lib path - if(MAGMA_LIBDIR) - set(MAGMA_magma_LIBRARY "MAGMA_magma_LIBRARY-NOTFOUND") - find_library(MAGMA_magma_LIBRARY - NAMES magma - HINTS ${MAGMA_LIBDIR}) + # call cmake macro to find the lib path + if(MAGMA_LIBDIR) + set(MAGMA_magma_LIBRARY "MAGMA_magma_LIBRARY-NOTFOUND") + find_library(MAGMA_magma_LIBRARY + NAMES magma + HINTS ${MAGMA_LIBDIR}) + else() + if(MAGMA_DIR) + set(MAGMA_magma_LIBRARY "MAGMA_magma_LIBRARY-NOTFOUND") + find_library(MAGMA_magma_LIBRARY + NAMES magma + HINTS ${MAGMA_DIR} + PATH_SUFFIXES lib lib32 lib64) else() - if(MAGMA_DIR) - set(MAGMA_magma_LIBRARY "MAGMA_magma_LIBRARY-NOTFOUND") - find_library(MAGMA_magma_LIBRARY - NAMES magma - HINTS ${MAGMA_DIR} - PATH_SUFFIXES lib lib32 lib64) - else() - set(MAGMA_magma_LIBRARY "MAGMA_magma_LIBRARY-NOTFOUND") - find_library(MAGMA_magma_LIBRARY - NAMES magma - HINTS ${_lib_env}) - endif() + set(MAGMA_magma_LIBRARY "MAGMA_magma_LIBRARY-NOTFOUND") + find_library(MAGMA_magma_LIBRARY + NAMES magma + HINTS ${_lib_env}) endif() - mark_as_advanced(MAGMA_magma_LIBRARY) + endif() + mark_as_advanced(MAGMA_magma_LIBRARY) - # If found, add path to cmake variable - # ------------------------------------ - if (MAGMA_magma_LIBRARY) - get_filename_component(magma_lib_path "${MAGMA_magma_LIBRARY}" PATH) - # set cmake variables - set(MAGMA_LIBRARIES "${MAGMA_magma_LIBRARY}") - set(MAGMA_LIBRARY_DIRS "${magma_lib_path}") - else () - set(MAGMA_LIBRARIES "MAGMA_LIBRARIES-NOTFOUND") - set(MAGMA_LIBRARY_DIRS "MAGMA_LIBRARY_DIRS-NOTFOUND") - if(NOT MAGMA_FIND_QUIETLY) - message(STATUS "Looking for magma -- lib magma not found") - endif() - endif () + # If found, add path to cmake variable + # ------------------------------------ + if (MAGMA_magma_LIBRARY) + get_filename_component(magma_lib_path "${MAGMA_magma_LIBRARY}" PATH) + # set cmake variables + set(MAGMA_LIBRARIES "${MAGMA_magma_LIBRARY}") + set(MAGMA_LIBRARY_DIRS "${magma_lib_path}") + else () + set(MAGMA_LIBRARIES "MAGMA_LIBRARIES-NOTFOUND") + set(MAGMA_LIBRARY_DIRS "MAGMA_LIBRARY_DIRS-NOTFOUND") + if(NOT MAGMA_FIND_QUIETLY) + message(STATUS "Looking for magma -- lib magma not found") + endif() + endif () - # check a function to validate the find - if (MAGMA_LIBRARIES) + # check a function to validate the find + if (MAGMA_LIBRARIES) - set(REQUIRED_LDFLAGS) - set(REQUIRED_INCDIRS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) + set(REQUIRED_LDFLAGS) + set(REQUIRED_INCDIRS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) - # MAGMA - if (MAGMA_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${MAGMA_INCLUDE_DIRS}") - endif() - if (MAGMA_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${MAGMA_LIBRARY_DIRS}") - endif() - set(REQUIRED_LIBS "${MAGMA_LIBRARIES}") - # CBLAS - if (CBLAS_INCLUDE_DIRS_DEP) - list(APPEND REQUIRED_INCDIRS "${CBLAS_INCLUDE_DIRS_DEP}") - elseif (CBLAS_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${CBLAS_INCLUDE_DIRS}") - endif() - if(CBLAS_LIBRARY_DIRS_DEP) - list(APPEND REQUIRED_LIBDIRS "${CBLAS_LIBRARY_DIRS_DEP}") - elseif(CBLAS_LIBRARY_DIRS) - list(APPEND REQUIRED_LIBDIRS "${CBLAS_LIBRARY_DIRS}") - endif() - if (CBLAS_LIBRARIES_DEP) - list(APPEND REQUIRED_LIBS "${CBLAS_LIBRARIES_DEP}") - 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}") - endif() - if(LAPACK_LIBRARY_DIRS) - 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}") - endif() - if(CUDA_LIBRARY_DIRS) - list(APPEND REQUIRED_LIBDIRS "${CUDA_LIBRARY_DIRS}") - endif() - list(APPEND REQUIRED_LIBS "${CUDA_CUBLAS_LIBRARIES};${CUDA_LIBRARIES}") + # MAGMA + if (MAGMA_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${MAGMA_INCLUDE_DIRS}") + endif() + if (MAGMA_LIBRARY_DIRS) + set(REQUIRED_LIBDIRS "${MAGMA_LIBRARY_DIRS}") + endif() + set(REQUIRED_LIBS "${MAGMA_LIBRARIES}") + # CBLAS + if (CBLAS_INCLUDE_DIRS_DEP) + list(APPEND REQUIRED_INCDIRS "${CBLAS_INCLUDE_DIRS_DEP}") + elseif (CBLAS_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${CBLAS_INCLUDE_DIRS}") + endif() + if(CBLAS_LIBRARY_DIRS_DEP) + list(APPEND REQUIRED_LIBDIRS "${CBLAS_LIBRARY_DIRS_DEP}") + elseif(CBLAS_LIBRARY_DIRS) + list(APPEND REQUIRED_LIBDIRS "${CBLAS_LIBRARY_DIRS}") + endif() + if (CBLAS_LIBRARIES_DEP) + list(APPEND REQUIRED_LIBS "${CBLAS_LIBRARIES_DEP}") + 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}") + endif() + if(LAPACK_LIBRARY_DIRS) + 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}") + endif() + if(CUDA_LIBRARY_DIRS) + list(APPEND REQUIRED_LIBDIRS "${CUDA_LIBRARY_DIRS}") + endif() + list(APPEND REQUIRED_LIBS "${CUDA_CUBLAS_LIBRARIES};${CUDA_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() - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_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() + list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") + string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - # test link - unset(MAGMA_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(magma_dgetrf MAGMA_WORKS) - mark_as_advanced(MAGMA_WORKS) + # test link + unset(MAGMA_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(magma_dgetrf MAGMA_WORKS) + mark_as_advanced(MAGMA_WORKS) - if(MAGMA_WORKS) - # save link with dependencies - 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 - magma, cblas, cuda and lapack libraries fails") - message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") - message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") - message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") - endif() - endif() - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_LIBRARIES) - endif(MAGMA_LIBRARIES) + if(MAGMA_WORKS) + # save link with dependencies + 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 + magma, cblas, cuda and lapack libraries fails") + message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") + message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") + message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") + endif() + endif() + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) + endif(MAGMA_LIBRARIES) endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT MAGMA_FOUND) OR (MAGMA_GIVEN_BY_USER) ) if (MAGMA_LIBRARIES) - 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_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of MAGMA library" FORCE) - else() - set(MAGMA_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of MAGMA library" FORCE) - endif() + 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_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of MAGMA library" FORCE) + else() + set(MAGMA_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of MAGMA library" FORCE) + endif() endif() mark_as_advanced(MAGMA_DIR) mark_as_advanced(MAGMA_DIR_FOUND) @@ -429,10 +429,10 @@ mark_as_advanced(MAGMA_DIR_FOUND) # ------------------------------- include(FindPackageHandleStandardArgs) if (PKG_CONFIG_EXECUTABLE AND MAGMA_FOUND) - find_package_handle_standard_args(MAGMA DEFAULT_MSG - MAGMA_LIBRARIES) + find_package_handle_standard_args(MAGMA DEFAULT_MSG + MAGMA_LIBRARIES) else() - find_package_handle_standard_args(MAGMA DEFAULT_MSG - MAGMA_LIBRARIES - MAGMA_WORKS) + find_package_handle_standard_args(MAGMA DEFAULT_MSG + MAGMA_LIBRARIES + MAGMA_WORKS) endif() diff --git a/CMakeModules/morse/find/FindMETIS.cmake b/CMakeModules/morse/find/FindMETIS.cmake index 16c85993255dedc2937aaa1b7fb60c503380d990..da2f1f1d7b056f97a185b9da672bfc2cd4cbb220 100644 --- a/CMakeModules/morse/find/FindMETIS.cmake +++ b/CMakeModules/morse/find/FindMETIS.cmake @@ -47,10 +47,10 @@ # License text for the above reference.) if (NOT METIS_FOUND) - 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() + 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() endif() # Looking for include @@ -62,24 +62,24 @@ unset(_inc_env) set(ENV_METIS_DIR "$ENV{METIS_DIR}") set(ENV_METIS_INCDIR "$ENV{METIS_INCDIR}") if(ENV_METIS_INCDIR) - list(APPEND _inc_env "${ENV_METIS_INCDIR}") + list(APPEND _inc_env "${ENV_METIS_INCDIR}") elseif(ENV_METIS_DIR) - list(APPEND _inc_env "${ENV_METIS_DIR}") - list(APPEND _inc_env "${ENV_METIS_DIR}/include") - list(APPEND _inc_env "${ENV_METIS_DIR}/include/metis") + list(APPEND _inc_env "${ENV_METIS_DIR}") + list(APPEND _inc_env "${ENV_METIS_DIR}/include") + list(APPEND _inc_env "${ENV_METIS_DIR}/include/metis") else() - if(WIN32) - string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") - else() - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{CPATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - endif() + if(WIN32) + string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") + else() + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{CPATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + endif() endif() list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") @@ -90,23 +90,23 @@ list(REMOVE_DUPLICATES _inc_env) # ------------------------------------------------- # call cmake macro to find the header path if(METIS_INCDIR) + set(METIS_metis.h_DIRS "METIS_metis.h_DIRS-NOTFOUND") + find_path(METIS_metis.h_DIRS + NAMES metis.h + HINTS ${METIS_INCDIR}) +else() + if(METIS_DIR) set(METIS_metis.h_DIRS "METIS_metis.h_DIRS-NOTFOUND") find_path(METIS_metis.h_DIRS NAMES metis.h - HINTS ${METIS_INCDIR}) -else() - if(METIS_DIR) - set(METIS_metis.h_DIRS "METIS_metis.h_DIRS-NOTFOUND") - find_path(METIS_metis.h_DIRS - NAMES metis.h - HINTS ${METIS_DIR} - PATH_SUFFIXES "include" "include/metis") - else() - set(METIS_metis.h_DIRS "METIS_metis.h_DIRS-NOTFOUND") - find_path(METIS_metis.h_DIRS - NAMES metis.h - HINTS ${_inc_env}) - endif() + HINTS ${METIS_DIR} + PATH_SUFFIXES "include" "include/metis") + else() + set(METIS_metis.h_DIRS "METIS_metis.h_DIRS-NOTFOUND") + find_path(METIS_metis.h_DIRS + NAMES metis.h + HINTS ${_inc_env}) + endif() endif() mark_as_advanced(METIS_metis.h_DIRS) @@ -114,12 +114,12 @@ mark_as_advanced(METIS_metis.h_DIRS) # If found, add path to cmake variable # ------------------------------------ if (METIS_metis.h_DIRS) - set(METIS_INCLUDE_DIRS "${METIS_metis.h_DIRS}") + set(METIS_INCLUDE_DIRS "${METIS_metis.h_DIRS}") else () - set(METIS_INCLUDE_DIRS "METIS_INCLUDE_DIRS-NOTFOUND") - if(NOT METIS_FIND_QUIETLY) - message(STATUS "Looking for metis -- metis.h not found") - endif() + set(METIS_INCLUDE_DIRS "METIS_INCLUDE_DIRS-NOTFOUND") + if(NOT METIS_FIND_QUIETLY) + message(STATUS "Looking for metis -- metis.h not found") + endif() endif() @@ -131,22 +131,22 @@ endif() unset(_lib_env) set(ENV_METIS_LIBDIR "$ENV{METIS_LIBDIR}") if(ENV_METIS_LIBDIR) - list(APPEND _lib_env "${ENV_METIS_LIBDIR}") + list(APPEND _lib_env "${ENV_METIS_LIBDIR}") elseif(ENV_METIS_DIR) - list(APPEND _lib_env "${ENV_METIS_DIR}") - list(APPEND _lib_env "${ENV_METIS_DIR}/lib") + list(APPEND _lib_env "${ENV_METIS_DIR}") + list(APPEND _lib_env "${ENV_METIS_DIR}/lib") else() - if(WIN32) - string(REPLACE ":" ";" _lib_env "$ENV{LIB}") + if(WIN32) + string(REPLACE ":" ";" _lib_env "$ENV{LIB}") + else() + if(APPLE) + string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") else() - if(APPLE) - string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") endif() + list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") + list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + endif() endif() list(REMOVE_DUPLICATES _lib_env) @@ -154,23 +154,23 @@ list(REMOVE_DUPLICATES _lib_env) # ---------------------------------------------- # call cmake macro to find the lib path if(METIS_LIBDIR) + set(METIS_metis_LIBRARY "METIS_metis_LIBRARY-NOTFOUND") + find_library(METIS_metis_LIBRARY + NAMES metis + HINTS ${METIS_LIBDIR}) +else() + if(METIS_DIR) set(METIS_metis_LIBRARY "METIS_metis_LIBRARY-NOTFOUND") find_library(METIS_metis_LIBRARY - NAMES metis - HINTS ${METIS_LIBDIR}) -else() - if(METIS_DIR) - set(METIS_metis_LIBRARY "METIS_metis_LIBRARY-NOTFOUND") - find_library(METIS_metis_LIBRARY - NAMES metis - HINTS ${METIS_DIR} - PATH_SUFFIXES lib lib32 lib64) - else() - set(METIS_metis_LIBRARY "METIS_metis_LIBRARY-NOTFOUND") - find_library(METIS_metis_LIBRARY - NAMES metis - HINTS ${_lib_env}) - endif() + NAMES metis + HINTS ${METIS_DIR} + PATH_SUFFIXES lib lib32 lib64) + else() + set(METIS_metis_LIBRARY "METIS_metis_LIBRARY-NOTFOUND") + find_library(METIS_metis_LIBRARY + NAMES metis + HINTS ${_lib_env}) + endif() endif() mark_as_advanced(METIS_metis_LIBRARY) @@ -178,77 +178,77 @@ mark_as_advanced(METIS_metis_LIBRARY) # If found, add path to cmake variable # ------------------------------------ if (METIS_metis_LIBRARY) - get_filename_component(metis_lib_path "${METIS_metis_LIBRARY}" PATH) - # set cmake variables - set(METIS_LIBRARIES "${METIS_metis_LIBRARY}") - set(METIS_LIBRARY_DIRS "${metis_lib_path}") + get_filename_component(metis_lib_path "${METIS_metis_LIBRARY}" PATH) + # set cmake variables + set(METIS_LIBRARIES "${METIS_metis_LIBRARY}") + set(METIS_LIBRARY_DIRS "${metis_lib_path}") else () - set(METIS_LIBRARIES "METIS_LIBRARIES-NOTFOUND") - set(METIS_LIBRARY_DIRS "METIS_LIBRARY_DIRS-NOTFOUND") - if(NOT METIS_FIND_QUIETLY) - message(STATUS "Looking for metis -- lib metis not found") - endif() + set(METIS_LIBRARIES "METIS_LIBRARIES-NOTFOUND") + set(METIS_LIBRARY_DIRS "METIS_LIBRARY_DIRS-NOTFOUND") + if(NOT METIS_FIND_QUIETLY) + message(STATUS "Looking for metis -- lib metis not found") + endif() endif () # check a function to validate the find if(METIS_LIBRARIES) - set(REQUIRED_INCDIRS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) + set(REQUIRED_INCDIRS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) - # METIS - if (METIS_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${METIS_INCLUDE_DIRS}") - endif() - if (METIS_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${METIS_LIBRARY_DIRS}") - endif() - set(REQUIRED_LIBS "${METIS_LIBRARIES}") - # m - find_library(M_LIBRARY NAMES m) - mark_as_advanced(M_LIBRARY) - if(M_LIBRARY) - list(APPEND REQUIRED_LIBS "-lm") - endif() + # METIS + if (METIS_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${METIS_INCLUDE_DIRS}") + endif() + if (METIS_LIBRARY_DIRS) + set(REQUIRED_LIBDIRS "${METIS_LIBRARY_DIRS}") + endif() + set(REQUIRED_LIBS "${METIS_LIBRARIES}") + # m + find_library(M_LIBRARY NAMES m) + mark_as_advanced(M_LIBRARY) + if(M_LIBRARY) + list(APPEND REQUIRED_LIBS "-lm") + endif() - # set required libraries for link - set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") - set(CMAKE_REQUIRED_LIBRARIES) - foreach(lib_dir ${REQUIRED_LIBDIRS}) - list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}") - endforeach() - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + # set required libraries for link + set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") + set(CMAKE_REQUIRED_LIBRARIES) + foreach(lib_dir ${REQUIRED_LIBDIRS}) + list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}") + endforeach() + list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") + string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - # test link - unset(METIS_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(METIS_NodeND METIS_WORKS) - mark_as_advanced(METIS_WORKS) + # test link + unset(METIS_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(METIS_NodeND METIS_WORKS) + mark_as_advanced(METIS_WORKS) - if(NOT METIS_WORKS) - if(NOT METIS_FIND_QUIETLY) - message(STATUS "Looking for METIS : test of METIS_NodeND with METIS library fails") - message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") - message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") - message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") - endif() + if(NOT METIS_WORKS) + if(NOT METIS_FIND_QUIETLY) + message(STATUS "Looking for METIS : test of METIS_NodeND with METIS library fails") + message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") + message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") + message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") endif() - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_LIBRARIES) + endif() + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) endif(METIS_LIBRARIES) if (METIS_LIBRARIES) - 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_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of METIS library" FORCE) - else() - set(METIS_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of METIS library" FORCE) - endif() + 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_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of METIS library" FORCE) + else() + set(METIS_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of METIS library" FORCE) + endif() endif() mark_as_advanced(METIS_DIR) mark_as_advanced(METIS_DIR_FOUND) @@ -257,8 +257,8 @@ mark_as_advanced(METIS_DIR_FOUND) # --------------------------------- include(FindPackageHandleStandardArgs) find_package_handle_standard_args(METIS DEFAULT_MSG - METIS_LIBRARIES - METIS_WORKS) + METIS_LIBRARIES + METIS_WORKS) # # TODO: Add possibility to check for specific functions in the library # diff --git a/CMakeModules/morse/find/FindMPIEXT.cmake b/CMakeModules/morse/find/FindMPIEXT.cmake index 68520a478eb4bef8943830a93830a73994b3ad07..1409989751594a714a0d4d17a23adb194aff356e 100644 --- a/CMakeModules/morse/find/FindMPIEXT.cmake +++ b/CMakeModules/morse/find/FindMPIEXT.cmake @@ -23,11 +23,11 @@ # add a cache variable to let the user specify the BLAS vendor if (NOT MPI_FOUND) - if(MPIEXT_FIND_REQUIRED) - find_package(MPI REQUIRED) - else() - find_package(MPI) - endif() + if(MPIEXT_FIND_REQUIRED) + find_package(MPI REQUIRED) + else() + find_package(MPI) + endif() endif () if (MPI_FOUND) @@ -103,9 +103,9 @@ int main(int argc, char **argv) { if(NOT SERIALIZED_TEST_RUNS) check_c_source_runs("${MPI_C_TEST_FUNNELED_SOURCE}" FUNNELED_TEST_RUNS) if(NOT FUNNELED_TEST_RUNS) - set(MPI_THREAD_SUPPORTED_LEVEL "MPI_THREAD_SINGLE") + set(MPI_THREAD_SUPPORTED_LEVEL "MPI_THREAD_SINGLE") else(NOT FUNNELED_TEST_RUNS) - set(MPI_THREAD_SUPPORTED_LEVEL "MPI_THREAD_FUNNELED") + set(MPI_THREAD_SUPPORTED_LEVEL "MPI_THREAD_FUNNELED") endif(NOT FUNNELED_TEST_RUNS) else(NOT SERIALIZED_TEST_RUNS) set(MPI_THREAD_SUPPORTED_LEVEL "MPI_THREAD_SERIALIZED") @@ -117,4 +117,4 @@ int main(int argc, char **argv) { set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE}) set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE}) -endif(MPI_FOUND) \ No newline at end of file +endif(MPI_FOUND) diff --git a/CMakeModules/morse/find/FindMUMPS.cmake b/CMakeModules/morse/find/FindMUMPS.cmake index df5300ceaad80a601202514fc51dad2d46ac4a59..4c956e85acee833a17a88045c8689d6cc9a533be 100644 --- a/CMakeModules/morse/find/FindMUMPS.cmake +++ b/CMakeModules/morse/find/FindMUMPS.cmake @@ -67,10 +67,10 @@ if (NOT MUMPS_FOUND) - 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() + 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() endif() # Set the version to find @@ -82,75 +82,75 @@ set(MUMPS_LOOK_FOR_METIS OFF) set(MUMPS_LOOK_FOR_PARMETIS OFF) if( MUMPS_FIND_COMPONENTS ) - foreach( component ${MUMPS_FIND_COMPONENTS} ) - if (${component} STREQUAL "SEQ") - # means we look for the sequential version of MUMPS (without MPI) - set(MUMPS_LOOK_FOR_SEQ ON) - set(MUMPS_LOOK_FOR_MPI OFF) - endif() - if (${component} STREQUAL "MPI") - # means we look for the MPI version of MUMPS (default) - set(MUMPS_LOOK_FOR_MPI ON) - set(MUMPS_LOOK_FOR_SEQ OFF) - endif() - if (${component} STREQUAL "SCOTCH") - set(MUMPS_LOOK_FOR_SCOTCH ON) - endif() - if (${component} STREQUAL "PTSCOTCH") - set(MUMPS_LOOK_FOR_PTSCOTCH ON) - endif() - if (${component} STREQUAL "METIS") - set(MUMPS_LOOK_FOR_METIS ON) - endif() - if (${component} STREQUAL "PARMETIS") - set(MUMPS_LOOK_FOR_PARMETIS ON) - endif() - endforeach() + foreach( component ${MUMPS_FIND_COMPONENTS} ) + if (${component} STREQUAL "SEQ") + # means we look for the sequential version of MUMPS (without MPI) + set(MUMPS_LOOK_FOR_SEQ ON) + set(MUMPS_LOOK_FOR_MPI OFF) + endif() + if (${component} STREQUAL "MPI") + # means we look for the MPI version of MUMPS (default) + set(MUMPS_LOOK_FOR_MPI ON) + set(MUMPS_LOOK_FOR_SEQ OFF) + endif() + if (${component} STREQUAL "SCOTCH") + set(MUMPS_LOOK_FOR_SCOTCH ON) + endif() + if (${component} STREQUAL "PTSCOTCH") + set(MUMPS_LOOK_FOR_PTSCOTCH ON) + endif() + if (${component} STREQUAL "METIS") + set(MUMPS_LOOK_FOR_METIS ON) + endif() + if (${component} STREQUAL "PARMETIS") + set(MUMPS_LOOK_FOR_PARMETIS ON) + endif() + endforeach() endif() if (NOT MUMPS_FIND_QUIETLY) - if (MUMPS_LOOK_FOR_SEQ) - message(STATUS "Looking for MUMPS - sequential version (without MPI)") - else() - message(STATUS "Looking for MUMPS - MPI version -" - " if you want to force detection of a sequential " - "version use find_package(MUMPS [REQUIRED] COMPONENTS SEQ [...])") - endif() + if (MUMPS_LOOK_FOR_SEQ) + message(STATUS "Looking for MUMPS - sequential version (without MPI)") + else() + message(STATUS "Looking for MUMPS - MPI version -" + " if you want to force detection of a sequential " + "version use find_package(MUMPS [REQUIRED] COMPONENTS SEQ [...])") + endif() endif() if (NOT MUMPS_FIND_QUIETLY) - message(STATUS "Looking for MUMPS - PkgConfig not used") + message(STATUS "Looking for MUMPS - PkgConfig not used") endif() # Required dependencies # --------------------- if (NOT MUMPS_FIND_QUIETLY) - message(STATUS "Looking for MUMPS - Try to detect pthread") + message(STATUS "Looking for MUMPS - Try to detect pthread") endif() if (NOT Threads_FOUND) - if (MUMPS_FIND_REQUIRED) - find_package(Threads REQUIRED) - else() - find_package(Threads) - endif() + if (MUMPS_FIND_REQUIRED) + find_package(Threads REQUIRED) + else() + find_package(Threads) + endif() endif() set(MUMPS_EXTRA_LIBRARIES "") if( THREADS_FOUND ) - list(APPEND MUMPS_EXTRA_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) + list(APPEND MUMPS_EXTRA_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) endif () # MUMPS depends on BLAS #---------------------- if (NOT MUMPS_FIND_QUIETLY) - message(STATUS "Looking for MUMPS - Try to detect BLAS") + message(STATUS "Looking for MUMPS - Try to detect BLAS") endif() if (NOT BLASEXT_FOUND) - if (MUMPS_FIND_REQUIRED) - find_package(BLASEXT REQUIRED) - else() - find_package(BLASEXT) - endif() + if (MUMPS_FIND_REQUIRED) + find_package(BLASEXT REQUIRED) + else() + find_package(BLASEXT) + endif() endif() # Optional dependencies @@ -159,90 +159,90 @@ endif() # MUMPS may depend on MPI #------------------------ if (NOT MPI_FOUND AND MUMPS_LOOK_FOR_MPI) - if (NOT MUMPS_FIND_QUIETLY) - message(STATUS "Looking for MUMPS - Try to detect MPI") - endif() - # allows to use an external mpi compilation by setting compilers with - # -DMPI_C_COMPILER=path/to/mpicc -DMPI_Fortran_COMPILER=path/to/mpif90 - # at cmake configure - if(NOT MPI_C_COMPILER) - set(MPI_C_COMPILER mpicc) - endif() - if (MUMPS_FIND_REQUIRED AND MUMPS_FIND_REQUIRED_MPI) - find_package(MPI REQUIRED) - else() - find_package(MPI) - endif() - if (MPI_FOUND) - mark_as_advanced(MPI_LIBRARY) - mark_as_advanced(MPI_EXTRA_LIBRARY) - endif() + if (NOT MUMPS_FIND_QUIETLY) + message(STATUS "Looking for MUMPS - Try to detect MPI") + endif() + # allows to use an external mpi compilation by setting compilers with + # -DMPI_C_COMPILER=path/to/mpicc -DMPI_Fortran_COMPILER=path/to/mpif90 + # at cmake configure + if(NOT MPI_C_COMPILER) + set(MPI_C_COMPILER mpicc) + endif() + if (MUMPS_FIND_REQUIRED AND MUMPS_FIND_REQUIRED_MPI) + find_package(MPI REQUIRED) + else() + find_package(MPI) + endif() + if (MPI_FOUND) + mark_as_advanced(MPI_LIBRARY) + mark_as_advanced(MPI_EXTRA_LIBRARY) + endif() endif (NOT MPI_FOUND AND MUMPS_LOOK_FOR_MPI) # MUMPS may depend on ScaLAPACK (if MPI version) #----------------------------------------------- if (NOT SCALAPACK_FOUND AND MUMPS_LOOK_FOR_MPI) - if (NOT MUMPS_FIND_QUIETLY) - message(STATUS "Looking for MUMPS - Try to detect SCALAPACK") - endif() - # SCALAPACK is a required dependency if MPI is used - if (MUMPS_FIND_REQUIRED AND MUMPS_FIND_REQUIRED_MPI) - find_package(SCALAPACK REQUIRED) - else() - find_package(SCALAPACK) - endif() + if (NOT MUMPS_FIND_QUIETLY) + message(STATUS "Looking for MUMPS - Try to detect SCALAPACK") + endif() + # SCALAPACK is a required dependency if MPI is used + if (MUMPS_FIND_REQUIRED AND MUMPS_FIND_REQUIRED_MPI) + find_package(SCALAPACK REQUIRED) + else() + find_package(SCALAPACK) + endif() endif (NOT SCALAPACK_FOUND AND MUMPS_LOOK_FOR_MPI) # MUMPS may depends on SCOTCH #---------------------------- if (MUMPS_LOOK_FOR_SCOTCH) - if (NOT MUMPS_FIND_QUIETLY) - message(STATUS "Looking for MUMPS - Try to detect SCOTCH with esmumps") - endif() - if (MUMPS_FIND_REQUIRED AND MUMPS_FIND_REQUIRED_SCOTCH) - find_package(SCOTCH REQUIRED COMPONENTS ESMUMPS) - else() - find_package(SCOTCH COMPONENTS ESMUMPS) - endif() + if (NOT MUMPS_FIND_QUIETLY) + message(STATUS "Looking for MUMPS - Try to detect SCOTCH with esmumps") + endif() + if (MUMPS_FIND_REQUIRED AND MUMPS_FIND_REQUIRED_SCOTCH) + find_package(SCOTCH REQUIRED COMPONENTS ESMUMPS) + else() + find_package(SCOTCH COMPONENTS ESMUMPS) + endif() endif() # MUMPS may depends on PTSCOTCH #------------------------------ if (MUMPS_LOOK_FOR_PTSCOTCH) - if (NOT MUMPS_FIND_QUIETLY) - message(STATUS "Looking for MUMPS - Try to detect PTSCOTCH with esmumps") - endif() - if (MUMPS_FIND_REQUIRED AND MUMPS_FIND_REQUIRED_PTSCOTCH) - find_package(PTSCOTCH REQUIRED COMPONENTS ESMUMPS) - else() - find_package(PTSCOTCH COMPONENTS ESMUMPS) - endif() + if (NOT MUMPS_FIND_QUIETLY) + message(STATUS "Looking for MUMPS - Try to detect PTSCOTCH with esmumps") + endif() + if (MUMPS_FIND_REQUIRED AND MUMPS_FIND_REQUIRED_PTSCOTCH) + find_package(PTSCOTCH REQUIRED COMPONENTS ESMUMPS) + else() + find_package(PTSCOTCH COMPONENTS ESMUMPS) + endif() endif() # MUMPS may depends on METIS #--------------------------- 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 AND MUMPS_FIND_REQUIRED_METIS) - find_package(METIS REQUIRED) - else() - find_package(METIS) - endif() + if (NOT MUMPS_FIND_QUIETLY) + message(STATUS "Looking for MUMPS - Try to detect METIS") + endif() + if (MUMPS_FIND_REQUIRED AND MUMPS_FIND_REQUIRED_METIS) + find_package(METIS REQUIRED) + else() + find_package(METIS) + endif() endif() # MUMPS may depends on PARMETIS #------------------------------ if (NOT PARMETIS_FOUND AND MUMPS_LOOK_FOR_PARMETIS) - if (NOT MUMPS_FIND_QUIETLY) - message(STATUS "Looking for MUMPS - Try to detect PARMETIS") - endif() - if (MUMPS_FIND_REQUIRED AND MUMPS_FIND_REQUIRED_PARMETIS) - find_package(PARMETIS REQUIRED) - else() - find_package(PARMETIS) - endif() + if (NOT MUMPS_FIND_QUIETLY) + message(STATUS "Looking for MUMPS - Try to detect PARMETIS") + endif() + if (MUMPS_FIND_REQUIRED AND MUMPS_FIND_REQUIRED_PARMETIS) + find_package(PARMETIS REQUIRED) + else() + find_package(PARMETIS) + endif() endif() # Looking for MUMPS @@ -254,24 +254,24 @@ unset(_inc_env) set(ENV_MUMPS_DIR "$ENV{MUMPS_DIR}") set(ENV_MUMPS_INCDIR "$ENV{MUMPS_INCDIR}") if(ENV_MUMPS_INCDIR) - list(APPEND _inc_env "${ENV_MUMPS_INCDIR}") + list(APPEND _inc_env "${ENV_MUMPS_INCDIR}") elseif(ENV_MUMPS_DIR) - list(APPEND _inc_env "${ENV_MUMPS_DIR}") - list(APPEND _inc_env "${ENV_MUMPS_DIR}/include") - list(APPEND _inc_env "${ENV_MUMPS_DIR}/include/mumps") + list(APPEND _inc_env "${ENV_MUMPS_DIR}") + list(APPEND _inc_env "${ENV_MUMPS_DIR}/include") + list(APPEND _inc_env "${ENV_MUMPS_DIR}/include/mumps") else() - if(WIN32) - string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") - else() - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{CPATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - endif() + if(WIN32) + string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") + else() + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{CPATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + endif() endif() list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") @@ -282,22 +282,22 @@ list(REMOVE_DUPLICATES _inc_env) unset(_lib_env) set(ENV_MUMPS_LIBDIR "$ENV{MUMPS_LIBDIR}") if(ENV_MUMPS_LIBDIR) - list(APPEND _lib_env "${ENV_MUMPS_LIBDIR}") + list(APPEND _lib_env "${ENV_MUMPS_LIBDIR}") elseif(ENV_MUMPS_DIR) - list(APPEND _lib_env "${ENV_MUMPS_DIR}") - list(APPEND _lib_env "${ENV_MUMPS_DIR}/lib") + list(APPEND _lib_env "${ENV_MUMPS_DIR}") + list(APPEND _lib_env "${ENV_MUMPS_DIR}/lib") else() - if(WIN32) - string(REPLACE ":" ";" _lib_env "$ENV{LIB}") + if(WIN32) + string(REPLACE ":" ";" _lib_env "$ENV{LIB}") + else() + if(APPLE) + string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") else() - if(APPLE) - string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") endif() + list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") + list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + endif() endif() list(REMOVE_DUPLICATES _lib_env) @@ -312,73 +312,73 @@ list(APPEND MUMPS_hdrs_to_find "smumps_c.h;dmumps_c.h;cmumps_c.h;zmumps_c.h") # call cmake macro to find the header path if(MUMPS_INCDIR) + foreach(mumps_hdr ${MUMPS_hdrs_to_find}) + set(MUMPS_${mumps_hdr}_DIRS "MUMPS_${mumps_hdr}_INCLUDE_DIRS-NOTFOUND") + find_path(MUMPS_${mumps_hdr}_DIRS + NAMES ${mumps_hdr} + HINTS ${MUMPS_INCDIR}) + endforeach() +else() + if(MUMPS_DIR) + set(MUMPS_${mumps_hdr}_DIRS "MUMPS_${mumps_hdr}_INCLUDE_DIRS-NOTFOUND") foreach(mumps_hdr ${MUMPS_hdrs_to_find}) - set(MUMPS_${mumps_hdr}_DIRS "MUMPS_${mumps_hdr}_INCLUDE_DIRS-NOTFOUND") - find_path(MUMPS_${mumps_hdr}_DIRS - NAMES ${mumps_hdr} - HINTS ${MUMPS_INCDIR}) + find_path(MUMPS_${mumps_hdr}_DIRS + NAMES ${mumps_hdr} + HINTS ${MUMPS_DIR} + PATH_SUFFIXES "include") endforeach() -else() - if(MUMPS_DIR) - set(MUMPS_${mumps_hdr}_DIRS "MUMPS_${mumps_hdr}_INCLUDE_DIRS-NOTFOUND") - foreach(mumps_hdr ${MUMPS_hdrs_to_find}) - find_path(MUMPS_${mumps_hdr}_DIRS - NAMES ${mumps_hdr} - HINTS ${MUMPS_DIR} - PATH_SUFFIXES "include") - endforeach() - else() - foreach(mumps_hdr ${MUMPS_hdrs_to_find}) - set(MUMPS_${mumps_hdr}_DIRS "MUMPS_${mumps_hdr}_INCLUDE_DIRS-NOTFOUND") - find_path(MUMPS_${mumps_hdr}_DIRS - NAMES ${mumps_hdr} - HINTS ${_inc_env}) - endforeach() - endif() + else() + foreach(mumps_hdr ${MUMPS_hdrs_to_find}) + set(MUMPS_${mumps_hdr}_DIRS "MUMPS_${mumps_hdr}_INCLUDE_DIRS-NOTFOUND") + find_path(MUMPS_${mumps_hdr}_DIRS + NAMES ${mumps_hdr} + HINTS ${_inc_env}) + endforeach() + endif() endif() # If found, add path to cmake variable # ------------------------------------ # detect which precisions are available if (MUMPS_smumps_c.h_DIRS) - mark_as_advanced(MUMPS_smumps_c.h_DIRS) - set(MUMPS_PREC_S ON) - set(MUMPS_INCLUDE_DIRS "${MUMPS_smumps_c.h_DIRS}") + mark_as_advanced(MUMPS_smumps_c.h_DIRS) + set(MUMPS_PREC_S ON) + set(MUMPS_INCLUDE_DIRS "${MUMPS_smumps_c.h_DIRS}") else () - set(MUMPS_PREC_S OFF) - if(NOT MUMPS_FIND_QUIETLY) - message(STATUS "Looking for mumps -- smumps_c.h not found") - endif() + set(MUMPS_PREC_S OFF) + if(NOT MUMPS_FIND_QUIETLY) + message(STATUS "Looking for mumps -- smumps_c.h not found") + endif() endif() if (MUMPS_dmumps_c.h_DIRS) - mark_as_advanced(MUMPS_dmumps_c.h_DIRS) - set(MUMPS_PREC_D ON) - set(MUMPS_INCLUDE_DIRS "${MUMPS_dmumps_c.h_DIRS}") + mark_as_advanced(MUMPS_dmumps_c.h_DIRS) + set(MUMPS_PREC_D ON) + set(MUMPS_INCLUDE_DIRS "${MUMPS_dmumps_c.h_DIRS}") else () - set(MUMPS_PREC_D OFF) - if(NOT MUMPS_FIND_QUIETLY) - message(STATUS "Looking for mumps -- dmumps_c.h not found") - endif() + set(MUMPS_PREC_D OFF) + if(NOT MUMPS_FIND_QUIETLY) + message(STATUS "Looking for mumps -- dmumps_c.h not found") + endif() endif() if (MUMPS_cmumps_c.h_DIRS) - mark_as_advanced(MUMPS_cmumps_c.h_DIRS) - set(MUMPS_PREC_C ON) - set(MUMPS_INCLUDE_DIRS "${MUMPS_cmumps_c.h_DIRS}") + mark_as_advanced(MUMPS_cmumps_c.h_DIRS) + set(MUMPS_PREC_C ON) + set(MUMPS_INCLUDE_DIRS "${MUMPS_cmumps_c.h_DIRS}") else () - set(MUMPS_PREC_C OFF) - if(NOT MUMPS_FIND_QUIETLY) - message(STATUS "Looking for mumps -- cmumps_c.h not found") - endif() + set(MUMPS_PREC_C OFF) + if(NOT MUMPS_FIND_QUIETLY) + message(STATUS "Looking for mumps -- cmumps_c.h not found") + endif() endif() if (MUMPS_zmumps_c.h_DIRS) - mark_as_advanced(MUMPS_zmumps_c.h_DIRS) - set(MUMPS_PREC_Z ON) - set(MUMPS_INCLUDE_DIRS "${MUMPS_zmumps_c.h_DIRS}") + mark_as_advanced(MUMPS_zmumps_c.h_DIRS) + set(MUMPS_PREC_Z ON) + set(MUMPS_INCLUDE_DIRS "${MUMPS_zmumps_c.h_DIRS}") else () - set(MUMPS_PREC_Z OFF) - if(NOT MUMPS_FIND_QUIETLY) - message(STATUS "Looking for mumps -- zmumps_c.h not found") - endif() + set(MUMPS_PREC_Z OFF) + if(NOT MUMPS_FIND_QUIETLY) + message(STATUS "Looking for mumps -- zmumps_c.h not found") + endif() endif() @@ -388,46 +388,46 @@ endif() # create list of libs to find set(MUMPS_libs_to_find "mumps_common;pord") if (MUMPS_LOOK_FOR_SEQ) - list(APPEND MUMPS_libs_to_find "mpiseq") + list(APPEND MUMPS_libs_to_find "mpiseq") endif() if(MUMPS_PREC_S) - list(APPEND MUMPS_libs_to_find "smumps") + list(APPEND MUMPS_libs_to_find "smumps") endif() if(MUMPS_PREC_D) - list(APPEND MUMPS_libs_to_find "dmumps") + list(APPEND MUMPS_libs_to_find "dmumps") endif() if(MUMPS_PREC_C) - list(APPEND MUMPS_libs_to_find "cmumps") + list(APPEND MUMPS_libs_to_find "cmumps") endif() if(MUMPS_PREC_Z) - list(APPEND MUMPS_libs_to_find "zmumps") + list(APPEND MUMPS_libs_to_find "zmumps") endif() # call cmake macro to find the lib path if(MUMPS_LIBDIR) + foreach(mumps_lib ${MUMPS_libs_to_find}) + set(MUMPS_${mumps_lib}_LIBRARY "MUMPS_${mumps_lib}_LIBRARY-NOTFOUND") + find_library(MUMPS_${mumps_lib}_LIBRARY + NAMES ${mumps_lib} + HINTS ${MUMPS_LIBDIR}) + endforeach() +else() + if(MUMPS_DIR) foreach(mumps_lib ${MUMPS_libs_to_find}) - set(MUMPS_${mumps_lib}_LIBRARY "MUMPS_${mumps_lib}_LIBRARY-NOTFOUND") - find_library(MUMPS_${mumps_lib}_LIBRARY - NAMES ${mumps_lib} - HINTS ${MUMPS_LIBDIR}) + set(MUMPS_${mumps_lib}_LIBRARY "MUMPS_${mumps_lib}_LIBRARY-NOTFOUND") + find_library(MUMPS_${mumps_lib}_LIBRARY + NAMES ${mumps_lib} + HINTS ${MUMPS_DIR} + PATH_SUFFIXES lib lib32 lib64) endforeach() -else() - if(MUMPS_DIR) - foreach(mumps_lib ${MUMPS_libs_to_find}) - set(MUMPS_${mumps_lib}_LIBRARY "MUMPS_${mumps_lib}_LIBRARY-NOTFOUND") - find_library(MUMPS_${mumps_lib}_LIBRARY - NAMES ${mumps_lib} - HINTS ${MUMPS_DIR} - PATH_SUFFIXES lib lib32 lib64) - endforeach() - else() - foreach(mumps_lib ${MUMPS_libs_to_find}) - set(MUMPS_${mumps_lib}_LIBRARY "MUMPS_${mumps_lib}_LIBRARY-NOTFOUND") - find_library(MUMPS_${mumps_lib}_LIBRARY - NAMES ${mumps_lib} - HINTS ${_lib_env}) - endforeach() - endif() + else() + foreach(mumps_lib ${MUMPS_libs_to_find}) + set(MUMPS_${mumps_lib}_LIBRARY "MUMPS_${mumps_lib}_LIBRARY-NOTFOUND") + find_library(MUMPS_${mumps_lib}_LIBRARY + NAMES ${mumps_lib} + HINTS ${_lib_env}) + endforeach() + endif() endif() # If found, add path to cmake variable @@ -436,109 +436,109 @@ set(MUMPS_LIBRARIES "") set(MUMPS_LIBRARY_DIRS "") # detect which precisions are available if (MUMPS_smumps_LIBRARY) - mark_as_advanced(MUMPS_smumps_LIBRARY) - list(APPEND MUMPS_LIBRARIES "${MUMPS_smumps_LIBRARY}") - get_filename_component(smumps_lib_path ${MUMPS_smumps_LIBRARY} PATH) - list(APPEND MUMPS_LIBRARY_DIRS "${smumps_lib_path}") + mark_as_advanced(MUMPS_smumps_LIBRARY) + list(APPEND MUMPS_LIBRARIES "${MUMPS_smumps_LIBRARY}") + get_filename_component(smumps_lib_path ${MUMPS_smumps_LIBRARY} PATH) + list(APPEND MUMPS_LIBRARY_DIRS "${smumps_lib_path}") else () - set(MUMPS_PREC_S OFF) - if(NOT MUMPS_FIND_QUIETLY) - message(STATUS "Looking for mumps -- libsmumps.a not found") - endif() + set(MUMPS_PREC_S OFF) + if(NOT MUMPS_FIND_QUIETLY) + message(STATUS "Looking for mumps -- libsmumps.a not found") + endif() endif() if (MUMPS_dmumps_LIBRARY) - mark_as_advanced(MUMPS_dmumps_LIBRARY) - list(APPEND MUMPS_LIBRARIES "${MUMPS_dmumps_LIBRARY}") - get_filename_component(dmumps_lib_path ${MUMPS_dmumps_LIBRARY} PATH) - list(APPEND MUMPS_LIBRARY_DIRS "${dmumps_lib_path}") + mark_as_advanced(MUMPS_dmumps_LIBRARY) + list(APPEND MUMPS_LIBRARIES "${MUMPS_dmumps_LIBRARY}") + get_filename_component(dmumps_lib_path ${MUMPS_dmumps_LIBRARY} PATH) + list(APPEND MUMPS_LIBRARY_DIRS "${dmumps_lib_path}") else () - set(MUMPS_PREC_D OFF) - if(NOT MUMPS_FIND_QUIETLY) - message(STATUS "Looking for mumps -- libdmumps.a not found") - endif() + set(MUMPS_PREC_D OFF) + if(NOT MUMPS_FIND_QUIETLY) + message(STATUS "Looking for mumps -- libdmumps.a not found") + endif() endif() if (MUMPS_cmumps_LIBRARY) - mark_as_advanced(MUMPS_cmumps_LIBRARY) - list(APPEND MUMPS_LIBRARIES "${MUMPS_cmumps_LIBRARY}") - get_filename_component(cmumps_lib_path ${MUMPS_cmumps_LIBRARY} PATH) - list(APPEND MUMPS_LIBRARY_DIRS "${cmumps_lib_path}") + mark_as_advanced(MUMPS_cmumps_LIBRARY) + list(APPEND MUMPS_LIBRARIES "${MUMPS_cmumps_LIBRARY}") + get_filename_component(cmumps_lib_path ${MUMPS_cmumps_LIBRARY} PATH) + list(APPEND MUMPS_LIBRARY_DIRS "${cmumps_lib_path}") else () - set(MUMPS_PREC_C OFF) - if(NOT MUMPS_FIND_QUIETLY) - message(STATUS "Looking for mumps -- libcmumps.a not found") - endif() + set(MUMPS_PREC_C OFF) + if(NOT MUMPS_FIND_QUIETLY) + message(STATUS "Looking for mumps -- libcmumps.a not found") + endif() endif() if (MUMPS_zmumps_LIBRARY) - mark_as_advanced(MUMPS_zmumps_LIBRARY) - list(APPEND MUMPS_LIBRARIES "${MUMPS_zmumps_LIBRARY}") - get_filename_component(zmumps_lib_path ${MUMPS_zmumps_LIBRARY} PATH) - list(APPEND MUMPS_LIBRARY_DIRS "${zmumps_lib_path}") + mark_as_advanced(MUMPS_zmumps_LIBRARY) + list(APPEND MUMPS_LIBRARIES "${MUMPS_zmumps_LIBRARY}") + get_filename_component(zmumps_lib_path ${MUMPS_zmumps_LIBRARY} PATH) + list(APPEND MUMPS_LIBRARY_DIRS "${zmumps_lib_path}") else () - set(MUMPS_PREC_Z OFF) - if(NOT MUMPS_FIND_QUIETLY) - message(STATUS "Looking for mumps -- libzmumps.a not found") - endif() + set(MUMPS_PREC_Z OFF) + if(NOT MUMPS_FIND_QUIETLY) + message(STATUS "Looking for mumps -- libzmumps.a not found") + endif() endif() # check that one precision arithmetic at least has been discovered if (NOT MUMPS_PREC_S AND NOT MUMPS_PREC_D AND NOT MUMPS_PREC_C AND NOT MUMPS_PREC_S) - if (MUMPS_FIND_REQUIRED) - message(FATAL_ERROR "Looking for mumps -- " - "no lib[sdcz]mumps.a have been found in ${MUMPS_DIR}/lib when required") - else() - if(NOT MUMPS_FIND_QUIETLY) - message(STATUS "Looking for mumps -- no lib[sdcz]mumps.a have been found") - endif() + if (MUMPS_FIND_REQUIRED) + message(FATAL_ERROR "Looking for mumps -- " + "no lib[sdcz]mumps.a have been found in ${MUMPS_DIR}/lib when required") + else() + if(NOT MUMPS_FIND_QUIETLY) + message(STATUS "Looking for mumps -- no lib[sdcz]mumps.a have been found") endif() + endif() endif() # other MUMPS libraries if (MUMPS_mumps_common_LIBRARY) - mark_as_advanced(MUMPS_mumps_common_LIBRARY) - list(APPEND MUMPS_LIBRARIES "${MUMPS_mumps_common_LIBRARY}") - get_filename_component(mumps_common_lib_path ${MUMPS_mumps_common_LIBRARY} PATH) - list(APPEND MUMPS_LIBRARY_DIRS "${mumps_common_lib_path}") + mark_as_advanced(MUMPS_mumps_common_LIBRARY) + list(APPEND MUMPS_LIBRARIES "${MUMPS_mumps_common_LIBRARY}") + get_filename_component(mumps_common_lib_path ${MUMPS_mumps_common_LIBRARY} PATH) + list(APPEND MUMPS_LIBRARY_DIRS "${mumps_common_lib_path}") else () - if (MUMPS_FIND_REQUIRED) - message(FATAL_ERROR "Looking for mumps -- " - "libmumps_common.a not found in ${MUMPS_DIR}/lib when required") - else() - if(NOT MUMPS_FIND_QUIETLY) - message(STATUS "Looking for mumps -- libmumps_common.a not found") - endif() + if (MUMPS_FIND_REQUIRED) + message(FATAL_ERROR "Looking for mumps -- " + "libmumps_common.a not found in ${MUMPS_DIR}/lib when required") + else() + if(NOT MUMPS_FIND_QUIETLY) + message(STATUS "Looking for mumps -- libmumps_common.a not found") endif() + endif() endif() if (MUMPS_mpiseq_LIBRARY) - mark_as_advanced(MUMPS_mpiseq_LIBRARY) - if (MUMPS_LOOK_FOR_SEQ) - list(APPEND MUMPS_LIBRARIES "${MUMPS_mpiseq_LIBRARY}") - get_filename_component(mpiseq_lib_path ${MUMPS_mpiseq_LIBRARY} PATH) - list(APPEND MUMPS_LIBRARY_DIRS "${mpiseq_lib_path}") - list(APPEND MUMPS_INCLUDE_DIRS "${mpiseq_lib_path}") - endif() + mark_as_advanced(MUMPS_mpiseq_LIBRARY) + if (MUMPS_LOOK_FOR_SEQ) + list(APPEND MUMPS_LIBRARIES "${MUMPS_mpiseq_LIBRARY}") + get_filename_component(mpiseq_lib_path ${MUMPS_mpiseq_LIBRARY} PATH) + list(APPEND MUMPS_LIBRARY_DIRS "${mpiseq_lib_path}") + list(APPEND MUMPS_INCLUDE_DIRS "${mpiseq_lib_path}") + endif() else () - if (MUMPS_FIND_REQUIRED AND MUMPS_LOOK_FOR_SEQ) - message(FATAL_ERROR "Looking for mumps -- " - "libmpiseq.a not found in ${MUMPS_DIR}/libseq when required") - else() - if(NOT MUMPS_FIND_QUIETLY) - message(STATUS "Looking for mumps -- libmpiseq.a not found") - endif() + if (MUMPS_FIND_REQUIRED AND MUMPS_LOOK_FOR_SEQ) + message(FATAL_ERROR "Looking for mumps -- " + "libmpiseq.a not found in ${MUMPS_DIR}/libseq when required") + else() + if(NOT MUMPS_FIND_QUIETLY) + message(STATUS "Looking for mumps -- libmpiseq.a not found") endif() + endif() endif() if (MUMPS_pord_LIBRARY) - mark_as_advanced(MUMPS_pord_LIBRARY) - list(APPEND MUMPS_LIBRARIES "${MUMPS_pord_LIBRARY}") - get_filename_component(pord_lib_path ${MUMPS_pord_LIBRARY} PATH) - list(APPEND MUMPS_LIBRARY_DIRS "${pord_lib_path}") + mark_as_advanced(MUMPS_pord_LIBRARY) + list(APPEND MUMPS_LIBRARIES "${MUMPS_pord_LIBRARY}") + get_filename_component(pord_lib_path ${MUMPS_pord_LIBRARY} PATH) + list(APPEND MUMPS_LIBRARY_DIRS "${pord_lib_path}") else () - if (MUMPS_FIND_REQUIRED) - message(FATAL_ERROR "Looking for mumps -- " - "libpord.a not found in ${MUMPS_DIR}/lib when required") - else() - if(NOT MUMPS_FIND_QUIETLY) - message(STATUS "Looking for mumps -- libpord.a not found") - endif() + if (MUMPS_FIND_REQUIRED) + message(FATAL_ERROR "Looking for mumps -- " + "libpord.a not found in ${MUMPS_DIR}/lib when required") + else() + if(NOT MUMPS_FIND_QUIETLY) + message(STATUS "Looking for mumps -- libpord.a not found") endif() + endif() endif() list(REMOVE_DUPLICATES MUMPS_LIBRARY_DIRS) list(REMOVE_DUPLICATES MUMPS_INCLUDE_DIRS) @@ -546,201 +546,201 @@ 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) - - # MUMPS - if (MUMPS_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${MUMPS_INCLUDE_DIRS}") - endif() - foreach(libdir ${MUMPS_LIBRARY_DIRS}) - if (libdir) - list(APPEND REQUIRED_LIBDIRS "${libdir}") - endif() + set(REQUIRED_LDFLAGS) + set(REQUIRED_INCDIRS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) + + # MUMPS + if (MUMPS_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${MUMPS_INCLUDE_DIRS}") + endif() + foreach(libdir ${MUMPS_LIBRARY_DIRS}) + if (libdir) + list(APPEND REQUIRED_LIBDIRS "${libdir}") + endif() + endforeach() + set(REQUIRED_LIBS "${MUMPS_LIBRARIES}") + # SCALAPACK + if (MUMPS_LOOK_FOR_MPI AND SCALAPACK_FOUND) + if (SCALAPACK_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${SCALAPACK_INCLUDE_DIRS}") + endif() + foreach(libdir ${SCALAPACK_LIBRARY_DIRS}) + if (libdir) + list(APPEND REQUIRED_LIBDIRS "${libdir}") + endif() endforeach() - set(REQUIRED_LIBS "${MUMPS_LIBRARIES}") - # SCALAPACK - if (MUMPS_LOOK_FOR_MPI AND SCALAPACK_FOUND) - if (SCALAPACK_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${SCALAPACK_INCLUDE_DIRS}") - endif() - foreach(libdir ${SCALAPACK_LIBRARY_DIRS}) - if (libdir) - list(APPEND REQUIRED_LIBDIRS "${libdir}") - 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) - if (MPI_C_INCLUDE_PATH) - list(APPEND REQUIRED_INCDIRS "${MPI_C_INCLUDE_PATH}") - endif() - if (MPI_Fortran_LINK_FLAGS) - if (${MPI_Fortran_LINK_FLAGS} MATCHES " -") - string(REGEX REPLACE " -" "-" MPI_Fortran_LINK_FLAGS ${MPI_Fortran_LINK_FLAGS}) - endif() - list(APPEND REQUIRED_LDFLAGS "${MPI_Fortran_LINK_FLAGS}") - endif() - list(APPEND REQUIRED_LIBS "${MPI_Fortran_LIBRARIES}") - endif() - # BLAS - if (BLAS_FOUND) - if (BLAS_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${BLAS_INCLUDE_DIRS}") - endif() - foreach(libdir ${BLAS_LIBRARY_DIRS}) - if (libdir) - list(APPEND REQUIRED_LIBDIRS "${libdir}") - 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) - if (SCOTCH_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${SCOTCH_INCLUDE_DIRS}") - endif() - foreach(libdir ${SCOTCH_LIBRARY_DIRS}) - if (libdir) - list(APPEND REQUIRED_LIBDIRS "${libdir}") - endif() - endforeach() - list(APPEND REQUIRED_LIBS "${SCOTCH_LIBRARIES}") - endif() - # PTSCOTCH - if (MUMPS_LOOK_FOR_PTSCOTCH AND PTSCOTCH_FOUND) - if (PTSCOTCH_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${PTSCOTCH_INCLUDE_DIRS}") - endif() - foreach(libdir ${PTSCOTCH_LIBRARY_DIRS}) - if (libdir) - list(APPEND REQUIRED_LIBDIRS "${libdir}") - endif() - endforeach() - list(APPEND REQUIRED_LIBS "${PTSCOTCH_LIBRARIES}") - endif() - # METIS - if (MUMPS_LOOK_FOR_METIS AND METIS_FOUND) - if (METIS_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${METIS_INCLUDE_DIRS}") - endif() - foreach(libdir ${METIS_LIBRARY_DIRS}) - if (libdir) - list(APPEND REQUIRED_LIBDIRS "${libdir}") - endif() - endforeach() - list(APPEND REQUIRED_LIBS "${METIS_LIBRARIES}") - endif() - # PARMETIS - if (MUMPS_LOOK_FOR_PARMETIS AND PARMETIS_FOUND) - if (PARMETIS_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${PARMETIS_INCLUDE_DIRS}") - endif() - foreach(libdir ${PARMETIS_LIBRARY_DIRS}) - if (libdir) - list(APPEND REQUIRED_LIBDIRS "${libdir}") - endif() - endforeach() - list(APPEND REQUIRED_LIBS "${PARMETIS_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 ${MUMPS_EXTRA_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}") + 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) + if (MPI_C_INCLUDE_PATH) + list(APPEND REQUIRED_INCDIRS "${MPI_C_INCLUDE_PATH}") + endif() + if (MPI_Fortran_LINK_FLAGS) + if (${MPI_Fortran_LINK_FLAGS} MATCHES " -") + string(REGEX REPLACE " -" "-" MPI_Fortran_LINK_FLAGS ${MPI_Fortran_LINK_FLAGS}) + endif() + list(APPEND REQUIRED_LDFLAGS "${MPI_Fortran_LINK_FLAGS}") + endif() + list(APPEND REQUIRED_LIBS "${MPI_Fortran_LIBRARIES}") + endif() + # BLAS + if (BLAS_FOUND) + if (BLAS_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${BLAS_INCLUDE_DIRS}") + endif() + foreach(libdir ${BLAS_LIBRARY_DIRS}) + if (libdir) + list(APPEND REQUIRED_LIBDIRS "${libdir}") + endif() endforeach() - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - - # test link - include(CheckFortranFunctionExists) - unset(MUMPS_PREC_S_WORKS CACHE) - check_fortran_function_exists(smumps MUMPS_PREC_S_WORKS) - mark_as_advanced(MUMPS_PREC_S_WORKS) - unset(MUMPS_PREC_D_WORKS CACHE) - check_fortran_function_exists(dmumps MUMPS_PREC_D_WORKS) - mark_as_advanced(MUMPS_PREC_D_WORKS) - unset(MUMPS_PREC_C_WORKS CACHE) - check_fortran_function_exists(cmumps MUMPS_PREC_C_WORKS) - mark_as_advanced(MUMPS_PREC_C_WORKS) - unset(MUMPS_PREC_Z_WORKS CACHE) - check_fortran_function_exists(zmumps MUMPS_PREC_Z_WORKS) - mark_as_advanced(MUMPS_PREC_Z_WORKS) - - set(MUMPS_WORKS FALSE) - if(MUMPS_PREC_S_WORKS OR MUMPS_PREC_D_WORKS OR MUMPS_PREC_C_WORKS OR MUMPS_PREC_Z_WORKS) - set(MUMPS_WORKS TRUE) - endif() - - if(MUMPS_WORKS) - # save link with dependencies - 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") - message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") - message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") - message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") - message(STATUS "Maybe MUMPS is linked with specific libraries. " - "Have you tried with COMPONENTS (MPI/SEQ, SCOTCH, PTSCOTCH, METIS, PARMETIS)? " - "See the explanation in FindMUMPS.cmake.") - endif() - endif() - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_LIBRARIES) + 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) + if (SCOTCH_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${SCOTCH_INCLUDE_DIRS}") + endif() + foreach(libdir ${SCOTCH_LIBRARY_DIRS}) + if (libdir) + list(APPEND REQUIRED_LIBDIRS "${libdir}") + endif() + endforeach() + list(APPEND REQUIRED_LIBS "${SCOTCH_LIBRARIES}") + endif() + # PTSCOTCH + if (MUMPS_LOOK_FOR_PTSCOTCH AND PTSCOTCH_FOUND) + if (PTSCOTCH_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${PTSCOTCH_INCLUDE_DIRS}") + endif() + foreach(libdir ${PTSCOTCH_LIBRARY_DIRS}) + if (libdir) + list(APPEND REQUIRED_LIBDIRS "${libdir}") + endif() + endforeach() + list(APPEND REQUIRED_LIBS "${PTSCOTCH_LIBRARIES}") + endif() + # METIS + if (MUMPS_LOOK_FOR_METIS AND METIS_FOUND) + if (METIS_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${METIS_INCLUDE_DIRS}") + endif() + foreach(libdir ${METIS_LIBRARY_DIRS}) + if (libdir) + list(APPEND REQUIRED_LIBDIRS "${libdir}") + endif() + endforeach() + list(APPEND REQUIRED_LIBS "${METIS_LIBRARIES}") + endif() + # PARMETIS + if (MUMPS_LOOK_FOR_PARMETIS AND PARMETIS_FOUND) + if (PARMETIS_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${PARMETIS_INCLUDE_DIRS}") + endif() + foreach(libdir ${PARMETIS_LIBRARY_DIRS}) + if (libdir) + list(APPEND REQUIRED_LIBDIRS "${libdir}") + endif() + endforeach() + list(APPEND REQUIRED_LIBS "${PARMETIS_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 ${MUMPS_EXTRA_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() + list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") + string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + + # test link + include(CheckFortranFunctionExists) + unset(MUMPS_PREC_S_WORKS CACHE) + check_fortran_function_exists(smumps MUMPS_PREC_S_WORKS) + mark_as_advanced(MUMPS_PREC_S_WORKS) + unset(MUMPS_PREC_D_WORKS CACHE) + check_fortran_function_exists(dmumps MUMPS_PREC_D_WORKS) + mark_as_advanced(MUMPS_PREC_D_WORKS) + unset(MUMPS_PREC_C_WORKS CACHE) + check_fortran_function_exists(cmumps MUMPS_PREC_C_WORKS) + mark_as_advanced(MUMPS_PREC_C_WORKS) + unset(MUMPS_PREC_Z_WORKS CACHE) + check_fortran_function_exists(zmumps MUMPS_PREC_Z_WORKS) + mark_as_advanced(MUMPS_PREC_Z_WORKS) + + set(MUMPS_WORKS FALSE) + if(MUMPS_PREC_S_WORKS OR MUMPS_PREC_D_WORKS OR MUMPS_PREC_C_WORKS OR MUMPS_PREC_Z_WORKS) + set(MUMPS_WORKS TRUE) + endif() + + if(MUMPS_WORKS) + # save link with dependencies + 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") + message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") + message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") + message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") + message(STATUS "Maybe MUMPS is linked with specific libraries. " + "Have you tried with COMPONENTS (MPI/SEQ, SCOTCH, PTSCOTCH, METIS, PARMETIS)? " + "See the explanation in FindMUMPS.cmake.") + endif() + endif() + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) endif(MUMPS_LIBRARIES) if (MUMPS_LIBRARIES) - 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_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of MUMPS library" FORCE) - else() - set(MUMPS_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of MUMPS library" FORCE) - endif() + 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_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of MUMPS library" FORCE) + else() + set(MUMPS_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of MUMPS library" FORCE) + endif() endif() mark_as_advanced(MUMPS_DIR) mark_as_advanced(MUMPS_DIR_FOUND) @@ -749,5 +749,5 @@ mark_as_advanced(MUMPS_DIR_FOUND) # ------------------------------- include(FindPackageHandleStandardArgs) find_package_handle_standard_args(MUMPS DEFAULT_MSG - MUMPS_LIBRARIES - MUMPS_WORKS) + MUMPS_LIBRARIES + MUMPS_WORKS) diff --git a/CMakeModules/morse/find/FindPAMPA.cmake b/CMakeModules/morse/find/FindPAMPA.cmake index 29b8426236cca579292e2b6c7a069df9d49eb340..f5f295376f61cbc9bd902a8321217890e428e6f3 100644 --- a/CMakeModules/morse/find/FindPAMPA.cmake +++ b/CMakeModules/morse/find/FindPAMPA.cmake @@ -52,28 +52,28 @@ # License text for the above reference.) if (NOT PAMPA_FOUND) - set(PAMPA_DIR "" CACHE PATH "Installation directory of PAMPA library") - if (NOT PAMPA_FIND_QUIETLY) - message(STATUS "A cache variable, namely PAMPA_DIR, has been set to specify the install directory of PAMPA") - endif() + set(PAMPA_DIR "" CACHE PATH "Installation directory of PAMPA library") + if (NOT PAMPA_FIND_QUIETLY) + message(STATUS "A cache variable, namely PAMPA_DIR, has been set to specify the install directory of PAMPA") + endif() endif() # PAMPA depends on MPI, try to find it if (NOT MPI_FOUND) - if (PAMPA_FIND_REQUIRED) - find_package(MPI REQUIRED) - else() - find_package(MPI) - endif() + if (PAMPA_FIND_REQUIRED) + find_package(MPI REQUIRED) + else() + find_package(MPI) + endif() endif() # PAMPA depends on PAMPA, try to find it if (NOT PTSCOTCH_FOUND) - if (PAMPA_FIND_REQUIRED) - find_package(PTSCOTCH REQUIRED) - else() - find_package(PTSCOTCH) - endif() + if (PAMPA_FIND_REQUIRED) + find_package(PTSCOTCH REQUIRED) + else() + find_package(PTSCOTCH) + endif() endif() # Looking for include @@ -85,24 +85,24 @@ unset(_inc_env) set(ENV_PAMPA_DIR "$ENV{PAMPA_DIR}") set(ENV_PAMPA_INCDIR "$ENV{PAMPA_INCDIR}") if(ENV_PAMPA_INCDIR) - list(APPEND _inc_env "${ENV_PAMPA_INCDIR}") + list(APPEND _inc_env "${ENV_PAMPA_INCDIR}") elseif(ENV_PAMPA_DIR) - list(APPEND _inc_env "${ENV_PAMPA_DIR}") - list(APPEND _inc_env "${ENV_PAMPA_DIR}/include") - list(APPEND _inc_env "${ENV_PAMPA_DIR}/include/ptscotch") + list(APPEND _inc_env "${ENV_PAMPA_DIR}") + list(APPEND _inc_env "${ENV_PAMPA_DIR}/include") + list(APPEND _inc_env "${ENV_PAMPA_DIR}/include/ptscotch") else() - if(WIN32) - string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") - else() - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{CPATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - endif() + if(WIN32) + string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") + else() + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{CPATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + endif() endif() list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") @@ -116,46 +116,46 @@ set(PAMPA_hdrs_to_find "pampa.h") # call cmake macro to find the header path if(PAMPA_INCDIR) + foreach(pampa_hdr ${PAMPA_hdrs_to_find}) + set(PAMPA_${pampa_hdr}_DIRS "PAMPA_${pampa_hdr}_DIRS-NOTFOUND") + find_path(PAMPA_${pampa_hdr}_DIRS + NAMES ${pampa_hdr} + HINTS ${PAMPA_INCDIR}) + mark_as_advanced(PAMPA_${pampa_hdr}_DIRS) + endforeach() +else() + if(PAMPA_DIR) foreach(pampa_hdr ${PAMPA_hdrs_to_find}) - set(PAMPA_${pampa_hdr}_DIRS "PAMPA_${pampa_hdr}_DIRS-NOTFOUND") - find_path(PAMPA_${pampa_hdr}_DIRS - NAMES ${pampa_hdr} - HINTS ${PAMPA_INCDIR}) - mark_as_advanced(PAMPA_${pampa_hdr}_DIRS) + set(PAMPA_${pampa_hdr}_DIRS "PAMPA_${pampa_hdr}_DIRS-NOTFOUND") + find_path(PAMPA_${pampa_hdr}_DIRS + NAMES ${pampa_hdr} + HINTS ${PAMPA_DIR} + PATH_SUFFIXES "include" "include/pampa") + mark_as_advanced(PAMPA_${pampa_hdr}_DIRS) endforeach() -else() - if(PAMPA_DIR) - foreach(pampa_hdr ${PAMPA_hdrs_to_find}) - set(PAMPA_${pampa_hdr}_DIRS "PAMPA_${pampa_hdr}_DIRS-NOTFOUND") - find_path(PAMPA_${pampa_hdr}_DIRS - NAMES ${pampa_hdr} - HINTS ${PAMPA_DIR} - PATH_SUFFIXES "include" "include/pampa") - mark_as_advanced(PAMPA_${pampa_hdr}_DIRS) - endforeach() - else() - foreach(pampa_hdr ${PAMPA_hdrs_to_find}) - set(PAMPA_${pampa_hdr}_DIRS "PAMPA_${pampa_hdr}_DIRS-NOTFOUND") - find_path(PAMPA_${pampa_hdr}_DIRS - NAMES ${pampa_hdr} - HINTS ${_inc_env} - PATH_SUFFIXES "pampa") - mark_as_advanced(PAMPA_${pampa_hdr}_DIRS) - endforeach() - endif() + else() + foreach(pampa_hdr ${PAMPA_hdrs_to_find}) + set(PAMPA_${pampa_hdr}_DIRS "PAMPA_${pampa_hdr}_DIRS-NOTFOUND") + find_path(PAMPA_${pampa_hdr}_DIRS + NAMES ${pampa_hdr} + HINTS ${_inc_env} + PATH_SUFFIXES "pampa") + mark_as_advanced(PAMPA_${pampa_hdr}_DIRS) + endforeach() + endif() endif() # If found, add path to cmake variable # ------------------------------------ foreach(pampa_hdr ${PAMPA_hdrs_to_find}) - if (PAMPA_${pampa_hdr}_DIRS) - list(APPEND PAMPA_INCLUDE_DIRS "${PAMPA_${pampa_hdr}_DIRS}") - else () - set(PAMPA_INCLUDE_DIRS "PAMPA_INCLUDE_DIRS-NOTFOUND") - if (NOT PAMPA_FIND_QUIETLY) - message(STATUS "Looking for pampa -- ${pampa_hdr} not found") - endif() + if (PAMPA_${pampa_hdr}_DIRS) + list(APPEND PAMPA_INCLUDE_DIRS "${PAMPA_${pampa_hdr}_DIRS}") + else () + set(PAMPA_INCLUDE_DIRS "PAMPA_INCLUDE_DIRS-NOTFOUND") + if (NOT PAMPA_FIND_QUIETLY) + message(STATUS "Looking for pampa -- ${pampa_hdr} not found") endif() + endif() endforeach() # Looking for lib @@ -166,22 +166,22 @@ endforeach() unset(_lib_env) set(ENV_PAMPA_LIBDIR "$ENV{PAMPA_LIBDIR}") if(ENV_PAMPA_LIBDIR) - list(APPEND _lib_env "${ENV_PAMPA_LIBDIR}") + list(APPEND _lib_env "${ENV_PAMPA_LIBDIR}") elseif(ENV_PAMPA_DIR) - list(APPEND _lib_env "${ENV_PAMPA_DIR}") - list(APPEND _lib_env "${ENV_PAMPA_DIR}/lib") + list(APPEND _lib_env "${ENV_PAMPA_DIR}") + list(APPEND _lib_env "${ENV_PAMPA_DIR}/lib") else() - if(WIN32) - string(REPLACE ":" ";" _lib_env "$ENV{LIB}") + if(WIN32) + string(REPLACE ":" ";" _lib_env "$ENV{LIB}") + else() + if(APPLE) + string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") else() - if(APPLE) - string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") endif() + list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") + list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + endif() endif() list(REMOVE_DUPLICATES _lib_env) @@ -192,29 +192,29 @@ set(PAMPA_libs_to_find "pampa;pampaerr") # call cmake macro to find the lib path if(PAMPA_LIBDIR) + foreach(pampa_lib ${PAMPA_libs_to_find}) + set(PAMPA_${pampa_lib}_LIBRARY "PAMPA_${pampa_lib}_LIBRARY-NOTFOUND") + find_library(PAMPA_${pampa_lib}_LIBRARY + NAMES ${pampa_lib} + HINTS ${PAMPA_LIBDIR}) + endforeach() +else() + if(PAMPA_DIR) foreach(pampa_lib ${PAMPA_libs_to_find}) - set(PAMPA_${pampa_lib}_LIBRARY "PAMPA_${pampa_lib}_LIBRARY-NOTFOUND") - find_library(PAMPA_${pampa_lib}_LIBRARY - NAMES ${pampa_lib} - HINTS ${PAMPA_LIBDIR}) + set(PAMPA_${pampa_lib}_LIBRARY "PAMPA_${pampa_lib}_LIBRARY-NOTFOUND") + find_library(PAMPA_${pampa_lib}_LIBRARY + NAMES ${pampa_lib} + HINTS ${PAMPA_DIR} + PATH_SUFFIXES lib lib32 lib64) endforeach() -else() - if(PAMPA_DIR) - foreach(pampa_lib ${PAMPA_libs_to_find}) - set(PAMPA_${pampa_lib}_LIBRARY "PAMPA_${pampa_lib}_LIBRARY-NOTFOUND") - find_library(PAMPA_${pampa_lib}_LIBRARY - NAMES ${pampa_lib} - HINTS ${PAMPA_DIR} - PATH_SUFFIXES lib lib32 lib64) - endforeach() - else() - foreach(pampa_lib ${PAMPA_libs_to_find}) - set(PAMPA_${pampa_lib}_LIBRARY "PAMPA_${pampa_lib}_LIBRARY-NOTFOUND") - find_library(PAMPA_${pampa_lib}_LIBRARY - NAMES ${pampa_lib} - HINTS ${_lib_env}) - endforeach() - endif() + else() + foreach(pampa_lib ${PAMPA_libs_to_find}) + set(PAMPA_${pampa_lib}_LIBRARY "PAMPA_${pampa_lib}_LIBRARY-NOTFOUND") + find_library(PAMPA_${pampa_lib}_LIBRARY + NAMES ${pampa_lib} + HINTS ${_lib_env}) + endforeach() + endif() endif() set(PAMPA_LIBRARIES "") @@ -223,19 +223,19 @@ set(PAMPA_LIBRARY_DIRS "") # ------------------------------------ foreach(pampa_lib ${PAMPA_libs_to_find}) - if (PAMPA_${pampa_lib}_LIBRARY) - get_filename_component(${pampa_lib}_lib_path "${PAMPA_${pampa_lib}_LIBRARY}" PATH) - # set cmake variables - list(APPEND PAMPA_LIBRARIES "${PAMPA_${pampa_lib}_LIBRARY}") - list(APPEND PAMPA_LIBRARY_DIRS "${${pampa_lib}_lib_path}") - else () - list(APPEND PAMPA_LIBRARIES "${PAMPA_${pampa_lib}_LIBRARY}") - if (NOT PAMPA_FIND_QUIETLY) - message(STATUS "Looking for ptscotch -- lib ${pampa_lib} not found") - endif() - endif () + if (PAMPA_${pampa_lib}_LIBRARY) + get_filename_component(${pampa_lib}_lib_path "${PAMPA_${pampa_lib}_LIBRARY}" PATH) + # set cmake variables + list(APPEND PAMPA_LIBRARIES "${PAMPA_${pampa_lib}_LIBRARY}") + list(APPEND PAMPA_LIBRARY_DIRS "${${pampa_lib}_lib_path}") + else () + list(APPEND PAMPA_LIBRARIES "${PAMPA_${pampa_lib}_LIBRARY}") + if (NOT PAMPA_FIND_QUIETLY) + message(STATUS "Looking for ptscotch -- lib ${pampa_lib} not found") + endif() + endif () - mark_as_advanced(PAMPA_${pampa_lib}_LIBRARY) + mark_as_advanced(PAMPA_${pampa_lib}_LIBRARY) endforeach() list(REMOVE_DUPLICATES PAMPA_LIBRARY_DIRS) @@ -243,92 +243,92 @@ list(REMOVE_DUPLICATES PAMPA_LIBRARY_DIRS) # check a function to validate the find if(PAMPA_LIBRARIES) - set(REQUIRED_LDFLAGS) - set(REQUIRED_INCDIRS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) + set(REQUIRED_LDFLAGS) + set(REQUIRED_INCDIRS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) - # PAMPA - if (PAMPA_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${PAMPA_INCLUDE_DIRS}") - endif() - if (PAMPA_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${PAMPA_LIBRARY_DIRS}") + # PAMPA + if (PAMPA_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${PAMPA_INCLUDE_DIRS}") + endif() + if (PAMPA_LIBRARY_DIRS) + set(REQUIRED_LIBDIRS "${PAMPA_LIBRARY_DIRS}") + endif() + set(REQUIRED_LIBS "${PAMPA_LIBRARIES}") + add_definitions(-Drestrict=__restrict) # pampa uses the restrict keyword + list(APPEND REQUIRED_FLAGS "-Drestrict=__restrict") + # MPI + if (MPI_FOUND) + if (MPI_C_INCLUDE_PATH) + list(APPEND CMAKE_REQUIRED_INCLUDES "${MPI_C_INCLUDE_PATH}") endif() - set(REQUIRED_LIBS "${PAMPA_LIBRARIES}") - add_definitions(-Drestrict=__restrict) # pampa uses the restrict keyword - list(APPEND REQUIRED_FLAGS "-Drestrict=__restrict") - # MPI - if (MPI_FOUND) - if (MPI_C_INCLUDE_PATH) - list(APPEND CMAKE_REQUIRED_INCLUDES "${MPI_C_INCLUDE_PATH}") - endif() - if (MPI_C_LINK_FLAGS) - if (${MPI_C_LINK_FLAGS} MATCHES " -") - string(REGEX REPLACE " -" "-" MPI_C_LINK_FLAGS ${MPI_C_LINK_FLAGS}) - endif() - list(APPEND REQUIRED_LDFLAGS "${MPI_C_LINK_FLAGS}") - endif() - list(APPEND REQUIRED_LIBS "${MPI_C_LIBRARIES}") + if (MPI_C_LINK_FLAGS) + if (${MPI_C_LINK_FLAGS} MATCHES " -") + string(REGEX REPLACE " -" "-" MPI_C_LINK_FLAGS ${MPI_C_LINK_FLAGS}) + endif() + list(APPEND REQUIRED_LDFLAGS "${MPI_C_LINK_FLAGS}") endif() - # PTSCOTCH - if (PTSCOTCH_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${PTSCOTCH_INCLUDE_DIRS}") + list(APPEND REQUIRED_LIBS "${MPI_C_LIBRARIES}") + endif() + # PTSCOTCH + if (PTSCOTCH_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${PTSCOTCH_INCLUDE_DIRS}") + endif() + foreach(libdir ${PTSCOTCH_LIBRARY_DIRS}) + if (libdir) + list(APPEND REQUIRED_LIBDIRS "${libdir}") endif() - foreach(libdir ${PTSCOTCH_LIBRARY_DIRS}) - if (libdir) - list(APPEND REQUIRED_LIBDIRS "${libdir}") - endif() - endforeach() - list(APPEND REQUIRED_LIBS "${PTSCOTCH_LIBRARIES_DEP}") - # 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}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + endforeach() + list(APPEND REQUIRED_LIBS "${PTSCOTCH_LIBRARIES_DEP}") + # 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}") + string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - # test link - unset(PAMPA_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(PAMPA_dmeshInit PAMPA_WORKS) - mark_as_advanced(PAMPA_WORKS) + # test link + unset(PAMPA_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(PAMPA_dmeshInit PAMPA_WORKS) + mark_as_advanced(PAMPA_WORKS) - if(PAMPA_WORKS) - # save link with dependencies - set(PAMPA_LIBRARIES_DEP "${REQUIRED_LIBS}") - set(PAMPA_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}") - set(PAMPA_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") - set(PAMPA_LINKER_FLAGS "${REQUIRED_LDFLAGS}") - list(REMOVE_DUPLICATES PAMPA_LIBRARY_DIRS_DEP) - list(REMOVE_DUPLICATES PAMPA_INCLUDE_DIRS_DEP) - list(REMOVE_DUPLICATES PAMPA_LINKER_FLAGS) - else() - if(NOT PAMPA_FIND_QUIETLY) - message(STATUS "Looking for PAMPA : test of PAMPA_dmeshInit with PAMPA library fails") - message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") - message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") - message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") - endif() + if(PAMPA_WORKS) + # save link with dependencies + set(PAMPA_LIBRARIES_DEP "${REQUIRED_LIBS}") + set(PAMPA_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}") + set(PAMPA_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") + set(PAMPA_LINKER_FLAGS "${REQUIRED_LDFLAGS}") + list(REMOVE_DUPLICATES PAMPA_LIBRARY_DIRS_DEP) + list(REMOVE_DUPLICATES PAMPA_INCLUDE_DIRS_DEP) + list(REMOVE_DUPLICATES PAMPA_LINKER_FLAGS) + else() + if(NOT PAMPA_FIND_QUIETLY) + message(STATUS "Looking for PAMPA : test of PAMPA_dmeshInit with PAMPA library fails") + message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") + message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") + message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") endif() - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_LIBRARIES) + endif() + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) endif(PAMPA_LIBRARIES) if (PAMPA_LIBRARIES) - list(GET PAMPA_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(PAMPA_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of PAMPA library" FORCE) - else() - set(PAMPA_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of PAMPA library" FORCE) - endif() + list(GET PAMPA_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(PAMPA_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of PAMPA library" FORCE) + else() + set(PAMPA_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of PAMPA library" FORCE) + endif() endif() mark_as_advanced(PAMPA_DIR) mark_as_advanced(PAMPA_DIR_FOUND) @@ -379,5 +379,5 @@ set(CMAKE_REQUIRED_INCLUDES "") # --------------------------------- include(FindPackageHandleStandardArgs) find_package_handle_standard_args(PAMPA DEFAULT_MSG - PAMPA_LIBRARIES - PAMPA_WORKS) + PAMPA_LIBRARIES + PAMPA_WORKS) diff --git a/CMakeModules/morse/find/FindPAPI.cmake b/CMakeModules/morse/find/FindPAPI.cmake index 0ee91c58b05067881790e8d5de87158a88bc6ed5..918edb43af6b4e4f259392196af4a579bfb80d11 100644 --- a/CMakeModules/morse/find/FindPAPI.cmake +++ b/CMakeModules/morse/find/FindPAPI.cmake @@ -46,10 +46,10 @@ # License text for the above reference.) if (NOT PAPI_FOUND) - set(PAPI_DIR "" CACHE PATH "Installation directory of PAPI library") - if (NOT PAPI_FIND_QUIETLY) - message(STATUS "A cache variable, namely PAPI_DIR, has been set to specify the install directory of PAPI") - endif() + set(PAPI_DIR "" CACHE PATH "Installation directory of PAPI library") + if (NOT PAPI_FIND_QUIETLY) + message(STATUS "A cache variable, namely PAPI_DIR, has been set to specify the install directory of PAPI") + endif() endif() set(ENV_PAPI_DIR "$ENV{PAPI_DIR}") @@ -57,7 +57,7 @@ set(ENV_PAPI_INCDIR "$ENV{PAPI_INCDIR}") set(ENV_PAPI_LIBDIR "$ENV{PAPI_LIBDIR}") set(PAPI_GIVEN_BY_USER "FALSE") if ( PAPI_DIR OR ( PAPI_INCDIR AND PAPI_LIBDIR) OR ENV_PAPI_DIR OR (ENV_PAPI_INCDIR AND ENV_PAPI_LIBDIR) ) - set(PAPI_GIVEN_BY_USER "TRUE") + set(PAPI_GIVEN_BY_USER "TRUE") endif() # Optionally use pkg-config to detect include/library dirs (if pkg-config is available) @@ -66,233 +66,233 @@ include(FindPkgConfig) find_package(PkgConfig QUIET) if(PKG_CONFIG_EXECUTABLE AND NOT PAPI_GIVEN_BY_USER) - pkg_search_module(PAPI papi) - if (NOT PAPI_FIND_QUIETLY) - if (PAPI_FOUND AND PAPI_LIBRARIES) - message(STATUS "Looking for PAPI - found using PkgConfig") - #if(NOT PAPI_INCLUDE_DIRS) - # message("${Magenta}PAPI_INCLUDE_DIRS is empty using PkgConfig." - # "Perhaps the path to papi headers is already present in your" - # "C(PLUS)_INCLUDE_PATH environment variable.${ColourReset}") - #endif() - else() - message(STATUS "${Magenta}Looking for PAPI - not found using PkgConfig." - "\n Perhaps you should add the directory containing papi.pc to the" - "\n PKG_CONFIG_PATH environment variable.${ColourReset}") - endif() + pkg_search_module(PAPI papi) + if (NOT PAPI_FIND_QUIETLY) + if (PAPI_FOUND AND PAPI_LIBRARIES) + message(STATUS "Looking for PAPI - found using PkgConfig") + #if(NOT PAPI_INCLUDE_DIRS) + # message("${Magenta}PAPI_INCLUDE_DIRS is empty using PkgConfig." + # "Perhaps the path to papi headers is already present in your" + # "C(PLUS)_INCLUDE_PATH environment variable.${ColourReset}") + #endif() + else() + message(STATUS "${Magenta}Looking for PAPI - not found using PkgConfig." + "\n Perhaps you should add the directory containing papi.pc to the" + "\n PKG_CONFIG_PATH environment variable.${ColourReset}") endif() + endif() endif(PKG_CONFIG_EXECUTABLE AND NOT PAPI_GIVEN_BY_USER) if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT PAPI_FOUND) OR (PAPI_GIVEN_BY_USER) ) - if (NOT PAPI_FIND_QUIETLY) - message(STATUS "Looking for PAPI - PkgConfig not used") - endif() + if (NOT PAPI_FIND_QUIETLY) + message(STATUS "Looking for PAPI - PkgConfig not used") + endif() - # Looking for include - # ------------------- + # Looking for include + # ------------------- - # Add system include paths to search include - # ------------------------------------------ - unset(_inc_env) - set(ENV_PAPI_DIR "$ENV{PAPI_DIR}") - set(ENV_PAPI_INCDIR "$ENV{PAPI_INCDIR}") - if(ENV_PAPI_INCDIR) - list(APPEND _inc_env "${ENV_PAPI_INCDIR}") - elseif(ENV_PAPI_DIR) - list(APPEND _inc_env "${ENV_PAPI_DIR}") - list(APPEND _inc_env "${ENV_PAPI_DIR}/include") - list(APPEND _inc_env "${ENV_PAPI_DIR}/include/papi") + # Add system include paths to search include + # ------------------------------------------ + unset(_inc_env) + set(ENV_PAPI_DIR "$ENV{PAPI_DIR}") + set(ENV_PAPI_INCDIR "$ENV{PAPI_INCDIR}") + if(ENV_PAPI_INCDIR) + list(APPEND _inc_env "${ENV_PAPI_INCDIR}") + elseif(ENV_PAPI_DIR) + list(APPEND _inc_env "${ENV_PAPI_DIR}") + list(APPEND _inc_env "${ENV_PAPI_DIR}/include") + list(APPEND _inc_env "${ENV_PAPI_DIR}/include/papi") + else() + if(WIN32) + string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") else() - if(WIN32) - string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") - else() - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{CPATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - endif() + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{CPATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") endif() - list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") - list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") - list(REMOVE_DUPLICATES _inc_env) + endif() + list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") + list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") + list(REMOVE_DUPLICATES _inc_env) - # Try to find the papi header in the given paths - # ------------------------------------------------- - # call cmake macro to find the header path - if(PAPI_INCDIR) - set(PAPI_papi.h_DIRS "PAPI_papi.h_DIRS-NOTFOUND") - find_path(PAPI_papi.h_DIRS - NAMES papi.h - HINTS ${PAPI_INCDIR}) + # Try to find the papi header in the given paths + # ------------------------------------------------- + # call cmake macro to find the header path + if(PAPI_INCDIR) + set(PAPI_papi.h_DIRS "PAPI_papi.h_DIRS-NOTFOUND") + find_path(PAPI_papi.h_DIRS + NAMES papi.h + HINTS ${PAPI_INCDIR}) + else() + if(PAPI_DIR) + set(PAPI_papi.h_DIRS "PAPI_papi.h_DIRS-NOTFOUND") + find_path(PAPI_papi.h_DIRS + NAMES papi.h + HINTS ${PAPI_DIR} + PATH_SUFFIXES "include" "include/papi") else() - if(PAPI_DIR) - set(PAPI_papi.h_DIRS "PAPI_papi.h_DIRS-NOTFOUND") - find_path(PAPI_papi.h_DIRS - NAMES papi.h - HINTS ${PAPI_DIR} - PATH_SUFFIXES "include" "include/papi") - else() - set(PAPI_papi.h_DIRS "PAPI_papi.h_DIRS-NOTFOUND") - find_path(PAPI_papi.h_DIRS - NAMES papi.h - HINTS ${_inc_env} - PATH_SUFFIXES "papi") - endif() + set(PAPI_papi.h_DIRS "PAPI_papi.h_DIRS-NOTFOUND") + find_path(PAPI_papi.h_DIRS + NAMES papi.h + HINTS ${_inc_env} + PATH_SUFFIXES "papi") endif() - mark_as_advanced(PAPI_papi.h_DIRS) + endif() + mark_as_advanced(PAPI_papi.h_DIRS) - # Add path to cmake variable - # ------------------------------------ - if (PAPI_papi.h_DIRS) - set(PAPI_INCLUDE_DIRS "${PAPI_papi.h_DIRS}") - else () - set(PAPI_INCLUDE_DIRS "PAPI_INCLUDE_DIRS-NOTFOUND") - if(NOT PAPI_FIND_QUIETLY) - message(STATUS "Looking for papi -- papi.h not found") - endif() - endif () + # Add path to cmake variable + # ------------------------------------ + if (PAPI_papi.h_DIRS) + set(PAPI_INCLUDE_DIRS "${PAPI_papi.h_DIRS}") + else () + set(PAPI_INCLUDE_DIRS "PAPI_INCLUDE_DIRS-NOTFOUND") + if(NOT PAPI_FIND_QUIETLY) + message(STATUS "Looking for papi -- papi.h not found") + endif() + endif () - if (PAPI_INCLUDE_DIRS) - list(REMOVE_DUPLICATES PAPI_INCLUDE_DIRS) - endif () + if (PAPI_INCLUDE_DIRS) + list(REMOVE_DUPLICATES PAPI_INCLUDE_DIRS) + endif () - # Looking for lib - # --------------- + # Looking for lib + # --------------- - # Add system library paths to search lib - # -------------------------------------- - unset(_lib_env) - set(ENV_PAPI_LIBDIR "$ENV{PAPI_LIBDIR}") - if(ENV_PAPI_LIBDIR) - list(APPEND _lib_env "${ENV_PAPI_LIBDIR}") - elseif(ENV_PAPI_DIR) - list(APPEND _lib_env "${ENV_PAPI_DIR}") - list(APPEND _lib_env "${ENV_PAPI_DIR}/lib") + # Add system library paths to search lib + # -------------------------------------- + unset(_lib_env) + set(ENV_PAPI_LIBDIR "$ENV{PAPI_LIBDIR}") + if(ENV_PAPI_LIBDIR) + list(APPEND _lib_env "${ENV_PAPI_LIBDIR}") + elseif(ENV_PAPI_DIR) + list(APPEND _lib_env "${ENV_PAPI_DIR}") + list(APPEND _lib_env "${ENV_PAPI_DIR}/lib") + else() + if(WIN32) + string(REPLACE ":" ";" _lib_env "$ENV{LIB}") else() - if(WIN32) - string(REPLACE ":" ";" _lib_env "$ENV{LIB}") - else() - if(APPLE) - string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - endif() + if(APPLE) + string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") + else() + string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") + endif() + list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") + list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") endif() - list(REMOVE_DUPLICATES _lib_env) + endif() + list(REMOVE_DUPLICATES _lib_env) - # Try to find the papi lib in the given paths - # ---------------------------------------------- + # Try to find the papi lib in the given paths + # ---------------------------------------------- - # call cmake macro to find the lib path - if(PAPI_LIBDIR) - set(PAPI_papi_LIBRARY "PAPI_papi_LIBRARY-NOTFOUND") - find_library(PAPI_papi_LIBRARY - NAMES papi - HINTS ${PAPI_LIBDIR}) + # call cmake macro to find the lib path + if(PAPI_LIBDIR) + set(PAPI_papi_LIBRARY "PAPI_papi_LIBRARY-NOTFOUND") + find_library(PAPI_papi_LIBRARY + NAMES papi + HINTS ${PAPI_LIBDIR}) + else() + if(PAPI_DIR) + set(PAPI_papi_LIBRARY "PAPI_papi_LIBRARY-NOTFOUND") + find_library(PAPI_papi_LIBRARY + NAMES papi + HINTS ${PAPI_DIR} + PATH_SUFFIXES lib lib32 lib64) else() - if(PAPI_DIR) - set(PAPI_papi_LIBRARY "PAPI_papi_LIBRARY-NOTFOUND") - find_library(PAPI_papi_LIBRARY - NAMES papi - HINTS ${PAPI_DIR} - PATH_SUFFIXES lib lib32 lib64) - else() - set(PAPI_papi_LIBRARY "PAPI_papi_LIBRARY-NOTFOUND") - find_library(PAPI_papi_LIBRARY - NAMES papi - HINTS ${_lib_env}) - endif() + set(PAPI_papi_LIBRARY "PAPI_papi_LIBRARY-NOTFOUND") + find_library(PAPI_papi_LIBRARY + NAMES papi + HINTS ${_lib_env}) endif() - mark_as_advanced(PAPI_papi_LIBRARY) + endif() + mark_as_advanced(PAPI_papi_LIBRARY) - # If found, add path to cmake variable - # ------------------------------------ - if (PAPI_papi_LIBRARY) - get_filename_component(papi_lib_path ${PAPI_papi_LIBRARY} PATH) - # set cmake variables (respects naming convention) - set(PAPI_LIBRARIES "${PAPI_papi_LIBRARY}") - set(PAPI_LIBRARY_DIRS "${papi_lib_path}") - else () - set(PAPI_LIBRARIES "PAPI_LIBRARIES-NOTFOUND") - set(PAPI_LIBRARY_DIRS "PAPI_LIBRARY_DIRS-NOTFOUND") - if(NOT PAPI_FIND_QUIETLY) - message(STATUS "Looking for papi -- lib papi not found") - endif() - endif () + # If found, add path to cmake variable + # ------------------------------------ + if (PAPI_papi_LIBRARY) + get_filename_component(papi_lib_path ${PAPI_papi_LIBRARY} PATH) + # set cmake variables (respects naming convention) + set(PAPI_LIBRARIES "${PAPI_papi_LIBRARY}") + set(PAPI_LIBRARY_DIRS "${papi_lib_path}") + else () + set(PAPI_LIBRARIES "PAPI_LIBRARIES-NOTFOUND") + set(PAPI_LIBRARY_DIRS "PAPI_LIBRARY_DIRS-NOTFOUND") + if(NOT PAPI_FIND_QUIETLY) + message(STATUS "Looking for papi -- lib papi not found") + endif() + endif () - if (PAPI_LIBRARY_DIRS) - list(REMOVE_DUPLICATES PAPI_LIBRARY_DIRS) - endif () + if (PAPI_LIBRARY_DIRS) + list(REMOVE_DUPLICATES PAPI_LIBRARY_DIRS) + endif () - # check a function to validate the find - if(PAPI_LIBRARIES) + # check a function to validate the find + if(PAPI_LIBRARIES) - set(REQUIRED_INCDIRS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) + set(REQUIRED_INCDIRS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) - # PAPI - if (PAPI_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${PAPI_INCLUDE_DIRS}") - endif() - if (PAPI_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${PAPI_LIBRARY_DIRS}") - endif() - set(REQUIRED_LIBS "${PAPI_LIBRARIES}") + # PAPI + if (PAPI_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${PAPI_INCLUDE_DIRS}") + endif() + if (PAPI_LIBRARY_DIRS) + set(REQUIRED_LIBDIRS "${PAPI_LIBRARY_DIRS}") + endif() + set(REQUIRED_LIBS "${PAPI_LIBRARIES}") - # set required libraries for link - set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") - set(CMAKE_REQUIRED_LIBRARIES) - foreach(lib_dir ${REQUIRED_LIBDIRS}) - list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}") - endforeach() - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + # set required libraries for link + set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") + set(CMAKE_REQUIRED_LIBRARIES) + foreach(lib_dir ${REQUIRED_LIBDIRS}) + list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}") + endforeach() + list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") + string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - # test link - unset(PAPI_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(PAPI_start PAPI_WORKS) - mark_as_advanced(PAPI_WORKS) + # test link + unset(PAPI_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(PAPI_start PAPI_WORKS) + mark_as_advanced(PAPI_WORKS) - if(NOT PAPI_WORKS) - if(NOT PAPI_FIND_QUIETLY) - message(STATUS "Looking for papi : test of PAPI_start with papi library fails") - message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") - message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") - message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") - endif() - endif() - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_LIBRARIES) - endif(PAPI_LIBRARIES) + if(NOT PAPI_WORKS) + if(NOT PAPI_FIND_QUIETLY) + message(STATUS "Looking for papi : test of PAPI_start with papi library fails") + message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") + message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") + message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") + endif() + endif() + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) + endif(PAPI_LIBRARIES) endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT PAPI_FOUND) OR (PAPI_GIVEN_BY_USER) ) if (PAPI_LIBRARIES) - if (PAPI_LIBRARY_DIRS) - list(GET PAPI_LIBRARY_DIRS 0 first_lib_path) - else() - list(GET PAPI_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(PAPI_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of PAPI library" FORCE) - else() - set(PAPI_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of PAPI library" FORCE) - endif() + if (PAPI_LIBRARY_DIRS) + list(GET PAPI_LIBRARY_DIRS 0 first_lib_path) + else() + list(GET PAPI_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(PAPI_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of PAPI library" FORCE) + else() + set(PAPI_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of PAPI library" FORCE) + endif() endif() mark_as_advanced(PAPI_DIR) mark_as_advanced(PAPI_DIR_FOUND) @@ -301,10 +301,10 @@ mark_as_advanced(PAPI_DIR_FOUND) # ------------------------------- include(FindPackageHandleStandardArgs) if (PKG_CONFIG_EXECUTABLE AND PAPI_FOUND) - find_package_handle_standard_args(PAPI DEFAULT_MSG - PAPI_LIBRARIES) + find_package_handle_standard_args(PAPI DEFAULT_MSG + PAPI_LIBRARIES) else() - find_package_handle_standard_args(PAPI DEFAULT_MSG - PAPI_LIBRARIES - PAPI_WORKS) + find_package_handle_standard_args(PAPI DEFAULT_MSG + PAPI_LIBRARIES + PAPI_WORKS) endif() diff --git a/CMakeModules/morse/find/FindPARMETIS.cmake b/CMakeModules/morse/find/FindPARMETIS.cmake index d68cb899e1420afd15070463a92c995f7aec5be7..fd2bd3f49c8b3d230868f0b228ca7b363c735872 100644 --- a/CMakeModules/morse/find/FindPARMETIS.cmake +++ b/CMakeModules/morse/find/FindPARMETIS.cmake @@ -47,10 +47,10 @@ # License text for the above reference.) if (NOT PARMETIS_FOUND) - 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() + 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() endif() @@ -63,24 +63,24 @@ unset(_inc_env) set(ENV_PARMETIS_DIR "$ENV{PARMETIS_DIR}") set(ENV_PARMETIS_INCDIR "$ENV{PARMETIS_INCDIR}") if(ENV_PARMETIS_INCDIR) - list(APPEND _inc_env "${ENV_PARMETIS_INCDIR}") + list(APPEND _inc_env "${ENV_PARMETIS_INCDIR}") elseif(ENV_PARMETIS_DIR) - list(APPEND _inc_env "${ENV_PARMETIS_DIR}") - list(APPEND _inc_env "${ENV_PARMETIS_DIR}/include") - list(APPEND _inc_env "${ENV_PARMETIS_DIR}/include/parmetis") + list(APPEND _inc_env "${ENV_PARMETIS_DIR}") + list(APPEND _inc_env "${ENV_PARMETIS_DIR}/include") + list(APPEND _inc_env "${ENV_PARMETIS_DIR}/include/parmetis") else() - if(WIN32) - string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") - else() - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{CPATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - endif() + if(WIN32) + string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") + else() + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{CPATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + endif() endif() list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") @@ -91,23 +91,23 @@ list(REMOVE_DUPLICATES _inc_env) # ------------------------------------------------- # call cmake macro to find the header path if(PARMETIS_INCDIR) + set(PARMETIS_parmetis.h_DIRS "PARMETIS_parmetis.h_DIRS-NOTFOUND") + find_path(PARMETIS_parmetis.h_DIRS + NAMES parmetis.h + HINTS ${PARMETIS_INCDIR}) +else() + if(PARMETIS_DIR) set(PARMETIS_parmetis.h_DIRS "PARMETIS_parmetis.h_DIRS-NOTFOUND") find_path(PARMETIS_parmetis.h_DIRS NAMES parmetis.h - HINTS ${PARMETIS_INCDIR}) -else() - if(PARMETIS_DIR) - set(PARMETIS_parmetis.h_DIRS "PARMETIS_parmetis.h_DIRS-NOTFOUND") - find_path(PARMETIS_parmetis.h_DIRS - NAMES parmetis.h - HINTS ${PARMETIS_DIR} - PATH_SUFFIXES "include" "include/parmetis") - else() - set(PARMETIS_parmetis.h_DIRS "PARMETIS_parmetis.h_DIRS-NOTFOUND") - find_path(PARMETIS_parmetis.h_DIRS - NAMES parmetis.h - HINTS ${_inc_env}) - endif() + HINTS ${PARMETIS_DIR} + PATH_SUFFIXES "include" "include/parmetis") + else() + set(PARMETIS_parmetis.h_DIRS "PARMETIS_parmetis.h_DIRS-NOTFOUND") + find_path(PARMETIS_parmetis.h_DIRS + NAMES parmetis.h + HINTS ${_inc_env}) + endif() endif() mark_as_advanced(PARMETIS_parmetis.h_DIRS) @@ -115,12 +115,12 @@ mark_as_advanced(PARMETIS_parmetis.h_DIRS) # If found, add path to cmake variable # ------------------------------------ if (PARMETIS_parmetis.h_DIRS AND NOT PARMETIS_FIND_QUIETLY) - set(PARMETIS_INCLUDE_DIRS "${PARMETIS_parmetis.h_DIRS}") + set(PARMETIS_INCLUDE_DIRS "${PARMETIS_parmetis.h_DIRS}") else () - set(PARMETIS_INCLUDE_DIRS "PARMETIS_INCLUDE_DIRS-NOTFOUND") - if(NOT PARMETIS_FIND_QUIETLY) - message(STATUS "Looking for parmetis -- parmetis.h not found") - endif() + set(PARMETIS_INCLUDE_DIRS "PARMETIS_INCLUDE_DIRS-NOTFOUND") + if(NOT PARMETIS_FIND_QUIETLY) + message(STATUS "Looking for parmetis -- parmetis.h not found") + endif() endif() @@ -132,22 +132,22 @@ endif() unset(_lib_env) set(ENV_PARMETIS_LIBDIR "$ENV{PARMETIS_LIBDIR}") if(ENV_PARMETIS_LIBDIR) - list(APPEND _lib_env "${ENV_PARMETIS_LIBDIR}") + list(APPEND _lib_env "${ENV_PARMETIS_LIBDIR}") elseif(ENV_PARMETIS_DIR) - list(APPEND _lib_env "${ENV_PARMETIS_DIR}") - list(APPEND _lib_env "${ENV_PARMETIS_DIR}/lib") + list(APPEND _lib_env "${ENV_PARMETIS_DIR}") + list(APPEND _lib_env "${ENV_PARMETIS_DIR}/lib") else() - if(WIN32) - string(REPLACE ":" ";" _lib_env "$ENV{LIB}") + if(WIN32) + string(REPLACE ":" ";" _lib_env "$ENV{LIB}") + else() + if(APPLE) + string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") else() - if(APPLE) - string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") endif() + list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") + list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + endif() endif() list(REMOVE_DUPLICATES _lib_env) @@ -155,100 +155,100 @@ list(REMOVE_DUPLICATES _lib_env) # ---------------------------------------------- # call cmake macro to find the lib path if(PARMETIS_LIBDIR) + set(PARMETIS_parmetis_LIBRARY "PARMETIS_parmetis_LIBRARY-NOTFOUND") + find_library(PARMETIS_parmetis_LIBRARY + NAMES parmetis + HINTS ${PARMETIS_LIBDIR}) +else() + if(PARMETIS_DIR) set(PARMETIS_parmetis_LIBRARY "PARMETIS_parmetis_LIBRARY-NOTFOUND") find_library(PARMETIS_parmetis_LIBRARY - NAMES parmetis - HINTS ${PARMETIS_LIBDIR}) -else() - if(PARMETIS_DIR) - set(PARMETIS_parmetis_LIBRARY "PARMETIS_parmetis_LIBRARY-NOTFOUND") - find_library(PARMETIS_parmetis_LIBRARY - NAMES parmetis - HINTS ${PARMETIS_DIR} - PATH_SUFFIXES lib lib32 lib64) - else() - set(PARMETIS_parmetis_LIBRARY "PARMETIS_parmetis_LIBRARY-NOTFOUND") - find_library(PARMETIS_parmetis_LIBRARY - NAMES parmetis - HINTS ${_lib_env}) - endif() + NAMES parmetis + HINTS ${PARMETIS_DIR} + PATH_SUFFIXES lib lib32 lib64) + else() + set(PARMETIS_parmetis_LIBRARY "PARMETIS_parmetis_LIBRARY-NOTFOUND") + find_library(PARMETIS_parmetis_LIBRARY + NAMES parmetis + HINTS ${_lib_env}) + endif() endif() mark_as_advanced(PARMETIS_parmetis_LIBRARY) # If found, add path to cmake variable # ------------------------------------ if (PARMETIS_parmetis_LIBRARY) - get_filename_component(parmetis_lib_path "${PARMETIS_parmetis_LIBRARY}" PATH) - # set cmake variables - set(PARMETIS_LIBRARIES "${PARMETIS_parmetis_LIBRARY}") - set(PARMETIS_LIBRARY_DIRS "${parmetis_lib_path}") + get_filename_component(parmetis_lib_path "${PARMETIS_parmetis_LIBRARY}" PATH) + # set cmake variables + set(PARMETIS_LIBRARIES "${PARMETIS_parmetis_LIBRARY}") + set(PARMETIS_LIBRARY_DIRS "${parmetis_lib_path}") else () - set(PARMETIS_LIBRARIES "PARMETIS_LIBRARIES-NOTFOUND") - set(PARMETIS_LIBRARY_DIRS "PARMETIS_LIBRARY_DIRS-NOTFOUND") - if (NOT PARMETIS_FIND_QUIETLY) - message(STATUS "Looking for parmetis -- lib parmetis not found") - endif() + set(PARMETIS_LIBRARIES "PARMETIS_LIBRARIES-NOTFOUND") + set(PARMETIS_LIBRARY_DIRS "PARMETIS_LIBRARY_DIRS-NOTFOUND") + if (NOT PARMETIS_FIND_QUIETLY) + message(STATUS "Looking for parmetis -- lib parmetis not found") + endif() endif () # check a function to validate the find if(PARMETIS_LIBRARIES) - set(REQUIRED_INCDIRS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) + set(REQUIRED_INCDIRS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) - # PARMETIS - if (PARMETIS_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${PARMETIS_INCLUDE_DIRS}") - endif() - if (PARMETIS_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${PARMETIS_LIBRARY_DIRS}") - endif() - set(REQUIRED_LIBS "${PARMETIS_LIBRARIES}") - # m - find_library(M_LIBRARY NAMES m) - mark_as_advanced(M_LIBRARY) - if(M_LIBRARY) - list(APPEND REQUIRED_LIBS "-lm") - endif() + # PARMETIS + if (PARMETIS_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${PARMETIS_INCLUDE_DIRS}") + endif() + if (PARMETIS_LIBRARY_DIRS) + set(REQUIRED_LIBDIRS "${PARMETIS_LIBRARY_DIRS}") + endif() + set(REQUIRED_LIBS "${PARMETIS_LIBRARIES}") + # m + find_library(M_LIBRARY NAMES m) + mark_as_advanced(M_LIBRARY) + if(M_LIBRARY) + list(APPEND REQUIRED_LIBS "-lm") + endif() - # set required libraries for link - set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") - set(CMAKE_REQUIRED_LIBRARIES) - foreach(lib_dir ${REQUIRED_LIBDIRS}) - list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}") - endforeach() - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + # set required libraries for link + set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") + set(CMAKE_REQUIRED_LIBRARIES) + foreach(lib_dir ${REQUIRED_LIBDIRS}) + list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}") + endforeach() + list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") + string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - # test link - unset(PARMETIS_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(ParMETIS_V3_NodeND PARMETIS_WORKS) - mark_as_advanced(PARMETIS_WORKS) + # test link + unset(PARMETIS_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(ParMETIS_V3_NodeND PARMETIS_WORKS) + mark_as_advanced(PARMETIS_WORKS) - if(NOT PARMETIS_WORKS) - if(NOT PARMETIS_FIND_QUIETLY) - message(STATUS "Looking for PARMETIS : test of ParMETIS_V3_NodeND with PARMETIS library fails") - message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") - message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") - message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") - endif() + if(NOT PARMETIS_WORKS) + if(NOT PARMETIS_FIND_QUIETLY) + message(STATUS "Looking for PARMETIS : test of ParMETIS_V3_NodeND with PARMETIS library fails") + message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") + message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") + message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") endif() - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_LIBRARIES) + endif() + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) endif(PARMETIS_LIBRARIES) if (PARMETIS_LIBRARIES) - 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_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of PARMETIS library" FORCE) - else() - set(PARMETIS_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of PARMETIS library" FORCE) - endif() + 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_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of PARMETIS library" FORCE) + else() + set(PARMETIS_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of PARMETIS library" FORCE) + endif() endif() mark_as_advanced(PARMETIS_DIR) mark_as_advanced(PARMETIS_DIR_FOUND) @@ -257,8 +257,8 @@ mark_as_advanced(PARMETIS_DIR_FOUND) # ---------------------------------- include(FindPackageHandleStandardArgs) find_package_handle_standard_args(PARMETIS DEFAULT_MSG - PARMETIS_LIBRARIES - PARMETIS_WORKS) + PARMETIS_LIBRARIES + PARMETIS_WORKS) # # TODO: Add possibility to check for specific functions in the library # diff --git a/CMakeModules/morse/find/FindPARSEC.cmake b/CMakeModules/morse/find/FindPARSEC.cmake index 0abdde392e83cea5d9b5304ec8a387fa9e23d6d7..d1daf48d3cb46c0e4a96e45c22f2192c933d10ee 100644 --- a/CMakeModules/morse/find/FindPARSEC.cmake +++ b/CMakeModules/morse/find/FindPARSEC.cmake @@ -67,10 +67,10 @@ include(CheckSymbolExists) if (NOT PARSEC_FOUND) - set(PARSEC_DIR "" CACHE PATH "Installation directory of PARSEC library") - if (NOT PARSEC_FIND_QUIETLY) - message(STATUS "A cache variable, namely PARSEC_DIR, has been set to specify the install directory of PARSEC") - endif() + set(PARSEC_DIR "" CACHE PATH "Installation directory of PARSEC library") + if (NOT PARSEC_FIND_QUIETLY) + message(STATUS "A cache variable, namely PARSEC_DIR, has been set to specify the install directory of PARSEC") + endif() endif() # PARSEC may depend on other packages (HWLOC, MPI, CUDA, ...) @@ -80,129 +80,129 @@ set(PARSEC_LOOK_FOR_CUDA FALSE) set(PARSEC_LOOK_FOR_MPI FALSE) if( PARSEC_FIND_COMPONENTS ) - foreach( component ${PARSEC_FIND_COMPONENTS} ) - if(${component} STREQUAL "HWLOC") - set(PARSEC_LOOK_FOR_HWLOC TRUE) - elseif(${component} STREQUAL "CUDA") - set(PARSEC_LOOK_FOR_CUDA TRUE) - elseif(${component} STREQUAL "MPI") - set(PARSEC_LOOK_FOR_MPI TRUE) - endif() - endforeach() + foreach( component ${PARSEC_FIND_COMPONENTS} ) + if(${component} STREQUAL "HWLOC") + set(PARSEC_LOOK_FOR_HWLOC TRUE) + elseif(${component} STREQUAL "CUDA") + set(PARSEC_LOOK_FOR_CUDA TRUE) + elseif(${component} STREQUAL "MPI") + set(PARSEC_LOOK_FOR_MPI TRUE) + endif() + endforeach() endif() # Required dependencies # --------------------- if (NOT PARSEC_FIND_QUIETLY) - message(STATUS "Looking for PARSEC - Try to detect pthread") + message(STATUS "Looking for PARSEC - Try to detect pthread") endif() if (PARSEC_FIND_REQUIRED) - find_package(Threads REQUIRED) + find_package(Threads REQUIRED) else() - find_package(Threads) + find_package(Threads) endif() set(PARSEC_EXTRA_LIBRARIES "") if( THREADS_FOUND ) - list(APPEND PARSEC_EXTRA_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) + list(APPEND PARSEC_EXTRA_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) endif () # Add math library to the list of extra # it normally exists on all common systems provided with a C compiler if (NOT PARSEC_FIND_QUIETLY) - message(STATUS "Looking for PARSEC - Try to detect libm") + message(STATUS "Looking for PARSEC - Try to detect libm") endif() set(PARSEC_M_LIBRARIES "") if(UNIX OR WIN32) - find_library( - PARSEC_M_m_LIBRARY - NAMES m - ) - mark_as_advanced(PARSEC_M_m_LIBRARY) - if (PARSEC_M_m_LIBRARY) - list(APPEND PARSEC_M_LIBRARIES "${PARSEC_M_m_LIBRARY}") - list(APPEND PARSEC_EXTRA_LIBRARIES "${PARSEC_M_m_LIBRARY}") - else() - if (PARSEC_FIND_REQUIRED) - message(FATAL_ERROR "Could NOT find libm on your system." - "Are you sure to a have a C compiler installed?") - endif() + find_library( + PARSEC_M_m_LIBRARY + NAMES m + ) + mark_as_advanced(PARSEC_M_m_LIBRARY) + if (PARSEC_M_m_LIBRARY) + list(APPEND PARSEC_M_LIBRARIES "${PARSEC_M_m_LIBRARY}") + list(APPEND PARSEC_EXTRA_LIBRARIES "${PARSEC_M_m_LIBRARY}") + else() + if (PARSEC_FIND_REQUIRED) + message(FATAL_ERROR "Could NOT find libm on your system." + "Are you sure to a have a C compiler installed?") endif() + endif() endif() # Try to find librt (libposix4 - POSIX.1b Realtime Extensions library) # on Unix systems except Apple ones because it does not exist on it if (NOT PARSEC_FIND_QUIETLY) - message(STATUS "Looking for PARSEC - Try to detect librt") + message(STATUS "Looking for PARSEC - Try to detect librt") endif() set(PARSEC_RT_LIBRARIES "") if(UNIX AND NOT APPLE) - find_library( - PARSEC_RT_rt_LIBRARY - NAMES rt - ) - mark_as_advanced(PARSEC_RT_rt_LIBRARY) - if (PARSEC_RT_rt_LIBRARY) - list(APPEND PARSEC_RT_LIBRARIES "${PARSEC_RT_rt_LIBRARY}") - list(APPEND PARSEC_EXTRA_LIBRARIES "${PARSEC_RT_rt_LIBRARY}") - else() - if (PARSEC_FIND_REQUIRED) - message(FATAL_ERROR "Could NOT find librt on your system") - endif() + find_library( + PARSEC_RT_rt_LIBRARY + NAMES rt + ) + mark_as_advanced(PARSEC_RT_rt_LIBRARY) + if (PARSEC_RT_rt_LIBRARY) + list(APPEND PARSEC_RT_LIBRARIES "${PARSEC_RT_rt_LIBRARY}") + list(APPEND PARSEC_EXTRA_LIBRARIES "${PARSEC_RT_rt_LIBRARY}") + else() + if (PARSEC_FIND_REQUIRED) + message(FATAL_ERROR "Could NOT find librt on your system") endif() + endif() endif() # Try to find libdl if (NOT PARSEC_FIND_QUIETLY) - message(STATUS "Looking for PARSEC - Try to detect libdl") + message(STATUS "Looking for PARSEC - Try to detect libdl") endif() set(PARSEC_DL_LIBRARIES "") find_library( - PARSEC_DL_LIBRARY - NAMES dl - ) + PARSEC_DL_LIBRARY + NAMES dl + ) mark_as_advanced(PARSEC_DL_LIBRARY) if (PARSEC_DL_LIBRARY) - list(APPEND PARSEC_DL_LIBRARIES "${PARSEC_DL_LIBRARY}") - list(APPEND PARSEC_EXTRA_LIBRARIES "${PARSEC_DL_LIBRARY}") + list(APPEND PARSEC_DL_LIBRARIES "${PARSEC_DL_LIBRARY}") + list(APPEND PARSEC_EXTRA_LIBRARIES "${PARSEC_DL_LIBRARY}") endif() # PARSEC may depend on HWLOC, try to find it if (NOT HWLOC_FOUND AND PARSEC_LOOK_FOR_HWLOC) - if (PARSEC_FIND_REQUIRED) - find_package(HWLOC REQUIRED) - else() - find_package(HWLOC) - endif() + if (PARSEC_FIND_REQUIRED) + find_package(HWLOC REQUIRED) + else() + find_package(HWLOC) + endif() endif() # PARSEC may depend on CUDA, try to find it if (NOT CUDA_FOUND AND PARSEC_LOOK_FOR_CUDA) - if (PARSEC_FIND_REQUIRED AND PARSEC_FIND_REQUIRED_CUDA) - find_package(CUDA REQUIRED) - else() - find_package(CUDA) - endif() - if (CUDA_FOUND) - mark_as_advanced(CUDA_BUILD_CUBIN) - mark_as_advanced(CUDA_BUILD_EMULATION) - mark_as_advanced(CUDA_SDK_ROOT_DIR) - mark_as_advanced(CUDA_TOOLKIT_ROOT_DIR) - mark_as_advanced(CUDA_VERBOSE_BUILD) - endif() + if (PARSEC_FIND_REQUIRED AND PARSEC_FIND_REQUIRED_CUDA) + find_package(CUDA REQUIRED) + else() + find_package(CUDA) + endif() + if (CUDA_FOUND) + mark_as_advanced(CUDA_BUILD_CUBIN) + mark_as_advanced(CUDA_BUILD_EMULATION) + mark_as_advanced(CUDA_SDK_ROOT_DIR) + mark_as_advanced(CUDA_TOOLKIT_ROOT_DIR) + mark_as_advanced(CUDA_VERBOSE_BUILD) + endif() endif() # PARSEC may depend on MPI, try to find it if (NOT MPI_FOUND AND PARSEC_LOOK_FOR_MPI) - if (PARSEC_FIND_REQUIRED AND PARSEC_FIND_REQUIRED_MPI) - find_package(MPI REQUIRED) - else() - find_package(MPI) - endif() - if (MPI_FOUND) - mark_as_advanced(MPI_LIBRARY) - mark_as_advanced(MPI_EXTRA_LIBRARY) - endif() + if (PARSEC_FIND_REQUIRED AND PARSEC_FIND_REQUIRED_MPI) + find_package(MPI REQUIRED) + else() + find_package(MPI) + endif() + if (MPI_FOUND) + mark_as_advanced(MPI_LIBRARY) + mark_as_advanced(MPI_EXTRA_LIBRARY) + endif() endif() set(ENV_PARSEC_DIR "$ENV{PARSEC_DIR}") @@ -210,7 +210,7 @@ set(ENV_PARSEC_INCDIR "$ENV{PARSEC_INCDIR}") set(ENV_PARSEC_LIBDIR "$ENV{PARSEC_LIBDIR}") set(PARSEC_GIVEN_BY_USER "FALSE") if ( PARSEC_DIR OR ( PARSEC_INCDIR AND PARSEC_LIBDIR) OR ENV_PARSEC_DIR OR (ENV_PARSEC_INCDIR AND ENV_PARSEC_LIBDIR) ) - set(PARSEC_GIVEN_BY_USER "TRUE") + set(PARSEC_GIVEN_BY_USER "TRUE") endif() # Optionally use pkg-config to detect include/library dirs (if pkg-config is available) @@ -220,419 +220,419 @@ find_package(PkgConfig QUIET) if(PKG_CONFIG_EXECUTABLE AND NOT PARSEC_GIVEN_BY_USER) - pkg_search_module(PARSEC parsec) - if (NOT PARSEC_FIND_QUIETLY) - if (PARSEC_FOUND AND PARSEC_LIBRARIES) - message(STATUS "Looking for PARSEC - found using PkgConfig") - #if(NOT PARSEC_SHM_INCLUDE_DIRS) - # message("${Magenta}PARSEC_SHM_INCLUDE_DIRS is empty using PkgConfig." - # "Perhaps the path to parsec headers is already present in your" - # "C(PLUS)_INCLUDE_PATH environment variable.${ColourReset}") - #endif() - else() - message(STATUS "${Magenta}Looking for PARSEC - not found using PkgConfig." - "\n Perhaps you should add the directory containing libparsec.pc" - "\n to the PKG_CONFIG_PATH environment variable.${ColourReset}") - endif() - endif() - - set(PARSEC_INCLUDE_DIRS_DEP "${PARSEC_INCLUDE_DIRS}") - set(PARSEC_LIBRARY_DIRS_DEP "${PARSEC_LIBRARY_DIRS}") - set(PARSEC_LIBRARIES_DEP "${PARSEC_LIBRARIES}") - - # create list of binaries to find - set(PARSEC_bins_to_find "daguepp") - - # call cmake macro to find the bin path - if(PARSEC_PREFIX) - foreach(parsec_bin ${PARSEC_bins_to_find}) - set(PARSEC_${parsec_bin}_BIN_DIR "PARSEC_${parsec_bin}_BIN_DIR-NOTFOUND") - find_path(PARSEC_${parsec_bin}_BIN_DIR - NAMES ${parsec_bin} - HINTS ${PARSEC_PREFIX} - PATH_SUFFIXES "bin") - endforeach() + pkg_search_module(PARSEC parsec) + if (NOT PARSEC_FIND_QUIETLY) + if (PARSEC_FOUND AND PARSEC_LIBRARIES) + message(STATUS "Looking for PARSEC - found using PkgConfig") + #if(NOT PARSEC_SHM_INCLUDE_DIRS) + # message("${Magenta}PARSEC_SHM_INCLUDE_DIRS is empty using PkgConfig." + # "Perhaps the path to parsec headers is already present in your" + # "C(PLUS)_INCLUDE_PATH environment variable.${ColourReset}") + #endif() else() - if (PARSEC_FIND_REQUIRED) - message(FATAL_ERROR "PARSEC_PREFIX not defined by pkg_search_module") - endif() + message(STATUS "${Magenta}Looking for PARSEC - not found using PkgConfig." + "\n Perhaps you should add the directory containing libparsec.pc" + "\n to the PKG_CONFIG_PATH environment variable.${ColourReset}") + endif() + endif() + + set(PARSEC_INCLUDE_DIRS_DEP "${PARSEC_INCLUDE_DIRS}") + set(PARSEC_LIBRARY_DIRS_DEP "${PARSEC_LIBRARY_DIRS}") + set(PARSEC_LIBRARIES_DEP "${PARSEC_LIBRARIES}") + + # create list of binaries to find + set(PARSEC_bins_to_find "daguepp") + + # call cmake macro to find the bin path + if(PARSEC_PREFIX) + foreach(parsec_bin ${PARSEC_bins_to_find}) + set(PARSEC_${parsec_bin}_BIN_DIR "PARSEC_${parsec_bin}_BIN_DIR-NOTFOUND") + find_path(PARSEC_${parsec_bin}_BIN_DIR + NAMES ${parsec_bin} + HINTS ${PARSEC_PREFIX} + PATH_SUFFIXES "bin") + endforeach() + else() + if (PARSEC_FIND_REQUIRED) + message(FATAL_ERROR "PARSEC_PREFIX not defined by pkg_search_module") endif() + endif() endif(PKG_CONFIG_EXECUTABLE AND NOT PARSEC_GIVEN_BY_USER) if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT PARSEC_FOUND) OR (PARSEC_GIVEN_BY_USER) ) - # Looking for include - # ------------------- - - # Add system include paths to search include - # ------------------------------------------ - unset(_inc_env) - set(ENV_PARSEC_DIR "$ENV{PARSEC_DIR}") - set(ENV_PARSEC_INCDIR "$ENV{PARSEC_INCDIR}") - if(ENV_PARSEC_INCDIR) - list(APPEND _inc_env "${ENV_PARSEC_INCDIR}") - elseif(ENV_PARSEC_DIR) - list(APPEND _inc_env "${ENV_PARSEC_DIR}") - list(APPEND _inc_env "${ENV_PARSEC_DIR}/include") - list(APPEND _inc_env "${ENV_PARSEC_DIR}/include/dague") + # Looking for include + # ------------------- + + # Add system include paths to search include + # ------------------------------------------ + unset(_inc_env) + set(ENV_PARSEC_DIR "$ENV{PARSEC_DIR}") + set(ENV_PARSEC_INCDIR "$ENV{PARSEC_INCDIR}") + if(ENV_PARSEC_INCDIR) + list(APPEND _inc_env "${ENV_PARSEC_INCDIR}") + elseif(ENV_PARSEC_DIR) + list(APPEND _inc_env "${ENV_PARSEC_DIR}") + list(APPEND _inc_env "${ENV_PARSEC_DIR}/include") + list(APPEND _inc_env "${ENV_PARSEC_DIR}/include/dague") + else() + if(WIN32) + string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") else() - if(WIN32) - string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") - else() - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{CPATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - endif() + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{CPATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") endif() - list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") - list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") - list(REMOVE_DUPLICATES _inc_env) + endif() + list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") + list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") + list(REMOVE_DUPLICATES _inc_env) - # Try to find the parsec headers in the given paths - # ------------------------------------------------- + # Try to find the parsec headers in the given paths + # ------------------------------------------------- - # create list of headers to find - set(PARSEC_hdrs_to_find "dague_config.h" "dague.h") + # create list of headers to find + set(PARSEC_hdrs_to_find "dague_config.h" "dague.h") - # call cmake macro to find the header path - if(PARSEC_INCDIR) - foreach(parsec_hdr ${PARSEC_hdrs_to_find}) - set(PARSEC_${parsec_hdr}_INCLUDE_DIRS "PARSEC_${parsec_hdr}_INCLUDE_DIRS-NOTFOUND") - find_path(PARSEC_${parsec_hdr}_INCLUDE_DIRS - NAMES ${parsec_hdr} - HINTS ${PARSEC_INCDIR}) - endforeach() + # call cmake macro to find the header path + if(PARSEC_INCDIR) + foreach(parsec_hdr ${PARSEC_hdrs_to_find}) + set(PARSEC_${parsec_hdr}_INCLUDE_DIRS "PARSEC_${parsec_hdr}_INCLUDE_DIRS-NOTFOUND") + find_path(PARSEC_${parsec_hdr}_INCLUDE_DIRS + NAMES ${parsec_hdr} + HINTS ${PARSEC_INCDIR}) + endforeach() + else() + if(PARSEC_DIR) + set(PARSEC_${parsec_hdr}_INCLUDE_DIRS "PARSEC_${parsec_hdr}_INCLUDE_DIRS-NOTFOUND") + foreach(parsec_hdr ${PARSEC_hdrs_to_find}) + find_path(PARSEC_${parsec_hdr}_INCLUDE_DIRS + NAMES ${parsec_hdr} + HINTS ${PARSEC_DIR} + PATH_SUFFIXES "include") + endforeach() else() - if(PARSEC_DIR) - set(PARSEC_${parsec_hdr}_INCLUDE_DIRS "PARSEC_${parsec_hdr}_INCLUDE_DIRS-NOTFOUND") - foreach(parsec_hdr ${PARSEC_hdrs_to_find}) - find_path(PARSEC_${parsec_hdr}_INCLUDE_DIRS - NAMES ${parsec_hdr} - HINTS ${PARSEC_DIR} - PATH_SUFFIXES "include") - endforeach() - else() - foreach(parsec_hdr ${PARSEC_hdrs_to_find}) - set(PARSEC_${parsec_hdr}_INCLUDE_DIRS "PARSEC_${parsec_hdr}_INCLUDE_DIRS-NOTFOUND") - find_path(PARSEC_${parsec_hdr}_INCLUDE_DIRS - NAMES ${parsec_hdr} - HINTS ${_inc_env}) - endforeach() - endif() + foreach(parsec_hdr ${PARSEC_hdrs_to_find}) + set(PARSEC_${parsec_hdr}_INCLUDE_DIRS "PARSEC_${parsec_hdr}_INCLUDE_DIRS-NOTFOUND") + find_path(PARSEC_${parsec_hdr}_INCLUDE_DIRS + NAMES ${parsec_hdr} + HINTS ${_inc_env}) + endforeach() endif() - - # If found, add path to cmake variable - # ------------------------------------ - set(PARSEC_INCLUDE_DIRS "") - foreach(parsec_hdr ${PARSEC_hdrs_to_find}) - - if (PARSEC_${parsec_hdr}_INCLUDE_DIRS) - # set cmake variables using the pkg-config naming convention - list(APPEND PARSEC_INCLUDE_DIRS "${PARSEC_${parsec_hdr}_INCLUDE_DIRS}" ) - else () - if(NOT PARSEC_FIND_QUIETLY) - message(STATUS "Looking for parsec -- ${parsec_hdr} not found") - endif() - endif () - mark_as_advanced(PARSEC_${parsec_hdr}_INCLUDE_DIRS) - - endforeach(parsec_hdr ${PARSEC_hdrs_to_find}) - - if (PARSEC_INCLUDE_DIRS) - list(REMOVE_DUPLICATES PARSEC_INCLUDE_DIRS) + endif() + + # If found, add path to cmake variable + # ------------------------------------ + set(PARSEC_INCLUDE_DIRS "") + foreach(parsec_hdr ${PARSEC_hdrs_to_find}) + + if (PARSEC_${parsec_hdr}_INCLUDE_DIRS) + # set cmake variables using the pkg-config naming convention + list(APPEND PARSEC_INCLUDE_DIRS "${PARSEC_${parsec_hdr}_INCLUDE_DIRS}" ) + else () + if(NOT PARSEC_FIND_QUIETLY) + message(STATUS "Looking for parsec -- ${parsec_hdr} not found") + endif() endif () - - # Looking for lib - # --------------- - - set(PARSEC_LIBRARIES "") - set(PARSEC_LIBRARY_DIRS "") - - # Add system library paths to search lib - # -------------------------------------- - unset(_lib_env) - set(ENV_PARSEC_LIBDIR "$ENV{PARSEC_LIBDIR}") - if(ENV_PARSEC_LIBDIR) - list(APPEND _lib_env "${ENV_PARSEC_LIBDIR}") - elseif(ENV_PARSEC_DIR) - list(APPEND _lib_env "${ENV_PARSEC_DIR}") - list(APPEND _lib_env "${ENV_PARSEC_DIR}/lib") + mark_as_advanced(PARSEC_${parsec_hdr}_INCLUDE_DIRS) + + endforeach(parsec_hdr ${PARSEC_hdrs_to_find}) + + if (PARSEC_INCLUDE_DIRS) + list(REMOVE_DUPLICATES PARSEC_INCLUDE_DIRS) + endif () + + # Looking for lib + # --------------- + + set(PARSEC_LIBRARIES "") + set(PARSEC_LIBRARY_DIRS "") + + # Add system library paths to search lib + # -------------------------------------- + unset(_lib_env) + set(ENV_PARSEC_LIBDIR "$ENV{PARSEC_LIBDIR}") + if(ENV_PARSEC_LIBDIR) + list(APPEND _lib_env "${ENV_PARSEC_LIBDIR}") + elseif(ENV_PARSEC_DIR) + list(APPEND _lib_env "${ENV_PARSEC_DIR}") + list(APPEND _lib_env "${ENV_PARSEC_DIR}/lib") + else() + if(WIN32) + string(REPLACE ":" ";" _lib_env "$ENV{LIB}") else() - if(WIN32) - string(REPLACE ":" ";" _lib_env "$ENV{LIB}") - else() - if(APPLE) - string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - endif() + if(APPLE) + string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") + else() + string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") + endif() + list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") + list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") endif() - list(REMOVE_DUPLICATES _lib_env) - - # Try to find the parsec libs in the given paths - # ---------------------------------------------- - - # create list of libs to find - set(PARSEC_libs_to_find "dague" "dague-base" "dague_distribution" "dague_distribution_matrix") - - # call cmake macro to find the lib path - if(PARSEC_LIBDIR) - foreach(parsec_lib ${PARSEC_libs_to_find}) - set(PARSEC_${parsec_lib}_LIBRARY "PARSEC_${parsec_lib}_LIBRARY-NOTFOUND") - find_library(PARSEC_${parsec_lib}_LIBRARY - NAMES ${parsec_lib} - HINTS ${PARSEC_LIBDIR}) - endforeach() + endif() + list(REMOVE_DUPLICATES _lib_env) + + # Try to find the parsec libs in the given paths + # ---------------------------------------------- + + # create list of libs to find + set(PARSEC_libs_to_find "dague" "dague-base" "dague_distribution" "dague_distribution_matrix") + + # call cmake macro to find the lib path + if(PARSEC_LIBDIR) + foreach(parsec_lib ${PARSEC_libs_to_find}) + set(PARSEC_${parsec_lib}_LIBRARY "PARSEC_${parsec_lib}_LIBRARY-NOTFOUND") + find_library(PARSEC_${parsec_lib}_LIBRARY + NAMES ${parsec_lib} + HINTS ${PARSEC_LIBDIR}) + endforeach() + else() + if(PARSEC_DIR) + foreach(parsec_lib ${PARSEC_libs_to_find}) + set(PARSEC_${parsec_lib}_LIBRARY "PARSEC_${parsec_lib}_LIBRARY-NOTFOUND") + find_library(PARSEC_${parsec_lib}_LIBRARY + NAMES ${parsec_lib} + HINTS ${PARSEC_DIR} + PATH_SUFFIXES lib lib32 lib64) + endforeach() else() - if(PARSEC_DIR) - foreach(parsec_lib ${PARSEC_libs_to_find}) - set(PARSEC_${parsec_lib}_LIBRARY "PARSEC_${parsec_lib}_LIBRARY-NOTFOUND") - find_library(PARSEC_${parsec_lib}_LIBRARY - NAMES ${parsec_lib} - HINTS ${PARSEC_DIR} - PATH_SUFFIXES lib lib32 lib64) - endforeach() - else() - foreach(parsec_lib ${PARSEC_libs_to_find}) - set(PARSEC_${parsec_lib}_LIBRARY "PARSEC_${parsec_lib}_LIBRARY-NOTFOUND") - find_library(PARSEC_${parsec_lib}_LIBRARY - NAMES ${parsec_lib} - HINTS ${_lib_env}) - endforeach() - endif() + foreach(parsec_lib ${PARSEC_libs_to_find}) + set(PARSEC_${parsec_lib}_LIBRARY "PARSEC_${parsec_lib}_LIBRARY-NOTFOUND") + find_library(PARSEC_${parsec_lib}_LIBRARY + NAMES ${parsec_lib} + HINTS ${_lib_env}) + endforeach() endif() + endif() - # If found, add path to cmake variable - # ------------------------------------ - foreach(parsec_lib ${PARSEC_libs_to_find}) + # If found, add path to cmake variable + # ------------------------------------ + foreach(parsec_lib ${PARSEC_libs_to_find}) - if (PARSEC_${parsec_lib}_LIBRARY) + if (PARSEC_${parsec_lib}_LIBRARY) - get_filename_component(${parsec_lib}_lib_path ${PARSEC_${parsec_lib}_LIBRARY} PATH) - # set cmake variables (respects naming convention) - list(APPEND PARSEC_LIBRARIES "${PARSEC_${parsec_lib}_LIBRARY}") - list(APPEND PARSEC_LIBRARY_DIRS "${${parsec_lib}_lib_path}") + get_filename_component(${parsec_lib}_lib_path ${PARSEC_${parsec_lib}_LIBRARY} PATH) + # set cmake variables (respects naming convention) + list(APPEND PARSEC_LIBRARIES "${PARSEC_${parsec_lib}_LIBRARY}") + list(APPEND PARSEC_LIBRARY_DIRS "${${parsec_lib}_lib_path}") - else (PARSEC_${parsec_lib}_LIBRARY) + else (PARSEC_${parsec_lib}_LIBRARY) - if(NOT PARSEC_FIND_QUIETLY) - message(STATUS "Looking for parsec -- lib ${parsec_lib} not found") - endif() + if(NOT PARSEC_FIND_QUIETLY) + message(STATUS "Looking for parsec -- lib ${parsec_lib} not found") + endif() - endif (PARSEC_${parsec_lib}_LIBRARY) + endif (PARSEC_${parsec_lib}_LIBRARY) - mark_as_advanced(PARSEC_${parsec_lib}_LIBRARY) + mark_as_advanced(PARSEC_${parsec_lib}_LIBRARY) - endforeach(parsec_lib ${PARSEC_libs_to_find}) + endforeach(parsec_lib ${PARSEC_libs_to_find}) - list(REMOVE_DUPLICATES PARSEC_LIBRARIES) - if (PARSEC_LIBRARY_DIRS) - list(REMOVE_DUPLICATES PARSEC_LIBRARY_DIRS) - endif () + list(REMOVE_DUPLICATES PARSEC_LIBRARIES) + if (PARSEC_LIBRARY_DIRS) + list(REMOVE_DUPLICATES PARSEC_LIBRARY_DIRS) + endif () - # Looking for parsec compilers - # ---------------------------- + # Looking for parsec compilers + # ---------------------------- - # Add system bin paths to search drivers - # -------------------------------------- - unset(_bin_env) - if(ENV_PARSEC_DIR) - list(APPEND _bin_env "${ENV_PARSEC_DIR}") - list(APPEND _bin_env "${ENV_PARSEC_DIR}/bin") - else() - string(REPLACE ":" ";" _bin_env "$ENV{PATH}") - endif() - list(REMOVE_DUPLICATES _bin_env) + # Add system bin paths to search drivers + # -------------------------------------- + unset(_bin_env) + if(ENV_PARSEC_DIR) + list(APPEND _bin_env "${ENV_PARSEC_DIR}") + list(APPEND _bin_env "${ENV_PARSEC_DIR}/bin") + else() + string(REPLACE ":" ";" _bin_env "$ENV{PATH}") + endif() + list(REMOVE_DUPLICATES _bin_env) - # create list of binaries to find - set(PARSEC_bins_to_find "daguepp") + # create list of binaries to find + set(PARSEC_bins_to_find "daguepp") - # call cmake macro to find the bin path - if(PARSEC_DIR) - foreach(parsec_bin ${PARSEC_bins_to_find}) - set(PARSEC_${parsec_bin}_BIN_DIR "PARSEC_${parsec_bin}_BIN_DIR-NOTFOUND") - find_path(PARSEC_${parsec_bin}_BIN_DIR - NAMES ${parsec_bin} - HINTS ${PARSEC_DIR} - PATH_SUFFIXES "bin") - endforeach() - else() - foreach(parsec_bin ${PARSEC_bins_to_find}) - set(PARSEC_${parsec_bin}_BIN_DIR "PARSEC_${parsec_bin}_BIN_DIR-NOTFOUND") - find_path(PARSEC_${parsec_bin}_BIN_DIR - NAMES ${parsec_bin} - HINTS ${_bin_env}) - endforeach() + # call cmake macro to find the bin path + if(PARSEC_DIR) + foreach(parsec_bin ${PARSEC_bins_to_find}) + set(PARSEC_${parsec_bin}_BIN_DIR "PARSEC_${parsec_bin}_BIN_DIR-NOTFOUND") + find_path(PARSEC_${parsec_bin}_BIN_DIR + NAMES ${parsec_bin} + HINTS ${PARSEC_DIR} + PATH_SUFFIXES "bin") + endforeach() + else() + foreach(parsec_bin ${PARSEC_bins_to_find}) + set(PARSEC_${parsec_bin}_BIN_DIR "PARSEC_${parsec_bin}_BIN_DIR-NOTFOUND") + find_path(PARSEC_${parsec_bin}_BIN_DIR + NAMES ${parsec_bin} + HINTS ${_bin_env}) + endforeach() + endif() + if (PARSEC_daguepp_BIN_DIR) + if (NOT PARSEC_FIND_QUIETLY) + message(STATUS "Look for PARSEC - compiler daguepp found in ${PARSEC_daguepp_BIN_DIR}") endif() - if (PARSEC_daguepp_BIN_DIR) - if (NOT PARSEC_FIND_QUIETLY) - message(STATUS "Look for PARSEC - compiler daguepp found in ${PARSEC_daguepp_BIN_DIR}") - endif() - else() - if (PARSEC_FIND_REQUIRED) - message(FATAL_ERROR "Look for PARSEC - compiler daguepp not found while required") - endif() + else() + if (PARSEC_FIND_REQUIRED) + message(FATAL_ERROR "Look for PARSEC - compiler daguepp not found while required") endif() + endif() - # check a function to validate the find - if(PARSEC_LIBRARIES) - - set(REQUIRED_FLAGS) - set(REQUIRED_LDFLAGS) - set(REQUIRED_INCDIRS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) - - # PARSEC - if (PARSEC_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${PARSEC_INCLUDE_DIRS}") - endif() - set(CMAKE_REQUIRED_FLAGS) - foreach(libdir ${PARSEC_LIBRARY_DIRS}) - if (libdir) - list(APPEND REQUIRED_LIBDIRS "${libdir}") - endif() - endforeach() - set(REQUIRED_LIBS "${PARSEC_LIBRARIES}") - # HWLOC - if (HWLOC_FOUND AND PARSEC_LOOK_FOR_HWLOC) - if (HWLOC_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${HWLOC_INCLUDE_DIRS}") - endif() - if (HWLOC_LIBRARY_DIRS) - list(APPEND REQUIRED_LIBDIRS "${HWLOC_LIBRARY_DIRS}") - endif() - foreach(lib ${HWLOC_LIBRARIES}) - if (EXISTS ${lib} OR ${lib} MATCHES "^-") - list(APPEND REQUIRED_LIBS "${lib}") - else() - list(APPEND REQUIRED_LIBS "-l${lib}") - endif() - endforeach() - endif() - # MPI - if (MPI_FOUND AND PARSEC_LOOK_FOR_MPI) - if (MPI_C_INCLUDE_PATH) - list(APPEND REQUIRED_INCDIRS "${MPI_C_INCLUDE_PATH}") - endif() - if (MPI_C_LINK_FLAGS) - if (${MPI_C_LINK_FLAGS} MATCHES " -") - string(REGEX REPLACE " -" "-" MPI_C_LINK_FLAGS ${MPI_C_LINK_FLAGS}) - endif() - list(APPEND REQUIRED_LDFLAGS "${MPI_C_LINK_FLAGS}") - endif() - list(APPEND REQUIRED_LIBS "${MPI_C_LIBRARIES}") - endif() - # CUDA - if (CUDA_FOUND AND PARSEC_LOOK_FOR_CUDA) - if (CUDA_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${CUDA_INCLUDE_DIRS}") - endif() - if (CUDA_LIBRARY_DIRS) - list(APPEND REQUIRED_LIBDIRS "${CUDA_LIBRARY_DIRS}") - 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}) - - # 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}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - - # test link - unset(PARSEC_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(dague_init PARSEC_WORKS) - mark_as_advanced(PARSEC_WORKS) - - if(PARSEC_WORKS) - # save link with dependencies - if (REQUIRED_FLAGS) - set(PARSEC_LIBRARIES_DEP "${REQUIRED_FLAGS};${REQUIRED_LIBS}") - else() - set(PARSEC_LIBRARIES_DEP "${REQUIRED_LIBS}") - endif() - set(PARSEC_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}") - set(PARSEC_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") - set(PARSEC_LINKER_FLAGS "${REQUIRED_LDFLAGS}") - list(REMOVE_DUPLICATES PARSEC_LIBRARY_DIRS_DEP) - list(REMOVE_DUPLICATES PARSEC_INCLUDE_DIRS_DEP) - list(REMOVE_DUPLICATES PARSEC_LINKER_FLAGS) - else() - if(NOT PARSEC_FIND_QUIETLY) - message(STATUS "Looking for parsec : test of dague_init fails") - message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") - message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") - message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") - message(STATUS "Maybe PARSEC is linked with specific libraries. " - "Have you tried with COMPONENTS (HWLOC, CUDA, MPI)? " - "See the explanation in FindPARSEC.cmake.") - endif() - endif() - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_LIBRARIES) - endif(PARSEC_LIBRARIES) + # check a function to validate the find + if(PARSEC_LIBRARIES) -endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT PARSEC_FOUND) OR (PARSEC_GIVEN_BY_USER) ) + set(REQUIRED_FLAGS) + set(REQUIRED_LDFLAGS) + set(REQUIRED_INCDIRS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) -if (PARSEC_LIBRARIES) - if (PARSEC_LIBRARY_DIRS) - foreach(dir ${PARSEC_LIBRARY_DIRS}) - if ("${dir}" MATCHES "parsec") - set(first_lib_path "${dir}") - endif() - endforeach() - else() - list(GET PARSEC_LIBRARIES 0 first_lib) - get_filename_component(first_lib_path "${first_lib}" PATH) + # PARSEC + if (PARSEC_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${PARSEC_INCLUDE_DIRS}") + endif() + set(CMAKE_REQUIRED_FLAGS) + foreach(libdir ${PARSEC_LIBRARY_DIRS}) + if (libdir) + list(APPEND REQUIRED_LIBDIRS "${libdir}") + endif() + endforeach() + set(REQUIRED_LIBS "${PARSEC_LIBRARIES}") + # HWLOC + if (HWLOC_FOUND AND PARSEC_LOOK_FOR_HWLOC) + if (HWLOC_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${HWLOC_INCLUDE_DIRS}") + endif() + if (HWLOC_LIBRARY_DIRS) + list(APPEND REQUIRED_LIBDIRS "${HWLOC_LIBRARY_DIRS}") + endif() + foreach(lib ${HWLOC_LIBRARIES}) + if (EXISTS ${lib} OR ${lib} MATCHES "^-") + list(APPEND REQUIRED_LIBS "${lib}") + else() + list(APPEND REQUIRED_LIBS "-l${lib}") + endif() + endforeach() + endif() + # MPI + if (MPI_FOUND AND PARSEC_LOOK_FOR_MPI) + if (MPI_C_INCLUDE_PATH) + list(APPEND REQUIRED_INCDIRS "${MPI_C_INCLUDE_PATH}") + endif() + if (MPI_C_LINK_FLAGS) + if (${MPI_C_LINK_FLAGS} MATCHES " -") + string(REGEX REPLACE " -" "-" MPI_C_LINK_FLAGS ${MPI_C_LINK_FLAGS}) + endif() + list(APPEND REQUIRED_LDFLAGS "${MPI_C_LINK_FLAGS}") + endif() + list(APPEND REQUIRED_LIBS "${MPI_C_LIBRARIES}") endif() - if (${first_lib_path} MATCHES "/lib(32|64)?$") - string(REGEX REPLACE "/lib(32|64)?$" "" not_cached_dir "${first_lib_path}") - set(PARSEC_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of PARSEC library" FORCE) + # CUDA + if (CUDA_FOUND AND PARSEC_LOOK_FOR_CUDA) + if (CUDA_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${CUDA_INCLUDE_DIRS}") + endif() + if (CUDA_LIBRARY_DIRS) + list(APPEND REQUIRED_LIBDIRS "${CUDA_LIBRARY_DIRS}") + 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}) + + # 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}") + string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + + # test link + unset(PARSEC_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(dague_init PARSEC_WORKS) + mark_as_advanced(PARSEC_WORKS) + + if(PARSEC_WORKS) + # save link with dependencies + if (REQUIRED_FLAGS) + set(PARSEC_LIBRARIES_DEP "${REQUIRED_FLAGS};${REQUIRED_LIBS}") + else() + set(PARSEC_LIBRARIES_DEP "${REQUIRED_LIBS}") + endif() + set(PARSEC_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}") + set(PARSEC_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") + set(PARSEC_LINKER_FLAGS "${REQUIRED_LDFLAGS}") + list(REMOVE_DUPLICATES PARSEC_LIBRARY_DIRS_DEP) + list(REMOVE_DUPLICATES PARSEC_INCLUDE_DIRS_DEP) + list(REMOVE_DUPLICATES PARSEC_LINKER_FLAGS) else() - set(PARSEC_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of PARSEC library" FORCE) + if(NOT PARSEC_FIND_QUIETLY) + message(STATUS "Looking for parsec : test of dague_init fails") + message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") + message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") + message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") + message(STATUS "Maybe PARSEC is linked with specific libraries. " + "Have you tried with COMPONENTS (HWLOC, CUDA, MPI)? " + "See the explanation in FindPARSEC.cmake.") + endif() endif() + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) + endif(PARSEC_LIBRARIES) + +endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT PARSEC_FOUND) OR (PARSEC_GIVEN_BY_USER) ) + +if (PARSEC_LIBRARIES) + if (PARSEC_LIBRARY_DIRS) + foreach(dir ${PARSEC_LIBRARY_DIRS}) + if ("${dir}" MATCHES "parsec") + set(first_lib_path "${dir}") + endif() + endforeach() + else() + list(GET PARSEC_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(PARSEC_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of PARSEC library" FORCE) + else() + set(PARSEC_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of PARSEC library" FORCE) + endif() endif() mark_as_advanced(PARSEC_DIR) mark_as_advanced(PARSEC_DIR_FOUND) @@ -641,20 +641,20 @@ mark_as_advanced(PARSEC_DIR_FOUND) # -------------------------------- include(FindPackageHandleStandardArgs) if (PKG_CONFIG_EXECUTABLE AND PARSEC_FOUND) - find_package_handle_standard_args(PARSEC DEFAULT_MSG - PARSEC_LIBRARIES - PARSEC_daguepp_BIN_DIR) + find_package_handle_standard_args(PARSEC DEFAULT_MSG + PARSEC_LIBRARIES + PARSEC_daguepp_BIN_DIR) else() - find_package_handle_standard_args(PARSEC DEFAULT_MSG - PARSEC_LIBRARIES - PARSEC_daguepp_BIN_DIR - PARSEC_WORKS) + find_package_handle_standard_args(PARSEC DEFAULT_MSG + PARSEC_LIBRARIES + PARSEC_daguepp_BIN_DIR + PARSEC_WORKS) endif() if ( PARSEC_daguepp_BIN_DIR ) - find_program(PARSEC_DAGUEPP - NAMES daguepp - HINTS ${PARSEC_daguepp_BIN_DIR}) + find_program(PARSEC_DAGUEPP + NAMES daguepp + HINTS ${PARSEC_daguepp_BIN_DIR}) else() - set(PARSEC_DAGUEPP "PARSEC_DAGUEPP-NOTFOUND") + set(PARSEC_DAGUEPP "PARSEC_DAGUEPP-NOTFOUND") endif() diff --git a/CMakeModules/morse/find/FindPASTIX.cmake b/CMakeModules/morse/find/FindPASTIX.cmake index d117bd631f3766e56b6b88f0f7de796fa8ade378..bb278e924e556cf909eb7674542bb90277b7dbbf 100644 --- a/CMakeModules/morse/find/FindPASTIX.cmake +++ b/CMakeModules/morse/find/FindPASTIX.cmake @@ -74,10 +74,10 @@ if (NOT PASTIX_FOUND) - 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() + 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() endif() # Set the version to find @@ -91,40 +91,40 @@ set(PASTIX_LOOK_FOR_PTSCOTCH OFF) set(PASTIX_LOOK_FOR_METIS OFF) if( PASTIX_FIND_COMPONENTS ) - foreach( component ${PASTIX_FIND_COMPONENTS} ) - if (${component} STREQUAL "SEQ") - # means we look for the sequential version of PaStiX (without MPI) - set(PASTIX_LOOK_FOR_SEQ ON) - set(PASTIX_LOOK_FOR_MPI OFF) - endif() - if (${component} STREQUAL "MPI") - # means we look for the MPI version of PaStiX (default) - set(PASTIX_LOOK_FOR_SEQ OFF) - set(PASTIX_LOOK_FOR_MPI ON) - endif() - if (${component} STREQUAL "STARPU") - # means we look for PaStiX with StarPU - set(PASTIX_LOOK_FOR_STARPU ON) - endif() - if (${component} STREQUAL "STARPU_CUDA") - # means we look for PaStiX with StarPU + CUDA - set(PASTIX_LOOK_FOR_STARPU ON) - set(PASTIX_LOOK_FOR_STARPU_CUDA ON) - endif() - if (${component} STREQUAL "STARPU_FXT") - # means we look for PaStiX with StarPU + FxT - set(PASTIX_LOOK_FOR_STARPU_FXT ON) - endif() - if (${component} STREQUAL "SCOTCH") - set(PASTIX_LOOK_FOR_SCOTCH ON) - endif() - if (${component} STREQUAL "SCOTCH") - set(PASTIX_LOOK_FOR_PTSCOTCH ON) - endif() - if (${component} STREQUAL "METIS") - set(PASTIX_LOOK_FOR_METIS ON) - endif() - endforeach() + foreach( component ${PASTIX_FIND_COMPONENTS} ) + if (${component} STREQUAL "SEQ") + # means we look for the sequential version of PaStiX (without MPI) + set(PASTIX_LOOK_FOR_SEQ ON) + set(PASTIX_LOOK_FOR_MPI OFF) + endif() + if (${component} STREQUAL "MPI") + # means we look for the MPI version of PaStiX (default) + set(PASTIX_LOOK_FOR_SEQ OFF) + set(PASTIX_LOOK_FOR_MPI ON) + endif() + if (${component} STREQUAL "STARPU") + # means we look for PaStiX with StarPU + set(PASTIX_LOOK_FOR_STARPU ON) + endif() + if (${component} STREQUAL "STARPU_CUDA") + # means we look for PaStiX with StarPU + CUDA + set(PASTIX_LOOK_FOR_STARPU ON) + set(PASTIX_LOOK_FOR_STARPU_CUDA ON) + endif() + if (${component} STREQUAL "STARPU_FXT") + # means we look for PaStiX with StarPU + FxT + set(PASTIX_LOOK_FOR_STARPU_FXT ON) + endif() + if (${component} STREQUAL "SCOTCH") + set(PASTIX_LOOK_FOR_SCOTCH ON) + endif() + if (${component} STREQUAL "SCOTCH") + set(PASTIX_LOOK_FOR_PTSCOTCH ON) + endif() + if (${component} STREQUAL "METIS") + set(PASTIX_LOOK_FOR_METIS ON) + endif() + endforeach() endif() # Dependencies detection @@ -135,83 +135,83 @@ endif() # --------------------- if (NOT PASTIX_FIND_QUIETLY) - message(STATUS "Looking for PASTIX - Try to detect pthread") + message(STATUS "Looking for PASTIX - Try to detect pthread") endif() if (PASTIX_FIND_REQUIRED) - find_package(Threads REQUIRED) + find_package(Threads REQUIRED) else() - find_package(Threads) + find_package(Threads) endif() set(PASTIX_EXTRA_LIBRARIES "") if( THREADS_FOUND ) - list(APPEND PASTIX_EXTRA_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) + list(APPEND PASTIX_EXTRA_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) endif () # Add math library to the list of extra # it normally exists on all common systems provided with a C compiler if (NOT PASTIX_FIND_QUIETLY) - message(STATUS "Looking for PASTIX - Try to detect libm") + message(STATUS "Looking for PASTIX - Try to detect libm") endif() set(PASTIX_M_LIBRARIES "") if(UNIX OR WIN32) - find_library( - PASTIX_M_m_LIBRARY - NAMES m - ) - mark_as_advanced(PASTIX_M_m_LIBRARY) - if (PASTIX_M_m_LIBRARY) - list(APPEND PASTIX_M_LIBRARIES "${PASTIX_M_m_LIBRARY}") - list(APPEND PASTIX_EXTRA_LIBRARIES "${PASTIX_M_m_LIBRARY}") - else() - if (PASTIX_FIND_REQUIRED) - message(FATAL_ERROR "Could NOT find libm on your system." - "Are you sure to a have a C compiler installed?") - endif() - endif() + find_library( + PASTIX_M_m_LIBRARY + NAMES m + ) + mark_as_advanced(PASTIX_M_m_LIBRARY) + if (PASTIX_M_m_LIBRARY) + list(APPEND PASTIX_M_LIBRARIES "${PASTIX_M_m_LIBRARY}") + list(APPEND PASTIX_EXTRA_LIBRARIES "${PASTIX_M_m_LIBRARY}") + else() + if (PASTIX_FIND_REQUIRED) + message(FATAL_ERROR "Could NOT find libm on your system." + "Are you sure to a have a C compiler installed?") + endif() + endif() endif() # Try to find librt (libposix4 - POSIX.1b Realtime Extensions library) # on Unix systems except Apple ones because it does not exist on it if (NOT PASTIX_FIND_QUIETLY) - message(STATUS "Looking for PASTIX - Try to detect librt") + message(STATUS "Looking for PASTIX - Try to detect librt") endif() set(PASTIX_RT_LIBRARIES "") if(UNIX AND NOT APPLE) - find_library( - PASTIX_RT_rt_LIBRARY - NAMES rt - ) - mark_as_advanced(PASTIX_RT_rt_LIBRARY) - if (PASTIX_RT_rt_LIBRARY) - list(APPEND PASTIX_RT_LIBRARIES "${PASTIX_RT_rt_LIBRARY}") - list(APPEND PASTIX_EXTRA_LIBRARIES "${PASTIX_RT_rt_LIBRARY}") - else() - if (PASTIX_FIND_REQUIRED) - message(FATAL_ERROR "Could NOT find librt on your system") - endif() - endif() + find_library( + PASTIX_RT_rt_LIBRARY + NAMES rt + ) + mark_as_advanced(PASTIX_RT_rt_LIBRARY) + if (PASTIX_RT_rt_LIBRARY) + list(APPEND PASTIX_RT_LIBRARIES "${PASTIX_RT_rt_LIBRARY}") + list(APPEND PASTIX_EXTRA_LIBRARIES "${PASTIX_RT_rt_LIBRARY}") + else() + if (PASTIX_FIND_REQUIRED) + message(FATAL_ERROR "Could NOT find librt on your system") + endif() + endif() endif() # PASTIX depends on HWLOC #------------------------ if (NOT PASTIX_FIND_QUIETLY) - message(STATUS "Looking for PASTIX - Try to detect HWLOC") + message(STATUS "Looking for PASTIX - Try to detect HWLOC") endif() if (PASTIX_FIND_REQUIRED) - find_package(HWLOC REQUIRED) + find_package(HWLOC REQUIRED) else() - find_package(HWLOC) + find_package(HWLOC) endif() # PASTIX depends on BLAS #----------------------- if (NOT PASTIX_FIND_QUIETLY) - message(STATUS "Looking for PASTIX - Try to detect BLAS") + message(STATUS "Looking for PASTIX - Try to detect BLAS") endif() if (PASTIX_FIND_REQUIRED) - find_package(BLASEXT REQUIRED) + find_package(BLASEXT REQUIRED) else() - find_package(BLASEXT) + find_package(BLASEXT) endif() # Optional dependencies @@ -220,109 +220,109 @@ endif() # PASTIX may depend on MPI #------------------------- if (NOT MPI_FOUND AND PASTIX_LOOK_FOR_MPI) - if (NOT PASTIX_FIND_QUIETLY) - message(STATUS "Looking for PASTIX - Try to detect MPI") - endif() - # allows to use an external mpi compilation by setting compilers with - # -DMPI_C_COMPILER=path/to/mpicc -DMPI_Fortran_COMPILER=path/to/mpif90 - # at cmake configure - if(NOT MPI_C_COMPILER) - set(MPI_C_COMPILER mpicc) - endif() - if (PASTIX_FIND_REQUIRED AND PASTIX_FIND_REQUIRED_MPI) - find_package(MPI REQUIRED) - else() - find_package(MPI) - endif() - if (MPI_FOUND) - mark_as_advanced(MPI_LIBRARY) - mark_as_advanced(MPI_EXTRA_LIBRARY) - endif() + if (NOT PASTIX_FIND_QUIETLY) + message(STATUS "Looking for PASTIX - Try to detect MPI") + endif() + # allows to use an external mpi compilation by setting compilers with + # -DMPI_C_COMPILER=path/to/mpicc -DMPI_Fortran_COMPILER=path/to/mpif90 + # at cmake configure + if(NOT MPI_C_COMPILER) + set(MPI_C_COMPILER mpicc) + endif() + if (PASTIX_FIND_REQUIRED AND PASTIX_FIND_REQUIRED_MPI) + find_package(MPI REQUIRED) + else() + find_package(MPI) + endif() + if (MPI_FOUND) + mark_as_advanced(MPI_LIBRARY) + mark_as_advanced(MPI_EXTRA_LIBRARY) + endif() endif (NOT MPI_FOUND AND PASTIX_LOOK_FOR_MPI) # PASTIX may depend on STARPU #---------------------------- if( NOT STARPU_FOUND AND PASTIX_LOOK_FOR_STARPU) - if (NOT PASTIX_FIND_QUIETLY) - message(STATUS "Looking for PASTIX - Try to detect StarPU") - endif() + if (NOT PASTIX_FIND_QUIETLY) + message(STATUS "Looking for PASTIX - Try to detect StarPU") + endif() - set(PASTIX_STARPU_VERSION "1.1" CACHE STRING "oldest STARPU version desired") - - # create list of components in order to make a single call to find_package(starpu...) - # we explicitly need a StarPU version built with hwloc - set(STARPU_COMPONENT_LIST "HWLOC") - - # StarPU may depend on MPI - # allows to use an external mpi compilation by setting compilers with - # -DMPI_C_COMPILER=path/to/mpicc -DMPI_Fortran_COMPILER=path/to/mpif90 - # at cmake configure - if (PASTIX_LOOK_FOR_MPI) - if(NOT MPI_C_COMPILER) - set(MPI_C_COMPILER mpicc) - endif() - list(APPEND STARPU_COMPONENT_LIST "MPI") - endif() - if (PASTIX_LOOK_FOR_STARPU_CUDA) - list(APPEND STARPU_COMPONENT_LIST "CUDA") - endif() - if (PASTIX_LOOK_FOR_STARPU_FXT) - list(APPEND STARPU_COMPONENT_LIST "FXT") - endif() - # set the list of optional dependencies we may discover - if (PASTIX_FIND_REQUIRED AND PASTIX_FIND_REQUIRED_STARPU) - find_package(STARPU ${PASTIX_STARPU_VERSION} REQUIRED - COMPONENTS ${STARPU_COMPONENT_LIST}) - else() - find_package(STARPU ${PASTIX_STARPU_VERSION} - COMPONENTS ${STARPU_COMPONENT_LIST}) - endif() + set(PASTIX_STARPU_VERSION "1.1" CACHE STRING "oldest STARPU version desired") + + # create list of components in order to make a single call to find_package(starpu...) + # we explicitly need a StarPU version built with hwloc + set(STARPU_COMPONENT_LIST "HWLOC") + + # StarPU may depend on MPI + # allows to use an external mpi compilation by setting compilers with + # -DMPI_C_COMPILER=path/to/mpicc -DMPI_Fortran_COMPILER=path/to/mpif90 + # at cmake configure + if (PASTIX_LOOK_FOR_MPI) + if(NOT MPI_C_COMPILER) + set(MPI_C_COMPILER mpicc) + endif() + list(APPEND STARPU_COMPONENT_LIST "MPI") + endif() + if (PASTIX_LOOK_FOR_STARPU_CUDA) + list(APPEND STARPU_COMPONENT_LIST "CUDA") + endif() + if (PASTIX_LOOK_FOR_STARPU_FXT) + list(APPEND STARPU_COMPONENT_LIST "FXT") + endif() + # set the list of optional dependencies we may discover + if (PASTIX_FIND_REQUIRED AND PASTIX_FIND_REQUIRED_STARPU) + find_package(STARPU ${PASTIX_STARPU_VERSION} REQUIRED + COMPONENTS ${STARPU_COMPONENT_LIST}) + else() + find_package(STARPU ${PASTIX_STARPU_VERSION} + COMPONENTS ${STARPU_COMPONENT_LIST}) + endif() endif( NOT STARPU_FOUND AND PASTIX_LOOK_FOR_STARPU) # PASTIX may depends on SCOTCH #----------------------------- 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 AND PASTIX_FIND_REQUIRED_SCOTCH) - find_package(SCOTCH REQUIRED) - else() - find_package(SCOTCH) - endif() + if (NOT PASTIX_FIND_QUIETLY) + message(STATUS "Looking for PASTIX - Try to detect SCOTCH") + endif() + if (PASTIX_FIND_REQUIRED AND PASTIX_FIND_REQUIRED_SCOTCH) + find_package(SCOTCH REQUIRED) + else() + find_package(SCOTCH) + endif() endif() # PASTIX may depends on PTSCOTCH #------------------------------- 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 AND PASTIX_FIND_REQUIRED_PTSCOTCH) - find_package(PTSCOTCH REQUIRED) - else() - find_package(PTSCOTCH) - endif() + if (NOT PASTIX_FIND_QUIETLY) + message(STATUS "Looking for PASTIX - Try to detect PTSCOTCH") + endif() + if (PASTIX_FIND_REQUIRED AND PASTIX_FIND_REQUIRED_PTSCOTCH) + find_package(PTSCOTCH REQUIRED) + else() + find_package(PTSCOTCH) + endif() endif() # PASTIX may depends on METIS #---------------------------- 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 AND PASTIX_FIND_REQUIRED_METIS) - find_package(METIS REQUIRED) - else() - find_package(METIS) - endif() + if (NOT PASTIX_FIND_QUIETLY) + message(STATUS "Looking for PASTIX - Try to detect METIS") + endif() + if (PASTIX_FIND_REQUIRED AND PASTIX_FIND_REQUIRED_METIS) + find_package(METIS REQUIRED) + else() + find_package(METIS) + endif() endif() # Error if pastix required and no partitioning lib found if (PASTIX_FIND_REQUIRED AND NOT SCOTCH_FOUND AND NOT PTSCOTCH_FOUND AND NOT METIS_FOUND) - message(FATAL_ERROR "Could NOT find any partitioning library on your system" + message(FATAL_ERROR "Could NOT find any partitioning library on your system" " (install scotch, ptscotch or metis)") endif() @@ -339,24 +339,24 @@ unset(_inc_env) set(ENV_PASTIX_DIR "$ENV{PASTIX_DIR}") set(ENV_PASTIX_INCDIR "$ENV{PASTIX_INCDIR}") if(ENV_PASTIX_INCDIR) - list(APPEND _inc_env "${ENV_PASTIX_INCDIR}") + list(APPEND _inc_env "${ENV_PASTIX_INCDIR}") elseif(ENV_PASTIX_DIR) - list(APPEND _inc_env "${ENV_PASTIX_DIR}") - list(APPEND _inc_env "${ENV_PASTIX_DIR}/include") - list(APPEND _inc_env "${ENV_PASTIX_DIR}/include/pastix") + list(APPEND _inc_env "${ENV_PASTIX_DIR}") + list(APPEND _inc_env "${ENV_PASTIX_DIR}/include") + list(APPEND _inc_env "${ENV_PASTIX_DIR}/include/pastix") else() - if(WIN32) - string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") - else() - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{CPATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - endif() + if(WIN32) + string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") + else() + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{CPATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + endif() endif() list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") @@ -367,36 +367,36 @@ list(REMOVE_DUPLICATES _inc_env) # --------------------------------------------------- # call cmake macro to find the header path if(PASTIX_INCDIR) + set(PASTIX_pastix.h_DIRS "PASTIX_pastix.h_DIRS-NOTFOUND") + find_path(PASTIX_pastix.h_DIRS + NAMES pastix.h + HINTS ${PASTIX_INCDIR}) +else() + if(PASTIX_DIR) set(PASTIX_pastix.h_DIRS "PASTIX_pastix.h_DIRS-NOTFOUND") find_path(PASTIX_pastix.h_DIRS NAMES pastix.h - HINTS ${PASTIX_INCDIR}) -else() - if(PASTIX_DIR) - set(PASTIX_pastix.h_DIRS "PASTIX_pastix.h_DIRS-NOTFOUND") - find_path(PASTIX_pastix.h_DIRS - NAMES pastix.h - HINTS ${PASTIX_DIR} - PATH_SUFFIXES "include" "include/pastix") - else() - set(PASTIX_pastix.h_DIRS "PASTIX_pastix.h_DIRS-NOTFOUND") - find_path(PASTIX_pastix.h_DIRS - NAMES pastix.h - HINTS ${_inc_env} - PATH_SUFFIXES "pastix") - endif() + HINTS ${PASTIX_DIR} + PATH_SUFFIXES "include" "include/pastix") + else() + set(PASTIX_pastix.h_DIRS "PASTIX_pastix.h_DIRS-NOTFOUND") + find_path(PASTIX_pastix.h_DIRS + NAMES pastix.h + HINTS ${_inc_env} + PATH_SUFFIXES "pastix") + endif() endif() mark_as_advanced(PASTIX_pastix.h_DIRS) # If found, add path to cmake variable # ------------------------------------ if (PASTIX_pastix.h_DIRS) - set(PASTIX_INCLUDE_DIRS "${PASTIX_pastix.h_DIRS}") + set(PASTIX_INCLUDE_DIRS "${PASTIX_pastix.h_DIRS}") else () - set(PASTIX_INCLUDE_DIRS "PASTIX_INCLUDE_DIRS-NOTFOUND") - if(NOT PASTIX_FIND_QUIETLY) - message(STATUS "Looking for pastix -- pastix.h not found") - endif() + set(PASTIX_INCLUDE_DIRS "PASTIX_INCLUDE_DIRS-NOTFOUND") + if(NOT PASTIX_FIND_QUIETLY) + message(STATUS "Looking for pastix -- pastix.h not found") + endif() endif() @@ -408,22 +408,22 @@ endif() unset(_lib_env) set(ENV_PASTIX_LIBDIR "$ENV{PASTIX_LIBDIR}") if(ENV_PASTIX_LIBDIR) - list(APPEND _lib_env "${ENV_PASTIX_LIBDIR}") + list(APPEND _lib_env "${ENV_PASTIX_LIBDIR}") elseif(ENV_PASTIX_DIR) - list(APPEND _lib_env "${ENV_PASTIX_DIR}") - list(APPEND _lib_env "${ENV_PASTIX_DIR}/lib") + list(APPEND _lib_env "${ENV_PASTIX_DIR}") + list(APPEND _lib_env "${ENV_PASTIX_DIR}/lib") else() - if(WIN32) - string(REPLACE ":" ";" _lib_env "$ENV{LIB}") + if(WIN32) + string(REPLACE ":" ";" _lib_env "$ENV{LIB}") + else() + if(APPLE) + string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") else() - if(APPLE) - string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") endif() + list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") + list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + endif() endif() list(REMOVE_DUPLICATES _lib_env) @@ -435,263 +435,263 @@ set(PASTIX_libs_to_find "pastix_murge;pastix") # call cmake macro to find the lib path if(PASTIX_LIBDIR) + foreach(pastix_lib ${PASTIX_libs_to_find}) + set(PASTIX_${pastix_lib}_LIBRARY "PASTIX_${pastix_lib}_LIBRARY-NOTFOUND") + find_library(PASTIX_${pastix_lib}_LIBRARY + NAMES ${pastix_lib} + HINTS ${PASTIX_LIBDIR}) + endforeach() +else() + if(PASTIX_DIR) foreach(pastix_lib ${PASTIX_libs_to_find}) - set(PASTIX_${pastix_lib}_LIBRARY "PASTIX_${pastix_lib}_LIBRARY-NOTFOUND") - find_library(PASTIX_${pastix_lib}_LIBRARY - NAMES ${pastix_lib} - HINTS ${PASTIX_LIBDIR}) + set(PASTIX_${pastix_lib}_LIBRARY "PASTIX_${pastix_lib}_LIBRARY-NOTFOUND") + find_library(PASTIX_${pastix_lib}_LIBRARY + NAMES ${pastix_lib} + HINTS ${PASTIX_DIR} + PATH_SUFFIXES lib lib32 lib64) endforeach() -else() - if(PASTIX_DIR) - foreach(pastix_lib ${PASTIX_libs_to_find}) - set(PASTIX_${pastix_lib}_LIBRARY "PASTIX_${pastix_lib}_LIBRARY-NOTFOUND") - find_library(PASTIX_${pastix_lib}_LIBRARY - NAMES ${pastix_lib} - HINTS ${PASTIX_DIR} - PATH_SUFFIXES lib lib32 lib64) - endforeach() - else() - foreach(pastix_lib ${PASTIX_libs_to_find}) - set(PASTIX_${pastix_lib}_LIBRARY "PASTIX_${pastix_lib}_LIBRARY-NOTFOUND") - find_library(PASTIX_${pastix_lib}_LIBRARY - NAMES ${pastix_lib} - HINTS ${_lib_env}) - endforeach() - endif() + else() + foreach(pastix_lib ${PASTIX_libs_to_find}) + set(PASTIX_${pastix_lib}_LIBRARY "PASTIX_${pastix_lib}_LIBRARY-NOTFOUND") + find_library(PASTIX_${pastix_lib}_LIBRARY + NAMES ${pastix_lib} + HINTS ${_lib_env}) + endforeach() + endif() endif() # If found, add path to cmake variable # ------------------------------------ foreach(pastix_lib ${PASTIX_libs_to_find}) - get_filename_component(${pastix_lib}_lib_path ${PASTIX_${pastix_lib}_LIBRARY} PATH) - # set cmake variables (respects naming convention) - if (PASTIX_LIBRARIES) - list(APPEND PASTIX_LIBRARIES "${PASTIX_${pastix_lib}_LIBRARY}") - else() - set(PASTIX_LIBRARIES "${PASTIX_${pastix_lib}_LIBRARY}") - endif() - if (PASTIX_LIBRARY_DIRS) - list(APPEND PASTIX_LIBRARY_DIRS "${${pastix_lib}_lib_path}") - else() - set(PASTIX_LIBRARY_DIRS "${${pastix_lib}_lib_path}") - endif() - mark_as_advanced(PASTIX_${pastix_lib}_LIBRARY) + get_filename_component(${pastix_lib}_lib_path ${PASTIX_${pastix_lib}_LIBRARY} PATH) + # set cmake variables (respects naming convention) + if (PASTIX_LIBRARIES) + list(APPEND PASTIX_LIBRARIES "${PASTIX_${pastix_lib}_LIBRARY}") + else() + set(PASTIX_LIBRARIES "${PASTIX_${pastix_lib}_LIBRARY}") + endif() + if (PASTIX_LIBRARY_DIRS) + list(APPEND PASTIX_LIBRARY_DIRS "${${pastix_lib}_lib_path}") + else() + set(PASTIX_LIBRARY_DIRS "${${pastix_lib}_lib_path}") + endif() + mark_as_advanced(PASTIX_${pastix_lib}_LIBRARY) 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) - - # PASTIX - if (PASTIX_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${PASTIX_INCLUDE_DIRS}") - endif() - foreach(libdir ${PASTIX_LIBRARY_DIRS}) - if (libdir) - list(APPEND REQUIRED_LIBDIRS "${libdir}") - endif() + set(REQUIRED_LDFLAGS) + set(REQUIRED_INCDIRS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) + + # PASTIX + if (PASTIX_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${PASTIX_INCLUDE_DIRS}") + endif() + foreach(libdir ${PASTIX_LIBRARY_DIRS}) + if (libdir) + list(APPEND REQUIRED_LIBDIRS "${libdir}") + endif() + endforeach() + set(REQUIRED_LIBS "${PASTIX_LIBRARIES}") + # STARPU + if (PASTIX_LOOK_FOR_STARPU AND STARPU_FOUND) + if (STARPU_INCLUDE_DIRS_DEP) + list(APPEND REQUIRED_INCDIRS "${STARPU_INCLUDE_DIRS_DEP}") + elseif (STARPU_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${STARPU_INCLUDE_DIRS}") + endif() + if(STARPU_LIBRARY_DIRS_DEP) + list(APPEND REQUIRED_LIBDIRS "${STARPU_LIBRARY_DIRS_DEP}") + elseif(STARPU_LIBRARY_DIRS) + list(APPEND REQUIRED_LIBDIRS "${STARPU_LIBRARY_DIRS}") + endif() + if (STARPU_LIBRARIES_DEP) + list(APPEND REQUIRED_LIBS "${STARPU_LIBRARIES_DEP}") + elseif (STARPU_LIBRARIES) + foreach(lib ${STARPU_LIBRARIES}) + if (EXISTS ${lib} OR ${lib} MATCHES "^-") + list(APPEND REQUIRED_LIBS "${lib}") + else() + list(APPEND REQUIRED_LIBS "-l${lib}") + endif() + endforeach() + endif() + endif() + # CUDA + if (PASTIX_LOOK_FOR_STARPU_CUDA AND CUDA_FOUND) + if (CUDA_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${CUDA_INCLUDE_DIRS}") + endif() + foreach(libdir ${CUDA_LIBRARY_DIRS}) + if (libdir) + list(APPEND REQUIRED_LIBDIRS "${libdir}") + endif() endforeach() - set(REQUIRED_LIBS "${PASTIX_LIBRARIES}") - # STARPU - if (PASTIX_LOOK_FOR_STARPU AND STARPU_FOUND) - if (STARPU_INCLUDE_DIRS_DEP) - list(APPEND REQUIRED_INCDIRS "${STARPU_INCLUDE_DIRS_DEP}") - elseif (STARPU_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${STARPU_INCLUDE_DIRS}") - endif() - if(STARPU_LIBRARY_DIRS_DEP) - list(APPEND REQUIRED_LIBDIRS "${STARPU_LIBRARY_DIRS_DEP}") - elseif(STARPU_LIBRARY_DIRS) - list(APPEND REQUIRED_LIBDIRS "${STARPU_LIBRARY_DIRS}") - endif() - if (STARPU_LIBRARIES_DEP) - list(APPEND REQUIRED_LIBS "${STARPU_LIBRARIES_DEP}") - elseif (STARPU_LIBRARIES) - foreach(lib ${STARPU_LIBRARIES}) - if (EXISTS ${lib} OR ${lib} MATCHES "^-") - list(APPEND REQUIRED_LIBS "${lib}") - else() - list(APPEND REQUIRED_LIBS "-l${lib}") - endif() - endforeach() - endif() - endif() - # CUDA - if (PASTIX_LOOK_FOR_STARPU_CUDA AND CUDA_FOUND) - if (CUDA_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${CUDA_INCLUDE_DIRS}") - endif() - foreach(libdir ${CUDA_LIBRARY_DIRS}) - if (libdir) - list(APPEND REQUIRED_LIBDIRS "${libdir}") - endif() - endforeach() - list(APPEND REQUIRED_LIBS "${CUDA_CUBLAS_LIBRARIES};${CUDA_LIBRARIES}") - endif() - # MPI - if (PASTIX_LOOK_FOR_MPI AND MPI_FOUND) - if (MPI_C_INCLUDE_PATH) - list(APPEND REQUIRED_INCDIRS "${MPI_C_INCLUDE_PATH}") - endif() - if (MPI_C_LINK_FLAGS) - if (${MPI_C_LINK_FLAGS} MATCHES " -") - string(REGEX REPLACE " -" "-" MPI_C_LINK_FLAGS ${MPI_C_LINK_FLAGS}) - endif() - list(APPEND REQUIRED_LDFLAGS "${MPI_C_LINK_FLAGS}") - endif() - list(APPEND REQUIRED_LIBS "${MPI_C_LIBRARIES}") - endif() - # HWLOC - if (HWLOC_FOUND) - if (HWLOC_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${HWLOC_INCLUDE_DIRS}") - endif() - foreach(libdir ${HWLOC_LIBRARY_DIRS}) - if (libdir) - list(APPEND REQUIRED_LIBDIRS "${libdir}") - endif() - endforeach() - foreach(lib ${HWLOC_LIBRARIES}) - if (EXISTS ${lib} OR ${lib} MATCHES "^-") - list(APPEND REQUIRED_LIBS "${lib}") - else() - list(APPEND REQUIRED_LIBS "-l${lib}") - endif() - endforeach() - endif() - # BLAS - if (BLAS_FOUND) - if (BLAS_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${BLAS_INCLUDE_DIRS}") - endif() - foreach(libdir ${BLAS_LIBRARY_DIRS}) - if (libdir) - list(APPEND REQUIRED_LIBDIRS "${libdir}") - 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) - if (SCOTCH_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${SCOTCH_INCLUDE_DIRS}") - endif() - foreach(libdir ${SCOTCH_LIBRARY_DIRS}) - if (libdir) - list(APPEND REQUIRED_LIBDIRS "${libdir}") - endif() - endforeach() - list(APPEND REQUIRED_LIBS "${SCOTCH_LIBRARIES}") - endif() - # PTSCOTCH - if (PASTIX_LOOK_FOR_PTSCOTCH AND PTSCOTCH_FOUND) - if (PTSCOTCH_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${PTSCOTCH_INCLUDE_DIRS}") - endif() - foreach(libdir ${PTSCOTCH_LIBRARY_DIRS}) - if (libdir) - list(APPEND REQUIRED_LIBDIRS "${libdir}") - endif() - endforeach() - list(APPEND REQUIRED_LIBS "${PTSCOTCH_LIBRARIES}") - endif() - # METIS - if (PASTIX_LOOK_FOR_METIS AND METIS_FOUND) - if (METIS_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${METIS_INCLUDE_DIRS}") - endif() - foreach(libdir ${METIS_LIBRARY_DIRS}) - if (libdir) - list(APPEND REQUIRED_LIBDIRS "${libdir}") - endif() - 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}) - - # 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}") + list(APPEND REQUIRED_LIBS "${CUDA_CUBLAS_LIBRARIES};${CUDA_LIBRARIES}") + endif() + # MPI + if (PASTIX_LOOK_FOR_MPI AND MPI_FOUND) + if (MPI_C_INCLUDE_PATH) + list(APPEND REQUIRED_INCDIRS "${MPI_C_INCLUDE_PATH}") + endif() + if (MPI_C_LINK_FLAGS) + if (${MPI_C_LINK_FLAGS} MATCHES " -") + string(REGEX REPLACE " -" "-" MPI_C_LINK_FLAGS ${MPI_C_LINK_FLAGS}) + endif() + list(APPEND REQUIRED_LDFLAGS "${MPI_C_LINK_FLAGS}") + endif() + list(APPEND REQUIRED_LIBS "${MPI_C_LIBRARIES}") + endif() + # HWLOC + if (HWLOC_FOUND) + if (HWLOC_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${HWLOC_INCLUDE_DIRS}") + endif() + foreach(libdir ${HWLOC_LIBRARY_DIRS}) + if (libdir) + list(APPEND REQUIRED_LIBDIRS "${libdir}") + endif() endforeach() - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") - list(APPEND CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - - # test link - unset(PASTIX_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(pastix PASTIX_WORKS) - mark_as_advanced(PASTIX_WORKS) - - if(PASTIX_WORKS) - # save link with dependencies - 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") - message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") - message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") - message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") - message(STATUS "Maybe PASTIX is linked with specific libraries. " - "Have you tried with COMPONENTS (MPI/SEQ, STARPU, STARPU_CUDA, SCOTCH, PTSCOTCH, METIS)? " - "See the explanation in FindPASTIX.cmake.") - endif() - endif() - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_LIBRARIES) + foreach(lib ${HWLOC_LIBRARIES}) + if (EXISTS ${lib} OR ${lib} MATCHES "^-") + list(APPEND REQUIRED_LIBS "${lib}") + else() + list(APPEND REQUIRED_LIBS "-l${lib}") + endif() + endforeach() + endif() + # BLAS + if (BLAS_FOUND) + if (BLAS_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${BLAS_INCLUDE_DIRS}") + endif() + foreach(libdir ${BLAS_LIBRARY_DIRS}) + if (libdir) + list(APPEND REQUIRED_LIBDIRS "${libdir}") + 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) + if (SCOTCH_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${SCOTCH_INCLUDE_DIRS}") + endif() + foreach(libdir ${SCOTCH_LIBRARY_DIRS}) + if (libdir) + list(APPEND REQUIRED_LIBDIRS "${libdir}") + endif() + endforeach() + list(APPEND REQUIRED_LIBS "${SCOTCH_LIBRARIES}") + endif() + # PTSCOTCH + if (PASTIX_LOOK_FOR_PTSCOTCH AND PTSCOTCH_FOUND) + if (PTSCOTCH_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${PTSCOTCH_INCLUDE_DIRS}") + endif() + foreach(libdir ${PTSCOTCH_LIBRARY_DIRS}) + if (libdir) + list(APPEND REQUIRED_LIBDIRS "${libdir}") + endif() + endforeach() + list(APPEND REQUIRED_LIBS "${PTSCOTCH_LIBRARIES}") + endif() + # METIS + if (PASTIX_LOOK_FOR_METIS AND METIS_FOUND) + if (METIS_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${METIS_INCLUDE_DIRS}") + endif() + foreach(libdir ${METIS_LIBRARY_DIRS}) + if (libdir) + list(APPEND REQUIRED_LIBDIRS "${libdir}") + endif() + 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}) + + # 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}") + string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + + # test link + unset(PASTIX_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(pastix PASTIX_WORKS) + mark_as_advanced(PASTIX_WORKS) + + if(PASTIX_WORKS) + # save link with dependencies + 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") + message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") + message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") + message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") + message(STATUS "Maybe PASTIX is linked with specific libraries. " + "Have you tried with COMPONENTS (MPI/SEQ, STARPU, STARPU_CUDA, SCOTCH, PTSCOTCH, METIS)? " + "See the explanation in FindPASTIX.cmake.") + endif() + endif() + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) endif(PASTIX_LIBRARIES) if (PASTIX_LIBRARIES) - 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_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of PASTIX library" FORCE) - else() - set(PASTIX_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of PASTIX library" FORCE) - endif() + 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_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of PASTIX library" FORCE) + else() + set(PASTIX_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of PASTIX library" FORCE) + endif() endif() mark_as_advanced(PASTIX_DIR) mark_as_advanced(PASTIX_DIR_FOUND) @@ -700,5 +700,5 @@ mark_as_advanced(PASTIX_DIR_FOUND) # --------------------------------- include(FindPackageHandleStandardArgs) find_package_handle_standard_args(PASTIX DEFAULT_MSG - PASTIX_LIBRARIES - PASTIX_WORKS) + PASTIX_LIBRARIES + PASTIX_WORKS) diff --git a/CMakeModules/morse/find/FindPETSc.cmake b/CMakeModules/morse/find/FindPETSc.cmake index be8841524b2d95388c9a3a0cf64befb988baa7da..1d7fb85953fbc681b3d0896d5602e9d2744610a7 100644 --- a/CMakeModules/morse/find/FindPETSc.cmake +++ b/CMakeModules/morse/find/FindPETSc.cmake @@ -23,30 +23,30 @@ # function (petsc_get_version) -if (EXISTS "${PETSC_DIR}/include/petscversion.h") -file (STRINGS "${PETSC_DIR}/include/petscversion.h" vstrings REGEX "#define PETSC_VERSION_(RELEASE|MAJOR|MINOR|SUBMINOR|PATCH) ") - foreach (line ${vstrings}) - string (REGEX REPLACE " +" ";" fields ${line}) # break line into three fields (the first is always "#define") - list (GET fields 1 var) - list (GET fields 2 val) - set (${var} ${val} PARENT_SCOPE) - set (${var} ${val}) # Also in local scope so we have access below - endforeach () - if (PETSC_VERSION_RELEASE) - set (PETSC_VERSION "${PETSC_VERSION_MAJOR}.${PETSC_VERSION_MINOR}.${PETSC_VERSION_SUBMINOR}p${PETSC_VERSION_PATCH}" PARENT_SCOPE) - else () - # make dev version compare higher than any patch level of a released version - set (PETSC_VERSION "${PETSC_VERSION_MAJOR}.${PETSC_VERSION_MINOR}.${PETSC_VERSION_SUBMINOR}.99" PARENT_SCOPE) - endif () + if (EXISTS "${PETSC_DIR}/include/petscversion.h") + file (STRINGS "${PETSC_DIR}/include/petscversion.h" vstrings REGEX "#define PETSC_VERSION_(RELEASE|MAJOR|MINOR|SUBMINOR|PATCH) ") + foreach (line ${vstrings}) + string (REGEX REPLACE " +" ";" fields ${line}) # break line into three fields (the first is always "#define") + list (GET fields 1 var) + list (GET fields 2 val) + set (${var} ${val} PARENT_SCOPE) + set (${var} ${val}) # Also in local scope so we have access below + endforeach () + if (PETSC_VERSION_RELEASE) + set (PETSC_VERSION "${PETSC_VERSION_MAJOR}.${PETSC_VERSION_MINOR}.${PETSC_VERSION_SUBMINOR}p${PETSC_VERSION_PATCH}" PARENT_SCOPE) + else () + # make dev version compare higher than any patch level of a released version + set (PETSC_VERSION "${PETSC_VERSION_MAJOR}.${PETSC_VERSION_MINOR}.${PETSC_VERSION_SUBMINOR}.99" PARENT_SCOPE) + endif () else () - message (SEND_ERROR "PETSC_DIR can not be used, ${PETSC_DIR}/include/petscversion.h does not exist") + message (SEND_ERROR "PETSC_DIR can not be used, ${PETSC_DIR}/include/petscversion.h does not exist") endif () endfunction () find_path (PETSC_DIR include/petsc.h HINTS ENV PETSC_DIR PATHS - ${AEROSOL_TOP_DIR}/../../petsc-3.3-p4 ${AEROSOL_TOP_DIR}/../../petsc-3.2-p7 ${AEROSOL_TOP_DIR}/../../petsc-3.2-p6 ${AEROSOL_TOP_DIR}/../../petsc-3.2-p5 + ${AEROSOL_TOP_DIR}/../../petsc-3.3-p4 ${AEROSOL_TOP_DIR}/../../petsc-3.2-p7 ${AEROSOL_TOP_DIR}/../../petsc-3.2-p6 ${AEROSOL_TOP_DIR}/../../petsc-3.2-p5 ${AEROSOL_TOP_DIR}/../../petsc /usr/lib/petscdir/3.1 /usr/lib/petscdir/3.0.0 /usr/lib/petscdir/2.3.3 /usr/lib/petscdir/2.3.2 # Debian $ENV{HOME}/petsc @@ -57,23 +57,23 @@ find_program (MAKE_EXECUTABLE NAMES make gmake) if (PETSC_DIR AND NOT PETSC_ARCH) set (_petsc_arches - $ENV{PETSC_ARCH} # If set, use environment variable first + $ENV{PETSC_ARCH} # If set, use environment variable first arch-linux2-cxx-opt arch-linux2-c-opt arch-linux2-cxx-debug arch-linux2-c-debug linux-x86_64-python - linux-gnu-c-debug linux-gnu-c-opt # Debian defaults - x86_64-unknown-linux-gnu i386-unknown-linux-gnu) + linux-gnu-c-debug linux-gnu-c-opt # Debian defaults + x86_64-unknown-linux-gnu i386-unknown-linux-gnu) set (petscconf "NOTFOUND" CACHE FILEPATH "Cleared" FORCE) foreach (arch ${_petsc_arches}) - if (NOT PETSC_ARCH) - find_path (petscconf petscconf.h -HINTS ${PETSC_DIR} -PATH_SUFFIXES ${arch}/include bmake/${arch} -NO_DEFAULT_PATH) - if (petscconf) -set (PETSC_ARCH "${arch}" CACHE STRING "PETSc build architecture") - endif (petscconf) - endif (NOT PETSC_ARCH) + if (NOT PETSC_ARCH) + find_path (petscconf petscconf.h + HINTS ${PETSC_DIR} + PATH_SUFFIXES ${arch}/include bmake/${arch} + NO_DEFAULT_PATH) + if (petscconf) + set (PETSC_ARCH "${arch}" CACHE STRING "PETSc build architecture") + endif (petscconf) + endif (NOT PETSC_ARCH) endforeach (arch) set (petscconf "NOTFOUND" CACHE INTERNAL "Scratch variable" FORCE) endif (PETSC_DIR AND NOT PETSC_ARCH) @@ -145,7 +145,7 @@ if (petsc_conf_rules AND petsc_conf_variables AND NOT petsc_config_current) # A temporary makefile to probe the PETSc configuration set (petsc_config_makefile "${PROJECT_BINARY_DIR}/Makefile.petsc") file (WRITE "${petsc_config_makefile}" -"## This file was autogenerated by FindPETSc.cmake + "## This file was autogenerated by FindPETSc.cmake # PETSC_DIR = ${PETSC_DIR} # PETSC_ARCH = ${PETSC_ARCH} include ${petsc_conf_rules} @@ -155,10 +155,10 @@ show : ") macro (PETSC_GET_VARIABLE name var) - set (${var} "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) - execute_process (COMMAND ${MAKE_EXECUTABLE} --no-print-directory -f ${petsc_config_makefile} show VARIABLE=${name} - OUTPUT_VARIABLE ${var} - RESULT_VARIABLE petsc_return) + set (${var} "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) + execute_process (COMMAND ${MAKE_EXECUTABLE} --no-print-directory -f ${petsc_config_makefile} show VARIABLE=${name} + OUTPUT_VARIABLE ${var} + RESULT_VARIABLE petsc_return) endmacro (PETSC_GET_VARIABLE) petsc_get_variable (PETSC_LIB_DIR petsc_lib_dir) petsc_get_variable (PETSC_EXTERNAL_LIB_BASIC petsc_libs_external) @@ -174,58 +174,58 @@ show : resolve_includes (petsc_includes_all "${petsc_cpp_line}") macro (PETSC_FIND_LIBRARY suffix name) - set (PETSC_LIBRARY_${suffix} "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) # Clear any stale value, if we got here, we need to find it again - find_library (PETSC_LIBRARY_${suffix} NAMES ${name} HINTS ${petsc_lib_dir} NO_DEFAULT_PATH) - set (PETSC_LIBRARIES_${suffix} "${PETSC_LIBRARY_${suffix}}") - mark_as_advanced (PETSC_LIBRARY_${suffix}) + set (PETSC_LIBRARY_${suffix} "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) # Clear any stale value, if we got here, we need to find it again + find_library (PETSC_LIBRARY_${suffix} NAMES ${name} HINTS ${petsc_lib_dir} NO_DEFAULT_PATH) + set (PETSC_LIBRARIES_${suffix} "${PETSC_LIBRARY_${suffix}}") + mark_as_advanced (PETSC_LIBRARY_${suffix}) endmacro (PETSC_FIND_LIBRARY suffix name) # Look for petscvec first, if it doesn't exist, we must be using single-library petsc_find_library (VEC petscvec) if (PETSC_LIBRARY_VEC) - petsc_find_library (SYS "petscsys;petsc") # libpetscsys is called libpetsc prior to 3.1 (when single-library was introduced) - petsc_find_library (MAT petscmat) - petsc_find_library (DM petscdm) - petsc_find_library (KSP petscksp) - petsc_find_library (SNES petscsnes) - petsc_find_library (TS petscts) - macro (PETSC_JOIN libs deps) - list (APPEND PETSC_LIBRARIES_${libs} ${PETSC_LIBRARIES_${deps}}) - endmacro (PETSC_JOIN libs deps) - petsc_join (VEC SYS) - petsc_join (MAT VEC) - petsc_join (DM MAT) - petsc_join (KSP DM) - petsc_join (SNES KSP) - petsc_join (TS SNES) - petsc_join (ALL TS) + petsc_find_library (SYS "petscsys;petsc") # libpetscsys is called libpetsc prior to 3.1 (when single-library was introduced) + petsc_find_library (MAT petscmat) + petsc_find_library (DM petscdm) + petsc_find_library (KSP petscksp) + petsc_find_library (SNES petscsnes) + petsc_find_library (TS petscts) + macro (PETSC_JOIN libs deps) + list (APPEND PETSC_LIBRARIES_${libs} ${PETSC_LIBRARIES_${deps}}) + endmacro (PETSC_JOIN libs deps) + petsc_join (VEC SYS) + petsc_join (MAT VEC) + petsc_join (DM MAT) + petsc_join (KSP DM) + petsc_join (SNES KSP) + petsc_join (TS SNES) + petsc_join (ALL TS) else () - set (PETSC_LIBRARY_VEC "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) # There is no libpetscvec - petsc_find_library (SINGLE petsc) - foreach (pkg SYS VEC MAT DM KSP SNES TS ALL) - set (PETSC_LIBRARIES_${pkg} "${PETSC_LIBRARY_SINGLE}") - endforeach () + set (PETSC_LIBRARY_VEC "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) # There is no libpetscvec + petsc_find_library (SINGLE petsc) + foreach (pkg SYS VEC MAT DM KSP SNES TS ALL) + set (PETSC_LIBRARIES_${pkg} "${PETSC_LIBRARY_SINGLE}") + endforeach () endif () if (PETSC_LIBRARY_TS) - message (STATUS "Recognized PETSc install with separate libraries for each package") + message (STATUS "Recognized PETSc install with separate libraries for each package") else () - message (STATUS "Recognized PETSc install with single library for all packages") + message (STATUS "Recognized PETSc install with single library for all packages") endif () include(Check${PETSC_LANGUAGE_BINDINGS}SourceRuns) macro (PETSC_TEST_RUNS includes libraries runs) - if(${PETSC_LANGUAGE_BINDINGS} STREQUAL "C") - set(_PETSC_ERR_FUNC "CHKERRQ(ierr)") - elseif(${PETSC_LANGUAGE_BINDINGS} STREQUAL "CXX") - set(_PETSC_ERR_FUNC "CHKERRXX(ierr)") - endif() - if (PETSC_VERSION VERSION_GREATER 3.1) - set (_PETSC_TSDestroy "TSDestroy(&ts)") - else () - set (_PETSC_TSDestroy "TSDestroy(ts)") - endif () + if(${PETSC_LANGUAGE_BINDINGS} STREQUAL "C") + set(_PETSC_ERR_FUNC "CHKERRQ(ierr)") + elseif(${PETSC_LANGUAGE_BINDINGS} STREQUAL "CXX") + set(_PETSC_ERR_FUNC "CHKERRXX(ierr)") + endif() + if (PETSC_VERSION VERSION_GREATER 3.1) + set (_PETSC_TSDestroy "TSDestroy(&ts)") + else () + set (_PETSC_TSDestroy "TSDestroy(ts)") + endif () - set(_PETSC_TEST_SOURCE " + set(_PETSC_TEST_SOURCE " static const char help[] = \"PETSc test program.\"; #include <petscts.h> int main(int argc,char *argv[]) { @@ -243,7 +243,7 @@ return 0; multipass_source_runs ("${includes}" "${libraries}" "${_PETSC_TEST_SOURCE}" ${runs} "${PETSC_LANGUAGE_BINDINGS}") if (${${runs}}) set (PETSC_EXECUTABLE_RUNS "YES" CACHE BOOL -"Can the system successfully run a PETSc executable? This variable can be manually set to \"YES\" to force CMake to accept a given PETSc configuration, but this will almost always result in a broken build. If you change PETSC_DIR, PETSC_ARCH, or PETSC_CURRENT you would have to reset this variable." FORCE) + "Can the system successfully run a PETSc executable? This variable can be manually set to \"YES\" to force CMake to accept a given PETSc configuration, but this will almost always result in a broken build. If you change PETSC_DIR, PETSC_ARCH, or PETSC_CURRENT you would have to reset this variable." FORCE) endif (${${runs}}) endmacro (PETSC_TEST_RUNS) @@ -254,40 +254,40 @@ return 0; petsc_test_runs ("${petsc_includes_minimal}" "${PETSC_LIBRARIES_TS}" petsc_works_minimal) if (petsc_works_minimal) - message (STATUS "Minimal PETSc includes and libraries work. This probably means we are building with shared libs.") - set (petsc_includes_needed "${petsc_includes_minimal}") + message (STATUS "Minimal PETSc includes and libraries work. This probably means we are building with shared libs.") + set (petsc_includes_needed "${petsc_includes_minimal}") else (petsc_works_minimal) # Minimal includes fail, see if just adding full includes fixes it - petsc_test_runs ("${petsc_includes_all}" "${PETSC_LIBRARIES_TS}" petsc_works_allincludes) - if (petsc_works_allincludes) # It does, we just need all the includes ( - message (STATUS "PETSc requires extra include paths, but links correctly with only interface libraries. This is an unexpected configuration (but it seems to work fine).") - set (petsc_includes_needed ${petsc_includes_all}) - else (petsc_works_allincludes) # We are going to need to link the external libs explicitly - resolve_libraries (petsc_libraries_external "${petsc_libs_external}") - foreach (pkg SYS VEC MAT DM KSP SNES TS ALL) -list (APPEND PETSC_LIBRARIES_${pkg} ${petsc_libraries_external}) - endforeach (pkg) - petsc_test_runs ("${petsc_includes_minimal}" "${PETSC_LIBRARIES_TS}" petsc_works_alllibraries) - if (petsc_works_alllibraries) -message (STATUS "PETSc only need minimal includes, but requires explicit linking to all dependencies. This is expected when PETSc is built with static libraries.") -set (petsc_includes_needed ${petsc_includes_minimal}) - else (petsc_works_alllibraries) -# It looks like we really need everything, should have listened to Matt -set (petsc_includes_needed ${petsc_includes_all}) -petsc_test_runs ("${petsc_includes_all}" "${PETSC_LIBRARIES_TS}" petsc_works_all) -if (petsc_works_all) # We fail anyways -message (STATUS "PETSc requires extra include paths and explicit linking to all dependencies. This probably means you have static libraries and something unexpected in PETSc headers.") -else (petsc_works_all) # We fail anyways -message (STATUS "PETSc could not be used, maybe the install is broken.") -endif (petsc_works_all) - endif (petsc_works_alllibraries) - endif (petsc_works_allincludes) + petsc_test_runs ("${petsc_includes_all}" "${PETSC_LIBRARIES_TS}" petsc_works_allincludes) + if (petsc_works_allincludes) # It does, we just need all the includes ( + message (STATUS "PETSc requires extra include paths, but links correctly with only interface libraries. This is an unexpected configuration (but it seems to work fine).") + set (petsc_includes_needed ${petsc_includes_all}) + else (petsc_works_allincludes) # We are going to need to link the external libs explicitly + resolve_libraries (petsc_libraries_external "${petsc_libs_external}") + foreach (pkg SYS VEC MAT DM KSP SNES TS ALL) + list (APPEND PETSC_LIBRARIES_${pkg} ${petsc_libraries_external}) + endforeach (pkg) + petsc_test_runs ("${petsc_includes_minimal}" "${PETSC_LIBRARIES_TS}" petsc_works_alllibraries) + if (petsc_works_alllibraries) + message (STATUS "PETSc only need minimal includes, but requires explicit linking to all dependencies. This is expected when PETSc is built with static libraries.") + set (petsc_includes_needed ${petsc_includes_minimal}) + else (petsc_works_alllibraries) + # It looks like we really need everything, should have listened to Matt + set (petsc_includes_needed ${petsc_includes_all}) + petsc_test_runs ("${petsc_includes_all}" "${PETSC_LIBRARIES_TS}" petsc_works_all) + if (petsc_works_all) # We fail anyways + message (STATUS "PETSc requires extra include paths and explicit linking to all dependencies. This probably means you have static libraries and something unexpected in PETSc headers.") + else (petsc_works_all) # We fail anyways + message (STATUS "PETSc could not be used, maybe the install is broken.") + endif (petsc_works_all) + endif (petsc_works_alllibraries) + endif (petsc_works_allincludes) endif (petsc_works_minimal) # We do an out-of-source build so __FILE__ will be an absolute path, hence __INSDIR__ is superfluous if (${PETSC_VERSION} VERSION_LESS 3.1) - set (PETSC_DEFINITIONS "-D__SDIR__=\"\"" CACHE STRING "PETSc definitions" FORCE) + set (PETSC_DEFINITIONS "-D__SDIR__=\"\"" CACHE STRING "PETSc definitions" FORCE) else () - set (PETSC_DEFINITIONS "-D__INSDIR__=" CACHE STRING "PETSc definitions" FORCE) + set (PETSC_DEFINITIONS "-D__INSDIR__=" CACHE STRING "PETSc definitions" FORCE) endif () # Sometimes this can be used to assist FindMPI.cmake set (PETSC_MPIEXEC ${petsc_mpiexec} CACHE FILEPATH "Executable for running PETSc MPI programs" FORCE) diff --git a/CMakeModules/morse/find/FindPTSCOTCH.cmake b/CMakeModules/morse/find/FindPTSCOTCH.cmake index 77878758039f0c7ac8c98654513d093e61e52efe..2873325830b0ecdd35f61f714a13ef89390ac471 100644 --- a/CMakeModules/morse/find/FindPTSCOTCH.cmake +++ b/CMakeModules/morse/find/FindPTSCOTCH.cmake @@ -60,40 +60,40 @@ # License text for the above reference.) if (NOT PTSCOTCH_FOUND) - 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() + 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() endif() # Set the version to find set(PTSCOTCH_LOOK_FOR_ESMUMPS OFF) if( PTSCOTCH_FIND_COMPONENTS ) - foreach( component ${PTSCOTCH_FIND_COMPONENTS} ) - if (${component} STREQUAL "ESMUMPS") - # means we look for esmumps library - set(PTSCOTCH_LOOK_FOR_ESMUMPS ON) - endif() - endforeach() + foreach( component ${PTSCOTCH_FIND_COMPONENTS} ) + if (${component} STREQUAL "ESMUMPS") + # means we look for esmumps library + set(PTSCOTCH_LOOK_FOR_ESMUMPS ON) + endif() + endforeach() endif() # PTSCOTCH depends on Threads, try to find it if (NOT THREADS_FOUND) - if (PTSCOTCH_FIND_REQUIRED) - find_package(Threads REQUIRED) - else() - find_package(Threads) - endif() + if (PTSCOTCH_FIND_REQUIRED) + find_package(Threads REQUIRED) + else() + find_package(Threads) + endif() endif() # PTSCOTCH depends on MPI, try to find it if (NOT MPI_FOUND) - if (PTSCOTCH_FIND_REQUIRED) - find_package(MPI REQUIRED) - else() - find_package(MPI) - endif() + if (PTSCOTCH_FIND_REQUIRED) + find_package(MPI REQUIRED) + else() + find_package(MPI) + endif() endif() # Looking for include @@ -105,24 +105,24 @@ unset(_inc_env) set(ENV_PTSCOTCH_DIR "$ENV{PTSCOTCH_DIR}") set(ENV_PTSCOTCH_INCDIR "$ENV{PTSCOTCH_INCDIR}") if(ENV_PTSCOTCH_INCDIR) - list(APPEND _inc_env "${ENV_PTSCOTCH_INCDIR}") + list(APPEND _inc_env "${ENV_PTSCOTCH_INCDIR}") elseif(ENV_PTSCOTCH_DIR) - list(APPEND _inc_env "${ENV_PTSCOTCH_DIR}") - list(APPEND _inc_env "${ENV_PTSCOTCH_DIR}/include") - list(APPEND _inc_env "${ENV_PTSCOTCH_DIR}/include/ptscotch") + list(APPEND _inc_env "${ENV_PTSCOTCH_DIR}") + list(APPEND _inc_env "${ENV_PTSCOTCH_DIR}/include") + list(APPEND _inc_env "${ENV_PTSCOTCH_DIR}/include/ptscotch") else() - if(WIN32) - string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") - else() - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{CPATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - endif() + if(WIN32) + string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") + else() + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{CPATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + endif() endif() list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") @@ -136,46 +136,46 @@ set(PTSCOTCH_hdrs_to_find "ptscotch.h;scotch.h") # call cmake macro to find the header path if(PTSCOTCH_INCDIR) + foreach(ptscotch_hdr ${PTSCOTCH_hdrs_to_find}) + set(PTSCOTCH_${ptscotch_hdr}_DIRS "PTSCOTCH_${ptscotch_hdr}_DIRS-NOTFOUND") + find_path(PTSCOTCH_${ptscotch_hdr}_DIRS + NAMES ${ptscotch_hdr} + HINTS ${PTSCOTCH_INCDIR}) + mark_as_advanced(PTSCOTCH_${ptscotch_hdr}_DIRS) + endforeach() +else() + if(PTSCOTCH_DIR) foreach(ptscotch_hdr ${PTSCOTCH_hdrs_to_find}) - set(PTSCOTCH_${ptscotch_hdr}_DIRS "PTSCOTCH_${ptscotch_hdr}_DIRS-NOTFOUND") - find_path(PTSCOTCH_${ptscotch_hdr}_DIRS - NAMES ${ptscotch_hdr} - HINTS ${PTSCOTCH_INCDIR}) - mark_as_advanced(PTSCOTCH_${ptscotch_hdr}_DIRS) + set(PTSCOTCH_${ptscotch_hdr}_DIRS "PTSCOTCH_${ptscotch_hdr}_DIRS-NOTFOUND") + find_path(PTSCOTCH_${ptscotch_hdr}_DIRS + NAMES ${ptscotch_hdr} + HINTS ${PTSCOTCH_DIR} + PATH_SUFFIXES "include" "include/scotch") + mark_as_advanced(PTSCOTCH_${ptscotch_hdr}_DIRS) endforeach() -else() - if(PTSCOTCH_DIR) - foreach(ptscotch_hdr ${PTSCOTCH_hdrs_to_find}) - set(PTSCOTCH_${ptscotch_hdr}_DIRS "PTSCOTCH_${ptscotch_hdr}_DIRS-NOTFOUND") - find_path(PTSCOTCH_${ptscotch_hdr}_DIRS - NAMES ${ptscotch_hdr} - HINTS ${PTSCOTCH_DIR} - PATH_SUFFIXES "include" "include/scotch") - mark_as_advanced(PTSCOTCH_${ptscotch_hdr}_DIRS) - endforeach() - else() - foreach(ptscotch_hdr ${PTSCOTCH_hdrs_to_find}) - set(PTSCOTCH_${ptscotch_hdr}_DIRS "PTSCOTCH_${ptscotch_hdr}_DIRS-NOTFOUND") - find_path(PTSCOTCH_${ptscotch_hdr}_DIRS - NAMES ${ptscotch_hdr} - HINTS ${_inc_env} - PATH_SUFFIXES "scotch") - mark_as_advanced(PTSCOTCH_${ptscotch_hdr}_DIRS) - endforeach() - endif() + else() + foreach(ptscotch_hdr ${PTSCOTCH_hdrs_to_find}) + set(PTSCOTCH_${ptscotch_hdr}_DIRS "PTSCOTCH_${ptscotch_hdr}_DIRS-NOTFOUND") + find_path(PTSCOTCH_${ptscotch_hdr}_DIRS + NAMES ${ptscotch_hdr} + HINTS ${_inc_env} + PATH_SUFFIXES "scotch") + mark_as_advanced(PTSCOTCH_${ptscotch_hdr}_DIRS) + endforeach() + endif() endif() # If found, add path to cmake variable # ------------------------------------ foreach(ptscotch_hdr ${PTSCOTCH_hdrs_to_find}) - if (PTSCOTCH_${ptscotch_hdr}_DIRS) - list(APPEND PTSCOTCH_INCLUDE_DIRS "${PTSCOTCH_${ptscotch_hdr}_DIRS}") - else () - set(PTSCOTCH_INCLUDE_DIRS "PTSCOTCH_INCLUDE_DIRS-NOTFOUND") - if (NOT PTSCOTCH_FIND_QUIETLY) - message(STATUS "Looking for ptscotch -- ${ptscotch_hdr} not found") - endif() + if (PTSCOTCH_${ptscotch_hdr}_DIRS) + list(APPEND PTSCOTCH_INCLUDE_DIRS "${PTSCOTCH_${ptscotch_hdr}_DIRS}") + else () + set(PTSCOTCH_INCLUDE_DIRS "PTSCOTCH_INCLUDE_DIRS-NOTFOUND") + if (NOT PTSCOTCH_FIND_QUIETLY) + message(STATUS "Looking for ptscotch -- ${ptscotch_hdr} not found") endif() + endif() endforeach() @@ -187,22 +187,22 @@ endforeach() unset(_lib_env) set(ENV_PTSCOTCH_LIBDIR "$ENV{PTSCOTCH_LIBDIR}") if(ENV_PTSCOTCH_LIBDIR) - list(APPEND _lib_env "${ENV_PTSCOTCH_LIBDIR}") + list(APPEND _lib_env "${ENV_PTSCOTCH_LIBDIR}") elseif(ENV_PTSCOTCH_DIR) - list(APPEND _lib_env "${ENV_PTSCOTCH_DIR}") - list(APPEND _lib_env "${ENV_PTSCOTCH_DIR}/lib") + list(APPEND _lib_env "${ENV_PTSCOTCH_DIR}") + list(APPEND _lib_env "${ENV_PTSCOTCH_DIR}/lib") else() - if(WIN32) - string(REPLACE ":" ";" _lib_env "$ENV{LIB}") + if(WIN32) + string(REPLACE ":" ";" _lib_env "$ENV{LIB}") + else() + if(APPLE) + string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") else() - if(APPLE) - string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") endif() + list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") + list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + endif() endif() list(REMOVE_DUPLICATES _lib_env) @@ -218,29 +218,29 @@ list(APPEND PTSCOTCH_libs_to_find "scotch;scotcherr") # call cmake macro to find the lib path if(PTSCOTCH_LIBDIR) + foreach(ptscotch_lib ${PTSCOTCH_libs_to_find}) + set(PTSCOTCH_${ptscotch_lib}_LIBRARY "PTSCOTCH_${ptscotch_lib}_LIBRARY-NOTFOUND") + find_library(PTSCOTCH_${ptscotch_lib}_LIBRARY + NAMES ${ptscotch_lib} + HINTS ${PTSCOTCH_LIBDIR}) + endforeach() +else() + if(PTSCOTCH_DIR) foreach(ptscotch_lib ${PTSCOTCH_libs_to_find}) - set(PTSCOTCH_${ptscotch_lib}_LIBRARY "PTSCOTCH_${ptscotch_lib}_LIBRARY-NOTFOUND") - find_library(PTSCOTCH_${ptscotch_lib}_LIBRARY - NAMES ${ptscotch_lib} - HINTS ${PTSCOTCH_LIBDIR}) + set(PTSCOTCH_${ptscotch_lib}_LIBRARY "PTSCOTCH_${ptscotch_lib}_LIBRARY-NOTFOUND") + find_library(PTSCOTCH_${ptscotch_lib}_LIBRARY + NAMES ${ptscotch_lib} + HINTS ${PTSCOTCH_DIR} + PATH_SUFFIXES lib lib32 lib64) endforeach() -else() - if(PTSCOTCH_DIR) - foreach(ptscotch_lib ${PTSCOTCH_libs_to_find}) - set(PTSCOTCH_${ptscotch_lib}_LIBRARY "PTSCOTCH_${ptscotch_lib}_LIBRARY-NOTFOUND") - find_library(PTSCOTCH_${ptscotch_lib}_LIBRARY - NAMES ${ptscotch_lib} - HINTS ${PTSCOTCH_DIR} - PATH_SUFFIXES lib lib32 lib64) - endforeach() - else() - foreach(ptscotch_lib ${PTSCOTCH_libs_to_find}) - set(PTSCOTCH_${ptscotch_lib}_LIBRARY "PTSCOTCH_${ptscotch_lib}_LIBRARY-NOTFOUND") - find_library(PTSCOTCH_${ptscotch_lib}_LIBRARY - NAMES ${ptscotch_lib} - HINTS ${_lib_env}) - endforeach() - endif() + else() + foreach(ptscotch_lib ${PTSCOTCH_libs_to_find}) + set(PTSCOTCH_${ptscotch_lib}_LIBRARY "PTSCOTCH_${ptscotch_lib}_LIBRARY-NOTFOUND") + find_library(PTSCOTCH_${ptscotch_lib}_LIBRARY + NAMES ${ptscotch_lib} + HINTS ${_lib_env}) + endforeach() + endif() endif() set(PTSCOTCH_LIBRARIES "") @@ -249,19 +249,19 @@ set(PTSCOTCH_LIBRARY_DIRS "") # ------------------------------------ foreach(ptscotch_lib ${PTSCOTCH_libs_to_find}) - if (PTSCOTCH_${ptscotch_lib}_LIBRARY) - get_filename_component(${ptscotch_lib}_lib_path "${PTSCOTCH_${ptscotch_lib}_LIBRARY}" PATH) - # set cmake variables - list(APPEND PTSCOTCH_LIBRARIES "${PTSCOTCH_${ptscotch_lib}_LIBRARY}") - list(APPEND PTSCOTCH_LIBRARY_DIRS "${${ptscotch_lib}_lib_path}") - else () - list(APPEND PTSCOTCH_LIBRARIES "${PTSCOTCH_${ptscotch_lib}_LIBRARY}") - if (NOT PTSCOTCH_FIND_QUIETLY) - message(STATUS "Looking for ptscotch -- lib ${ptscotch_lib} not found") - endif() - endif () + if (PTSCOTCH_${ptscotch_lib}_LIBRARY) + get_filename_component(${ptscotch_lib}_lib_path "${PTSCOTCH_${ptscotch_lib}_LIBRARY}" PATH) + # set cmake variables + list(APPEND PTSCOTCH_LIBRARIES "${PTSCOTCH_${ptscotch_lib}_LIBRARY}") + list(APPEND PTSCOTCH_LIBRARY_DIRS "${${ptscotch_lib}_lib_path}") + else () + list(APPEND PTSCOTCH_LIBRARIES "${PTSCOTCH_${ptscotch_lib}_LIBRARY}") + if (NOT PTSCOTCH_FIND_QUIETLY) + message(STATUS "Looking for ptscotch -- lib ${ptscotch_lib} not found") + endif() + endif () - mark_as_advanced(PTSCOTCH_${ptscotch_lib}_LIBRARY) + mark_as_advanced(PTSCOTCH_${ptscotch_lib}_LIBRARY) endforeach() list(REMOVE_DUPLICATES PTSCOTCH_LIBRARY_DIRS) @@ -269,103 +269,103 @@ list(REMOVE_DUPLICATES PTSCOTCH_LIBRARY_DIRS) # check a function to validate the find if(PTSCOTCH_LIBRARIES) - set(REQUIRED_LDFLAGS) - set(REQUIRED_INCDIRS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) + set(REQUIRED_LDFLAGS) + set(REQUIRED_INCDIRS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) - # PTSCOTCH - if (PTSCOTCH_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${PTSCOTCH_INCLUDE_DIRS}") - endif() - if (PTSCOTCH_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${PTSCOTCH_LIBRARY_DIRS}") - endif() - set(REQUIRED_LIBS "${PTSCOTCH_LIBRARIES}") - # MPI - if (MPI_FOUND) - if (MPI_C_INCLUDE_PATH) - list(APPEND CMAKE_REQUIRED_INCLUDES "${MPI_C_INCLUDE_PATH}") - endif() - if (MPI_C_LINK_FLAGS) - if (${MPI_C_LINK_FLAGS} MATCHES " -") - string(REGEX REPLACE " -" "-" MPI_C_LINK_FLAGS ${MPI_C_LINK_FLAGS}) - endif() - list(APPEND REQUIRED_LDFLAGS "${MPI_C_LINK_FLAGS}") - endif() - list(APPEND REQUIRED_LIBS "${MPI_C_LIBRARIES}") - endif() - # THREADS - if(CMAKE_THREAD_LIBS_INIT) - list(APPEND REQUIRED_LIBS "${CMAKE_THREAD_LIBS_INIT}") - endif() - set(Z_LIBRARY "Z_LIBRARY-NOTFOUND") - find_library(Z_LIBRARY NAMES z) - mark_as_advanced(Z_LIBRARY) - if(Z_LIBRARY) - list(APPEND REQUIRED_LIBS "-lz") - endif() - set(M_LIBRARY "M_LIBRARY-NOTFOUND") - find_library(M_LIBRARY NAMES m) - mark_as_advanced(M_LIBRARY) - if(M_LIBRARY) - list(APPEND REQUIRED_LIBS "-lm") + # PTSCOTCH + if (PTSCOTCH_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${PTSCOTCH_INCLUDE_DIRS}") + endif() + if (PTSCOTCH_LIBRARY_DIRS) + set(REQUIRED_LIBDIRS "${PTSCOTCH_LIBRARY_DIRS}") + endif() + set(REQUIRED_LIBS "${PTSCOTCH_LIBRARIES}") + # MPI + if (MPI_FOUND) + if (MPI_C_INCLUDE_PATH) + list(APPEND CMAKE_REQUIRED_INCLUDES "${MPI_C_INCLUDE_PATH}") endif() - set(RT_LIBRARY "RT_LIBRARY-NOTFOUND") - find_library(RT_LIBRARY NAMES rt) - mark_as_advanced(RT_LIBRARY) - if(RT_LIBRARY) - list(APPEND REQUIRED_LIBS "-lrt") + if (MPI_C_LINK_FLAGS) + if (${MPI_C_LINK_FLAGS} MATCHES " -") + string(REGEX REPLACE " -" "-" MPI_C_LINK_FLAGS ${MPI_C_LINK_FLAGS}) + endif() + list(APPEND REQUIRED_LDFLAGS "${MPI_C_LINK_FLAGS}") endif() + list(APPEND REQUIRED_LIBS "${MPI_C_LIBRARIES}") + endif() + # THREADS + if(CMAKE_THREAD_LIBS_INIT) + list(APPEND REQUIRED_LIBS "${CMAKE_THREAD_LIBS_INIT}") + endif() + set(Z_LIBRARY "Z_LIBRARY-NOTFOUND") + find_library(Z_LIBRARY NAMES z) + mark_as_advanced(Z_LIBRARY) + if(Z_LIBRARY) + list(APPEND REQUIRED_LIBS "-lz") + endif() + set(M_LIBRARY "M_LIBRARY-NOTFOUND") + find_library(M_LIBRARY NAMES m) + mark_as_advanced(M_LIBRARY) + if(M_LIBRARY) + list(APPEND REQUIRED_LIBS "-lm") + endif() + set(RT_LIBRARY "RT_LIBRARY-NOTFOUND") + find_library(RT_LIBRARY NAMES rt) + mark_as_advanced(RT_LIBRARY) + if(RT_LIBRARY) + list(APPEND REQUIRED_LIBS "-lrt") + 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}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - - # test link - unset(PTSCOTCH_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(SCOTCH_dgraphInit PTSCOTCH_WORKS) - mark_as_advanced(PTSCOTCH_WORKS) - - if(PTSCOTCH_WORKS) - # save link with dependencies - 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") - message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") - message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") - message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") - 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}") + string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + + # test link + unset(PTSCOTCH_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(SCOTCH_dgraphInit PTSCOTCH_WORKS) + mark_as_advanced(PTSCOTCH_WORKS) + + if(PTSCOTCH_WORKS) + # save link with dependencies + 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") + message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") + message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") + message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") endif() - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_LIBRARIES) + endif() + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) endif(PTSCOTCH_LIBRARIES) if (PTSCOTCH_LIBRARIES) - 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_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of PTSCOTCH library" FORCE) - else() - set(PTSCOTCH_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of PTSCOTCH library" FORCE) - endif() + 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_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of PTSCOTCH library" FORCE) + else() + set(PTSCOTCH_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of PTSCOTCH library" FORCE) + endif() endif() mark_as_advanced(PTSCOTCH_DIR) mark_as_advanced(PTSCOTCH_DIR_FOUND) @@ -416,8 +416,8 @@ set(CMAKE_REQUIRED_INCLUDES "") # --------------------------------- include(FindPackageHandleStandardArgs) find_package_handle_standard_args(PTSCOTCH DEFAULT_MSG - PTSCOTCH_LIBRARIES - PTSCOTCH_WORKS) + PTSCOTCH_LIBRARIES + PTSCOTCH_WORKS) # # TODO: Add possibility to check for specific functions in the library # diff --git a/CMakeModules/morse/find/FindQUARK.cmake b/CMakeModules/morse/find/FindQUARK.cmake index 0222033922d36a63869f2d39bc0694a36bcdda3d..adc5b65c79e9fb1ac67fd4ff6682c6a7280336a2 100644 --- a/CMakeModules/morse/find/FindQUARK.cmake +++ b/CMakeModules/morse/find/FindQUARK.cmake @@ -60,10 +60,10 @@ if (NOT QUARK_FOUND) - 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() + 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() endif() # QUARK may depend on HWLOC @@ -71,29 +71,29 @@ endif() set(QUARK_LOOK_FOR_HWLOC FALSE) if( QUARK_FIND_COMPONENTS ) - foreach( component ${QUARK_FIND_COMPONENTS} ) - if(${component} STREQUAL "HWLOC") - set(QUARK_LOOK_FOR_HWLOC TRUE) - endif() - endforeach() + foreach( component ${QUARK_FIND_COMPONENTS} ) + if(${component} STREQUAL "HWLOC") + set(QUARK_LOOK_FOR_HWLOC TRUE) + endif() + endforeach() endif() # QUARK may depend on Threads, try to find it if (NOT Threads_FOUND) - if (QUARK_FIND_REQUIRED) - find_package(Threads REQUIRED) - else() - find_package(Threads) - endif() + if (QUARK_FIND_REQUIRED) + find_package(Threads REQUIRED) + else() + find_package(Threads) + endif() endif() # QUARK may depend on HWLOC, try to find it if (NOT HWLOC_FOUND AND QUARK_LOOK_FOR_HWLOC) - if (QUARK_FIND_REQUIRED AND QUARK_FIND_REQUIRED_HWLOC) - find_package(HWLOC REQUIRED) - else() - find_package(HWLOC) - endif() + if (QUARK_FIND_REQUIRED AND QUARK_FIND_REQUIRED_HWLOC) + find_package(HWLOC REQUIRED) + else() + find_package(HWLOC) + endif() endif() # Looking for include @@ -105,25 +105,25 @@ unset(_inc_env) set(ENV_QUARK_DIR "$ENV{QUARK_DIR}") set(ENV_QUARK_INCDIR "$ENV{QUARK_INCDIR}") if(ENV_QUARK_INCDIR) - list(APPEND _inc_env "${ENV_QUARK_INCDIR}") + list(APPEND _inc_env "${ENV_QUARK_INCDIR}") elseif(ENV_QUARK_DIR) - list(APPEND _inc_env "${ENV_QUARK_DIR}") - list(APPEND _inc_env "${ENV_QUARK_DIR}/include") - list(APPEND _inc_env "${ENV_QUARK_DIR}/include/quark") - list(APPEND _inc_env "${ENV_QUARK_DIR}/include/plasma") + list(APPEND _inc_env "${ENV_QUARK_DIR}") + list(APPEND _inc_env "${ENV_QUARK_DIR}/include") + list(APPEND _inc_env "${ENV_QUARK_DIR}/include/quark") + list(APPEND _inc_env "${ENV_QUARK_DIR}/include/plasma") else() - if(WIN32) - string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") - else() - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{CPATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - endif() + if(WIN32) + string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") + else() + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{CPATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + endif() endif() list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") @@ -134,35 +134,35 @@ list(REMOVE_DUPLICATES _inc_env) # ------------------------------------------------- # call cmake macro to find the header path if(QUARK_INCDIR) + set(QUARK_quark.h_DIRS "QUARK_quark.h_DIRS-NOTFOUND") + find_path(QUARK_quark.h_DIRS + NAMES quark.h + HINTS ${QUARK_INCDIR}) +else() + if(QUARK_DIR) set(QUARK_quark.h_DIRS "QUARK_quark.h_DIRS-NOTFOUND") find_path(QUARK_quark.h_DIRS NAMES quark.h - HINTS ${QUARK_INCDIR}) -else() - if(QUARK_DIR) - set(QUARK_quark.h_DIRS "QUARK_quark.h_DIRS-NOTFOUND") - find_path(QUARK_quark.h_DIRS - NAMES quark.h - HINTS ${QUARK_DIR} - PATH_SUFFIXES "include" "include/quark" "include/plasma") - else() - set(QUARK_quark.h_DIRS "QUARK_quark.h_DIRS-NOTFOUND") - find_path(QUARK_quark.h_DIRS - NAMES quark.h - HINTS ${_inc_env}) - endif() + HINTS ${QUARK_DIR} + PATH_SUFFIXES "include" "include/quark" "include/plasma") + else() + set(QUARK_quark.h_DIRS "QUARK_quark.h_DIRS-NOTFOUND") + find_path(QUARK_quark.h_DIRS + NAMES quark.h + HINTS ${_inc_env}) + endif() endif() mark_as_advanced(QUARK_quark.h_DIRS) # If found, add path to cmake variable # ------------------------------------ if (QUARK_quark.h_DIRS) - set(QUARK_INCLUDE_DIRS "${QUARK_quark.h_DIRS}") + set(QUARK_INCLUDE_DIRS "${QUARK_quark.h_DIRS}") else () - set(QUARK_INCLUDE_DIRS "QUARK_INCLUDE_DIRS-NOTFOUND") - if(NOT QUARK_FIND_QUIETLY) - message(STATUS "Looking for quark -- quark.h not found") - endif() + set(QUARK_INCLUDE_DIRS "QUARK_INCLUDE_DIRS-NOTFOUND") + if(NOT QUARK_FIND_QUIETLY) + message(STATUS "Looking for quark -- quark.h not found") + endif() endif() @@ -174,22 +174,22 @@ endif() unset(_lib_env) set(ENV_QUARK_LIBDIR "$ENV{QUARK_LIBDIR}") if(ENV_QUARK_LIBDIR) - list(APPEND _lib_env "${ENV_QUARK_LIBDIR}") + list(APPEND _lib_env "${ENV_QUARK_LIBDIR}") elseif(ENV_QUARK_DIR) - list(APPEND _lib_env "${ENV_QUARK_DIR}") - list(APPEND _lib_env "${ENV_QUARK_DIR}/lib") + list(APPEND _lib_env "${ENV_QUARK_DIR}") + list(APPEND _lib_env "${ENV_QUARK_DIR}/lib") else() - if(WIN32) - string(REPLACE ":" ";" _lib_env "$ENV{LIB}") + if(WIN32) + string(REPLACE ":" ";" _lib_env "$ENV{LIB}") + else() + if(APPLE) + string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") else() - if(APPLE) - string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") endif() + list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") + list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + endif() endif() list(REMOVE_DUPLICATES _lib_env) @@ -198,121 +198,121 @@ list(REMOVE_DUPLICATES _lib_env) # call cmake macro to find the lib path if(QUARK_LIBDIR) + set(QUARK_quark_LIBRARY "QUARK_quark_LIBRARY-NOTFOUND") + find_library(QUARK_quark_LIBRARY + NAMES quark + HINTS ${QUARK_LIBDIR}) +else() + if(QUARK_DIR) set(QUARK_quark_LIBRARY "QUARK_quark_LIBRARY-NOTFOUND") find_library(QUARK_quark_LIBRARY - NAMES quark - HINTS ${QUARK_LIBDIR}) -else() - if(QUARK_DIR) - set(QUARK_quark_LIBRARY "QUARK_quark_LIBRARY-NOTFOUND") - find_library(QUARK_quark_LIBRARY - NAMES quark - HINTS ${QUARK_DIR} - PATH_SUFFIXES lib lib32 lib64) - else() - set(QUARK_quark_LIBRARY "QUARK_quark_LIBRARY-NOTFOUND") - find_library(QUARK_quark_LIBRARY - NAMES quark - HINTS ${_lib_env}) - endif() + NAMES quark + HINTS ${QUARK_DIR} + PATH_SUFFIXES lib lib32 lib64) + else() + set(QUARK_quark_LIBRARY "QUARK_quark_LIBRARY-NOTFOUND") + find_library(QUARK_quark_LIBRARY + NAMES quark + HINTS ${_lib_env}) + endif() endif() mark_as_advanced(QUARK_quark_LIBRARY) # If found, add path to cmake variable # ------------------------------------ if (QUARK_quark_LIBRARY) - get_filename_component(quark_lib_path "${QUARK_quark_LIBRARY}" PATH) - # set cmake variables - set(QUARK_LIBRARIES "${QUARK_quark_LIBRARY}") - set(QUARK_LIBRARY_DIRS "${quark_lib_path}") + get_filename_component(quark_lib_path "${QUARK_quark_LIBRARY}" PATH) + # set cmake variables + set(QUARK_LIBRARIES "${QUARK_quark_LIBRARY}") + set(QUARK_LIBRARY_DIRS "${quark_lib_path}") else () - set(QUARK_LIBRARIES "QUARK_LIBRARIES-NOTFOUND") - set(QUARK_LIBRARY_DIRS "QUARK_LIBRARY_DIRS-NOTFOUND") - if(NOT QUARK_FIND_QUIETLY) - message(STATUS "Looking for quark -- lib quark not found") - endif() + set(QUARK_LIBRARIES "QUARK_LIBRARIES-NOTFOUND") + set(QUARK_LIBRARY_DIRS "QUARK_LIBRARY_DIRS-NOTFOUND") + if(NOT QUARK_FIND_QUIETLY) + message(STATUS "Looking for quark -- lib quark not found") + endif() endif () # check a function to validate the find if(QUARK_LIBRARIES) - set(REQUIRED_INCDIRS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) + set(REQUIRED_INCDIRS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) - # QUARK - if (QUARK_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${QUARK_INCLUDE_DIRS}") - endif() - if (QUARK_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${QUARK_LIBRARY_DIRS}") + # QUARK + if (QUARK_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${QUARK_INCLUDE_DIRS}") + endif() + if (QUARK_LIBRARY_DIRS) + set(REQUIRED_LIBDIRS "${QUARK_LIBRARY_DIRS}") + endif() + set(REQUIRED_LIBS "${QUARK_LIBRARIES}") + # HWLOC + if (HWLOC_FOUND AND QUARK_LOOK_FOR_HWLOC) + if (HWLOC_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${HWLOC_INCLUDE_DIRS}") endif() - set(REQUIRED_LIBS "${QUARK_LIBRARIES}") - # HWLOC - if (HWLOC_FOUND AND QUARK_LOOK_FOR_HWLOC) - if (HWLOC_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${HWLOC_INCLUDE_DIRS}") - endif() - if (HWLOC_LIBRARY_DIRS) - list(APPEND REQUIRED_LIBDIRS "${HWLOC_LIBRARY_DIRS}") - endif() - foreach(lib ${HWLOC_LIBRARIES}) - if (EXISTS ${lib} OR ${lib} MATCHES "^-") - list(APPEND REQUIRED_LIBS "${lib}") - else() - list(APPEND REQUIRED_LIBS "-l${lib}") - endif() - endforeach() + if (HWLOC_LIBRARY_DIRS) + list(APPEND REQUIRED_LIBDIRS "${HWLOC_LIBRARY_DIRS}") endif() - # THREADS - list(APPEND REQUIRED_LIBS "${CMAKE_THREAD_LIBS_INIT}") - - # set required libraries for link - set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") - set(CMAKE_REQUIRED_LIBRARIES) - foreach(lib_dir ${REQUIRED_LIBDIRS}) - list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}") + foreach(lib ${HWLOC_LIBRARIES}) + if (EXISTS ${lib} OR ${lib} MATCHES "^-") + list(APPEND REQUIRED_LIBS "${lib}") + else() + list(APPEND REQUIRED_LIBS "-l${lib}") + endif() endforeach() - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + endif() + # THREADS + list(APPEND REQUIRED_LIBS "${CMAKE_THREAD_LIBS_INIT}") - # test link - unset(QUARK_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(QUARK_New QUARK_WORKS) - mark_as_advanced(QUARK_WORKS) + # set required libraries for link + set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") + set(CMAKE_REQUIRED_LIBRARIES) + foreach(lib_dir ${REQUIRED_LIBDIRS}) + list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}") + endforeach() + list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") + string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - if(QUARK_WORKS) - # save link with dependencies - set(QUARK_LIBRARIES_DEP "${REQUIRED_LIBS}") - set(QUARK_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}") - set(QUARK_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") - list(REMOVE_DUPLICATES QUARK_LIBRARY_DIRS_DEP) - list(REMOVE_DUPLICATES QUARK_INCLUDE_DIRS_DEP) - else() - if(NOT QUARK_FIND_QUIETLY) - message(STATUS "Looking for QUARK : test of QUARK_New with QUARK library fails") - message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") - message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") - message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") - message(STATUS "Maybe QUARK is linked with specific libraries like. " - "Have you tried with COMPONENTS (HWLOC)? See the explanation in FindQUARK.cmake.") - endif() + # test link + unset(QUARK_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(QUARK_New QUARK_WORKS) + mark_as_advanced(QUARK_WORKS) + + if(QUARK_WORKS) + # save link with dependencies + set(QUARK_LIBRARIES_DEP "${REQUIRED_LIBS}") + set(QUARK_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}") + set(QUARK_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") + list(REMOVE_DUPLICATES QUARK_LIBRARY_DIRS_DEP) + list(REMOVE_DUPLICATES QUARK_INCLUDE_DIRS_DEP) + else() + if(NOT QUARK_FIND_QUIETLY) + message(STATUS "Looking for QUARK : test of QUARK_New with QUARK library fails") + message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") + message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") + message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") + message(STATUS "Maybe QUARK is linked with specific libraries like. " + "Have you tried with COMPONENTS (HWLOC)? See the explanation in FindQUARK.cmake.") endif() - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_LIBRARIES) + endif() + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) endif(QUARK_LIBRARIES) if (QUARK_LIBRARIES) - 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_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of QUARK library" FORCE) - else() - set(QUARK_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of QUARK library" FORCE) - endif() + 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_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of QUARK library" FORCE) + else() + set(QUARK_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of QUARK library" FORCE) + endif() endif() mark_as_advanced(QUARK_DIR) mark_as_advanced(QUARK_DIR_FOUND) @@ -321,5 +321,5 @@ mark_as_advanced(QUARK_DIR_FOUND) # --------------------------------- include(FindPackageHandleStandardArgs) find_package_handle_standard_args(QUARK DEFAULT_MSG - QUARK_LIBRARIES - QUARK_WORKS) + QUARK_LIBRARIES + QUARK_WORKS) diff --git a/CMakeModules/morse/find/FindSCALAPACK.cmake b/CMakeModules/morse/find/FindSCALAPACK.cmake index f1e9c8e6ef1046a115cbf09bcd808f3f01a04acf..4f19b1e4048a88fafa2c5bfa51728e35759b5319 100644 --- a/CMakeModules/morse/find/FindSCALAPACK.cmake +++ b/CMakeModules/morse/find/FindSCALAPACK.cmake @@ -56,61 +56,61 @@ # 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}") + # 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() - 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_PLATFORM_IMPLICIT_LINK_DIRECTORIES," - "CMAKE_C_IMPLICIT_LINK_DIRECTORIES)${ColourReset}") - if(_lib_env) - message("${Yellow}${_lib_to_find} has not been found in" - "${_lib_env}${ColourReset}") - endif() - endif() + 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_PLATFORM_IMPLICIT_LINK_DIRECTORIES," + "CMAKE_C_IMPLICIT_LINK_DIRECTORIES)${ColourReset}") + if(_lib_env) + message("${Yellow}${_lib_to_find} has not been found in" + "${_lib_env}${ColourReset}") + 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}") + 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() if (NOT SCALAPACK_FOUND) - 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() + 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() endif (NOT SCALAPACK_FOUND) option(SCALAPACK_VERBOSE "Print some additional information during SCALAPACK libraries detection" OFF) mark_as_advanced(SCALAPACK_VERBOSE) if (BLAS_VERBOSE) - set(SCALAPACK_VERBOSE ON) + set(SCALAPACK_VERBOSE ON) endif () set(_scalapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) 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) set(SCALAPACK_FOUND FALSE) @@ -119,166 +119,166 @@ set(SCALAPACK95_FOUND FALSE) # TODO: move this stuff to separate module macro(Check_Scalapack_Libraries LIBRARIES _prefix _name _flags _list _blaslapack _mpi _threads) -# This macro checks for the existence of the combination of fortran libraries -# given by _list. If the combination is found, this macro checks (using the -# Check_Fortran_Function_Exists macro) whether can link against that library -# combination using the name of a routine given by _name using the linker -# flags given by _flags. If the combination of libraries is found and passes -# the link test, LIBRARIES is set to the list of complete library paths that -# have been found. Otherwise, LIBRARIES is set to FALSE. - -# N.B. _prefix is the prefix applied to the names of all cached variables that -# are generated internally and marked advanced by this macro. - -set(_libraries_work TRUE) -set(${LIBRARIES}) -set(_combined_name) -set(ENV_MKLROOT "$ENV{MKLROOT}") -set(ENV_BLAS_DIR "$ENV{BLAS_DIR}") -set(ENV_BLAS_LIBDIR "$ENV{BLAS_LIBDIR}") -set(ENV_SCALAPACK_DIR "$ENV{SCALAPACK_DIR}") -set(ENV_SCALAPACK_LIBDIR "$ENV{SCALAPACK_LIBDIR}") -if (NOT _libdir) - if (BLAS_LIBDIR) + # This macro checks for the existence of the combination of fortran libraries + # given by _list. If the combination is found, this macro checks (using the + # Check_Fortran_Function_Exists macro) whether can link against that library + # combination using the name of a routine given by _name using the linker + # flags given by _flags. If the combination of libraries is found and passes + # the link test, LIBRARIES is set to the list of complete library paths that + # have been found. Otherwise, LIBRARIES is set to FALSE. + + # N.B. _prefix is the prefix applied to the names of all cached variables that + # are generated internally and marked advanced by this macro. + + set(_libraries_work TRUE) + set(${LIBRARIES}) + set(_combined_name) + set(ENV_MKLROOT "$ENV{MKLROOT}") + set(ENV_BLAS_DIR "$ENV{BLAS_DIR}") + set(ENV_BLAS_LIBDIR "$ENV{BLAS_LIBDIR}") + set(ENV_SCALAPACK_DIR "$ENV{SCALAPACK_DIR}") + set(ENV_SCALAPACK_LIBDIR "$ENV{SCALAPACK_LIBDIR}") + if (NOT _libdir) + if (BLAS_LIBDIR) list(APPEND _libdir "${BLAS_LIBDIR}") - elseif (BLAS_DIR) + elseif (BLAS_DIR) list(APPEND _libdir "${BLAS_DIR}") list(APPEND _libdir "${BLAS_DIR}/lib") if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") - list(APPEND _libdir "${BLAS_DIR}/lib64") - list(APPEND _libdir "${BLAS_DIR}/lib/intel64") + list(APPEND _libdir "${BLAS_DIR}/lib64") + list(APPEND _libdir "${BLAS_DIR}/lib/intel64") else() - list(APPEND _libdir "${BLAS_DIR}/lib32") - list(APPEND _libdir "${BLAS_DIR}/lib/ia32") + list(APPEND _libdir "${BLAS_DIR}/lib32") + list(APPEND _libdir "${BLAS_DIR}/lib/ia32") endif() - elseif(ENV_BLAS_LIBDIR) + elseif(ENV_BLAS_LIBDIR) list(APPEND _libdir "${ENV_BLAS_LIBDIR}") - elseif(ENV_BLAS_DIR) + elseif(ENV_BLAS_DIR) list(APPEND _libdir "${ENV_BLAS_DIR}") list(APPEND _libdir "${ENV_BLAS_DIR}/lib") if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") - list(APPEND _libdir "${ENV_BLAS_DIR}/lib64") - list(APPEND _libdir "${ENV_BLAS_DIR}/lib/intel64") + list(APPEND _libdir "${ENV_BLAS_DIR}/lib64") + list(APPEND _libdir "${ENV_BLAS_DIR}/lib/intel64") else() - list(APPEND _libdir "${ENV_BLAS_DIR}/lib32") - list(APPEND _libdir "${ENV_BLAS_DIR}/lib/ia32") + list(APPEND _libdir "${ENV_BLAS_DIR}/lib32") + list(APPEND _libdir "${ENV_BLAS_DIR}/lib/ia32") endif() - endif() - if (SCALAPACK_LIBDIR) - list(APPEND _libdir "${SCALAPACK_LIBDIR}") - elseif (SCALAPACK_DIR) - list(APPEND _libdir "${SCALAPACK_DIR}") - list(APPEND _libdir "${SCALAPACK_DIR}/lib") - if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") - list(APPEND _libdir "${SCALAPACK_DIR}/lib64") - list(APPEND _libdir "${SCALAPACK_DIR}/lib/intel64") - else() - list(APPEND _libdir "${SCALAPACK_DIR}/lib32") - list(APPEND _libdir "${SCALAPACK_DIR}/lib/ia32") endif() - elseif(ENV_SCALAPACK_LIBDIR) + if (SCALAPACK_LIBDIR) + list(APPEND _libdir "${SCALAPACK_LIBDIR}") + elseif (SCALAPACK_DIR) + list(APPEND _libdir "${SCALAPACK_DIR}") + list(APPEND _libdir "${SCALAPACK_DIR}/lib") + if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") + list(APPEND _libdir "${SCALAPACK_DIR}/lib64") + list(APPEND _libdir "${SCALAPACK_DIR}/lib/intel64") + else() + list(APPEND _libdir "${SCALAPACK_DIR}/lib32") + list(APPEND _libdir "${SCALAPACK_DIR}/lib/ia32") + endif() + elseif(ENV_SCALAPACK_LIBDIR) list(APPEND _libdir "${ENV_SCALAPACK_LIBDIR}") - elseif(ENV_SCALAPACK_DIR) + elseif(ENV_SCALAPACK_DIR) list(APPEND _libdir "${ENV_SCALAPACK_DIR}") list(APPEND _libdir "${ENV_SCALAPACK_DIR}/lib") if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") - list(APPEND _libdir "${ENV_SCALAPACK_DIR}/lib64") - list(APPEND _libdir "${ENV_SCALAPACK_DIR}/lib/intel64") + list(APPEND _libdir "${ENV_SCALAPACK_DIR}/lib64") + list(APPEND _libdir "${ENV_SCALAPACK_DIR}/lib/intel64") else() - list(APPEND _libdir "${ENV_SCALAPACK_DIR}/lib32") - list(APPEND _libdir "${ENV_SCALAPACK_DIR}/lib/ia32") + list(APPEND _libdir "${ENV_SCALAPACK_DIR}/lib32") + list(APPEND _libdir "${ENV_SCALAPACK_DIR}/lib/ia32") endif() - else() - if (ENV_MKLROOT) - list(APPEND _libdir "${ENV_MKLROOT}/lib") - if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") - list(APPEND _libdir "${ENV_MKLROOT}/lib64") - list(APPEND _libdir "${ENV_MKLROOT}/lib/intel64") - else() - list(APPEND _libdir "${ENV_MKLROOT}/lib32") - list(APPEND _libdir "${ENV_MKLROOT}/lib/ia32") - endif() - endif() - if (WIN32) - string(REPLACE ":" ";" _libdir2 "$ENV{LIB}") - elseif (APPLE) - string(REPLACE ":" ";" _libdir2 "$ENV{DYLD_LIBRARY_PATH}") - else () - string(REPLACE ":" ";" _libdir2 "$ENV{LD_LIBRARY_PATH}") + else() + if (ENV_MKLROOT) + list(APPEND _libdir "${ENV_MKLROOT}/lib") + if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") + list(APPEND _libdir "${ENV_MKLROOT}/lib64") + list(APPEND _libdir "${ENV_MKLROOT}/lib/intel64") + else() + list(APPEND _libdir "${ENV_MKLROOT}/lib32") + list(APPEND _libdir "${ENV_MKLROOT}/lib/ia32") + endif() + endif() + if (WIN32) + string(REPLACE ":" ";" _libdir2 "$ENV{LIB}") + elseif (APPLE) + 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 () - list(APPEND _libdir "${_libdir2}") - list(APPEND _libdir "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") - list(APPEND _libdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") endif () -endif () -if (SCALAPACK_VERBOSE) + if (SCALAPACK_VERBOSE) message("${Cyan}Try to find SCALAPACK libraries: ${_list}") -endif () + endif () -foreach(_library ${_list}) - set(_combined_name ${_combined_name}_${_library}) + foreach(_library ${_list}) + set(_combined_name ${_combined_name}_${_library}) + + if(_libraries_work) + if (BLA_STATIC) + if (WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) + endif ( WIN32 ) + if (APPLE) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) + else (APPLE) + set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + endif (APPLE) + else (BLA_STATIC) + if (CMAKE_SYSTEM_NAME STREQUAL "Linux") + # for ubuntu's libblas3gf and libscalapack3gf packages + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf) + endif () + endif (BLA_STATIC) + find_library(${_prefix}_${_library}_LIBRARY + NAMES ${_library} + HINTS ${_libdir} + ) + mark_as_advanced(${_prefix}_${_library}_LIBRARY) + # Print status if not found + # ------------------------- + if (NOT ${_prefix}_${_library}_LIBRARY AND NOT SCALAPACK_FIND_QUIETLY AND SCALAPACK_VERBOSE) + Print_Find_Library_Blas_Status(scalapack ${_library} ${_libdir}) + endif () + set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) + set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) + endif(_libraries_work) + endforeach(_library ${_list}) if(_libraries_work) - if (BLA_STATIC) - if (WIN32) - set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) - endif ( WIN32 ) - if (APPLE) - set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) - else (APPLE) - set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) - endif (APPLE) - else (BLA_STATIC) - if (CMAKE_SYSTEM_NAME STREQUAL "Linux") - # for ubuntu's libblas3gf and libscalapack3gf packages - set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf) - endif () - endif (BLA_STATIC) - find_library(${_prefix}_${_library}_LIBRARY - NAMES ${_library} - HINTS ${_libdir} - ) - mark_as_advanced(${_prefix}_${_library}_LIBRARY) - # Print status if not found - # ------------------------- - if (NOT ${_prefix}_${_library}_LIBRARY AND NOT SCALAPACK_FIND_QUIETLY AND SCALAPACK_VERBOSE) - Print_Find_Library_Blas_Status(scalapack ${_library} ${_libdir}) + # Test this combination of libraries. + if(UNIX AND BLA_STATIC) + set(CMAKE_REQUIRED_LIBRARIES ${_flags} "-Wl,--start-group" ${${LIBRARIES}} ${_blaslapack} "-Wl,--end-group" ${_mpi} ${_threads}) + else(UNIX AND BLA_STATIC) + set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blaslapack} ${_mpi} ${_threads}) + endif(UNIX AND BLA_STATIC) + if (SCALAPACK_VERBOSE) + message("${Cyan}SCALAPACK libs found. Try to compile symbol ${_name} with" + "following libraries: ${CMAKE_REQUIRED_LIBRARIES}") endif () - set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) - set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) + if(NOT SCALAPACK_FOUND) + unset(${_prefix}${_combined_name}_WORKS CACHE) + endif() + if (NOT _LANGUAGES_ MATCHES Fortran) + check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS) + else (NOT _LANGUAGES_ MATCHES Fortran) + check_fortran_function_exists(${_name} ${_prefix}${_combined_name}_WORKS) + endif (NOT _LANGUAGES_ MATCHES Fortran) + set(CMAKE_REQUIRED_LIBRARIES) + mark_as_advanced(${_prefix}${_combined_name}_WORKS) + set(_libraries_work ${${_prefix}${_combined_name}_WORKS}) endif(_libraries_work) -endforeach(_library ${_list}) - -if(_libraries_work) - # Test this combination of libraries. - if(UNIX AND BLA_STATIC) - set(CMAKE_REQUIRED_LIBRARIES ${_flags} "-Wl,--start-group" ${${LIBRARIES}} ${_blaslapack} "-Wl,--end-group" ${_mpi} ${_threads}) - else(UNIX AND BLA_STATIC) - set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blaslapack} ${_mpi} ${_threads}) - endif(UNIX AND BLA_STATIC) - if (SCALAPACK_VERBOSE) - message("${Cyan}SCALAPACK libs found. Try to compile symbol ${_name} with" - "following libraries: ${CMAKE_REQUIRED_LIBRARIES}") - endif () - if(NOT SCALAPACK_FOUND) - unset(${_prefix}${_combined_name}_WORKS CACHE) - endif() - if (NOT _LANGUAGES_ MATCHES Fortran) - check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS) - else (NOT _LANGUAGES_ MATCHES Fortran) - check_fortran_function_exists(${_name} ${_prefix}${_combined_name}_WORKS) - endif (NOT _LANGUAGES_ MATCHES Fortran) - set(CMAKE_REQUIRED_LIBRARIES) - mark_as_advanced(${_prefix}${_combined_name}_WORKS) - set(_libraries_work ${${_prefix}${_combined_name}_WORKS}) -endif(_libraries_work) - - if(_libraries_work) - set(${LIBRARIES} ${${LIBRARIES}} ${_blaslapack} ${_mpi} ${_threads}) - else(_libraries_work) + + if(_libraries_work) + set(${LIBRARIES} ${${LIBRARIES}} ${_blaslapack} ${_mpi} ${_threads}) + else(_libraries_work) set(${LIBRARIES} FALSE) - endif(_libraries_work) + endif(_libraries_work) endmacro(Check_Scalapack_Libraries) @@ -288,27 +288,27 @@ set(SCALAPACK_LIBRARIES) set(SCALAPACK95_LIBRARIES) if (NOT BLAS_FOUND) - if(SCALAPACK_FIND_QUIETLY OR NOT SCALAPACK_FIND_REQUIRED) - find_package(BLASEXT) - else() - find_package(BLASEXT REQUIRED) - endif() + if(SCALAPACK_FIND_QUIETLY OR NOT SCALAPACK_FIND_REQUIRED) + find_package(BLASEXT) + else() + find_package(BLASEXT REQUIRED) + endif() endif () if (NOT LAPACK_FOUND) - if(SCALAPACK_FIND_QUIETLY OR NOT SCALAPACK_FIND_REQUIRED) - find_package(LAPACKEXT) - else() - find_package(LAPACKEXT REQUIRED) - endif() + if(SCALAPACK_FIND_QUIETLY OR NOT SCALAPACK_FIND_REQUIRED) + find_package(LAPACKEXT) + else() + find_package(LAPACKEXT REQUIRED) + endif() endif () if (NOT MPI_FOUND) - if(SCALAPACK_FIND_QUIETLY OR NOT SCALAPACK_FIND_REQUIRED) - find_package(MPI) - else() - find_package(MPI REQUIRED) - endif() + if(SCALAPACK_FIND_QUIETLY OR NOT SCALAPACK_FIND_REQUIRED) + find_package(MPI) + else() + find_package(MPI REQUIRED) + endif() endif () if(BLAS_FOUND AND LAPACK_FOUND AND MPI_FOUND) @@ -322,168 +322,168 @@ if(BLAS_FOUND AND LAPACK_FOUND AND MPI_FOUND) endif(NOT BLA_VENDOR) endif ($ENV{BLA_VENDOR} MATCHES ".+") -# Generic SCALAPACK library -if (BLA_VENDOR STREQUAL "Generic" OR - BLA_VENDOR STREQUAL "All") - if ( NOT SCALAPACK_LIBRARIES ) - check_scalapack_libraries( - SCALAPACK_LIBRARIES - SCALAPACK - pdgemm - "" - "scalapack" # scalapack lib to look for - "${LAPACK_LIBRARIES};${BLAS_LIBRARIES}" # blas and lapack libs - "${MPI_Fortran_LIBRARIES}" # mpi libs - "" # threads libs - ) - endif ( NOT SCALAPACK_LIBRARIES ) -endif () -#intel scalapack -if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") - if (UNIX AND NOT WIN32) - find_library(M_LIBRARY NAMES m) - mark_as_advanced(M_LIBRARY) - if(M_LIBRARY) - set(LM "-lm") - else() - set(LM "") - endif() + # Generic SCALAPACK library + if (BLA_VENDOR STREQUAL "Generic" OR + BLA_VENDOR STREQUAL "All") + if ( NOT SCALAPACK_LIBRARIES ) + check_scalapack_libraries( + SCALAPACK_LIBRARIES + SCALAPACK + pdgemm + "" + "scalapack" # scalapack lib to look for + "${LAPACK_LIBRARIES};${BLAS_LIBRARIES}" # blas and lapack libs + "${MPI_Fortran_LIBRARIES}" # mpi libs + "" # threads libs + ) + endif ( NOT SCALAPACK_LIBRARIES ) endif () - if (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX) - if(SCALAPACK_FIND_QUIETLY OR NOT SCALAPACK_FIND_REQUIRED) - find_PACKAGE(Threads) - else() - find_package(Threads REQUIRED) - endif() + #intel scalapack + if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") + if (UNIX AND NOT WIN32) + find_library(M_LIBRARY NAMES m) + mark_as_advanced(M_LIBRARY) + if(M_LIBRARY) + set(LM "-lm") + else() + set(LM "") + endif() + endif () + if (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX) + if(SCALAPACK_FIND_QUIETLY OR NOT SCALAPACK_FIND_REQUIRED) + find_PACKAGE(Threads) + else() + find_package(Threads REQUIRED) + endif() - set(SCALAPACK_SEARCH_LIBS "") + set(SCALAPACK_SEARCH_LIBS "") - if (BLA_F95) - set(SCALAPACK_mkl_SEARCH_SYMBOL "PDGEMM") - set(_LIBRARIES SCALAPACK95_LIBRARIES) - set(_BLAS_LIBRARIES ${BLAS95_LIBRARIES}) - list(APPEND SCALAPACK_SEARCH_LIBS "mkl_scalapack_lp64") - else() - set(SCALAPACK_mkl_SEARCH_SYMBOL "pdgemm") - set(_LIBRARIES SCALAPACK_LIBRARIES) - set(_BLAS_LIBRARIES ${BLAS_LIBRARIES}) - list(APPEND SCALAPACK_SEARCH_LIBS "mkl_scalapack_lp64") - endif() + if (BLA_F95) + set(SCALAPACK_mkl_SEARCH_SYMBOL "PDGEMM") + set(_LIBRARIES SCALAPACK95_LIBRARIES) + set(_BLAS_LIBRARIES ${BLAS95_LIBRARIES}) + list(APPEND SCALAPACK_SEARCH_LIBS "mkl_scalapack_lp64") + else() + set(SCALAPACK_mkl_SEARCH_SYMBOL "pdgemm") + set(_LIBRARIES SCALAPACK_LIBRARIES) + set(_BLAS_LIBRARIES ${BLAS_LIBRARIES}) + list(APPEND SCALAPACK_SEARCH_LIBS "mkl_scalapack_lp64") + endif() - # First try empty scalapack libs - if (NOT ${_LIBRARIES}) - check_scalapack_libraries( - ${_LIBRARIES} - BLAS - ${SCALAPACK_mkl_SEARCH_SYMBOL} - "" - "" - "${_BLAS_LIBRARIES}" - "mkl_blacs_intelmpi_lp64" - "${MPI_Fortran_LIBRARIES}" - ) - endif () - # Then try the search libs - foreach (IT ${SCALAPACK_SEARCH_LIBS}) + # First try empty scalapack libs if (NOT ${_LIBRARIES}) - check_scalapack_libraries( - ${_LIBRARIES} - BLAS - ${SCALAPACK_mkl_SEARCH_SYMBOL} - "" - "${IT}" - "${_BLAS_LIBRARIES}" - "mkl_blacs_intelmpi_lp64" - "${MPI_Fortran_LIBRARIES}" - ) + check_scalapack_libraries( + ${_LIBRARIES} + BLAS + ${SCALAPACK_mkl_SEARCH_SYMBOL} + "" + "" + "${_BLAS_LIBRARIES};mkl_blacs_intelmpi_lp64" + "" + "${MPI_Fortran_LIBRARIES}" + ) endif () - endforeach () - endif () -endif() + # Then try the search libs + foreach (IT ${SCALAPACK_SEARCH_LIBS}) + if (NOT ${_LIBRARIES}) + check_scalapack_libraries( + ${_LIBRARIES} + BLAS + ${SCALAPACK_mkl_SEARCH_SYMBOL} + "" + "${IT}" + "${_BLAS_LIBRARIES};mkl_blacs_intelmpi_lp64" + "" + "${MPI_Fortran_LIBRARIES}" + ) + endif () + endforeach () + endif () + endif() else(BLAS_FOUND AND LAPACK_FOUND AND MPI_FOUND) message(STATUS "SCALAPACK requires BLAS, LAPACK, and MPI") endif(BLAS_FOUND AND LAPACK_FOUND AND MPI_FOUND) if(BLA_F95) - if(SCALAPACK95_LIBRARIES) - set(SCALAPACK95_FOUND TRUE) - else(SCALAPACK95_LIBRARIES) - set(SCALAPACK95_FOUND FALSE) - endif(SCALAPACK95_LIBRARIES) - if(NOT SCALAPACK_FIND_QUIETLY) - if(SCALAPACK95_FOUND) - message(STATUS "A library with SCALAPACK95 API found.") - message(STATUS "SCALAPACK_LIBRARIES ${SCALAPACK_LIBRARIES}") - 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 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." - "\nYou could also specify a BLAS vendor to look for by setting -DBLA_VENDOR=blas_vendor_name." - "\nList of possible BLAS vendor: Goto, ATLAS PhiPACK, CXML, DXML, SunPerf, SCSL, SGIMATH, IBMESSL, Intel10_32 (intel mkl v10 32 bit)," - "Intel10_64lp (intel mkl v10 64 bit, lp thread model, lp64 model), Intel10_64lp_seq (intel mkl v10 64 bit, sequential code, lp64 model)," - "Intel( older versions of mkl 32 and 64 bit), ACML, ACML_MP, ACML_GPU, Apple, NAS, Generic") - if(SCALAPACK_FIND_REQUIRED) - message(FATAL_ERROR - "A required library with SCALAPACK95 API not found. Please specify library location." - ) - else(SCALAPACK_FIND_REQUIRED) - message(STATUS - "A library with SCALAPACK95 API not found. Please specify library location." - ) - endif(SCALAPACK_FIND_REQUIRED) - endif(SCALAPACK95_FOUND) - endif(NOT SCALAPACK_FIND_QUIETLY) - set(SCALAPACK_FOUND "${SCALAPACK95_FOUND}") - set(SCALAPACK_LIBRARIES "${SCALAPACK95_LIBRARIES}") + if(SCALAPACK95_LIBRARIES) + set(SCALAPACK95_FOUND TRUE) + else(SCALAPACK95_LIBRARIES) + set(SCALAPACK95_FOUND FALSE) + endif(SCALAPACK95_LIBRARIES) + if(NOT SCALAPACK_FIND_QUIETLY) + if(SCALAPACK95_FOUND) + message(STATUS "A library with SCALAPACK95 API found.") + message(STATUS "SCALAPACK_LIBRARIES ${SCALAPACK_LIBRARIES}") + 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 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." + "\nYou could also specify a BLAS vendor to look for by setting -DBLA_VENDOR=blas_vendor_name." + "\nList of possible BLAS vendor: Goto, ATLAS PhiPACK, CXML, DXML, SunPerf, SCSL, SGIMATH, IBMESSL, Intel10_32 (intel mkl v10 32 bit)," + "Intel10_64lp (intel mkl v10 64 bit, lp thread model, lp64 model), Intel10_64lp_seq (intel mkl v10 64 bit, sequential code, lp64 model)," + "Intel( older versions of mkl 32 and 64 bit), ACML, ACML_MP, ACML_GPU, Apple, NAS, Generic") + if(SCALAPACK_FIND_REQUIRED) + message(FATAL_ERROR + "A required library with SCALAPACK95 API not found. Please specify library location." + ) + else(SCALAPACK_FIND_REQUIRED) + message(STATUS + "A library with SCALAPACK95 API not found. Please specify library location." + ) + endif(SCALAPACK_FIND_REQUIRED) + endif(SCALAPACK95_FOUND) + endif(NOT SCALAPACK_FIND_QUIETLY) + set(SCALAPACK_FOUND "${SCALAPACK95_FOUND}") + set(SCALAPACK_LIBRARIES "${SCALAPACK95_LIBRARIES}") else(BLA_F95) - if(SCALAPACK_LIBRARIES) - set(SCALAPACK_FOUND TRUE) - else(SCALAPACK_LIBRARIES) - set(SCALAPACK_FOUND FALSE) - endif(SCALAPACK_LIBRARIES) - - if(NOT SCALAPACK_FIND_QUIETLY) - if(SCALAPACK_FOUND) - message(STATUS "A library with SCALAPACK API found.") - message(STATUS "SCALAPACK_LIBRARIES ${SCALAPACK_LIBRARIES}") - 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 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." - "\nYou could also specify a BLAS vendor to look for by setting -DBLA_VENDOR=blas_vendor_name." - "\nList of possible BLAS vendor: Goto, ATLAS PhiPACK, CXML, DXML, SunPerf, SCSL, SGIMATH, IBMESSL, Intel10_32 (intel mkl v10 32 bit)," - "Intel10_64lp (intel mkl v10 64 bit, lp thread model, lp64 model), Intel10_64lp_seq (intel mkl v10 64 bit, sequential code, lp64 model)," - "Intel( older versions of mkl 32 and 64 bit), ACML, ACML_MP, ACML_GPU, Apple, NAS, Generic") - if(SCALAPACK_FIND_REQUIRED) - message(FATAL_ERROR - "A required library with SCALAPACK API not found. Please specify library location." - ) - else(SCALAPACK_FIND_REQUIRED) - message(STATUS - "A library with SCALAPACK API not found. Please specify library location." - ) - endif(SCALAPACK_FIND_REQUIRED) - endif(SCALAPACK_FOUND) - endif(NOT SCALAPACK_FIND_QUIETLY) + if(SCALAPACK_LIBRARIES) + set(SCALAPACK_FOUND TRUE) + else(SCALAPACK_LIBRARIES) + set(SCALAPACK_FOUND FALSE) + endif(SCALAPACK_LIBRARIES) + + if(NOT SCALAPACK_FIND_QUIETLY) + if(SCALAPACK_FOUND) + message(STATUS "A library with SCALAPACK API found.") + message(STATUS "SCALAPACK_LIBRARIES ${SCALAPACK_LIBRARIES}") + 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 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." + "\nYou could also specify a BLAS vendor to look for by setting -DBLA_VENDOR=blas_vendor_name." + "\nList of possible BLAS vendor: Goto, ATLAS PhiPACK, CXML, DXML, SunPerf, SCSL, SGIMATH, IBMESSL, Intel10_32 (intel mkl v10 32 bit)," + "Intel10_64lp (intel mkl v10 64 bit, lp thread model, lp64 model), Intel10_64lp_seq (intel mkl v10 64 bit, sequential code, lp64 model)," + "Intel( older versions of mkl 32 and 64 bit), ACML, ACML_MP, ACML_GPU, Apple, NAS, Generic") + if(SCALAPACK_FIND_REQUIRED) + message(FATAL_ERROR + "A required library with SCALAPACK API not found. Please specify library location." + ) + else(SCALAPACK_FIND_REQUIRED) + message(STATUS + "A library with SCALAPACK API not found. Please specify library location." + ) + endif(SCALAPACK_FIND_REQUIRED) + endif(SCALAPACK_FOUND) + endif(NOT SCALAPACK_FIND_QUIETLY) endif(BLA_F95) set(CMAKE_FIND_LIBRARY_SUFFIXES ${_scalapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) if (SCALAPACK_LIBRARIES) - 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_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of SCALAPACK library" FORCE) - else() - set(SCALAPACK_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of SCALAPACK library" FORCE) - endif() + 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_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of SCALAPACK library" FORCE) + else() + set(SCALAPACK_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of SCALAPACK library" FORCE) + endif() endif() mark_as_advanced(SCALAPACK_DIR) mark_as_advanced(SCALAPACK_DIR_FOUND) diff --git a/CMakeModules/morse/find/FindSCOTCH.cmake b/CMakeModules/morse/find/FindSCOTCH.cmake index b3ea6437eccd0151cd9f7b048b82d4e172499ea9..fd3d1722324503022f1a9d1030b8f1419fc02e16 100644 --- a/CMakeModules/morse/find/FindSCOTCH.cmake +++ b/CMakeModules/morse/find/FindSCOTCH.cmake @@ -52,31 +52,31 @@ # License text for the above reference.) if (NOT SCOTCH_FOUND) - 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() + 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() endif() # Set the version to find set(SCOTCH_LOOK_FOR_ESMUMPS OFF) if( SCOTCH_FIND_COMPONENTS ) - foreach( component ${SCOTCH_FIND_COMPONENTS} ) - if (${component} STREQUAL "ESMUMPS") - # means we look for esmumps library - set(SCOTCH_LOOK_FOR_ESMUMPS ON) - endif() - endforeach() + foreach( component ${SCOTCH_FIND_COMPONENTS} ) + if (${component} STREQUAL "ESMUMPS") + # means we look for esmumps library + set(SCOTCH_LOOK_FOR_ESMUMPS ON) + endif() + endforeach() endif() # SCOTCH may depend on Threads, try to find it if (NOT THREADS_FOUND) - if (SCOTCH_FIND_REQUIRED) - find_package(Threads REQUIRED) - else() - find_package(Threads) - endif() + if (SCOTCH_FIND_REQUIRED) + find_package(Threads REQUIRED) + else() + find_package(Threads) + endif() endif() # Looking for include @@ -88,24 +88,24 @@ unset(_inc_env) set(ENV_SCOTCH_DIR "$ENV{SCOTCH_DIR}") set(ENV_SCOTCH_INCDIR "$ENV{SCOTCH_INCDIR}") if(ENV_SCOTCH_INCDIR) - list(APPEND _inc_env "${ENV_SCOTCH_INCDIR}") + list(APPEND _inc_env "${ENV_SCOTCH_INCDIR}") elseif(ENV_SCOTCH_DIR) - list(APPEND _inc_env "${ENV_SCOTCH_DIR}") - list(APPEND _inc_env "${ENV_SCOTCH_DIR}/include") - list(APPEND _inc_env "${ENV_SCOTCH_DIR}/include/scotch") + list(APPEND _inc_env "${ENV_SCOTCH_DIR}") + list(APPEND _inc_env "${ENV_SCOTCH_DIR}/include") + list(APPEND _inc_env "${ENV_SCOTCH_DIR}/include/scotch") else() - if(WIN32) - string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") - else() - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{CPATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - endif() + if(WIN32) + string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") + else() + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{CPATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + endif() endif() list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") @@ -116,36 +116,36 @@ list(REMOVE_DUPLICATES _inc_env) # ------------------------------------------------- # call cmake macro to find the header path if(SCOTCH_INCDIR) + set(SCOTCH_scotch.h_DIRS "SCOTCH_scotch.h_DIRS-NOTFOUND") + find_path(SCOTCH_scotch.h_DIRS + NAMES scotch.h + HINTS ${SCOTCH_INCDIR}) +else() + if(SCOTCH_DIR) set(SCOTCH_scotch.h_DIRS "SCOTCH_scotch.h_DIRS-NOTFOUND") find_path(SCOTCH_scotch.h_DIRS NAMES scotch.h - HINTS ${SCOTCH_INCDIR}) -else() - if(SCOTCH_DIR) - set(SCOTCH_scotch.h_DIRS "SCOTCH_scotch.h_DIRS-NOTFOUND") - find_path(SCOTCH_scotch.h_DIRS - NAMES scotch.h - HINTS ${SCOTCH_DIR} - PATH_SUFFIXES "include" "include/scotch") - else() - set(SCOTCH_scotch.h_DIRS "SCOTCH_scotch.h_DIRS-NOTFOUND") - find_path(SCOTCH_scotch.h_DIRS - NAMES scotch.h - HINTS ${_inc_env} - PATH_SUFFIXES "scotch") - endif() + HINTS ${SCOTCH_DIR} + PATH_SUFFIXES "include" "include/scotch") + else() + set(SCOTCH_scotch.h_DIRS "SCOTCH_scotch.h_DIRS-NOTFOUND") + find_path(SCOTCH_scotch.h_DIRS + NAMES scotch.h + HINTS ${_inc_env} + PATH_SUFFIXES "scotch") + endif() endif() mark_as_advanced(SCOTCH_scotch.h_DIRS) # If found, add path to cmake variable # ------------------------------------ if (SCOTCH_scotch.h_DIRS) - set(SCOTCH_INCLUDE_DIRS "${SCOTCH_scotch.h_DIRS}") + set(SCOTCH_INCLUDE_DIRS "${SCOTCH_scotch.h_DIRS}") else () - set(SCOTCH_INCLUDE_DIRS "SCOTCH_INCLUDE_DIRS-NOTFOUND") - if (NOT SCOTCH_FIND_QUIETLY) - message(STATUS "Looking for scotch -- scotch.h not found") - endif() + set(SCOTCH_INCLUDE_DIRS "SCOTCH_INCLUDE_DIRS-NOTFOUND") + if (NOT SCOTCH_FIND_QUIETLY) + message(STATUS "Looking for scotch -- scotch.h not found") + endif() endif() @@ -157,22 +157,22 @@ endif() unset(_lib_env) set(ENV_SCOTCH_LIBDIR "$ENV{SCOTCH_LIBDIR}") if(ENV_SCOTCH_LIBDIR) - list(APPEND _lib_env "${ENV_SCOTCH_LIBDIR}") + list(APPEND _lib_env "${ENV_SCOTCH_LIBDIR}") elseif(ENV_SCOTCH_DIR) - list(APPEND _lib_env "${ENV_SCOTCH_DIR}") - list(APPEND _lib_env "${ENV_SCOTCH_DIR}/lib") + list(APPEND _lib_env "${ENV_SCOTCH_DIR}") + list(APPEND _lib_env "${ENV_SCOTCH_DIR}/lib") else() - if(WIN32) - string(REPLACE ":" ";" _lib_env "$ENV{LIB}") + if(WIN32) + string(REPLACE ":" ";" _lib_env "$ENV{LIB}") + else() + if(APPLE) + string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") else() - if(APPLE) - string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") endif() + list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") + list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + endif() endif() list(REMOVE_DUPLICATES _lib_env) @@ -186,29 +186,29 @@ endif() # call cmake macro to find the lib path if(SCOTCH_LIBDIR) + foreach(scotch_lib ${SCOTCH_libs_to_find}) + set(SCOTCH_${scotch_lib}_LIBRARY "SCOTCH_${scotch_lib}_LIBRARY-NOTFOUND") + find_library(SCOTCH_${scotch_lib}_LIBRARY + NAMES ${scotch_lib} + HINTS ${SCOTCH_LIBDIR}) + endforeach() +else() + if(SCOTCH_DIR) foreach(scotch_lib ${SCOTCH_libs_to_find}) - set(SCOTCH_${scotch_lib}_LIBRARY "SCOTCH_${scotch_lib}_LIBRARY-NOTFOUND") - find_library(SCOTCH_${scotch_lib}_LIBRARY - NAMES ${scotch_lib} - HINTS ${SCOTCH_LIBDIR}) + set(SCOTCH_${scotch_lib}_LIBRARY "SCOTCH_${scotch_lib}_LIBRARY-NOTFOUND") + find_library(SCOTCH_${scotch_lib}_LIBRARY + NAMES ${scotch_lib} + HINTS ${SCOTCH_DIR} + PATH_SUFFIXES lib lib32 lib64) endforeach() -else() - if(SCOTCH_DIR) - foreach(scotch_lib ${SCOTCH_libs_to_find}) - set(SCOTCH_${scotch_lib}_LIBRARY "SCOTCH_${scotch_lib}_LIBRARY-NOTFOUND") - find_library(SCOTCH_${scotch_lib}_LIBRARY - NAMES ${scotch_lib} - HINTS ${SCOTCH_DIR} - PATH_SUFFIXES lib lib32 lib64) - endforeach() - else() - foreach(scotch_lib ${SCOTCH_libs_to_find}) - set(SCOTCH_${scotch_lib}_LIBRARY "SCOTCH_${scotch_lib}_LIBRARY-NOTFOUND") - find_library(SCOTCH_${scotch_lib}_LIBRARY - NAMES ${scotch_lib} - HINTS ${_lib_env}) - endforeach() - endif() + else() + foreach(scotch_lib ${SCOTCH_libs_to_find}) + set(SCOTCH_${scotch_lib}_LIBRARY "SCOTCH_${scotch_lib}_LIBRARY-NOTFOUND") + find_library(SCOTCH_${scotch_lib}_LIBRARY + NAMES ${scotch_lib} + HINTS ${_lib_env}) + endforeach() + endif() endif() set(SCOTCH_LIBRARIES "") @@ -217,19 +217,19 @@ set(SCOTCH_LIBRARY_DIRS "") # ------------------------------------ foreach(scotch_lib ${SCOTCH_libs_to_find}) - if (SCOTCH_${scotch_lib}_LIBRARY) - get_filename_component(${scotch_lib}_lib_path "${SCOTCH_${scotch_lib}_LIBRARY}" PATH) - # set cmake variables - list(APPEND SCOTCH_LIBRARIES "${SCOTCH_${scotch_lib}_LIBRARY}") - list(APPEND SCOTCH_LIBRARY_DIRS "${${scotch_lib}_lib_path}") - else () - list(APPEND SCOTCH_LIBRARIES "${SCOTCH_${scotch_lib}_LIBRARY}") - if (NOT SCOTCH_FIND_QUIETLY) - message(STATUS "Looking for scotch -- lib ${scotch_lib} not found") - endif() - endif () + if (SCOTCH_${scotch_lib}_LIBRARY) + get_filename_component(${scotch_lib}_lib_path "${SCOTCH_${scotch_lib}_LIBRARY}" PATH) + # set cmake variables + list(APPEND SCOTCH_LIBRARIES "${SCOTCH_${scotch_lib}_LIBRARY}") + list(APPEND SCOTCH_LIBRARY_DIRS "${${scotch_lib}_lib_path}") + else () + list(APPEND SCOTCH_LIBRARIES "${SCOTCH_${scotch_lib}_LIBRARY}") + if (NOT SCOTCH_FIND_QUIETLY) + message(STATUS "Looking for scotch -- lib ${scotch_lib} not found") + endif() + endif () - mark_as_advanced(SCOTCH_${scotch_lib}_LIBRARY) + mark_as_advanced(SCOTCH_${scotch_lib}_LIBRARY) endforeach() list(REMOVE_DUPLICATES SCOTCH_LIBRARY_DIRS) @@ -237,81 +237,81 @@ list(REMOVE_DUPLICATES SCOTCH_LIBRARY_DIRS) # check a function to validate the find if(SCOTCH_LIBRARIES) - set(REQUIRED_INCDIRS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) + set(REQUIRED_INCDIRS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) - # SCOTCH - if (SCOTCH_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${SCOTCH_INCLUDE_DIRS}") - endif() - if (SCOTCH_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${SCOTCH_LIBRARY_DIRS}") - endif() - set(REQUIRED_LIBS "${SCOTCH_LIBRARIES}") - # THREADS - if(CMAKE_THREAD_LIBS_INIT) - list(APPEND REQUIRED_LIBS "${CMAKE_THREAD_LIBS_INIT}") - endif() - set(Z_LIBRARY "Z_LIBRARY-NOTFOUND") - find_library(Z_LIBRARY NAMES z) - mark_as_advanced(Z_LIBRARY) - if(Z_LIBRARY) - list(APPEND REQUIRED_LIBS "-lz") - endif() - set(M_LIBRARY "M_LIBRARY-NOTFOUND") - find_library(M_LIBRARY NAMES m) - mark_as_advanced(M_LIBRARY) - if(M_LIBRARY) - list(APPEND REQUIRED_LIBS "-lm") - endif() - set(RT_LIBRARY "RT_LIBRARY-NOTFOUND") - find_library(RT_LIBRARY NAMES rt) - mark_as_advanced(RT_LIBRARY) - if(RT_LIBRARY) - list(APPEND REQUIRED_LIBS "-lrt") - endif() + # SCOTCH + if (SCOTCH_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${SCOTCH_INCLUDE_DIRS}") + endif() + if (SCOTCH_LIBRARY_DIRS) + set(REQUIRED_LIBDIRS "${SCOTCH_LIBRARY_DIRS}") + endif() + set(REQUIRED_LIBS "${SCOTCH_LIBRARIES}") + # THREADS + if(CMAKE_THREAD_LIBS_INIT) + list(APPEND REQUIRED_LIBS "${CMAKE_THREAD_LIBS_INIT}") + endif() + set(Z_LIBRARY "Z_LIBRARY-NOTFOUND") + find_library(Z_LIBRARY NAMES z) + mark_as_advanced(Z_LIBRARY) + if(Z_LIBRARY) + list(APPEND REQUIRED_LIBS "-lz") + endif() + set(M_LIBRARY "M_LIBRARY-NOTFOUND") + find_library(M_LIBRARY NAMES m) + mark_as_advanced(M_LIBRARY) + if(M_LIBRARY) + list(APPEND REQUIRED_LIBS "-lm") + endif() + set(RT_LIBRARY "RT_LIBRARY-NOTFOUND") + find_library(RT_LIBRARY NAMES rt) + mark_as_advanced(RT_LIBRARY) + if(RT_LIBRARY) + list(APPEND REQUIRED_LIBS "-lrt") + endif() - # set required libraries for link - set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") - set(CMAKE_REQUIRED_LIBRARIES) - foreach(lib_dir ${REQUIRED_LIBDIRS}) - list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}") - endforeach() - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + # set required libraries for link + set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") + set(CMAKE_REQUIRED_LIBRARIES) + foreach(lib_dir ${REQUIRED_LIBDIRS}) + list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}") + endforeach() + list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") + string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - # test link - unset(SCOTCH_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(SCOTCH_graphInit SCOTCH_WORKS) - mark_as_advanced(SCOTCH_WORKS) + # test link + unset(SCOTCH_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(SCOTCH_graphInit SCOTCH_WORKS) + mark_as_advanced(SCOTCH_WORKS) - if(SCOTCH_WORKS) - # save link with dependencies - set(SCOTCH_LIBRARIES "${REQUIRED_LIBS}") - else() - if(NOT SCOTCH_FIND_QUIETLY) - message(STATUS "Looking for SCOTCH : test of SCOTCH_graphInit with SCOTCH library fails") - message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") - message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") - message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") - endif() + if(SCOTCH_WORKS) + # save link with dependencies + set(SCOTCH_LIBRARIES "${REQUIRED_LIBS}") + else() + if(NOT SCOTCH_FIND_QUIETLY) + message(STATUS "Looking for SCOTCH : test of SCOTCH_graphInit with SCOTCH library fails") + message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") + message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") + message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") endif() - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_LIBRARIES) + endif() + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) endif(SCOTCH_LIBRARIES) if (SCOTCH_LIBRARIES) - 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_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of SCOTCH library" FORCE) - else() - set(SCOTCH_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of SCOTCH library" FORCE) - endif() + 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_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of SCOTCH library" FORCE) + else() + set(SCOTCH_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of SCOTCH library" FORCE) + endif() endif() mark_as_advanced(SCOTCH_DIR) mark_as_advanced(SCOTCH_DIR_FOUND) @@ -362,8 +362,8 @@ set(CMAKE_REQUIRED_INCLUDES "") # --------------------------------- include(FindPackageHandleStandardArgs) find_package_handle_standard_args(SCOTCH DEFAULT_MSG - SCOTCH_LIBRARIES - SCOTCH_WORKS) + SCOTCH_LIBRARIES + SCOTCH_WORKS) # # TODO: Add possibility to check for specific functions in the library # diff --git a/CMakeModules/morse/find/FindSIMGRID.cmake b/CMakeModules/morse/find/FindSIMGRID.cmake index ec7b9695e169b3ae7ef7ad5ce24d9c7779d5c464..89e29823b154a1eabb4accce715a823f217c45bc 100644 --- a/CMakeModules/morse/find/FindSIMGRID.cmake +++ b/CMakeModules/morse/find/FindSIMGRID.cmake @@ -46,10 +46,10 @@ # License text for the above reference.) if (NOT SIMGRID_FOUND) - set(SIMGRID_DIR "" CACHE PATH "Installation directory of SIMGRID library") - if (NOT SIMGRID_FIND_QUIETLY) - message(STATUS "A cache variable, namely SIMGRID_DIR, has been set to specify the install directory of SIMGRID") - endif() + set(SIMGRID_DIR "" CACHE PATH "Installation directory of SIMGRID library") + if (NOT SIMGRID_FIND_QUIETLY) + message(STATUS "A cache variable, namely SIMGRID_DIR, has been set to specify the install directory of SIMGRID") + endif() endif() set(ENV_SIMGRID_DIR "$ENV{SIMGRID_DIR}") @@ -57,7 +57,7 @@ set(ENV_SIMGRID_INCDIR "$ENV{SIMGRID_INCDIR}") set(ENV_SIMGRID_LIBDIR "$ENV{SIMGRID_LIBDIR}") set(SIMGRID_GIVEN_BY_USER "FALSE") if ( SIMGRID_DIR OR ( SIMGRID_INCDIR AND SIMGRID_LIBDIR) OR ENV_SIMGRID_DIR OR (ENV_SIMGRID_INCDIR AND ENV_SIMGRID_LIBDIR) ) - set(SIMGRID_GIVEN_BY_USER "TRUE") + set(SIMGRID_GIVEN_BY_USER "TRUE") endif() # Optionally use pkg-config to detect include/library dirs (if pkg-config is available) @@ -66,233 +66,233 @@ include(FindPkgConfig) find_package(PkgConfig QUIET) if(PKG_CONFIG_EXECUTABLE AND NOT SIMGRID_GIVEN_BY_USER) - pkg_search_module(SIMGRID simgrid) - if (NOT SIMGRID_FIND_QUIETLY) - if (SIMGRID_FOUND AND SIMGRID_LIBRARIES) - message(STATUS "Looking for SIMGRID - found using PkgConfig") - #if(NOT SIMGRID_INCLUDE_DIRS) - # message("${Magenta}SIMGRID_INCLUDE_DIRS is empty using PkgConfig." - # "Perhaps the path to simgrid headers is already present in your" - # "C(PLUS)_INCLUDE_PATH environment variable.${ColourReset}") - #endif() - else() - message(STATUS "${Magenta}Looking for SIMGRID - not found using PkgConfig." - "\n Perhaps you should add the directory containing simgrid.pc to the" - "\n PKG_CONFIG_PATH environment variable.${ColourReset}") - endif() + pkg_search_module(SIMGRID simgrid) + if (NOT SIMGRID_FIND_QUIETLY) + if (SIMGRID_FOUND AND SIMGRID_LIBRARIES) + message(STATUS "Looking for SIMGRID - found using PkgConfig") + #if(NOT SIMGRID_INCLUDE_DIRS) + # message("${Magenta}SIMGRID_INCLUDE_DIRS is empty using PkgConfig." + # "Perhaps the path to simgrid headers is already present in your" + # "C(PLUS)_INCLUDE_PATH environment variable.${ColourReset}") + #endif() + else() + message(STATUS "${Magenta}Looking for SIMGRID - not found using PkgConfig." + "\n Perhaps you should add the directory containing simgrid.pc to the" + "\n PKG_CONFIG_PATH environment variable.${ColourReset}") endif() + endif() endif(PKG_CONFIG_EXECUTABLE AND NOT SIMGRID_GIVEN_BY_USER) if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT SIMGRID_FOUND) OR (SIMGRID_GIVEN_BY_USER) ) - if (NOT SIMGRID_FIND_QUIETLY) - message(STATUS "Looking for SIMGRID - PkgConfig not used") - endif() + if (NOT SIMGRID_FIND_QUIETLY) + message(STATUS "Looking for SIMGRID - PkgConfig not used") + endif() - # Looking for include - # ------------------- + # Looking for include + # ------------------- - # Add system include paths to search include - # ------------------------------------------ - unset(_inc_env) - set(ENV_SIMGRID_DIR "$ENV{SIMGRID_DIR}") - set(ENV_SIMGRID_INCDIR "$ENV{SIMGRID_INCDIR}") - if(ENV_SIMGRID_INCDIR) - list(APPEND _inc_env "${ENV_SIMGRID_INCDIR}") - elseif(ENV_SIMGRID_DIR) - list(APPEND _inc_env "${ENV_SIMGRID_DIR}") - list(APPEND _inc_env "${ENV_SIMGRID_DIR}/include") - list(APPEND _inc_env "${ENV_SIMGRID_DIR}/include/simgrid") + # Add system include paths to search include + # ------------------------------------------ + unset(_inc_env) + set(ENV_SIMGRID_DIR "$ENV{SIMGRID_DIR}") + set(ENV_SIMGRID_INCDIR "$ENV{SIMGRID_INCDIR}") + if(ENV_SIMGRID_INCDIR) + list(APPEND _inc_env "${ENV_SIMGRID_INCDIR}") + elseif(ENV_SIMGRID_DIR) + list(APPEND _inc_env "${ENV_SIMGRID_DIR}") + list(APPEND _inc_env "${ENV_SIMGRID_DIR}/include") + list(APPEND _inc_env "${ENV_SIMGRID_DIR}/include/simgrid") + else() + if(WIN32) + string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") else() - if(WIN32) - string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") - else() - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{CPATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - endif() + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{CPATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") endif() - list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") - list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") - list(REMOVE_DUPLICATES _inc_env) + endif() + list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") + list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") + list(REMOVE_DUPLICATES _inc_env) - # Try to find the simgrid header in the given paths - # ------------------------------------------------- - # call cmake macro to find the header path - if(SIMGRID_INCDIR) - set(SIMGRID_simgrid.h_DIRS "SIMGRID_simgrid.h_DIRS-NOTFOUND") - find_path(SIMGRID_simgrid.h_DIRS - NAMES simgrid.h - HINTS ${SIMGRID_INCDIR}) + # Try to find the simgrid header in the given paths + # ------------------------------------------------- + # call cmake macro to find the header path + if(SIMGRID_INCDIR) + set(SIMGRID_simgrid.h_DIRS "SIMGRID_simgrid.h_DIRS-NOTFOUND") + find_path(SIMGRID_simgrid.h_DIRS + NAMES simgrid.h + HINTS ${SIMGRID_INCDIR}) + else() + if(SIMGRID_DIR) + set(SIMGRID_simgrid.h_DIRS "SIMGRID_simgrid.h_DIRS-NOTFOUND") + find_path(SIMGRID_simgrid.h_DIRS + NAMES simgrid.h + HINTS ${SIMGRID_DIR} + PATH_SUFFIXES "include" "include/simgrid") else() - if(SIMGRID_DIR) - set(SIMGRID_simgrid.h_DIRS "SIMGRID_simgrid.h_DIRS-NOTFOUND") - find_path(SIMGRID_simgrid.h_DIRS - NAMES simgrid.h - HINTS ${SIMGRID_DIR} - PATH_SUFFIXES "include" "include/simgrid") - else() - set(SIMGRID_simgrid.h_DIRS "SIMGRID_simgrid.h_DIRS-NOTFOUND") - find_path(SIMGRID_simgrid.h_DIRS - NAMES simgrid.h - HINTS ${_inc_env} - PATH_SUFFIXES "simgrid") - endif() + set(SIMGRID_simgrid.h_DIRS "SIMGRID_simgrid.h_DIRS-NOTFOUND") + find_path(SIMGRID_simgrid.h_DIRS + NAMES simgrid.h + HINTS ${_inc_env} + PATH_SUFFIXES "simgrid") endif() - mark_as_advanced(SIMGRID_simgrid.h_DIRS) + endif() + mark_as_advanced(SIMGRID_simgrid.h_DIRS) - # Add path to cmake variable - # ------------------------------------ - if (SIMGRID_simgrid.h_DIRS) - set(SIMGRID_INCLUDE_DIRS "${SIMGRID_simgrid.h_DIRS}") - else () - set(SIMGRID_INCLUDE_DIRS "SIMGRID_INCLUDE_DIRS-NOTFOUND") - if(NOT SIMGRID_FIND_QUIETLY) - message(STATUS "Looking for simgrid -- simgrid.h not found") - endif() - endif () + # Add path to cmake variable + # ------------------------------------ + if (SIMGRID_simgrid.h_DIRS) + set(SIMGRID_INCLUDE_DIRS "${SIMGRID_simgrid.h_DIRS}") + else () + set(SIMGRID_INCLUDE_DIRS "SIMGRID_INCLUDE_DIRS-NOTFOUND") + if(NOT SIMGRID_FIND_QUIETLY) + message(STATUS "Looking for simgrid -- simgrid.h not found") + endif() + endif () - if (SIMGRID_INCLUDE_DIRS) - list(REMOVE_DUPLICATES SIMGRID_INCLUDE_DIRS) - endif () + if (SIMGRID_INCLUDE_DIRS) + list(REMOVE_DUPLICATES SIMGRID_INCLUDE_DIRS) + endif () - # Looking for lib - # --------------- + # Looking for lib + # --------------- - # Add system library paths to search lib - # -------------------------------------- - unset(_lib_env) - set(ENV_SIMGRID_LIBDIR "$ENV{SIMGRID_LIBDIR}") - if(ENV_SIMGRID_LIBDIR) - list(APPEND _lib_env "${ENV_SIMGRID_LIBDIR}") - elseif(ENV_SIMGRID_DIR) - list(APPEND _lib_env "${ENV_SIMGRID_DIR}") - list(APPEND _lib_env "${ENV_SIMGRID_DIR}/lib") + # Add system library paths to search lib + # -------------------------------------- + unset(_lib_env) + set(ENV_SIMGRID_LIBDIR "$ENV{SIMGRID_LIBDIR}") + if(ENV_SIMGRID_LIBDIR) + list(APPEND _lib_env "${ENV_SIMGRID_LIBDIR}") + elseif(ENV_SIMGRID_DIR) + list(APPEND _lib_env "${ENV_SIMGRID_DIR}") + list(APPEND _lib_env "${ENV_SIMGRID_DIR}/lib") + else() + if(WIN32) + string(REPLACE ":" ";" _lib_env "$ENV{LIB}") else() - if(WIN32) - string(REPLACE ":" ";" _lib_env "$ENV{LIB}") - else() - if(APPLE) - string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - endif() + if(APPLE) + string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") + else() + string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") + endif() + list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") + list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") endif() - list(REMOVE_DUPLICATES _lib_env) + endif() + list(REMOVE_DUPLICATES _lib_env) - # Try to find the simgrid lib in the given paths - # ---------------------------------------------- + # Try to find the simgrid lib in the given paths + # ---------------------------------------------- - # call cmake macro to find the lib path - if(SIMGRID_LIBDIR) - set(SIMGRID_simgrid_LIBRARY "SIMGRID_simgrid_LIBRARY-NOTFOUND") - find_library(SIMGRID_simgrid_LIBRARY - NAMES simgrid - HINTS ${SIMGRID_LIBDIR}) + # call cmake macro to find the lib path + if(SIMGRID_LIBDIR) + set(SIMGRID_simgrid_LIBRARY "SIMGRID_simgrid_LIBRARY-NOTFOUND") + find_library(SIMGRID_simgrid_LIBRARY + NAMES simgrid + HINTS ${SIMGRID_LIBDIR}) + else() + if(SIMGRID_DIR) + set(SIMGRID_simgrid_LIBRARY "SIMGRID_simgrid_LIBRARY-NOTFOUND") + find_library(SIMGRID_simgrid_LIBRARY + NAMES simgrid + HINTS ${SIMGRID_DIR} + PATH_SUFFIXES lib lib32 lib64) else() - if(SIMGRID_DIR) - set(SIMGRID_simgrid_LIBRARY "SIMGRID_simgrid_LIBRARY-NOTFOUND") - find_library(SIMGRID_simgrid_LIBRARY - NAMES simgrid - HINTS ${SIMGRID_DIR} - PATH_SUFFIXES lib lib32 lib64) - else() - set(SIMGRID_simgrid_LIBRARY "SIMGRID_simgrid_LIBRARY-NOTFOUND") - find_library(SIMGRID_simgrid_LIBRARY - NAMES simgrid - HINTS ${_lib_env}) - endif() + set(SIMGRID_simgrid_LIBRARY "SIMGRID_simgrid_LIBRARY-NOTFOUND") + find_library(SIMGRID_simgrid_LIBRARY + NAMES simgrid + HINTS ${_lib_env}) endif() - mark_as_advanced(SIMGRID_simgrid_LIBRARY) + endif() + mark_as_advanced(SIMGRID_simgrid_LIBRARY) - # If found, add path to cmake variable - # ------------------------------------ - if (SIMGRID_simgrid_LIBRARY) - get_filename_component(simgrid_lib_path ${SIMGRID_simgrid_LIBRARY} PATH) - # set cmake variables (respects naming convention) - set(SIMGRID_LIBRARIES "${SIMGRID_simgrid_LIBRARY}") - set(SIMGRID_LIBRARY_DIRS "${simgrid_lib_path}") - else () - set(SIMGRID_LIBRARIES "SIMGRID_LIBRARIES-NOTFOUND") - set(SIMGRID_LIBRARY_DIRS "SIMGRID_LIBRARY_DIRS-NOTFOUND") - if(NOT SIMGRID_FIND_QUIETLY) - message(STATUS "Looking for simgrid -- lib simgrid not found") - endif() - endif () + # If found, add path to cmake variable + # ------------------------------------ + if (SIMGRID_simgrid_LIBRARY) + get_filename_component(simgrid_lib_path ${SIMGRID_simgrid_LIBRARY} PATH) + # set cmake variables (respects naming convention) + set(SIMGRID_LIBRARIES "${SIMGRID_simgrid_LIBRARY}") + set(SIMGRID_LIBRARY_DIRS "${simgrid_lib_path}") + else () + set(SIMGRID_LIBRARIES "SIMGRID_LIBRARIES-NOTFOUND") + set(SIMGRID_LIBRARY_DIRS "SIMGRID_LIBRARY_DIRS-NOTFOUND") + if(NOT SIMGRID_FIND_QUIETLY) + message(STATUS "Looking for simgrid -- lib simgrid not found") + endif() + endif () - if (SIMGRID_LIBRARY_DIRS) - list(REMOVE_DUPLICATES SIMGRID_LIBRARY_DIRS) - endif () + if (SIMGRID_LIBRARY_DIRS) + list(REMOVE_DUPLICATES SIMGRID_LIBRARY_DIRS) + endif () - # check a function to validate the find - if(SIMGRID_LIBRARIES) + # check a function to validate the find + if(SIMGRID_LIBRARIES) - set(REQUIRED_INCDIRS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) + set(REQUIRED_INCDIRS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) - # SIMGRID - if (SIMGRID_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${SIMGRID_INCLUDE_DIRS}") - endif() - if (SIMGRID_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${SIMGRID_LIBRARY_DIRS}") - endif() - set(REQUIRED_LIBS "${SIMGRID_LIBRARIES}") + # SIMGRID + if (SIMGRID_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${SIMGRID_INCLUDE_DIRS}") + endif() + if (SIMGRID_LIBRARY_DIRS) + set(REQUIRED_LIBDIRS "${SIMGRID_LIBRARY_DIRS}") + endif() + set(REQUIRED_LIBS "${SIMGRID_LIBRARIES}") - # set required libraries for link - set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") - set(CMAKE_REQUIRED_LIBRARIES) - foreach(lib_dir ${REQUIRED_LIBDIRS}) - list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}") - endforeach() - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + # set required libraries for link + set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") + set(CMAKE_REQUIRED_LIBRARIES) + foreach(lib_dir ${REQUIRED_LIBDIRS}) + list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}") + endforeach() + list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") + string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - # test link - unset(SIMGRID_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(MSG_main SIMGRID_WORKS) - mark_as_advanced(SIMGRID_WORKS) + # test link + unset(SIMGRID_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(MSG_main SIMGRID_WORKS) + mark_as_advanced(SIMGRID_WORKS) - if(NOT SIMGRID_WORKS) - if(NOT SIMGRID_FIND_QUIETLY) - message(STATUS "Looking for simgrid : test of fut_keychange with simgrid library fails") - message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") - message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") - message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") - endif() - endif() - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_LIBRARIES) - endif(SIMGRID_LIBRARIES) + if(NOT SIMGRID_WORKS) + if(NOT SIMGRID_FIND_QUIETLY) + message(STATUS "Looking for simgrid : test of fut_keychange with simgrid library fails") + message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") + message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") + message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") + endif() + endif() + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) + endif(SIMGRID_LIBRARIES) endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT SIMGRID_FOUND) OR (SIMGRID_GIVEN_BY_USER) ) if (SIMGRID_LIBRARIES) - if (SIMGRID_LIBRARY_DIRS) - list(GET SIMGRID_LIBRARY_DIRS 0 first_lib_path) - else() - list(GET SIMGRID_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(SIMGRID_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of SIMGRID library" FORCE) - else() - set(SIMGRID_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of SIMGRID library" FORCE) - endif() + if (SIMGRID_LIBRARY_DIRS) + list(GET SIMGRID_LIBRARY_DIRS 0 first_lib_path) + else() + list(GET SIMGRID_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(SIMGRID_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of SIMGRID library" FORCE) + else() + set(SIMGRID_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of SIMGRID library" FORCE) + endif() endif() mark_as_advanced(SIMGRID_DIR) mark_as_advanced(SIMGRID_DIR_FOUND) @@ -301,10 +301,10 @@ mark_as_advanced(SIMGRID_DIR_FOUND) # ------------------------------- include(FindPackageHandleStandardArgs) if (PKG_CONFIG_EXECUTABLE AND SIMGRID_FOUND) - find_package_handle_standard_args(SIMGRID DEFAULT_MSG - SIMGRID_LIBRARIES) + find_package_handle_standard_args(SIMGRID DEFAULT_MSG + SIMGRID_LIBRARIES) else() - find_package_handle_standard_args(SIMGRID DEFAULT_MSG - SIMGRID_LIBRARIES - SIMGRID_WORKS) + find_package_handle_standard_args(SIMGRID DEFAULT_MSG + SIMGRID_LIBRARIES + SIMGRID_WORKS) endif() diff --git a/CMakeModules/morse/find/FindSTARPU.cmake b/CMakeModules/morse/find/FindSTARPU.cmake index e594ac38f7aea2f085174582cb9ab9e981d9f06c..15973c71aeb4fa2159a2013032af01928823264f 100644 --- a/CMakeModules/morse/find/FindSTARPU.cmake +++ b/CMakeModules/morse/find/FindSTARPU.cmake @@ -68,10 +68,10 @@ # License text for the above reference.) if (NOT STARPU_FOUND) - 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() + 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() endif() # STARPU may depend on other packages (HWLOC, MPI, CUDA, BLAS, MAGMA, FXT, ...) @@ -85,115 +85,115 @@ set(STARPU_LOOK_FOR_FXT FALSE) set(STARPU_LOOK_FOR_SIMGRID FALSE) if( STARPU_FIND_COMPONENTS ) - foreach( component ${STARPU_FIND_COMPONENTS} ) - if(${component} STREQUAL "HWLOC") - set(STARPU_LOOK_FOR_HWLOC TRUE) - elseif(${component} STREQUAL "CUDA") - set(STARPU_LOOK_FOR_CUDA TRUE) - elseif(${component} STREQUAL "MPI") - set(STARPU_LOOK_FOR_MPI TRUE) - elseif(${component} STREQUAL "BLAS") - set(STARPU_LOOK_FOR_BLAS TRUE) - elseif(${component} STREQUAL "MAGMA") - set(STARPU_LOOK_FOR_MAGMA TRUE) - elseif(${component} STREQUAL "FXT") - set(STARPU_LOOK_FOR_FXT TRUE) - elseif(${component} STREQUAL "SIMGRID") - set(STARPU_LOOK_FOR_SIMGRID TRUE) - endif() - endforeach() + foreach( component ${STARPU_FIND_COMPONENTS} ) + if(${component} STREQUAL "HWLOC") + set(STARPU_LOOK_FOR_HWLOC TRUE) + elseif(${component} STREQUAL "CUDA") + set(STARPU_LOOK_FOR_CUDA TRUE) + elseif(${component} STREQUAL "MPI") + set(STARPU_LOOK_FOR_MPI TRUE) + elseif(${component} STREQUAL "BLAS") + set(STARPU_LOOK_FOR_BLAS TRUE) + elseif(${component} STREQUAL "MAGMA") + set(STARPU_LOOK_FOR_MAGMA TRUE) + elseif(${component} STREQUAL "FXT") + set(STARPU_LOOK_FOR_FXT TRUE) + elseif(${component} STREQUAL "SIMGRID") + set(STARPU_LOOK_FOR_SIMGRID TRUE) + endif() + endforeach() endif() # STARPU may depend on pthread, try to find it find_package(Threads) if( THREADS_FOUND ) - list(APPEND STARPU_EXTRA_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) + list(APPEND STARPU_EXTRA_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) endif () # STARPU may depend on libm, try to find it find_library(M_m_LIBRARY NAMES m) mark_as_advanced(M_m_LIBRARY) if( M_m_LIBRARY ) - list(APPEND STARPU_EXTRA_LIBRARIES ${M_m_LIBRARY}) + list(APPEND STARPU_EXTRA_LIBRARIES ${M_m_LIBRARY}) endif () # STARPU may depend on librt, try to find it find_library(RT_rt_LIBRARY NAMES m) mark_as_advanced(RT_rt_LIBRARY) if( RT_rt_LIBRARY ) - list(APPEND STARPU_EXTRA_LIBRARIES ${RT_rt_LIBRARY}) + list(APPEND STARPU_EXTRA_LIBRARIES ${RT_rt_LIBRARY}) endif () # STARPU may depend on HWLOC, try to find it if (NOT HWLOC_FOUND AND STARPU_LOOK_FOR_HWLOC) - if (STARPU_FIND_REQUIRED AND STARPU_FIND_REQUIRED_HWLOC) - find_package(HWLOC REQUIRED) - else() - find_package(HWLOC) - endif() + if (STARPU_FIND_REQUIRED AND STARPU_FIND_REQUIRED_HWLOC) + find_package(HWLOC REQUIRED) + else() + find_package(HWLOC) + endif() endif() # STARPU may depend on CUDA, try to find it if (NOT CUDA_FOUND AND STARPU_LOOK_FOR_CUDA) - if (STARPU_FIND_REQUIRED AND STARPU_FIND_REQUIRED_CUDA) - find_package(CUDA REQUIRED) - else() - find_package(CUDA) - endif() - if (CUDA_FOUND) - mark_as_advanced(CUDA_BUILD_CUBIN) - mark_as_advanced(CUDA_BUILD_EMULATION) - mark_as_advanced(CUDA_SDK_ROOT_DIR) - mark_as_advanced(CUDA_TOOLKIT_ROOT_DIR) - mark_as_advanced(CUDA_VERBOSE_BUILD) - endif() + if (STARPU_FIND_REQUIRED AND STARPU_FIND_REQUIRED_CUDA) + find_package(CUDA REQUIRED) + else() + find_package(CUDA) + endif() + if (CUDA_FOUND) + mark_as_advanced(CUDA_BUILD_CUBIN) + mark_as_advanced(CUDA_BUILD_EMULATION) + mark_as_advanced(CUDA_SDK_ROOT_DIR) + mark_as_advanced(CUDA_TOOLKIT_ROOT_DIR) + mark_as_advanced(CUDA_VERBOSE_BUILD) + endif() endif() # STARPU may depend on MPI, try to find it if (NOT MPI_FOUND AND STARPU_LOOK_FOR_MPI) - if (STARPU_FIND_REQUIRED AND STARPU_FIND_REQUIRED_MPI) - find_package(MPI REQUIRED) - else() - find_package(MPI) - endif() - if (MPI_FOUND) - mark_as_advanced(MPI_LIBRARY) - mark_as_advanced(MPI_EXTRA_LIBRARY) - endif() + if (STARPU_FIND_REQUIRED AND STARPU_FIND_REQUIRED_MPI) + find_package(MPI REQUIRED) + else() + find_package(MPI) + endif() + if (MPI_FOUND) + mark_as_advanced(MPI_LIBRARY) + mark_as_advanced(MPI_EXTRA_LIBRARY) + endif() endif() # STARPU may depend on BLAS, try to find it if (NOT BLAS_FOUND AND STARPU_LOOK_FOR_BLAS) - if (STARPU_FIND_REQUIRED AND STARPU_FIND_REQUIRED_BLAS) - find_package(BLASEXT REQUIRED) - else() - find_package(BLASEXT) - endif() + if (STARPU_FIND_REQUIRED AND STARPU_FIND_REQUIRED_BLAS) + find_package(BLASEXT REQUIRED) + else() + find_package(BLASEXT) + endif() endif() # STARPU may depend on MAGMA, try to find it if (NOT MAGMA_FOUND AND STARPU_LOOK_FOR_MAGMA) - if (STARPU_FIND_REQUIRED AND STARPU_FIND_REQUIRED_MAGMA) - find_package(MAGMA REQUIRED) - else() - find_package(MAGMA) - endif() + if (STARPU_FIND_REQUIRED AND STARPU_FIND_REQUIRED_MAGMA) + find_package(MAGMA REQUIRED) + else() + find_package(MAGMA) + endif() endif() # STARPU may depend on FXT, try to find it if (NOT FXT_FOUND AND STARPU_LOOK_FOR_FXT) - if (STARPU_FIND_REQUIRED AND STARPU_FIND_REQUIRED_FXT) - find_package(FXT REQUIRED) - else() - find_package(FXT) - endif() + if (STARPU_FIND_REQUIRED AND STARPU_FIND_REQUIRED_FXT) + find_package(FXT REQUIRED) + else() + find_package(FXT) + endif() endif() # STARPU may depend on SIMGRID, try to find it if (NOT SIMGRID_FOUND AND STARPU_LOOK_FOR_SIMGRID) - if (STARPU_FIND_REQUIRED AND STARPU_FIND_REQUIRED_SIMGRID) - find_package(SIMGRID REQUIRED) - else() - find_package(SIMGRID) - endif() + if (STARPU_FIND_REQUIRED AND STARPU_FIND_REQUIRED_SIMGRID) + find_package(SIMGRID REQUIRED) + else() + find_package(SIMGRID) + endif() endif() set(ENV_STARPU_DIR "$ENV{STARPU_DIR}") @@ -201,7 +201,7 @@ set(ENV_STARPU_INCDIR "$ENV{STARPU_INCDIR}") set(ENV_STARPU_LIBDIR "$ENV{STARPU_LIBDIR}") set(STARPU_GIVEN_BY_USER "FALSE") if ( STARPU_DIR OR ( STARPU_INCDIR AND STARPU_LIBDIR) OR ENV_STARPU_DIR OR (ENV_STARPU_INCDIR AND ENV_STARPU_LIBDIR) ) - set(STARPU_GIVEN_BY_USER "TRUE") + set(STARPU_GIVEN_BY_USER "TRUE") endif() # Optionally use pkg-config to detect include/library dirs (if pkg-config is available) @@ -211,702 +211,702 @@ find_package(PkgConfig QUIET) if(PKG_CONFIG_EXECUTABLE AND NOT STARPU_GIVEN_BY_USER) - pkg_search_module(STARPU_SHM libstarpu) - set(STARPU_INCLUDE_DIRS "${STARPU_SHM_INCLUDE_DIRS}") - set(STARPU_LIBRARY_DIRS "${STARPU_SHM_LIBRARY_DIRS}") - if(STARPU_LOOK_FOR_MPI AND MPI_FOUND) - pkg_search_module(STARPU_MPI libstarpumpi) - endif() - if (NOT STARPU_FIND_QUIETLY) - if (STARPU_SHM_FOUND AND STARPU_SHM_LIBRARIES) - message(STATUS "Looking for STARPU - found using PkgConfig") - #if(NOT STARPU_SHM_INCLUDE_DIRS) - # message("${Magenta}STARPU_SHM_INCLUDE_DIRS is empty using PkgConfig." - # "Perhaps the path to starpu headers is already present in your" - # "C(PLUS)_INCLUDE_PATH environment variable.${ColourReset}") - #endif() - set(STARPU_VERSION_STRING "${STARPU_SHM_VERSION}") - string(REPLACE "." ";" STARPU_VERSION_STRING_LIST ${STARPU_VERSION_STRING}) - list(GET STARPU_VERSION_STRING_LIST 0 STARPU_VERSION_MAJOR) - list(GET STARPU_VERSION_STRING_LIST 1 STARPU_VERSION_MINOR) - else() - message(STATUS "${Magenta}Looking for STARPU - not found using PkgConfig." - "\n Perhaps you should add the directory containing libstarpu.pc" - "\n to the PKG_CONFIG_PATH environment variable.${ColourReset}") - endif() - if (STARPU_LOOK_FOR_MPI) - if (STARPU_MPI_FOUND AND STARPU_MPI_LIBRARIES) - message(STATUS "Looking for STARPU MPI - found using PkgConfig") - else() - message(STATUS "${Magenta}Looking for STARPU MPI - not found using PkgConfig." - "Perhaps you should add the directory containing libstarpumpi.pc to" - "the PKG_CONFIG_PATH environment variable.${ColourReset}") - endif() - endif() - endif() - - if (STARPU_FIND_VERSION_EXACT) - if( NOT (STARPU_FIND_VERSION_MAJOR STREQUAL STARPU_VERSION_MAJOR) OR - NOT (STARPU_FIND_VERSION_MINOR STREQUAL STARPU_VERSION_MINOR) ) - if(STARPU_FIND_REQUIRED AND NOT STARPU_FIND_QUIETLY) - message(FATAL_ERROR - "STARPU version found is ${STARPU_VERSION_STRING}" - "when required is ${STARPU_FIND_VERSION}") - endif() - endif() + pkg_search_module(STARPU_SHM libstarpu) + set(STARPU_INCLUDE_DIRS "${STARPU_SHM_INCLUDE_DIRS}") + set(STARPU_LIBRARY_DIRS "${STARPU_SHM_LIBRARY_DIRS}") + if(STARPU_LOOK_FOR_MPI AND MPI_FOUND) + pkg_search_module(STARPU_MPI libstarpumpi) + endif() + if (NOT STARPU_FIND_QUIETLY) + if (STARPU_SHM_FOUND AND STARPU_SHM_LIBRARIES) + message(STATUS "Looking for STARPU - found using PkgConfig") + #if(NOT STARPU_SHM_INCLUDE_DIRS) + # message("${Magenta}STARPU_SHM_INCLUDE_DIRS is empty using PkgConfig." + # "Perhaps the path to starpu headers is already present in your" + # "C(PLUS)_INCLUDE_PATH environment variable.${ColourReset}") + #endif() + set(STARPU_VERSION_STRING "${STARPU_SHM_VERSION}") + string(REPLACE "." ";" STARPU_VERSION_STRING_LIST ${STARPU_VERSION_STRING}) + list(GET STARPU_VERSION_STRING_LIST 0 STARPU_VERSION_MAJOR) + list(GET STARPU_VERSION_STRING_LIST 1 STARPU_VERSION_MINOR) else() - # if the version found is older than the required then error - if( (STARPU_FIND_VERSION_MAJOR STRGREATER STARPU_VERSION_MAJOR) OR - (STARPU_FIND_VERSION_MINOR STRGREATER STARPU_VERSION_MINOR) ) - if(STARPU_FIND_REQUIRED AND NOT STARPU_FIND_QUIETLY) - message(FATAL_ERROR - "STARPU version found is ${STARPU_VERSION_STRING}" - "when required is ${STARPU_FIND_VERSION} or newer") - endif() - endif() + message(STATUS "${Magenta}Looking for STARPU - not found using PkgConfig." + "\n Perhaps you should add the directory containing libstarpu.pc" + "\n to the PKG_CONFIG_PATH environment variable.${ColourReset}") endif() - - if(STARPU_MPI_LIBRARIES) - if (STARPU_LOOK_FOR_SIMGRID) - # Cmake does not fetch explicit libfxt.a static paths from pkg-config... - find_package(FXT) - string(REGEX MATCH "[^;]*/libfxt.a" FXT_STATIC_LIB "${STARPU_MPI_LDFLAGS_OTHER}") - list(APPEND STARPU_MPI_LIBRARIES "${FXT_STATIC_LIB}") - endif() - set(STARPU_LIBRARIES "${STARPU_MPI_LIBRARIES}") - set(STARPU_LINKER_FLAGS "${STARPU_MPI_LDFLAGS_OTHER}") - elseif(STARPU_SHM_LIBRARIES) - set(STARPU_LIBRARIES "${STARPU_SHM_LIBRARIES}") - set(STARPU_LINKER_FLAGS "${STARPU_SHM_LDFLAGS_OTHER}") - else() - set(STARPU_LIBRARIES "STARPU_LIBRARIES-NOTFOUND") + if (STARPU_LOOK_FOR_MPI) + if (STARPU_MPI_FOUND AND STARPU_MPI_LIBRARIES) + message(STATUS "Looking for STARPU MPI - found using PkgConfig") + else() + message(STATUS "${Magenta}Looking for STARPU MPI - not found using PkgConfig." + "Perhaps you should add the directory containing libstarpumpi.pc to" + "the PKG_CONFIG_PATH environment variable.${ColourReset}") + endif() endif() - set(STARPU_INCLUDE_DIRS_DEP "${STARPU_INCLUDE_DIRS}") - set(STARPU_LIBRARY_DIRS_DEP "${STARPU_LIBRARY_DIRS}") - set(STARPU_LIBRARIES_DEP "${STARPU_LIBRARIES}") - if (STARPU_SHM_FOUND) - set(STARPU_FOUND "TRUE") - else() - set(STARPU_FOUND "FALSE") + endif() + + if (STARPU_FIND_VERSION_EXACT) + if( NOT (STARPU_FIND_VERSION_MAJOR STREQUAL STARPU_VERSION_MAJOR) OR + NOT (STARPU_FIND_VERSION_MINOR STREQUAL STARPU_VERSION_MINOR) ) + if(STARPU_FIND_REQUIRED AND NOT STARPU_FIND_QUIETLY) + message(FATAL_ERROR + "STARPU version found is ${STARPU_VERSION_STRING}" + "when required is ${STARPU_FIND_VERSION}") + endif() endif() - if (STARPU_LOOK_FOR_MPI AND NOT STARPU_MPI_FOUND) - set(STARPU_FOUND "FALSE") + else() + # if the version found is older than the required then error + if( (STARPU_FIND_VERSION_MAJOR STRGREATER STARPU_VERSION_MAJOR) OR + (STARPU_FIND_VERSION_MINOR STRGREATER STARPU_VERSION_MINOR) ) + if(STARPU_FIND_REQUIRED AND NOT STARPU_FIND_QUIETLY) + message(FATAL_ERROR + "STARPU version found is ${STARPU_VERSION_STRING}" + "when required is ${STARPU_FIND_VERSION} or newer") + endif() endif() + endif() + + if(STARPU_MPI_LIBRARIES) + if (STARPU_LOOK_FOR_SIMGRID) + # Cmake does not fetch explicit libfxt.a static paths from pkg-config... + find_package(FXT) + string(REGEX MATCH "[^;]*/libfxt.a" FXT_STATIC_LIB "${STARPU_MPI_LDFLAGS_OTHER}") + list(APPEND STARPU_MPI_LIBRARIES "${FXT_STATIC_LIB}") + endif() + set(STARPU_LIBRARIES "${STARPU_MPI_LIBRARIES}") + set(STARPU_LINKER_FLAGS "${STARPU_MPI_LDFLAGS_OTHER}") + elseif(STARPU_SHM_LIBRARIES) + set(STARPU_LIBRARIES "${STARPU_SHM_LIBRARIES}") + set(STARPU_LINKER_FLAGS "${STARPU_SHM_LDFLAGS_OTHER}") + else() + set(STARPU_LIBRARIES "STARPU_LIBRARIES-NOTFOUND") + endif() + set(STARPU_INCLUDE_DIRS_DEP "${STARPU_INCLUDE_DIRS}") + set(STARPU_LIBRARY_DIRS_DEP "${STARPU_LIBRARY_DIRS}") + set(STARPU_LIBRARIES_DEP "${STARPU_LIBRARIES}") + if (STARPU_SHM_FOUND) + set(STARPU_FOUND "TRUE") + else() + set(STARPU_FOUND "FALSE") + endif() + if (STARPU_LOOK_FOR_MPI AND NOT STARPU_MPI_FOUND) + set(STARPU_FOUND "FALSE") + endif() endif(PKG_CONFIG_EXECUTABLE AND NOT STARPU_GIVEN_BY_USER) if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT STARPU_FOUND) OR (STARPU_GIVEN_BY_USER) ) - # Looking for include - # ------------------- + # Looking for include + # ------------------- + + # Add system include paths to search include + # ------------------------------------------ + unset(_inc_env) + set(ENV_STARPU_DIR "$ENV{STARPU_DIR}") + set(ENV_STARPU_INCDIR "$ENV{STARPU_INCDIR}") + if(ENV_STARPU_INCDIR) + list(APPEND _inc_env "${ENV_STARPU_INCDIR}") + elseif(ENV_STARPU_DIR) + list(APPEND _inc_env "${ENV_STARPU_DIR}") + list(APPEND _inc_env "${ENV_STARPU_DIR}/include") + list(APPEND _inc_env "${ENV_STARPU_DIR}/include/starpu/1.0") + list(APPEND _inc_env "${ENV_STARPU_DIR}/include/starpu/1.1") + list(APPEND _inc_env "${ENV_STARPU_DIR}/include/starpu/1.2") + list(APPEND _inc_env "${ENV_STARPU_DIR}/include/starpu/1.3") + else() + if(WIN32) + string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") + else() + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{CPATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + endif() + endif() + list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") + list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") + list(REMOVE_DUPLICATES _inc_env) - # Add system include paths to search include - # ------------------------------------------ - unset(_inc_env) - set(ENV_STARPU_DIR "$ENV{STARPU_DIR}") - set(ENV_STARPU_INCDIR "$ENV{STARPU_INCDIR}") - if(ENV_STARPU_INCDIR) - list(APPEND _inc_env "${ENV_STARPU_INCDIR}") - elseif(ENV_STARPU_DIR) - list(APPEND _inc_env "${ENV_STARPU_DIR}") - list(APPEND _inc_env "${ENV_STARPU_DIR}/include") - list(APPEND _inc_env "${ENV_STARPU_DIR}/include/starpu/1.0") - list(APPEND _inc_env "${ENV_STARPU_DIR}/include/starpu/1.1") - list(APPEND _inc_env "${ENV_STARPU_DIR}/include/starpu/1.2") - list(APPEND _inc_env "${ENV_STARPU_DIR}/include/starpu/1.3") + # Try to find the version of StarPU in starpu_config.h file + set(STARPU_hdrs_to_find "starpu_config.h") + + # call cmake macro to find the header path + if(STARPU_INCDIR) + foreach(starpu_hdr ${STARPU_hdrs_to_find}) + set(STARPU_${starpu_hdr}_INCLUDE_DIRS "STARPU_${starpu_hdr}_INCLUDE_DIRS-NOTFOUND") + find_path(STARPU_${starpu_hdr}_INCLUDE_DIRS + NAMES ${starpu_hdr} + HINTS ${STARPU_INCDIR}) + endforeach() + else() + if(STARPU_DIR) + foreach(starpu_hdr ${STARPU_hdrs_to_find}) + set(STARPU_${starpu_hdr}_INCLUDE_DIRS "STARPU_${starpu_hdr}_INCLUDE_DIRS-NOTFOUND") + find_path(STARPU_${starpu_hdr}_INCLUDE_DIRS + NAMES ${starpu_hdr} + HINTS ${STARPU_DIR} + PATH_SUFFIXES "include" + "include/starpu/1.0" + "include/starpu/1.1" + "include/starpu/1.2" + "include/starpu/1.3") + endforeach() else() - if(WIN32) - string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") - else() - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{CPATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - endif() + foreach(starpu_hdr ${STARPU_hdrs_to_find}) + set(STARPU_${starpu_hdr}_INCLUDE_DIRS "STARPU_${starpu_hdr}_INCLUDE_DIRS-NOTFOUND") + find_path(STARPU_${starpu_hdr}_INCLUDE_DIRS + NAMES ${starpu_hdr} + HINTS ${_inc_env} + PATH_SUFFIXES + "starpu/1.0" + "starpu/1.1" + "starpu/1.2" + "starpu/1.3") + endforeach() endif() - list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") - list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") - list(REMOVE_DUPLICATES _inc_env) - - # Try to find the version of StarPU in starpu_config.h file - set(STARPU_hdrs_to_find "starpu_config.h") - - # call cmake macro to find the header path - if(STARPU_INCDIR) - foreach(starpu_hdr ${STARPU_hdrs_to_find}) - set(STARPU_${starpu_hdr}_INCLUDE_DIRS "STARPU_${starpu_hdr}_INCLUDE_DIRS-NOTFOUND") - find_path(STARPU_${starpu_hdr}_INCLUDE_DIRS - NAMES ${starpu_hdr} - HINTS ${STARPU_INCDIR}) - endforeach() + endif() + mark_as_advanced(STARPU_starpu_config.h_INCLUDE_DIRS) + + ### + # + # GET_VERSION: Get the version of the software by parsing a file + # + ### + MACRO(GET_VERSION _PACKAGE _filepath) + + #message(STATUS "Looking for ${_PACKAGE} version in the file ${_filepath}") + file(READ "${_filepath}" _file) + string(REGEX REPLACE + "(.*)define([ \t]*)${_PACKAGE}_MAJOR_VERSION([ \t]*)([0-9]+)(.*)" + "\\4" ${_PACKAGE}_VERSION_MAJOR "${_file}") + string(REGEX REPLACE + "(.*)define([ \t]*)${_PACKAGE}_MINOR_VERSION([ \t]*)([0-9]+)(.*)" + "\\4" ${_PACKAGE}_VERSION_MINOR "${_file}") + set(${_PACKAGE}_VERSION_STRING + "${${_PACKAGE}_VERSION_MAJOR}.${${_PACKAGE}_VERSION_MINOR}" CACHE PATH "StarPU version found in starpu_config.h") + #message(STATUS "${_PACKAGE}_VERSION_MAJOR = -${${_PACKAGE}_VERSION_MAJOR}-") + #message(STATUS "${_PACKAGE}_VERSION_MINOR = -${${_PACKAGE}_VERSION_MINOR}-") + + ENDMACRO(GET_VERSION) + + # Find the version of StarPU in starpu_config.h file + # remark: the version is defined in this file since the STARPU 1.0 version + if (STARPU_starpu_config.h_INCLUDE_DIRS) + GET_VERSION("STARPU" "${STARPU_starpu_config.h_INCLUDE_DIRS}/starpu_config.h") + if (STARPU_VERSION_MAJOR AND STARPU_VERSION_MINOR) + if (STARPU_FIND_VERSION_EXACT) + if (STARPU_FIND_VERSION_MAJOR AND STARPU_FIND_VERSION_MINOR) + if( NOT (STARPU_FIND_VERSION_MAJOR STREQUAL STARPU_VERSION_MAJOR) OR + NOT (STARPU_FIND_VERSION_MINOR STREQUAL STARPU_VERSION_MINOR) ) + if(STARPU_FIND_REQUIRED AND NOT STARPU_FIND_QUIETLY) + message(FATAL_ERROR + "STARPU version found is ${STARPU_VERSION_STRING} " + "when required is ${STARPU_FIND_VERSION}") + endif() + endif() + endif() + else() + if (STARPU_FIND_VERSION_MAJOR AND STARPU_FIND_VERSION_MINOR) + # if the version found is older than the required then error + if( (STARPU_FIND_VERSION_MAJOR STRGREATER STARPU_VERSION_MAJOR) OR + (STARPU_FIND_VERSION_MINOR STRGREATER STARPU_VERSION_MINOR) ) + if(STARPU_FIND_REQUIRED AND NOT STARPU_FIND_QUIETLY) + message(FATAL_ERROR + "STARPU version found is ${STARPU_VERSION_STRING} " + "when required is ${STARPU_FIND_VERSION} or newer") + endif() + endif() + endif() + endif() else() - if(STARPU_DIR) - foreach(starpu_hdr ${STARPU_hdrs_to_find}) - set(STARPU_${starpu_hdr}_INCLUDE_DIRS "STARPU_${starpu_hdr}_INCLUDE_DIRS-NOTFOUND") - find_path(STARPU_${starpu_hdr}_INCLUDE_DIRS - NAMES ${starpu_hdr} - HINTS ${STARPU_DIR} - PATH_SUFFIXES "include" - "include/starpu/1.0" - "include/starpu/1.1" - "include/starpu/1.2" - "include/starpu/1.3") - endforeach() - else() - foreach(starpu_hdr ${STARPU_hdrs_to_find}) - set(STARPU_${starpu_hdr}_INCLUDE_DIRS "STARPU_${starpu_hdr}_INCLUDE_DIRS-NOTFOUND") - find_path(STARPU_${starpu_hdr}_INCLUDE_DIRS - NAMES ${starpu_hdr} - HINTS ${_inc_env} - PATH_SUFFIXES - "starpu/1.0" - "starpu/1.1" - "starpu/1.2" - "starpu/1.3") - endforeach() - endif() + if(STARPU_FIND_REQUIRED AND NOT STARPU_FIND_QUIETLY) + message(FATAL_ERROR + "STARPU version has not been found using starpu_config.h" + "located in ${STARPU_starpu_config.h_INCLUDE_DIRS}") + endif() + endif() + else() + if(STARPU_FIND_REQUIRED AND NOT STARPU_FIND_QUIETLY) + message(FATAL_ERROR + "starpu_config.h has not been found while required to get StarPU version") endif() - mark_as_advanced(STARPU_starpu_config.h_INCLUDE_DIRS) - - ### - # - # GET_VERSION: Get the version of the software by parsing a file - # - ### - MACRO(GET_VERSION _PACKAGE _filepath) - - #message(STATUS "Looking for ${_PACKAGE} version in the file ${_filepath}") - file(READ "${_filepath}" _file) - string(REGEX REPLACE - "(.*)define([ \t]*)${_PACKAGE}_MAJOR_VERSION([ \t]*)([0-9]+)(.*)" - "\\4" ${_PACKAGE}_VERSION_MAJOR "${_file}") - string(REGEX REPLACE - "(.*)define([ \t]*)${_PACKAGE}_MINOR_VERSION([ \t]*)([0-9]+)(.*)" - "\\4" ${_PACKAGE}_VERSION_MINOR "${_file}") - set(${_PACKAGE}_VERSION_STRING - "${${_PACKAGE}_VERSION_MAJOR}.${${_PACKAGE}_VERSION_MINOR}" CACHE PATH "StarPU version found in starpu_config.h") - #message(STATUS "${_PACKAGE}_VERSION_MAJOR = -${${_PACKAGE}_VERSION_MAJOR}-") - #message(STATUS "${_PACKAGE}_VERSION_MINOR = -${${_PACKAGE}_VERSION_MINOR}-") - - ENDMACRO(GET_VERSION) - - # Find the version of StarPU in starpu_config.h file - # remark: the version is defined in this file since the STARPU 1.0 version - if (STARPU_starpu_config.h_INCLUDE_DIRS) - GET_VERSION("STARPU" "${STARPU_starpu_config.h_INCLUDE_DIRS}/starpu_config.h") - if (STARPU_VERSION_MAJOR AND STARPU_VERSION_MINOR) - if (STARPU_FIND_VERSION_EXACT) - if (STARPU_FIND_VERSION_MAJOR AND STARPU_FIND_VERSION_MINOR) - if( NOT (STARPU_FIND_VERSION_MAJOR STREQUAL STARPU_VERSION_MAJOR) OR - NOT (STARPU_FIND_VERSION_MINOR STREQUAL STARPU_VERSION_MINOR) ) - if(STARPU_FIND_REQUIRED AND NOT STARPU_FIND_QUIETLY) - message(FATAL_ERROR - "STARPU version found is ${STARPU_VERSION_STRING} " - "when required is ${STARPU_FIND_VERSION}") - endif() - endif() - endif() - else() - if (STARPU_FIND_VERSION_MAJOR AND STARPU_FIND_VERSION_MINOR) - # if the version found is older than the required then error - if( (STARPU_FIND_VERSION_MAJOR STRGREATER STARPU_VERSION_MAJOR) OR - (STARPU_FIND_VERSION_MINOR STRGREATER STARPU_VERSION_MINOR) ) - if(STARPU_FIND_REQUIRED AND NOT STARPU_FIND_QUIETLY) - message(FATAL_ERROR - "STARPU version found is ${STARPU_VERSION_STRING} " - "when required is ${STARPU_FIND_VERSION} or newer") - endif() - endif() - endif() - endif() - else() - if(STARPU_FIND_REQUIRED AND NOT STARPU_FIND_QUIETLY) - message(FATAL_ERROR - "STARPU version has not been found using starpu_config.h" - "located in ${STARPU_starpu_config.h_INCLUDE_DIRS}") - endif() - endif() + endif() + + + # Try to find the starpu headers in the given paths + # ------------------------------------------------- + + # create list of headers to find + list(APPEND STARPU_hdrs_to_find "starpu.h;starpu_profiling.h") + if(STARPU_LOOK_FOR_MPI AND MPI_FOUND) + list(APPEND STARPU_hdrs_to_find "starpu_mpi.h") + endif() + if(STARPU_LOOK_FOR_CUDA AND CUDA_FOUND) + list(APPEND STARPU_hdrs_to_find "starpu_cuda.h;starpu_scheduler.h") + endif() + + # call cmake macro to find the header path + if(STARPU_INCDIR) + foreach(starpu_hdr ${STARPU_hdrs_to_find}) + set(STARPU_${starpu_hdr}_INCLUDE_DIRS "STARPU_${starpu_hdr}_INCLUDE_DIRS-NOTFOUND") + find_path(STARPU_${starpu_hdr}_INCLUDE_DIRS + NAMES ${starpu_hdr} + HINTS ${STARPU_INCDIR}) + endforeach() + else() + if(STARPU_DIR) + set(STARPU_${starpu_hdr}_INCLUDE_DIRS "STARPU_${starpu_hdr}_INCLUDE_DIRS-NOTFOUND") + foreach(starpu_hdr ${STARPU_hdrs_to_find}) + find_path(STARPU_${starpu_hdr}_INCLUDE_DIRS + NAMES ${starpu_hdr} + HINTS ${STARPU_DIR} + PATH_SUFFIXES "include" + "include/starpu/1.0" + "include/starpu/1.1" + "include/starpu/1.2" + "include/starpu/1.3") + endforeach() else() - if(STARPU_FIND_REQUIRED AND NOT STARPU_FIND_QUIETLY) - message(FATAL_ERROR - "starpu_config.h has not been found while required to get StarPU version") - endif() + foreach(starpu_hdr ${STARPU_hdrs_to_find}) + set(STARPU_${starpu_hdr}_INCLUDE_DIRS "STARPU_${starpu_hdr}_INCLUDE_DIRS-NOTFOUND") + find_path(STARPU_${starpu_hdr}_INCLUDE_DIRS + NAMES ${starpu_hdr} + HINTS ${_inc_env} + PATH_SUFFIXES + "starpu/1.0" + "starpu/1.1" + "starpu/1.2" + "starpu/1.3") + endforeach() endif() + endif() + + # If found, add path to cmake variable + # ------------------------------------ + set(STARPU_INCLUDE_DIRS "") + foreach(starpu_hdr ${STARPU_hdrs_to_find}) + + if (STARPU_${starpu_hdr}_INCLUDE_DIRS) + # set cmake variables using the pkg-config naming convention + list(APPEND STARPU_INCLUDE_DIRS "${STARPU_${starpu_hdr}_INCLUDE_DIRS}" ) + else () + if(NOT STARPU_FIND_QUIETLY) + message(STATUS "Looking for starpu -- ${starpu_hdr} not found") + endif() + if(starpu_hdr STREQUAL "starpu_mpi.h") + if(NOT STARPU_FIND_REQUIRED_MPI) + if (NOT STARPU_FIND_QUIETLY) + message(STATUS "Looking for starpu -- ${starpu_hdr} not required") + endif() + else() + list(APPEND STARPU_INCLUDE_DIRS "${STARPU_${starpu_hdr}_INCLUDE_DIRS}" ) + endif() + elseif( (starpu_hdr STREQUAL "starpu_cuda.h") OR (starpu_hdr STREQUAL "starpu_scheduler.h") ) + if(NOT STARPU_FIND_REQUIRED_CUDA) + if (NOT STARPU_FIND_QUIETLY) + message(STATUS "Looking for starpu -- ${starpu_hdr} not required") + endif() + else() + list(APPEND STARPU_INCLUDE_DIRS "${STARPU_${starpu_hdr}_INCLUDE_DIRS}" ) + endif() + endif() + endif () + mark_as_advanced(STARPU_${starpu_hdr}_INCLUDE_DIRS) + endforeach(starpu_hdr ${STARPU_hdrs_to_find}) - # Try to find the starpu headers in the given paths - # ------------------------------------------------- + if (STARPU_INCLUDE_DIRS) + list(REMOVE_DUPLICATES STARPU_INCLUDE_DIRS) + endif () - # create list of headers to find - list(APPEND STARPU_hdrs_to_find "starpu.h;starpu_profiling.h") - if(STARPU_LOOK_FOR_MPI AND MPI_FOUND) - list(APPEND STARPU_hdrs_to_find "starpu_mpi.h") + if (STARPU_starpu_config.h_INCLUDE_DIRS) + # Looking for lib + # --------------- + + set(STARPU_SHM_LIBRARIES "") + set(STARPU_MPI_LIBRARIES "") + set(STARPU_LIBRARY_DIRS "") + + # Add system library paths to search lib + # -------------------------------------- + unset(_lib_env) + set(ENV_STARPU_LIBDIR "$ENV{STARPU_LIBDIR}") + if(ENV_STARPU_LIBDIR) + list(APPEND _lib_env "${ENV_STARPU_LIBDIR}") + elseif(ENV_STARPU_DIR) + list(APPEND _lib_env "${ENV_STARPU_DIR}") + list(APPEND _lib_env "${ENV_STARPU_DIR}/lib") + else() + if(WIN32) + string(REPLACE ":" ";" _lib_env "$ENV{LIB}") + else() + if(APPLE) + string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") + else() + string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") + endif() + list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") + list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + endif() endif() - if(STARPU_LOOK_FOR_CUDA AND CUDA_FOUND) - list(APPEND STARPU_hdrs_to_find "starpu_cuda.h;starpu_scheduler.h") + list(REMOVE_DUPLICATES _lib_env) + + # Try to find the starpu libs in the given paths + # ---------------------------------------------- + + # create list of libs to find + set(STARPU_libs_to_find "starpu-${STARPU_VERSION_STRING}") + set(STARPU_SHM_libs_to_find "starpu-${STARPU_VERSION_STRING}") + if (STARPU_LOOK_FOR_MPI OR MPI_FOUND) + list(INSERT STARPU_libs_to_find 0 "starpumpi-${STARPU_VERSION_STRING}") + set(STARPU_MPI_libs_to_find "${STARPU_libs_to_find}") endif() - # call cmake macro to find the header path - if(STARPU_INCDIR) - foreach(starpu_hdr ${STARPU_hdrs_to_find}) - set(STARPU_${starpu_hdr}_INCLUDE_DIRS "STARPU_${starpu_hdr}_INCLUDE_DIRS-NOTFOUND") - find_path(STARPU_${starpu_hdr}_INCLUDE_DIRS - NAMES ${starpu_hdr} - HINTS ${STARPU_INCDIR}) - endforeach() + # call cmake macro to find the lib path + if(STARPU_LIBDIR) + foreach(starpu_lib ${STARPU_libs_to_find}) + set(STARPU_${starpu_lib}_LIBRARY "STARPU_${starpu_lib}_LIBRARY-NOTFOUND") + find_library(STARPU_${starpu_lib}_LIBRARY + NAMES ${starpu_lib} + HINTS ${STARPU_LIBDIR}) + endforeach() else() - if(STARPU_DIR) - set(STARPU_${starpu_hdr}_INCLUDE_DIRS "STARPU_${starpu_hdr}_INCLUDE_DIRS-NOTFOUND") - foreach(starpu_hdr ${STARPU_hdrs_to_find}) - find_path(STARPU_${starpu_hdr}_INCLUDE_DIRS - NAMES ${starpu_hdr} - HINTS ${STARPU_DIR} - PATH_SUFFIXES "include" - "include/starpu/1.0" - "include/starpu/1.1" - "include/starpu/1.2" - "include/starpu/1.3") - endforeach() - else() - foreach(starpu_hdr ${STARPU_hdrs_to_find}) - set(STARPU_${starpu_hdr}_INCLUDE_DIRS "STARPU_${starpu_hdr}_INCLUDE_DIRS-NOTFOUND") - find_path(STARPU_${starpu_hdr}_INCLUDE_DIRS - NAMES ${starpu_hdr} - HINTS ${_inc_env} - PATH_SUFFIXES - "starpu/1.0" - "starpu/1.1" - "starpu/1.2" - "starpu/1.3") - endforeach() - endif() + if(STARPU_DIR) + foreach(starpu_lib ${STARPU_libs_to_find}) + set(STARPU_${starpu_lib}_LIBRARY "STARPU_${starpu_lib}_LIBRARY-NOTFOUND") + find_library(STARPU_${starpu_lib}_LIBRARY + NAMES ${starpu_lib} + HINTS ${STARPU_DIR} + PATH_SUFFIXES lib lib32 lib64) + endforeach() + else() + foreach(starpu_lib ${STARPU_libs_to_find}) + set(STARPU_${starpu_lib}_LIBRARY "STARPU_${starpu_lib}_LIBRARY-NOTFOUND") + find_library(STARPU_${starpu_lib}_LIBRARY + NAMES ${starpu_lib} + HINTS ${_lib_env}) + endforeach() + endif() endif() # If found, add path to cmake variable # ------------------------------------ - set(STARPU_INCLUDE_DIRS "") - foreach(starpu_hdr ${STARPU_hdrs_to_find}) + foreach(starpu_lib ${STARPU_libs_to_find}) + + if (STARPU_${starpu_lib}_LIBRARY) + + get_filename_component(${starpu_lib}_lib_path ${STARPU_${starpu_lib}_LIBRARY} PATH) + # set cmake variables (respects naming convention) + + foreach(starpu_shm_lib ${STARPU_SHM_libs_to_find}) + if(starpu_shm_lib STREQUAL starpu_lib) + list(APPEND STARPU_SHM_LIBRARIES "${STARPU_${starpu_lib}_LIBRARY}") + endif() + endforeach() + if (STARPU_LOOK_FOR_MPI AND MPI_FOUND) + foreach(starpu_mpi_lib ${STARPU_MPI_libs_to_find}) + if(starpu_mpi_lib STREQUAL starpu_lib) + list(APPEND STARPU_MPI_LIBRARIES "${STARPU_${starpu_lib}_LIBRARY}") + endif() + endforeach() + endif () + list(APPEND STARPU_LIBRARY_DIRS "${${starpu_lib}_lib_path}") + + else (STARPU_${starpu_lib}_LIBRARY) + + if(NOT STARPU_FIND_QUIETLY) + message(STATUS "Looking for starpu -- lib ${starpu_lib} not found") + endif() + if(starpu_lib STREQUAL "starpumpi-${STARPU_VERSION_STRING}" AND + NOT STARPU_FIND_REQUIRED_MPI) + # if MPI optional, not a problem: no NOTFOUND in list of MPI LIBRARIES + if(NOT STARPU_FIND_QUIETLY) + message(STATUS "Looking for starpu -- lib ${starpu_lib} not required") + endif() + else() + # for any other lib, add NOTFOUND in the proper list of LIBRARIES + foreach(starpu_shm_lib ${STARPU_SHM_libs_to_find}) + if(starpu_shm_lib STREQUAL starpu_lib) + set(STARPU_SHM_LIBRARIES "${STARPU_${starpu_lib}_LIBRARY}") + endif() + endforeach() + if (STARPU_LOOK_FOR_MPI AND MPI_FOUND) + foreach(starpu_mpi_lib ${STARPU_MPI_libs_to_find}) + if(starpu_mpi_lib STREQUAL starpu_lib) + list(APPEND STARPU_MPI_LIBRARIES "${STARPU_${starpu_mpi_lib}_LIBRARY}") + endif() + endforeach() + endif () + endif() + + endif (STARPU_${starpu_lib}_LIBRARY) + + mark_as_advanced(STARPU_${starpu_lib}_LIBRARY) + + endforeach(starpu_lib ${STARPU_libs_to_find}) + + list(REMOVE_DUPLICATES STARPU_SHM_LIBRARIES) + list(REMOVE_DUPLICATES STARPU_MPI_LIBRARIES) + if (STARPU_LIBRARY_DIRS) + list(REMOVE_DUPLICATES STARPU_LIBRARY_DIRS) + endif () + + if (STARPU_SHM_LIBRARIES AND STARPU_LIBRARY_DIRS AND STARPU_INCLUDE_DIRS) + set(STARPU_SHM_FOUND TRUE) + if(STARPU_MPI_LIBRARIES) + set(STARPU_MPI_FOUND TRUE) + endif() + endif() - if (STARPU_${starpu_hdr}_INCLUDE_DIRS) - # set cmake variables using the pkg-config naming convention - list(APPEND STARPU_INCLUDE_DIRS "${STARPU_${starpu_hdr}_INCLUDE_DIRS}" ) - else () - if(NOT STARPU_FIND_QUIETLY) - message(STATUS "Looking for starpu -- ${starpu_hdr} not found") - endif() - if(starpu_hdr STREQUAL "starpu_mpi.h") - if(NOT STARPU_FIND_REQUIRED_MPI) - if (NOT STARPU_FIND_QUIETLY) - message(STATUS "Looking for starpu -- ${starpu_hdr} not required") - endif() - else() - list(APPEND STARPU_INCLUDE_DIRS "${STARPU_${starpu_hdr}_INCLUDE_DIRS}" ) - endif() - elseif( (starpu_hdr STREQUAL "starpu_cuda.h") OR (starpu_hdr STREQUAL "starpu_scheduler.h") ) - if(NOT STARPU_FIND_REQUIRED_CUDA) - if (NOT STARPU_FIND_QUIETLY) - message(STATUS "Looking for starpu -- ${starpu_hdr} not required") - endif() - else() - list(APPEND STARPU_INCLUDE_DIRS "${STARPU_${starpu_hdr}_INCLUDE_DIRS}" ) - endif() - endif() - endif () - mark_as_advanced(STARPU_${starpu_hdr}_INCLUDE_DIRS) - - endforeach(starpu_hdr ${STARPU_hdrs_to_find}) + else(STARPU_starpu_config.h_INCLUDE_DIRS) + if(NOT STARPU_FIND_QUIETLY) + message(STATUS "The version of StarPU is not known so that we do not search libraries") + endif() + endif(STARPU_starpu_config.h_INCLUDE_DIRS) + foreach(lib ${STARPU_SHM_LIBRARIES}) + if (NOT lib) + set(STARPU_SHM_LIBRARIES "STARPU_SHM_LIBRARIES-NOTFOUND") + endif() + endforeach() + foreach(lib ${STARPU_MPI_LIBRARIES}) + if (NOT lib) + set(STARPU_MPI_LIBRARIES "STARPU_MPI_LIBRARIES-NOTFOUND") + endif() + endforeach() + if(STARPU_LOOK_FOR_MPI) + set(STARPU_LIBRARIES "${STARPU_MPI_LIBRARIES}") + else() + set(STARPU_LIBRARIES "${STARPU_SHM_LIBRARIES}") + endif() + + # 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) + + # STARPU if (STARPU_INCLUDE_DIRS) - list(REMOVE_DUPLICATES STARPU_INCLUDE_DIRS) - endif () - - if (STARPU_starpu_config.h_INCLUDE_DIRS) - # Looking for lib - # --------------- - - set(STARPU_SHM_LIBRARIES "") - set(STARPU_MPI_LIBRARIES "") - set(STARPU_LIBRARY_DIRS "") - - # Add system library paths to search lib - # -------------------------------------- - unset(_lib_env) - set(ENV_STARPU_LIBDIR "$ENV{STARPU_LIBDIR}") - if(ENV_STARPU_LIBDIR) - list(APPEND _lib_env "${ENV_STARPU_LIBDIR}") - elseif(ENV_STARPU_DIR) - list(APPEND _lib_env "${ENV_STARPU_DIR}") - list(APPEND _lib_env "${ENV_STARPU_DIR}/lib") - else() - if(WIN32) - string(REPLACE ":" ";" _lib_env "$ENV{LIB}") - else() - if(APPLE) - string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - endif() - endif() - list(REMOVE_DUPLICATES _lib_env) - - # Try to find the starpu libs in the given paths - # ---------------------------------------------- - - # create list of libs to find - set(STARPU_libs_to_find "starpu-${STARPU_VERSION_STRING}") - set(STARPU_SHM_libs_to_find "starpu-${STARPU_VERSION_STRING}") - if (STARPU_LOOK_FOR_MPI OR MPI_FOUND) - list(INSERT STARPU_libs_to_find 0 "starpumpi-${STARPU_VERSION_STRING}") - set(STARPU_MPI_libs_to_find "${STARPU_libs_to_find}") - endif() - - # call cmake macro to find the lib path - if(STARPU_LIBDIR) - foreach(starpu_lib ${STARPU_libs_to_find}) - set(STARPU_${starpu_lib}_LIBRARY "STARPU_${starpu_lib}_LIBRARY-NOTFOUND") - find_library(STARPU_${starpu_lib}_LIBRARY - NAMES ${starpu_lib} - HINTS ${STARPU_LIBDIR}) - endforeach() - else() - if(STARPU_DIR) - foreach(starpu_lib ${STARPU_libs_to_find}) - set(STARPU_${starpu_lib}_LIBRARY "STARPU_${starpu_lib}_LIBRARY-NOTFOUND") - find_library(STARPU_${starpu_lib}_LIBRARY - NAMES ${starpu_lib} - HINTS ${STARPU_DIR} - PATH_SUFFIXES lib lib32 lib64) - endforeach() - else() - foreach(starpu_lib ${STARPU_libs_to_find}) - set(STARPU_${starpu_lib}_LIBRARY "STARPU_${starpu_lib}_LIBRARY-NOTFOUND") - find_library(STARPU_${starpu_lib}_LIBRARY - NAMES ${starpu_lib} - HINTS ${_lib_env}) - endforeach() - endif() - endif() - - # If found, add path to cmake variable - # ------------------------------------ - foreach(starpu_lib ${STARPU_libs_to_find}) - - if (STARPU_${starpu_lib}_LIBRARY) - - get_filename_component(${starpu_lib}_lib_path ${STARPU_${starpu_lib}_LIBRARY} PATH) - # set cmake variables (respects naming convention) - - foreach(starpu_shm_lib ${STARPU_SHM_libs_to_find}) - if(starpu_shm_lib STREQUAL starpu_lib) - list(APPEND STARPU_SHM_LIBRARIES "${STARPU_${starpu_lib}_LIBRARY}") - endif() - endforeach() - if (STARPU_LOOK_FOR_MPI AND MPI_FOUND) - foreach(starpu_mpi_lib ${STARPU_MPI_libs_to_find}) - if(starpu_mpi_lib STREQUAL starpu_lib) - list(APPEND STARPU_MPI_LIBRARIES "${STARPU_${starpu_lib}_LIBRARY}") - endif() - endforeach() - endif () - list(APPEND STARPU_LIBRARY_DIRS "${${starpu_lib}_lib_path}") - - else (STARPU_${starpu_lib}_LIBRARY) - - if(NOT STARPU_FIND_QUIETLY) - message(STATUS "Looking for starpu -- lib ${starpu_lib} not found") - endif() - if(starpu_lib STREQUAL "starpumpi-${STARPU_VERSION_STRING}" AND - NOT STARPU_FIND_REQUIRED_MPI) - # if MPI optional, not a problem: no NOTFOUND in list of MPI LIBRARIES - if(NOT STARPU_FIND_QUIETLY) - message(STATUS "Looking for starpu -- lib ${starpu_lib} not required") - endif() - else() - # for any other lib, add NOTFOUND in the proper list of LIBRARIES - foreach(starpu_shm_lib ${STARPU_SHM_libs_to_find}) - if(starpu_shm_lib STREQUAL starpu_lib) - set(STARPU_SHM_LIBRARIES "${STARPU_${starpu_lib}_LIBRARY}") - endif() - endforeach() - if (STARPU_LOOK_FOR_MPI AND MPI_FOUND) - foreach(starpu_mpi_lib ${STARPU_MPI_libs_to_find}) - if(starpu_mpi_lib STREQUAL starpu_lib) - list(APPEND STARPU_MPI_LIBRARIES "${STARPU_${starpu_mpi_lib}_LIBRARY}") - endif() - endforeach() - endif () - endif() - - endif (STARPU_${starpu_lib}_LIBRARY) - - mark_as_advanced(STARPU_${starpu_lib}_LIBRARY) - - endforeach(starpu_lib ${STARPU_libs_to_find}) - - list(REMOVE_DUPLICATES STARPU_SHM_LIBRARIES) - list(REMOVE_DUPLICATES STARPU_MPI_LIBRARIES) - if (STARPU_LIBRARY_DIRS) - list(REMOVE_DUPLICATES STARPU_LIBRARY_DIRS) - endif () - - if (STARPU_SHM_LIBRARIES AND STARPU_LIBRARY_DIRS AND STARPU_INCLUDE_DIRS) - set(STARPU_SHM_FOUND TRUE) - if(STARPU_MPI_LIBRARIES) - set(STARPU_MPI_FOUND TRUE) - endif() - endif() - - else(STARPU_starpu_config.h_INCLUDE_DIRS) - if(NOT STARPU_FIND_QUIETLY) - message(STATUS "The version of StarPU is not known so that we do not search libraries") - endif() - endif(STARPU_starpu_config.h_INCLUDE_DIRS) - - foreach(lib ${STARPU_SHM_LIBRARIES}) - if (NOT lib) - set(STARPU_SHM_LIBRARIES "STARPU_SHM_LIBRARIES-NOTFOUND") - endif() + set(REQUIRED_INCDIRS "${STARPU_INCLUDE_DIRS}") + endif() + set(CMAKE_REQUIRED_FLAGS) + foreach(libdir ${STARPU_LIBRARY_DIRS}) + if (libdir) + list(APPEND REQUIRED_LIBDIRS "${libdir}") + endif() endforeach() - foreach(lib ${STARPU_MPI_LIBRARIES}) - if (NOT lib) - set(STARPU_MPI_LIBRARIES "STARPU_MPI_LIBRARIES-NOTFOUND") - endif() + set(REQUIRED_LIBS "${STARPU_LIBRARIES}") + # HWLOC + if (HWLOC_FOUND AND STARPU_LOOK_FOR_HWLOC) + if (HWLOC_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${HWLOC_INCLUDE_DIRS}") + endif() + if (HWLOC_LIBRARY_DIRS) + list(APPEND REQUIRED_LIBDIRS "${HWLOC_LIBRARY_DIRS}") + endif() + foreach(lib ${HWLOC_LIBRARIES}) + if (EXISTS ${lib} OR ${lib} MATCHES "^-") + list(APPEND REQUIRED_LIBS "${lib}") + else() + list(APPEND REQUIRED_LIBS "-l${lib}") + endif() + endforeach() + endif() + # MPI + if (MPI_FOUND AND STARPU_LOOK_FOR_MPI) + if (MPI_C_INCLUDE_PATH) + list(APPEND REQUIRED_INCDIRS "${MPI_C_INCLUDE_PATH}") + endif() + if (MPI_C_LINK_FLAGS) + if (${MPI_C_LINK_FLAGS} MATCHES " -") + string(REGEX REPLACE " -" "-" MPI_C_LINK_FLAGS ${MPI_C_LINK_FLAGS}) + endif() + list(APPEND REQUIRED_LDFLAGS "${MPI_C_LINK_FLAGS}") + endif() + list(APPEND REQUIRED_LIBS "${MPI_C_LIBRARIES}") + endif() + # MAGMA + if (MAGMA_FOUND AND STARPU_LOOK_FOR_MAGMA) + if (MAGMA_INCLUDE_DIRS_DEP) + list(APPEND REQUIRED_INCDIRS "${MAGMA_INCLUDE_DIRS_DEP}") + elseif(MAGMA_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${MAGMA_INCLUDE_DIRS}") + endif() + if (MAGMA_LIBRARY_DIRS_DEP) + list(APPEND REQUIRED_LIBDIRS "${MAGMA_LIBRARY_DIRS_DEP}") + elseif(MAGMA_LIBRARY_DIRS) + list(APPEND REQUIRED_LIBDIRS "${MAGMA_LIBRARY_DIRS}") + endif() + if (MAGMA_LIBRARIES_DEP) + list(APPEND REQUIRED_LIBS "${MAGMA_LIBRARIES_DEP}") + elseif(MAGMA_LIBRARIES) + foreach(lib ${MAGMA_LIBRARIES}) + if (EXISTS ${lib} OR ${lib} MATCHES "^-") + list(APPEND REQUIRED_LIBS "${lib}") + else() + list(APPEND REQUIRED_LIBS "-l${lib}") + 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) + if (CUDA_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${CUDA_INCLUDE_DIRS}") + endif() + if (CUDA_LIBRARY_DIRS) + list(APPEND REQUIRED_LIBDIRS "${CUDA_LIBRARY_DIRS}") + endif() + list(APPEND REQUIRED_LIBS "${CUDA_CUBLAS_LIBRARIES};${CUDA_LIBRARIES}") + endif() + # FXT + if (FXT_FOUND AND STARPU_LOOK_FOR_FXT) + if (FXT_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${FXT_INCLUDE_DIRS}") + endif() + if (FXT_LIBRARY_DIRS) + list(APPEND REQUIRED_LIBDIRS "${FXT_LIBRARY_DIRS}") + endif() + foreach(lib ${FXT_LIBRARIES}) + if (EXISTS ${lib} OR ${lib} MATCHES "^-") + list(APPEND REQUIRED_LIBS "${lib}") + else() + list(APPEND REQUIRED_LIBS "-l${lib}") + endif() + endforeach() + endif() + # SIMGRID + if (SIMGRID_FOUND AND STARPU_LOOK_FOR_SIMGRID) + if (SIMGRID_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${SIMGRID_INCLUDE_DIRS}") + endif() + if (SIMGRID_LIBRARY_DIRS) + list(APPEND REQUIRED_LIBDIRS "${SIMGRID_LIBRARY_DIRS}") + endif() + foreach(lib ${SIMGRID_LIBRARIES}) + if (EXISTS ${lib} OR ${lib} MATCHES "^-") + list(APPEND REQUIRED_LIBS "${lib}") + else() + list(APPEND REQUIRED_LIBS "-l${lib}") + endif() + endforeach() + list(APPEND REQUIRED_FLAGS "-include starpu_simgrid_wrap.h") + endif() + # BLAS + if (BLAS_FOUND AND STARPU_LOOK_FOR_BLAS) + if (BLAS_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${BLAS_INCLUDE_DIRS}") + endif() + if (BLAS_LIBRARY_DIRS) + 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_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}) + + # 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() - if(STARPU_LOOK_FOR_MPI) - set(STARPU_LIBRARIES "${STARPU_MPI_LIBRARIES}") + list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") + list(APPEND CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") + string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + + # test link + unset(STARPU_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(starpu_init STARPU_WORKS) + mark_as_advanced(STARPU_WORKS) + + if(STARPU_WORKS) + # save link with dependencies + if (REQUIRED_FLAGS) + set(STARPU_LIBRARIES_DEP "${REQUIRED_FLAGS};${REQUIRED_LIBS}") + else() + set(STARPU_LIBRARIES_DEP "${REQUIRED_LIBS}") + 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() - set(STARPU_LIBRARIES "${STARPU_SHM_LIBRARIES}") + if(NOT STARPU_FIND_QUIETLY) + message(STATUS "Looking for starpu : test of starpu_init fails") + message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") + message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") + message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") + message(STATUS "Maybe STARPU is linked with specific libraries. " + "Have you tried with COMPONENTS (HWLOC, CUDA, MPI, BLAS, MAGMA, FXT, SIMGRID)? " + "See the explanation in FindSTARPU.cmake.") + endif() endif() - - # 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) - - # STARPU - if (STARPU_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${STARPU_INCLUDE_DIRS}") - endif() - set(CMAKE_REQUIRED_FLAGS) - foreach(libdir ${STARPU_LIBRARY_DIRS}) - if (libdir) - list(APPEND REQUIRED_LIBDIRS "${libdir}") - endif() - endforeach() - set(REQUIRED_LIBS "${STARPU_LIBRARIES}") - # HWLOC - if (HWLOC_FOUND AND STARPU_LOOK_FOR_HWLOC) - if (HWLOC_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${HWLOC_INCLUDE_DIRS}") - endif() - if (HWLOC_LIBRARY_DIRS) - list(APPEND REQUIRED_LIBDIRS "${HWLOC_LIBRARY_DIRS}") - endif() - foreach(lib ${HWLOC_LIBRARIES}) - if (EXISTS ${lib} OR ${lib} MATCHES "^-") - list(APPEND REQUIRED_LIBS "${lib}") - else() - list(APPEND REQUIRED_LIBS "-l${lib}") - endif() - endforeach() - endif() - # MPI - if (MPI_FOUND AND STARPU_LOOK_FOR_MPI) - if (MPI_C_INCLUDE_PATH) - list(APPEND REQUIRED_INCDIRS "${MPI_C_INCLUDE_PATH}") - endif() - if (MPI_C_LINK_FLAGS) - if (${MPI_C_LINK_FLAGS} MATCHES " -") - string(REGEX REPLACE " -" "-" MPI_C_LINK_FLAGS ${MPI_C_LINK_FLAGS}) - endif() - list(APPEND REQUIRED_LDFLAGS "${MPI_C_LINK_FLAGS}") - endif() - list(APPEND REQUIRED_LIBS "${MPI_C_LIBRARIES}") - endif() - # MAGMA - if (MAGMA_FOUND AND STARPU_LOOK_FOR_MAGMA) - if (MAGMA_INCLUDE_DIRS_DEP) - list(APPEND REQUIRED_INCDIRS "${MAGMA_INCLUDE_DIRS_DEP}") - elseif(MAGMA_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${MAGMA_INCLUDE_DIRS}") - endif() - if (MAGMA_LIBRARY_DIRS_DEP) - list(APPEND REQUIRED_LIBDIRS "${MAGMA_LIBRARY_DIRS_DEP}") - elseif(MAGMA_LIBRARY_DIRS) - list(APPEND REQUIRED_LIBDIRS "${MAGMA_LIBRARY_DIRS}") - endif() - if (MAGMA_LIBRARIES_DEP) - list(APPEND REQUIRED_LIBS "${MAGMA_LIBRARIES_DEP}") - elseif(MAGMA_LIBRARIES) - foreach(lib ${MAGMA_LIBRARIES}) - if (EXISTS ${lib} OR ${lib} MATCHES "^-") - list(APPEND REQUIRED_LIBS "${lib}") - else() - list(APPEND REQUIRED_LIBS "-l${lib}") - 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) - if (CUDA_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${CUDA_INCLUDE_DIRS}") - endif() - if (CUDA_LIBRARY_DIRS) - list(APPEND REQUIRED_LIBDIRS "${CUDA_LIBRARY_DIRS}") - endif() - list(APPEND REQUIRED_LIBS "${CUDA_CUBLAS_LIBRARIES};${CUDA_LIBRARIES}") - endif() - # FXT - if (FXT_FOUND AND STARPU_LOOK_FOR_FXT) - if (FXT_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${FXT_INCLUDE_DIRS}") - endif() - if (FXT_LIBRARY_DIRS) - list(APPEND REQUIRED_LIBDIRS "${FXT_LIBRARY_DIRS}") - endif() - foreach(lib ${FXT_LIBRARIES}) - if (EXISTS ${lib} OR ${lib} MATCHES "^-") - list(APPEND REQUIRED_LIBS "${lib}") - else() - list(APPEND REQUIRED_LIBS "-l${lib}") - endif() - endforeach() - endif() - # SIMGRID - if (SIMGRID_FOUND AND STARPU_LOOK_FOR_SIMGRID) - if (SIMGRID_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${SIMGRID_INCLUDE_DIRS}") - endif() - if (SIMGRID_LIBRARY_DIRS) - list(APPEND REQUIRED_LIBDIRS "${SIMGRID_LIBRARY_DIRS}") - endif() - foreach(lib ${SIMGRID_LIBRARIES}) - if (EXISTS ${lib} OR ${lib} MATCHES "^-") - list(APPEND REQUIRED_LIBS "${lib}") - else() - list(APPEND REQUIRED_LIBS "-l${lib}") - endif() - endforeach() - list(APPEND REQUIRED_FLAGS "-include starpu_simgrid_wrap.h") - endif() - # BLAS - if (BLAS_FOUND AND STARPU_LOOK_FOR_BLAS) - if (BLAS_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${BLAS_INCLUDE_DIRS}") - endif() - if (BLAS_LIBRARY_DIRS) - 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_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}) - - # 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}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - - # test link - unset(STARPU_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(starpu_init STARPU_WORKS) - mark_as_advanced(STARPU_WORKS) - - if(STARPU_WORKS) - # save link with dependencies - if (REQUIRED_FLAGS) - set(STARPU_LIBRARIES_DEP "${REQUIRED_FLAGS};${REQUIRED_LIBS}") - else() - set(STARPU_LIBRARIES_DEP "${REQUIRED_LIBS}") - 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") - message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") - message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") - message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") - message(STATUS "Maybe STARPU is linked with specific libraries. " - "Have you tried with COMPONENTS (HWLOC, CUDA, MPI, BLAS, MAGMA, FXT, SIMGRID)? " - "See the explanation in FindSTARPU.cmake.") - endif() - endif() - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_LIBRARIES) - endif(STARPU_LIBRARIES) + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) + endif(STARPU_LIBRARIES) endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT STARPU_FOUND) OR (STARPU_GIVEN_BY_USER) ) if (STARPU_LIBRARIES) - 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_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of STARPU library" FORCE) - else() - set(STARPU_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of STARPU library" FORCE) - endif() + 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_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of STARPU library" FORCE) + else() + set(STARPU_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of STARPU library" FORCE) + endif() endif() mark_as_advanced(STARPU_DIR) mark_as_advanced(STARPU_DIR_FOUND) @@ -915,34 +915,34 @@ mark_as_advanced(STARPU_DIR_FOUND) # -------------------------------- include(FindPackageHandleStandardArgs) if(NOT STARPU_FIND_QUIETLY) - if(STARPU_SHM_FOUND) - message(STATUS "StarPU library has been found.") - if(STARPU_MPI_LIBRARIES) - message(STATUS "The mpi version of StarPU has been found so that we manage" - "two lists of libs, one sequential and one parallel (see" - "STARPU_SHM_LIBRARIES and STARPU_MPI_LIBRARIES).") - endif() - message(STATUS "StarPU shared memory libraries stored in STARPU_SHM_LIBRARIES") + if(STARPU_SHM_FOUND) + message(STATUS "StarPU library has been found.") + if(STARPU_MPI_LIBRARIES) + message(STATUS "The mpi version of StarPU has been found so that we manage" + "two lists of libs, one sequential and one parallel (see" + "STARPU_SHM_LIBRARIES and STARPU_MPI_LIBRARIES).") endif() + message(STATUS "StarPU shared memory libraries stored in STARPU_SHM_LIBRARIES") + endif() endif() if (PKG_CONFIG_EXECUTABLE AND STARPU_SHM_FOUND AND NOT STARPU_GIVEN_BY_USER) - find_package_handle_standard_args(STARPU DEFAULT_MSG - STARPU_SHM_LIBRARIES) + find_package_handle_standard_args(STARPU DEFAULT_MSG + STARPU_SHM_LIBRARIES) else() - find_package_handle_standard_args(STARPU DEFAULT_MSG - STARPU_SHM_LIBRARIES - STARPU_WORKS) + find_package_handle_standard_args(STARPU DEFAULT_MSG + STARPU_SHM_LIBRARIES + STARPU_WORKS) endif() if(STARPU_LOOK_FOR_MPI) - if(STARPU_MPI_LIBRARIES AND NOT STARPU_FIND_QUIETLY) - message(STATUS "StarPU mpi libraries stored in STARPU_MPI_LIBRARIES") - endif() - if (PKG_CONFIG_EXECUTABLE AND STARPU_MPI_FOUND AND NOT STARPU_GIVEN_BY_USER) - find_package_handle_standard_args(STARPU DEFAULT_MSG - STARPU_MPI_LIBRARIES) - else() - find_package_handle_standard_args(STARPU DEFAULT_MSG - STARPU_MPI_LIBRARIES - STARPU_WORKS) - endif() + if(STARPU_MPI_LIBRARIES AND NOT STARPU_FIND_QUIETLY) + message(STATUS "StarPU mpi libraries stored in STARPU_MPI_LIBRARIES") + endif() + if (PKG_CONFIG_EXECUTABLE AND STARPU_MPI_FOUND AND NOT STARPU_GIVEN_BY_USER) + find_package_handle_standard_args(STARPU DEFAULT_MSG + STARPU_MPI_LIBRARIES) + else() + find_package_handle_standard_args(STARPU DEFAULT_MSG + STARPU_MPI_LIBRARIES + STARPU_WORKS) + endif() endif() diff --git a/CMakeModules/morse/find/FindSUITESPARSE.cmake b/CMakeModules/morse/find/FindSUITESPARSE.cmake index f2493d36ef165a3e4e0c986e8fd8aedf6b58fcd4..6a017bfab7553a22a291c17ada62c34df9381a63 100644 --- a/CMakeModules/morse/find/FindSUITESPARSE.cmake +++ b/CMakeModules/morse/find/FindSUITESPARSE.cmake @@ -55,58 +55,58 @@ if (NOT SUITESPARSE_FOUND) - set(SUITESPARSE_DIR "" CACHE PATH "Installation directory of SUITESPARSE library") - if (NOT SUITESPARSE_FIND_QUIETLY) - message(STATUS "A cache variable, namely SUITESPARSE_DIR, has been set to specify the install directory of SUITESPARSE") - endif() + set(SUITESPARSE_DIR "" CACHE PATH "Installation directory of SUITESPARSE library") + if (NOT SUITESPARSE_FIND_QUIETLY) + message(STATUS "A cache variable, namely SUITESPARSE_DIR, has been set to specify the install directory of SUITESPARSE") + endif() endif() if (NOT SUITESPARSE_FIND_QUIETLY) - message(STATUS "Looking for SUITESPARSE") + message(STATUS "Looking for SUITESPARSE") endif() if (NOT SUITESPARSE_FIND_QUIETLY) - message(STATUS "Looking for SUITESPARSE - PkgConfig not used") + message(STATUS "Looking for SUITESPARSE - PkgConfig not used") endif() # Required dependencies # --------------------- if (NOT SUITESPARSE_FIND_QUIETLY) - message(STATUS "Looking for SUITESPARSE - Try to detect metis") + message(STATUS "Looking for SUITESPARSE - Try to detect metis") endif() if (NOT METIS_FOUND) - if (SUITESPARSE_FIND_REQUIRED) - find_package(METIS REQUIRED) - else() - find_package(METIS) - endif() + if (SUITESPARSE_FIND_REQUIRED) + find_package(METIS REQUIRED) + else() + find_package(METIS) + endif() endif() # SUITESPARSE depends on BLAS #---------------------------- if (NOT SUITESPARSE_FIND_QUIETLY) - message(STATUS "Looking for SUITESPARSE - Try to detect BLAS") + message(STATUS "Looking for SUITESPARSE - Try to detect BLAS") endif() if (NOT BLASEXT_FOUND) - if (SUITESPARSE_FIND_REQUIRED) - find_package(BLASEXT REQUIRED) - else() - find_package(BLASEXT) - endif() + if (SUITESPARSE_FIND_REQUIRED) + find_package(BLASEXT REQUIRED) + else() + find_package(BLASEXT) + endif() endif() # SUITESPARSE depends on LAPACK #------------------------------ if (NOT SUITESPARSE_FIND_QUIETLY) - message(STATUS "Looking for SUITESPARSE - Try to detect LAPACK") + message(STATUS "Looking for SUITESPARSE - Try to detect LAPACK") endif() if (NOT LAPACKEXT_FOUND) - if (SUITESPARSE_FIND_REQUIRED) - find_package(LAPACKEXT REQUIRED) - else() - find_package(LAPACKEXT) - endif() + if (SUITESPARSE_FIND_REQUIRED) + find_package(LAPACKEXT REQUIRED) + else() + find_package(LAPACKEXT) + endif() endif() # Looking for SUITESPARSE @@ -118,24 +118,24 @@ unset(_inc_env) set(ENV_SUITESPARSE_DIR "$ENV{SUITESPARSE_DIR}") set(ENV_SUITESPARSE_INCDIR "$ENV{SUITESPARSE_INCDIR}") if(ENV_SUITESPARSE_INCDIR) - list(APPEND _inc_env "${ENV_SUITESPARSE_INCDIR}") + list(APPEND _inc_env "${ENV_SUITESPARSE_INCDIR}") elseif(ENV_SUITESPARSE_DIR) - list(APPEND _inc_env "${ENV_SUITESPARSE_DIR}") - list(APPEND _inc_env "${ENV_SUITESPARSE_DIR}/include") - list(APPEND _inc_env "${ENV_SUITESPARSE_DIR}/include/suitesparse") + list(APPEND _inc_env "${ENV_SUITESPARSE_DIR}") + list(APPEND _inc_env "${ENV_SUITESPARSE_DIR}/include") + list(APPEND _inc_env "${ENV_SUITESPARSE_DIR}/include/suitesparse") else() - if(WIN32) - string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") - else() - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{CPATH}") - list(APPEND _inc_env "${_path_env}") - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") - list(APPEND _inc_env "${_path_env}") - endif() + if(WIN32) + string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") + else() + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{CPATH}") + list(APPEND _inc_env "${_path_env}") + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}") + list(APPEND _inc_env "${_path_env}") + endif() endif() list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}") list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") @@ -146,22 +146,22 @@ list(REMOVE_DUPLICATES _inc_env) unset(_lib_env) set(ENV_SUITESPARSE_LIBDIR "$ENV{SUITESPARSE_LIBDIR}") if(ENV_SUITESPARSE_LIBDIR) - list(APPEND _lib_env "${ENV_SUITESPARSE_LIBDIR}") + list(APPEND _lib_env "${ENV_SUITESPARSE_LIBDIR}") elseif(ENV_SUITESPARSE_DIR) - list(APPEND _lib_env "${ENV_SUITESPARSE_DIR}") - list(APPEND _lib_env "${ENV_SUITESPARSE_DIR}/lib") + list(APPEND _lib_env "${ENV_SUITESPARSE_DIR}") + list(APPEND _lib_env "${ENV_SUITESPARSE_DIR}/lib") else() - if(WIN32) - string(REPLACE ":" ";" _lib_env "$ENV{LIB}") + if(WIN32) + string(REPLACE ":" ";" _lib_env "$ENV{LIB}") + else() + if(APPLE) + string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") else() - if(APPLE) - string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") endif() + list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") + list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + endif() endif() list(REMOVE_DUPLICATES _lib_env) @@ -172,64 +172,64 @@ list(REMOVE_DUPLICATES _lib_env) # ---------------------------------------------- # create list of headers to find -list(APPEND SUITESPARSE_hdrs_to_find - "amd.h" - "btf.h" - "ccolamd.h" - "colamd.h" - "cs.h" - "klu.h" - "ldl.h" - "RBio.h" - "spqr.hpp" - "SuiteSparse_config.h" - "umfpack.h") +list(APPEND SUITESPARSE_hdrs_to_find + "amd.h" + "btf.h" + "ccolamd.h" + "colamd.h" + "cs.h" + "klu.h" + "ldl.h" + "RBio.h" + "spqr.hpp" + "SuiteSparse_config.h" + "umfpack.h") # call cmake macro to find the header path if(SUITESPARSE_INCDIR) + foreach(suitesparse_hdr ${SUITESPARSE_hdrs_to_find}) + set(SUITESPARSE_${suitesparse_hdr}_DIRS "SUITESPARSE_${suitesparse_hdr}_INCLUDE_DIRS-NOTFOUND") + find_path(SUITESPARSE_${suitesparse_hdr}_DIRS + NAMES ${suitesparse_hdr} + HINTS ${SUITESPARSE_INCDIR}) + mark_as_advanced(SUITESPARSE_${suitesparse_hdr}_DIRS) + endforeach() +else() + if(SUITESPARSE_DIR) + set(SUITESPARSE_${suitesparse_hdr}_DIRS "SUITESPARSE_${suitesparse_hdr}_INCLUDE_DIRS-NOTFOUND") foreach(suitesparse_hdr ${SUITESPARSE_hdrs_to_find}) - set(SUITESPARSE_${suitesparse_hdr}_DIRS "SUITESPARSE_${suitesparse_hdr}_INCLUDE_DIRS-NOTFOUND") - find_path(SUITESPARSE_${suitesparse_hdr}_DIRS - NAMES ${suitesparse_hdr} - HINTS ${SUITESPARSE_INCDIR}) - mark_as_advanced(SUITESPARSE_${suitesparse_hdr}_DIRS) + find_path(SUITESPARSE_${suitesparse_hdr}_DIRS + NAMES ${suitesparse_hdr} + HINTS ${SUITESPARSE_DIR} + PATH_SUFFIXES "include") + mark_as_advanced(SUITESPARSE_${suitesparse_hdr}_DIRS) endforeach() -else() - if(SUITESPARSE_DIR) - set(SUITESPARSE_${suitesparse_hdr}_DIRS "SUITESPARSE_${suitesparse_hdr}_INCLUDE_DIRS-NOTFOUND") - foreach(suitesparse_hdr ${SUITESPARSE_hdrs_to_find}) - find_path(SUITESPARSE_${suitesparse_hdr}_DIRS - NAMES ${suitesparse_hdr} - HINTS ${SUITESPARSE_DIR} - PATH_SUFFIXES "include") - mark_as_advanced(SUITESPARSE_${suitesparse_hdr}_DIRS) - endforeach() - else() - foreach(suitesparse_hdr ${SUITESPARSE_hdrs_to_find}) - set(SUITESPARSE_${suitesparse_hdr}_DIRS "SUITESPARSE_${suitesparse_hdr}_INCLUDE_DIRS-NOTFOUND") - find_path(SUITESPARSE_${suitesparse_hdr}_DIRS - NAMES ${suitesparse_hdr} - HINTS ${_inc_env}) - mark_as_advanced(SUITESPARSE_${suitesparse_hdr}_DIRS) - endforeach() - endif() + else() + foreach(suitesparse_hdr ${SUITESPARSE_hdrs_to_find}) + set(SUITESPARSE_${suitesparse_hdr}_DIRS "SUITESPARSE_${suitesparse_hdr}_INCLUDE_DIRS-NOTFOUND") + find_path(SUITESPARSE_${suitesparse_hdr}_DIRS + NAMES ${suitesparse_hdr} + HINTS ${_inc_env}) + mark_as_advanced(SUITESPARSE_${suitesparse_hdr}_DIRS) + endforeach() + endif() endif() # If found, add path to cmake variable # ------------------------------------ # detect which precisions are available foreach(suitesparse_hdr ${SUITESPARSE_hdrs_to_find}) - if (SUITESPARSE_${suitesparse_hdr}_DIRS) - list(APPEND SUITESPARSE_INCLUDE_DIRS "${SUITESPARSE_${suitesparse_hdr}_DIRS}") - else () - # SuiteSparse_config.h is the minimum to find, consider others as optional? - if (NOT SUITESPARSE_${SuiteSparse_config.h}_DIRS ) - set(SUITESPARSE_INCLUDE_DIRS "SUITESPARSE_INCLUDE_DIRS-NOTFOUND") - endif() - if (NOT SUITESPARSE_FIND_QUIETLY) - message(STATUS "Looking for suitesparse -- ${suitesparse_hdr} not found") - endif() + if (SUITESPARSE_${suitesparse_hdr}_DIRS) + list(APPEND SUITESPARSE_INCLUDE_DIRS "${SUITESPARSE_${suitesparse_hdr}_DIRS}") + else () + # SuiteSparse_config.h is the minimum to find, consider others as optional? + if (NOT SUITESPARSE_${SuiteSparse_config.h}_DIRS ) + set(SUITESPARSE_INCLUDE_DIRS "SUITESPARSE_INCLUDE_DIRS-NOTFOUND") endif() + if (NOT SUITESPARSE_FIND_QUIETLY) + message(STATUS "Looking for suitesparse -- ${suitesparse_hdr} not found") + endif() + endif() endforeach() @@ -238,49 +238,49 @@ endforeach() # create list of libs to find set(SUITESPARSE_libs_to_find - "cholmod" - "cxsparse" - "klu" - "ldl" - "spqr" - "umfpack" - "amd" - "btf" - "camd" - "ccolamd" - "colamd" - "rbio" - "suitesparseconfig" - ) + "cholmod" + "cxsparse" + "klu" + "ldl" + "spqr" + "umfpack" + "amd" + "btf" + "camd" + "ccolamd" + "colamd" + "rbio" + "suitesparseconfig" + ) # call cmake macro to find the lib path if(SUITESPARSE_LIBDIR) + foreach(suitesparse_lib ${SUITESPARSE_libs_to_find}) + set(SUITESPARSE_${suitesparse_lib}_LIBRARY "SUITESPARSE_${suitesparse_lib}_LIBRARY-NOTFOUND") + find_library(SUITESPARSE_${suitesparse_lib}_LIBRARY + NAMES ${suitesparse_lib} + HINTS ${SUITESPARSE_LIBDIR}) + mark_as_advanced(SUITESPARSE_${suitesparse_lib}_LIBRARY) + endforeach() +else() + if(SUITESPARSE_DIR) foreach(suitesparse_lib ${SUITESPARSE_libs_to_find}) - set(SUITESPARSE_${suitesparse_lib}_LIBRARY "SUITESPARSE_${suitesparse_lib}_LIBRARY-NOTFOUND") - find_library(SUITESPARSE_${suitesparse_lib}_LIBRARY - NAMES ${suitesparse_lib} - HINTS ${SUITESPARSE_LIBDIR}) - mark_as_advanced(SUITESPARSE_${suitesparse_lib}_LIBRARY) + set(SUITESPARSE_${suitesparse_lib}_LIBRARY "SUITESPARSE_${suitesparse_lib}_LIBRARY-NOTFOUND") + find_library(SUITESPARSE_${suitesparse_lib}_LIBRARY + NAMES ${suitesparse_lib} + HINTS ${SUITESPARSE_DIR} + PATH_SUFFIXES lib lib32 lib64) + mark_as_advanced(SUITESPARSE_${suitesparse_lib}_LIBRARY) endforeach() -else() - if(SUITESPARSE_DIR) - foreach(suitesparse_lib ${SUITESPARSE_libs_to_find}) - set(SUITESPARSE_${suitesparse_lib}_LIBRARY "SUITESPARSE_${suitesparse_lib}_LIBRARY-NOTFOUND") - find_library(SUITESPARSE_${suitesparse_lib}_LIBRARY - NAMES ${suitesparse_lib} - HINTS ${SUITESPARSE_DIR} - PATH_SUFFIXES lib lib32 lib64) - mark_as_advanced(SUITESPARSE_${suitesparse_lib}_LIBRARY) - endforeach() - else() - foreach(suitesparse_lib ${SUITESPARSE_libs_to_find}) - set(SUITESPARSE_${suitesparse_lib}_LIBRARY "SUITESPARSE_${suitesparse_lib}_LIBRARY-NOTFOUND") - find_library(SUITESPARSE_${suitesparse_lib}_LIBRARY - NAMES ${suitesparse_lib} - HINTS ${_lib_env}) - mark_as_advanced(SUITESPARSE_${suitesparse_lib}_LIBRARY) - endforeach() - endif() + else() + foreach(suitesparse_lib ${SUITESPARSE_libs_to_find}) + set(SUITESPARSE_${suitesparse_lib}_LIBRARY "SUITESPARSE_${suitesparse_lib}_LIBRARY-NOTFOUND") + find_library(SUITESPARSE_${suitesparse_lib}_LIBRARY + NAMES ${suitesparse_lib} + HINTS ${_lib_env}) + mark_as_advanced(SUITESPARSE_${suitesparse_lib}_LIBRARY) + endforeach() + endif() endif() # If found, add path to cmake variable @@ -288,19 +288,19 @@ endif() set(SUITESPARSE_LIBRARIES "") set(SUITESPARSE_LIBRARY_DIRS "") foreach(suitesparse_lib ${SUITESPARSE_libs_to_find}) - if (SUITESPARSE_${suitesparse_lib}_LIBRARY) - list(APPEND SUITESPARSE_LIBRARIES "${SUITESPARSE_${suitesparse_lib}_LIBRARY}") - get_filename_component(${suitesparse_lib}_lib_path ${SUITESPARSE_${suitesparse_lib}_LIBRARY} PATH) - list(APPEND SUITESPARSE_LIBRARY_DIRS "${${suitesparse_lib}_lib_path}") - else () - # libsuitesparseconfig is the minimum to find, consider others as optional? - if (NOT SUITESPARSE_suitesparseconfig_LIBRARY) - list(APPEND SUITESPARSE_LIBRARIES "${SUITESPARSE_LIBRARIES-NOTFOUND}") - endif() - if(NOT SUITESPARSE_FIND_QUIETLY) - message(STATUS "Looking for suitesparse -- lib${suitesparse_lib}.a/so not found") - endif() + if (SUITESPARSE_${suitesparse_lib}_LIBRARY) + list(APPEND SUITESPARSE_LIBRARIES "${SUITESPARSE_${suitesparse_lib}_LIBRARY}") + get_filename_component(${suitesparse_lib}_lib_path ${SUITESPARSE_${suitesparse_lib}_LIBRARY} PATH) + list(APPEND SUITESPARSE_LIBRARY_DIRS "${${suitesparse_lib}_lib_path}") + else () + # libsuitesparseconfig is the minimum to find, consider others as optional? + if (NOT SUITESPARSE_suitesparseconfig_LIBRARY) + list(APPEND SUITESPARSE_LIBRARIES "${SUITESPARSE_LIBRARIES-NOTFOUND}") endif() + if(NOT SUITESPARSE_FIND_QUIETLY) + message(STATUS "Looking for suitesparse -- lib${suitesparse_lib}.a/so not found") + endif() + endif() endforeach() list(REMOVE_DUPLICATES SUITESPARSE_LIBRARY_DIRS) list(REMOVE_DUPLICATES SUITESPARSE_INCLUDE_DIRS) @@ -308,119 +308,119 @@ list(REMOVE_DUPLICATES SUITESPARSE_INCLUDE_DIRS) # check a function to validate the find if(SUITESPARSE_LIBRARIES) - set(REQUIRED_LDFLAGS) - set(REQUIRED_INCDIRS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) + set(REQUIRED_LDFLAGS) + set(REQUIRED_INCDIRS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) - # SUITESPARSE - if (SUITESPARSE_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${SUITESPARSE_INCLUDE_DIRS}") + # SUITESPARSE + if (SUITESPARSE_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${SUITESPARSE_INCLUDE_DIRS}") + endif() + foreach(libdir ${SUITESPARSE_LIBRARY_DIRS}) + if (libdir) + list(APPEND REQUIRED_LIBDIRS "${libdir}") + endif() + endforeach() + set(REQUIRED_LIBS "${SUITESPARSE_LIBRARIES}") + # METIS + if (METIS_FOUND) + if (METIS_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${METIS_INCLUDE_DIRS}") endif() - foreach(libdir ${SUITESPARSE_LIBRARY_DIRS}) - if (libdir) - list(APPEND REQUIRED_LIBDIRS "${libdir}") - endif() + foreach(libdir ${METIS_LIBRARY_DIRS}) + if (libdir) + list(APPEND REQUIRED_LIBDIRS "${libdir}") + endif() endforeach() - set(REQUIRED_LIBS "${SUITESPARSE_LIBRARIES}") - # METIS - if (METIS_FOUND) - if (METIS_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${METIS_INCLUDE_DIRS}") - endif() - foreach(libdir ${METIS_LIBRARY_DIRS}) - if (libdir) - list(APPEND REQUIRED_LIBDIRS "${libdir}") - endif() - endforeach() - list(APPEND REQUIRED_LIBS "${METIS_LIBRARIES}") + list(APPEND REQUIRED_LIBS "${METIS_LIBRARIES}") + endif() + # LAPACK + if (LAPACK_FOUND) + if (LAPACK_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${LAPACK_INCLUDE_DIRS}") endif() - # LAPACK - if (LAPACK_FOUND) - if (LAPACK_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${LAPACK_INCLUDE_DIRS}") - endif() - foreach(libdir ${LAPACK_LIBRARY_DIRS}) - if (libdir) - list(APPEND REQUIRED_LIBDIRS "${libdir}") - endif() - endforeach() - list(APPEND REQUIRED_LIBS "${LAPACK_LIBRARIES}") - if (LAPACK_LINKER_FLAGS) - list(APPEND REQUIRED_LDFLAGS "${LAPACK_LINKER_FLAGS}") - endif() + foreach(libdir ${LAPACK_LIBRARY_DIRS}) + if (libdir) + list(APPEND REQUIRED_LIBDIRS "${libdir}") + endif() + endforeach() + list(APPEND REQUIRED_LIBS "${LAPACK_LIBRARIES}") + if (LAPACK_LINKER_FLAGS) + list(APPEND REQUIRED_LDFLAGS "${LAPACK_LINKER_FLAGS}") endif() - # BLAS - if (BLAS_FOUND) - if (BLAS_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${BLAS_INCLUDE_DIRS}") - endif() - foreach(libdir ${BLAS_LIBRARY_DIRS}) - if (libdir) - list(APPEND REQUIRED_LIBDIRS "${libdir}") - endif() - endforeach() - list(APPEND REQUIRED_LIBS "${BLAS_LIBRARIES}") - if (BLAS_LINKER_FLAGS) - list(APPEND REQUIRED_LDFLAGS "${BLAS_LINKER_FLAGS}") - endif() + endif() + # BLAS + if (BLAS_FOUND) + if (BLAS_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${BLAS_INCLUDE_DIRS}") endif() - # others - set(M_LIBRARY "M_LIBRARY-NOTFOUND") - find_library(M_LIBRARY NAMES m) - mark_as_advanced(M_LIBRARY) - if(M_LIBRARY) - list(APPEND REQUIRED_LIBS "-lm") + foreach(libdir ${BLAS_LIBRARY_DIRS}) + if (libdir) + list(APPEND REQUIRED_LIBDIRS "${libdir}") + endif() + endforeach() + list(APPEND REQUIRED_LIBS "${BLAS_LIBRARIES}") + if (BLAS_LINKER_FLAGS) + list(APPEND REQUIRED_LDFLAGS "${BLAS_LINKER_FLAGS}") endif() + endif() + # others + set(M_LIBRARY "M_LIBRARY-NOTFOUND") + find_library(M_LIBRARY NAMES m) + mark_as_advanced(M_LIBRARY) + if(M_LIBRARY) + list(APPEND REQUIRED_LIBS "-lm") + 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}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_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() + list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") + string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - # test link - include(CheckFortranFunctionExists) - unset(SUITESPARSE_WORKS CACHE) - check_function_exists(SuiteSparse_start SUITESPARSE_WORKS) - mark_as_advanced(SUITESPARSE_WORKS) + # test link + include(CheckFortranFunctionExists) + unset(SUITESPARSE_WORKS CACHE) + check_function_exists(SuiteSparse_start SUITESPARSE_WORKS) + mark_as_advanced(SUITESPARSE_WORKS) - if(SUITESPARSE_WORKS) - # save link with dependencies - set(SUITESPARSE_LIBRARIES_DEP "${REQUIRED_LIBS}") - set(SUITESPARSE_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}") - set(SUITESPARSE_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") - set(SUITESPARSE_LINKER_FLAGS "${REQUIRED_LDFLAGS}") - list(REMOVE_DUPLICATES SUITESPARSE_LIBRARY_DIRS_DEP) - list(REMOVE_DUPLICATES SUITESPARSE_INCLUDE_DIRS_DEP) - list(REMOVE_DUPLICATES SUITESPARSE_LINKER_FLAGS) - else() - if(NOT SUITESPARSE_FIND_QUIETLY) - message(STATUS "Looking for SUITESPARSE : test of symbol SuiteSparse_start fails") - message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") - message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") - message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") - message(STATUS "Maybe SUITESPARSE is linked with specific libraries. ") - endif() + if(SUITESPARSE_WORKS) + # save link with dependencies + set(SUITESPARSE_LIBRARIES_DEP "${REQUIRED_LIBS}") + set(SUITESPARSE_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}") + set(SUITESPARSE_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") + set(SUITESPARSE_LINKER_FLAGS "${REQUIRED_LDFLAGS}") + list(REMOVE_DUPLICATES SUITESPARSE_LIBRARY_DIRS_DEP) + list(REMOVE_DUPLICATES SUITESPARSE_INCLUDE_DIRS_DEP) + list(REMOVE_DUPLICATES SUITESPARSE_LINKER_FLAGS) + else() + if(NOT SUITESPARSE_FIND_QUIETLY) + message(STATUS "Looking for SUITESPARSE : test of symbol SuiteSparse_start fails") + message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") + message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") + message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") + message(STATUS "Maybe SUITESPARSE is linked with specific libraries. ") endif() - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_LIBRARIES) + endif() + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) endif(SUITESPARSE_LIBRARIES) if (SUITESPARSE_LIBRARIES) - list(GET SUITESPARSE_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(SUITESPARSE_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of SUITESPARSE library" FORCE) - else() - set(SUITESPARSE_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of SUITESPARSE library" FORCE) - endif() + list(GET SUITESPARSE_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(SUITESPARSE_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of SUITESPARSE library" FORCE) + else() + set(SUITESPARSE_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of SUITESPARSE library" FORCE) + endif() endif() mark_as_advanced(SUITESPARSE_DIR) mark_as_advanced(SUITESPARSE_DIR_FOUND) @@ -429,5 +429,5 @@ mark_as_advanced(SUITESPARSE_DIR_FOUND) # ------------------------------- include(FindPackageHandleStandardArgs) find_package_handle_standard_args(SUITESPARSE DEFAULT_MSG - SUITESPARSE_LIBRARIES - SUITESPARSE_WORKS) + SUITESPARSE_LIBRARIES + SUITESPARSE_WORKS) diff --git a/CMakeModules/morse/find/FindTMG.cmake b/CMakeModules/morse/find/FindTMG.cmake index 3b2ba95c5ca3b6393a4df0d091f1d78020d058ba..745cb4516eb5c8db5835ca8872e213255848754f 100644 --- a/CMakeModules/morse/find/FindTMG.cmake +++ b/CMakeModules/morse/find/FindTMG.cmake @@ -52,248 +52,248 @@ if (NOT TMG_FOUND) - 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() + 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() 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 anyway, try to find it if (NOT LAPACK_FOUND) - if(TMG_FIND_REQUIRED) - find_package(LAPACKEXT REQUIRED) - else() - find_package(LAPACKEXT) - endif() + if(TMG_FIND_REQUIRED) + find_package(LAPACKEXT REQUIRED) + else() + find_package(LAPACKEXT) + endif() endif() # TMG depends on LAPACK if (LAPACK_FOUND) - # check if a tmg function exists in the LAPACK lib - set(CMAKE_REQUIRED_LIBRARIES "${LAPACK_LINKER_FLAGS};${LAPACK_LIBRARIES}") - include(CheckFunctionExists) - include(CheckFortranFunctionExists) + # check if a tmg function exists in the LAPACK lib + set(CMAKE_REQUIRED_LIBRARIES "${LAPACK_LINKER_FLAGS};${LAPACK_LIBRARIES}") + include(CheckFunctionExists) + include(CheckFortranFunctionExists) + unset(TMG_WORKS CACHE) + 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(dlarnv TMG_WORKS) + check_function_exists(dlagsy TMG_WORKS) else (NOT _LANGUAGES_ MATCHES Fortran) - check_fortran_function_exists(dlarnv TMG_WORKS) + check_fortran_function_exists(dlagsy 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() - set(CMAKE_REQUIRED_LIBRARIES) + mark_as_advanced(TMG_WORKS) + endif() + set(CMAKE_REQUIRED_LIBRARIES) - if(TMG_WORKS) - if(NOT TMG_FIND_QUIETLY) - message(STATUS "Looking for tmg: test with lapack succeeds") - endif() - # test succeeds: TMG is in LAPACK - set(TMG_LIBRARIES "${LAPACK_LIBRARIES}") - 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(TMG_WORKS) + if(NOT TMG_FIND_QUIETLY) + message(STATUS "Looking for tmg: test with lapack succeeds") + endif() + # test succeeds: TMG is in LAPACK + set(TMG_LIBRARIES "${LAPACK_LIBRARIES}") + 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) - message(STATUS "Looking for tmg : test with lapack fails") - message(STATUS "Looking for tmg : try to find it elsewhere") - endif() - # test fails: try to find TMG lib exterior to LAPACK + if(NOT TMG_FIND_QUIETLY) + message(STATUS "Looking for tmg : test with lapack fails") + message(STATUS "Looking for tmg : try to find it elsewhere") + endif() + # test fails: try to find TMG lib exterior to LAPACK - # Looking for lib tmg - # ------------------- + # Looking for lib tmg + # ------------------- - # Add system library paths to search lib - # -------------------------------------- - unset(_lib_env) - set(ENV_TMG_DIR "$ENV{TMG_DIR}") - set(ENV_TMG_LIBDIR "$ENV{TMG_LIBDIR}") - if(ENV_TMG_LIBDIR) - list(APPEND _lib_env "${ENV_TMG_LIBDIR}") - elseif(ENV_TMG_DIR) - list(APPEND _lib_env "${ENV_TMG_DIR}") - list(APPEND _lib_env "${ENV_TMG_DIR}/lib") - else() - if(WIN32) - string(REPLACE ":" ";" _lib_env "$ENV{LIB}") - else() - if(APPLE) - string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - endif() - endif() - list(REMOVE_DUPLICATES _lib_env) + # Add system library paths to search lib + # -------------------------------------- + unset(_lib_env) + set(ENV_TMG_DIR "$ENV{TMG_DIR}") + set(ENV_TMG_LIBDIR "$ENV{TMG_LIBDIR}") + if(ENV_TMG_LIBDIR) + list(APPEND _lib_env "${ENV_TMG_LIBDIR}") + elseif(ENV_TMG_DIR) + list(APPEND _lib_env "${ENV_TMG_DIR}") + list(APPEND _lib_env "${ENV_TMG_DIR}/lib") + else() + if(WIN32) + string(REPLACE ":" ";" _lib_env "$ENV{LIB}") + else() + if(APPLE) + string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") + else() + string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") + endif() + list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") + list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + endif() + endif() + list(REMOVE_DUPLICATES _lib_env) - # Try to find the tmg lib in the given paths - # ---------------------------------------------- + # Try to find the tmg lib in the given paths + # ---------------------------------------------- - # call cmake macro to find the lib path - if(TMG_LIBDIR) - set(TMG_tmg_LIBRARY "TMG_tmg_LIBRARY-NOTFOUND") - find_library(TMG_tmg_LIBRARY - NAMES tmglib tmg - HINTS ${TMG_LIBDIR} ) - else() - if(TMG_DIR) - set(TMG_tmg_LIBRARY "TMG_tmg_LIBRARY-NOTFOUND") - find_library(TMG_tmg_LIBRARY - NAMES tmglib tmg - HINTS ${TMG_DIR} - PATH_SUFFIXES lib lib32 lib64 ) - else() - set(TMG_tmg_LIBRARY "TMG_tmg_LIBRARY-NOTFOUND") - find_library(TMG_tmg_LIBRARY - NAMES tmglib tmg - HINTS ${_lib_env} ) - endif() - endif() - mark_as_advanced(TMG_tmg_LIBRARY) + # call cmake macro to find the lib path + if(TMG_LIBDIR) + set(TMG_tmg_LIBRARY "TMG_tmg_LIBRARY-NOTFOUND") + find_library(TMG_tmg_LIBRARY + NAMES tmglib tmg + HINTS ${TMG_LIBDIR} ) + else() + if(TMG_DIR) + set(TMG_tmg_LIBRARY "TMG_tmg_LIBRARY-NOTFOUND") + find_library(TMG_tmg_LIBRARY + NAMES tmglib tmg + HINTS ${TMG_DIR} + PATH_SUFFIXES lib lib32 lib64 ) + else() + set(TMG_tmg_LIBRARY "TMG_tmg_LIBRARY-NOTFOUND") + find_library(TMG_tmg_LIBRARY + NAMES tmglib tmg + HINTS ${_lib_env} ) + endif() + endif() + mark_as_advanced(TMG_tmg_LIBRARY) - # If found, add path to cmake variable - # ------------------------------------ - if (TMG_tmg_LIBRARY) - get_filename_component(tmg_lib_path ${TMG_tmg_LIBRARY} PATH) - # set cmake variables (respects naming convention) - set(TMG_LIBRARIES "${TMG_tmg_LIBRARY}") - set(TMG_LIBRARY_DIRS "${tmg_lib_path}") - else () - set(TMG_LIBRARIES "TMG_LIBRARIES-NOTFOUND") - set(TMG_LIBRARY_DIRS "TMG_LIBRARY_DIRS-NOTFOUND") - if(NOT TMG_FIND_QUIETLY) - message(STATUS "Looking for tmg -- lib tmg not found") - endif() - endif () + # If found, add path to cmake variable + # ------------------------------------ + if (TMG_tmg_LIBRARY) + get_filename_component(tmg_lib_path ${TMG_tmg_LIBRARY} PATH) + # set cmake variables (respects naming convention) + set(TMG_LIBRARIES "${TMG_tmg_LIBRARY}") + set(TMG_LIBRARY_DIRS "${tmg_lib_path}") + else () + set(TMG_LIBRARIES "TMG_LIBRARIES-NOTFOUND") + set(TMG_LIBRARY_DIRS "TMG_LIBRARY_DIRS-NOTFOUND") + if(NOT TMG_FIND_QUIETLY) + message(STATUS "Looking for tmg -- lib tmg not found") + endif() + endif () - if (TMG_LIBRARY_DIRS) - list(REMOVE_DUPLICATES TMG_LIBRARY_DIRS) - endif () + if (TMG_LIBRARY_DIRS) + list(REMOVE_DUPLICATES TMG_LIBRARY_DIRS) + endif () - # check a function to validate the find - if(TMG_LIBRARIES) + # check a function to validate the find + if(TMG_LIBRARIES) - set(REQUIRED_LDFLAGS) - set(REQUIRED_INCDIRS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) + set(REQUIRED_LDFLAGS) + set(REQUIRED_INCDIRS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) - # TMG - if (TMG_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${TMG_INCLUDE_DIRS}") - endif() - if (TMG_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${TMG_LIBRARY_DIRS}") - endif() - set(REQUIRED_LIBS "${TMG_LIBRARIES}") - # LAPACK - if (LAPACK_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${LAPACK_INCLUDE_DIRS}") - endif() - if (LAPACK_LIBRARY_DIRS) - 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() + # TMG + if (TMG_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${TMG_INCLUDE_DIRS}") + endif() + if (TMG_LIBRARY_DIRS) + set(REQUIRED_LIBDIRS "${TMG_LIBRARY_DIRS}") + endif() + set(REQUIRED_LIBS "${TMG_LIBRARIES}") + # LAPACK + if (LAPACK_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${LAPACK_INCLUDE_DIRS}") + endif() + if (LAPACK_LIBRARY_DIRS) + 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() - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_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() + list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") + string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - # test link - 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() + # test link + 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) - # save link with dependencies - 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") - message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") - message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") - message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") - endif() - endif() - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_LIBRARIES) - endif(TMG_LIBRARIES) + if(TMG_WORKS) + # save link with dependencies + 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") + message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") + message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") + message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") + endif() + endif() + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) + endif(TMG_LIBRARIES) - endif() + endif() else() - if(NOT TMG_FIND_QUIETLY) - message(STATUS "TMG requires LAPACK but LAPACK has not been found." - "Please look for LAPACK first.") - endif() + if(NOT TMG_FIND_QUIETLY) + message(STATUS "TMG requires LAPACK but LAPACK has not been found." + "Please look for LAPACK first.") + endif() endif() if (TMG_LIBRARIES) - 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_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of TMG library" FORCE) - else() - set(TMG_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of TMG library" FORCE) - endif() + 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_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of TMG library" FORCE) + else() + set(TMG_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of TMG library" FORCE) + endif() endif() mark_as_advanced(TMG_DIR) mark_as_advanced(TMG_DIR_FOUND) @@ -302,5 +302,5 @@ mark_as_advanced(TMG_DIR_FOUND) # ------------------------------- include(FindPackageHandleStandardArgs) find_package_handle_standard_args(TMG DEFAULT_MSG - TMG_LIBRARIES - TMG_WORKS) + TMG_LIBRARIES + TMG_WORKS) diff --git a/CMakeModules/morse/find/RulesJDF.cmake b/CMakeModules/morse/find/RulesJDF.cmake index d3b811e7538d6a7cd96c3a3bdbe8f3572d1d850e..2251edd5dd4c9c49be7af08a84a551c41f5896dd 100644 --- a/CMakeModules/morse/find/RulesJDF.cmake +++ b/CMakeModules/morse/find/RulesJDF.cmake @@ -24,18 +24,18 @@ macro(jdf_rules jdf_rules_OUTPUTLIST jdf_rules_SOURCES) if( jdf_rules_IsInBinaryDir ) add_custom_command( - OUTPUT ${jdf_rules_OSRC}.h ${jdf_rules_OSRC}.c - COMMAND ${PARSEC_DAGUEPP} ${DAGUEPP_CFLAGS} ${ADDITIONAL_DAGUEPP_CFLAGS} -E -i ${jdf_rules_SRC}.jdf -o ${jdf_rules_OSRC} -f ${jdf_rules_BSRC} - MAIN_DEPENDENCY ${CMAKE_CURRENT_BINARY_DIR}/${jdf_rules_SRC}.jdf - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${jdf_rules_SRC}.jdf ${PARSEC_DAGUEPP}) + OUTPUT ${jdf_rules_OSRC}.h ${jdf_rules_OSRC}.c + COMMAND ${PARSEC_DAGUEPP} ${DAGUEPP_CFLAGS} ${ADDITIONAL_DAGUEPP_CFLAGS} -E -i ${jdf_rules_SRC}.jdf -o ${jdf_rules_OSRC} -f ${jdf_rules_BSRC} + MAIN_DEPENDENCY ${CMAKE_CURRENT_BINARY_DIR}/${jdf_rules_SRC}.jdf + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${jdf_rules_SRC}.jdf ${PARSEC_DAGUEPP}) else( jdf_rules_IsInBinaryDir ) add_custom_command( - OUTPUT ${jdf_rules_OSRC}.h ${jdf_rules_OSRC}.c - COMMAND ${PARSEC_DAGUEPP} ${DAGUEPP_CFLAGS} ${ADDITIONAL_DAGUEPP_CFLAGS} -E -i ${jdf_rules_SRC}.jdf -o ${jdf_rules_OSRC} -f ${jdf_rules_BSRC} - MAIN_DEPENDENCY ${jdf_rules_SRC}.jdf - DEPENDS ${jdf_rules_SRC}.jdf ${PARSEC_DAGUEPP}) + OUTPUT ${jdf_rules_OSRC}.h ${jdf_rules_OSRC}.c + COMMAND ${PARSEC_DAGUEPP} ${DAGUEPP_CFLAGS} ${ADDITIONAL_DAGUEPP_CFLAGS} -E -i ${jdf_rules_SRC}.jdf -o ${jdf_rules_OSRC} -f ${jdf_rules_BSRC} + MAIN_DEPENDENCY ${jdf_rules_SRC}.jdf + DEPENDS ${jdf_rules_SRC}.jdf ${PARSEC_DAGUEPP}) endif( jdf_rules_IsInBinaryDir ) @@ -43,7 +43,7 @@ macro(jdf_rules jdf_rules_OUTPUTLIST jdf_rules_SOURCES) list(APPEND ${jdf_rules_OUTPUTLIST} "${CMAKE_CURRENT_BINARY_DIR}/${jdf_rules_OSRC}.h;${CMAKE_CURRENT_BINARY_DIR}/${jdf_rules_OSRC}.c") get_source_file_property(jdf_rules_CompileFlags ${jdf_rules_SOURCE} COMPILE_FLAGS ) if( jdf_rules_CompileFlags ) - set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${jdf_rules_OSRC}.c PROPERTIES COMPILE_FLAGS ${jdf_rules_CompileFlags} ) + set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${jdf_rules_OSRC}.c PROPERTIES COMPILE_FLAGS ${jdf_rules_CompileFlags} ) endif() endforeach() diff --git a/CMakeModules/morse/precision_generator/subs.py b/CMakeModules/morse/precision_generator/subs.py index 4df0a6f236c490c9acb02a7fd075cbb233dc2467..e195f43b26d81ec789bc1fc5806dee7c7391c873 100644 --- a/CMakeModules/morse/precision_generator/subs.py +++ b/CMakeModules/morse/precision_generator/subs.py @@ -227,6 +227,17 @@ subs = { # old python (2.4) requires this line to be list [] rather than tuple () to use index() function. ['s', 'd', 'c', 'z' ], + + # TODO clean; shouldn't be added this way + ('cblas_sscal', ' cblas_dscal', 'cblas_csscal', 'cblas_zdscal'), + ('stsmqr_hetra1', 'dtsmqr_hetra1', 'ctsmqr_hetra1', 'ztsmqr_hetra1'), + ('stsmlq_hetra1', 'dtsmlq_hetra1', 'ctsmlq_hetra1', 'ztsmlq_hetra1'), + ('codelet_ssyrfb', 'codelet_dsyrfb', 'codelet_cherfb', 'codelet_zherfb'), + ('cl_ssyrfb', 'cl_dsyrfb', 'cl_cherfb', 'cl_zherfb'), + ('she2ge', 'dhe2ge', 'che2ge', 'zhe2ge'), + ('sgbcpy', 'dgbcpy', 'cgbcpy', 'zgbcpy'), + + # ----- Preprocessor ('#define PRECISION_s', '#define PRECISION_d', '#define PRECISION_c', '#\s*define PRECISION_z' ), ('#undef PRECISION_s', '#undef PRECISION_d', '#undef PRECISION_c', '#undef PRECISION_z' ), @@ -310,6 +321,7 @@ subs = { ('CORE_s', 'CORE_d', 'CORE_s', 'CORE_d' ), ('cpu_gpu_s', 'cpu_gpu_d', 'cpu_gpu_c', 'cpu_gpu_z' ), ('cublasS', 'cublasD', 'cublasC', 'cublasZ' ), + ('CUDA_S', 'CUDA_D', 'CUDA_C', 'CUDA_Z' ), ('CUDA_s', 'CUDA_d', 'CUDA_c', 'CUDA_z' ), ('example_s', 'example_d', 'example_c', 'example_z' ), ('ipt_s', 'ipt_d', 'ipt_c', 'ipt_z' ), @@ -370,6 +382,9 @@ subs = { ('RUNTIME_S', 'RUNTIME_D', 'RUNTIME_C', 'RUNTIME_Z' ), ('RUNTIME_s', 'RUNTIME_d', 'RUNTIME_c', 'RUNTIME_z' ), + ('TASK_s', 'TASK_d', 'TASK_s', 'TASK_d' ), + ('dataflush', 'dataflush', 'dataflush', 'sataflush' ), # Correct previous line + # ----- Complex numbers # \b regexp here avoids conjugate -> conjfugate, # assuming we always translate from z, not to z. @@ -399,8 +414,8 @@ subs = { ('sgetmatrix', 'dgetmatrix', 'cgetmatrix', 'zgetmatrix' ), ('sinplace', 'dinplace', 'cinplace', 'zinplace' ), ('slocality', 'dlocality', 'clocality', 'zlocality' ), - ('slapack', 'dlapack', 'clapack', 'zlapack' ), - ('SLAPACK', 'DLAPACK', 'CLAPACK', 'ZLAPACK' ), + ('slapack', 'dlapack', 'clapack', 'zlapack' ), + ('SLAPACK', 'DLAPACK', 'CLAPACK', 'ZLAPACK' ), ('smalloc', 'dmalloc', 'cmalloc', 'zmalloc' ), ('smalloc', 'dmalloc', 'smalloc', 'dmalloc' ), ('spanel_to_q', 'dpanel_to_q', 'cpanel_to_q', 'zpanel_to_q' ), @@ -414,7 +429,7 @@ subs = { ('SSIZE', 'DSIZE', 'CSIZE', 'ZSIZE' ), ('ssplit', 'dsplit', 'csplit', 'zsplit' ), ('stile', 'dtile', 'ctile', 'ztile' ), - ('STILE', 'DTILE', 'CTILE', 'ZTILE' ), + ('STILE', 'DTILE', 'CTILE', 'ZTILE' ), ('stranspose', 'dtranspose', 'ctranspose', 'ztranspose' ), ('szero', 'dzero', 'czero', 'zzero' ), ('sy2sb', 'sy2sb', 'he2hb', 'he2hb' ), @@ -433,10 +448,10 @@ subs = { ('isamax', 'idamax', 'isamax', 'idamax' ), ('saxpy', 'daxpy', 'caxpy', 'zaxpy' ), ('scopy', 'dcopy', 'ccopy', 'zcopy' ), + ('sgeadd', 'dgeadd', 'cgeadd', 'zgeadd' ), ('sgecfi', 'dgecfi', 'cgecfi', 'zgecfi' ), - ('sgemm', 'dgemm', 'cgemm', 'zgemm' ), ('sgemdm', 'dgemdm', 'cgemdm', 'zgemdm' ), - ('SGEMDM', 'DGEMDM', 'CGEMDM', 'ZGEMDM' ), + ('sgemm', 'dgemm', 'cgemm', 'zgemm' ), ('sgemv', 'dgemv', 'cgemv', 'zgemv' ), ('sscal', 'dscal', 'cscal', 'zscal' ), ('sscal', 'dscal', 'csscal', 'zdscal' ), @@ -446,13 +461,13 @@ subs = { ('ssymv', 'dsymv', 'csymv', 'zsymv' ), ('ssyr2k', 'dsyr2k', 'csyr2k', 'zsyr2k' ), ('ssyrk', 'dsyrk', 'csyrk', 'zsyrk' ), + ('stradd', 'dtradd', 'ctradd', 'ztradd' ), ('strmm', 'dtrmm', 'ctrmm', 'ztrmm' ), ('strmv', 'dtrmv', 'ctrmv', 'ztrmv' ), ('strsm', 'dtrsm', 'ctrsm', 'ztrsm' ), ('strsv', 'dtrsv', 'ctrsv', 'ztrsv' ), # ADD FOR NEW VERSION OF CHAMELEON - ('sgeadd', 'dgeadd', 'cgeadd', 'zgeadd' ), ('shbcpy', 'dhbcpy', 'chbcpy', 'zhbcpy' ), ('ssyrbt', 'dsyrbt', 'cherbt', 'zherbt' ), ('ssygv', 'dsygv', 'chegv', 'zhegv' ), @@ -482,8 +497,9 @@ subs = { ('sgeqrs', 'dgeqrs', 'cgeqrs', 'zgeqrs' ), ('sgeqrt', 'dgeqrt', 'cgeqrt', 'zgeqrt' ), ('sgessm', 'dgessm', 'cgessm', 'zgessm' ), - ('sgessq', 'dgessq', 'cgessq', 'zgessq' ), + ('sgessq', 'dgessq', 'cgessq', 'zgessq' ), ('sgesv', 'dgesv', 'cgesv', 'zgesv' ), + ('sgesvd', 'dgesvd', 'cgesvd', 'zgesvd' ), ('sgesv', 'sgesv', 'cgesv', 'cgesv' ), ('sget22', 'dget22', 'cget22', 'zget22' ), ('sgetf2', 'dgetf2', 'cgetf2', 'zgetf2' ), @@ -523,12 +539,13 @@ subs = { ('slascl', 'dlascl', 'clascl', 'zlascl' ), ('slaset', 'dlaset', 'claset', 'zlaset' ), ('slaswp', 'dlaswp', 'claswp', 'zlaswp' ), + ('slatro', 'dlatro', 'clatro', 'zlatro' ), ('slatrd', 'dlatrd', 'clatrd', 'zlatrd' ), ('slauum', 'dlauum', 'clauum', 'zlauum' ), ('spack', 'dpack', 'cpack', 'zpack' ), ('splgsy', 'dplgsy', 'cplgsy', 'zplgsy' ), ('splrnt', 'dplrnt', 'cplrnt', 'zplrnt' ), - ('splssq', 'dplssq', 'cplssq', 'zplssq' ), + ('splssq', 'dplssq', 'cplssq', 'zplssq' ), ('sposv', 'dposv', 'cposv', 'zposv' ), ('ssysv', 'dsysv', 'csysv', 'zsysv' ), ('sposv', 'sposv', 'cposv', 'cposv' ), @@ -562,7 +579,7 @@ subs = { ('stsmqr', 'dtsmqr', 'ctsmqr', 'ztsmqr' ), ('stsmlq', 'dtsmlq', 'ctsmlq', 'ztsmlq' ), ('stsqrt', 'dtsqrt', 'ctsqrt', 'ztsqrt' ), - ('stslqt', 'dtslqt', 'ctslqt', 'ztslqt' ), + ('stslqt', 'dtslqt', 'ctslqt', 'ztslqt' ), ('ststrf', 'dtstrf', 'ctstrf', 'ztstrf' ), ('sttlqt', 'dttlqt', 'cttlqt', 'zttlqt' ), ('sttmlq', 'dttmlq', 'cttmlq', 'zttmlq' ), @@ -572,6 +589,10 @@ subs = { ('sstegr', 'dstegr', 'cstegr', 'zstegr' ), ('ssyssq', 'dsyssq', 'csyssq', 'zsyssq' ), + # ----- LAPACK Eigenvalues + ('slatms', 'dlatms', 'slatms', 'dlatms' ), + ('slasrt', 'dlasrt', 'slasrt', 'dlasrt' ), + # ----- BLAS and LAPACK, where complex base name != real base name # BLAS, with precision ('sasum', 'dasum', 'scasum', 'dzasum' ), @@ -684,7 +705,6 @@ subs = { ('sytrf', 'sytrf', 'hetrf', 'hetrf' ), # ----- For norms: compute result in Real or Double - ('sgeadd', 'dgeadd', 'sgeadd', 'dgeadd' ), ('slange', 'dlange', 'slange', 'dlange' ), ('slaset', 'dlaset', 'slaset', 'dlaset' ), ('splssq', 'dplssq', 'splssq', 'dplssq' ), @@ -713,6 +733,10 @@ subs = { ('ISAMAX', 'IDAMAX', 'ISAMAX', 'IDAMAX' ), ('SAXPY', 'DAXPY', 'CAXPY', 'ZAXPY' ), ('SCOPY', 'DCOPY', 'CCOPY', 'ZCOPY' ), + ('SGEADD', 'DGEADD', 'CGEADD', 'ZGEADD' ), + ('SGECFI', 'DGECFI', 'CGECFI', 'ZGECFI' ), + ('SGEMDM', 'DGEMDM', 'CGEMDM', 'ZGEMDM' ), + ('SGEMM', 'DGEMM', 'CGEMM', 'ZGEMM' ), ('SGEMV', 'DGEMV', 'CGEMV', 'ZGEMV' ), ('SSCAL', 'DSCAL', 'CSCAL', 'ZSCAL' ), ('SSCAL', 'DSCAL', 'CSSCAL', 'ZDSCAL' ), @@ -722,9 +746,11 @@ subs = { ('SSYMV', 'DSYMV', 'CSYMV', 'ZSYMV' ), ('SSYR2K', 'DSYR2K', 'CSYR2K', 'ZSYR2K' ), ('SSYRK', 'DSYRK', 'CSYRK', 'ZSYRK' ), + ('STRADD', 'DTRADD', 'CTRADD', 'ZTRADD' ), ('STRMM', 'DTRMM', 'CTRMM', 'ZTRMM' ), ('STRMV', 'DTRMV', 'CTRMV', 'ZTRMV' ), ('STRSM', 'DTRSM', 'CTRSM', 'ZTRSM' ), + ('STRSMPL', 'DTRSMPL', 'CTRSMPL', 'ZTRSMPL' ), ('STRSV', 'DTRSV', 'CTRSV', 'ZTRSV' ), # LAPACK @@ -742,7 +768,6 @@ subs = { ('SGELQF', 'DGELQF', 'CGELQF', 'ZGELQF' ), ('SGELQS', 'DGELQS', 'CGELQS', 'ZGELQS' ), ('SGELS', 'DGELS', 'CGELS', 'ZGELS' ), - ('SGEMM', 'DGEMM', 'CGEMM', 'ZGEMM' ), ('SGEQLF', 'DGEQLF', 'CGEQLF', 'ZGEQLF' ), ('SGEQP3', 'DGEQP3', 'CGEQP3', 'ZGEQP3' ), ('SGEQR2', 'DGEQR2', 'CGEQR2', 'ZGEQR2' ), @@ -811,7 +836,6 @@ subs = { ('SSTERM', 'DSTERM', 'CSTERM', 'ZSTERM' ), ('SSTT21', 'DSTT21', 'CSTT21', 'ZSTT21' ), ('STREVC', 'DTREVC', 'CTREVC', 'ZTREVC' ), - ('STRSMPL', 'DTRSMPL', 'CTRSMPL', 'ZTRSMPL' ), ('STRTRI', 'DTRTRI', 'CTRTRI', 'ZTRTRI' ), ('STSQRT', 'DTSQRT', 'CTSQRT', 'ZTSQRT' ), ('STSTRF', 'DTSTRF', 'CTSTRF', 'ZTSTRF' ), @@ -957,6 +981,9 @@ subs = { ('s_get_idparm', 'd_get_idparm', 's_get_idparm', 'd_get_idparm', ), #('stesting', 'dtesting', 'ctesting', 'ztesting' ), #('SAUXILIARY', 'DAUXILIARY', 'CAUXILIARY', 'ZAUXILIARY' ), + # BUILD + ('sbuild', 'dbuild', 'cbuild', 'zbuild' ), + ], # ------------------------------------------------------------