diff --git a/LICENCE.txt b/LICENCE.txt index b95821f36afa3579a5f1de4fe840aec43b7a4b96..3b885875f9556c32fafb21c4d9d7e4dae5a1d500 100644 --- a/LICENCE.txt +++ b/LICENCE.txt @@ -1,11 +1,7 @@ ### # -# @copyright (c) 2009-2014 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. -# @copyright (c) 2012-2016 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, -# Univ. Bordeaux. All rights reserved. -# @copyright (c) 2016 KAUST. All rights reserved. +# @copyright (c) 2012-2020 Inria. All rights reserved. +# @copyright (c) 2012-2020 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. # ### # diff --git a/modules/MorseInit.cmake b/modules/MorseInit.cmake index c9e9ce851709d82d678d5e342984ff9ea2e2d2a1..ecce590a19e5866e2ee7a6a3e377b94acbf13e59 100644 --- a/modules/MorseInit.cmake +++ b/modules/MorseInit.cmake @@ -61,7 +61,7 @@ include(Ressources) list(APPEND CMAKE_MODULE_PATH ${MORSE_CMAKE_MODULE_PATH}/find) # To load some macros used in Finds (could be useful for other projects) -include(FindInit) +include(FindMorseInit) ### Build type set( CMAKE_BUILD_TYPE_DROP_LIST "Debug" "Release" "MinSizeRel" "RelWithDebInfo") diff --git a/modules/find/FindAL4SAN.cmake b/modules/find/FindAL4SAN.cmake index edb721a08ae8a4db5834ba79f57a6b58b6fed551..31940f7c7c75cfeb1e5aa960122aec4d113323ae 100644 --- a/modules/find/FindAL4SAN.cmake +++ b/modules/find/FindAL4SAN.cmake @@ -1,12 +1,9 @@ ### # -# @copyright (c) 2009-2014 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. # @copyright (c) 2012-2020 Inria. All rights reserved. # @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. +# @copyright (c) 2017-2018 King Abdullah University of Science and Technology (KAUST). All rights reserved. # -# @copyright 2017-2018 King Abdullah University of Science and Technology (KAUST). All rights reserved. ### # # - Find AL4SAN include dirs and libraries @@ -92,11 +89,11 @@ if(PKG_CONFIG_EXECUTABLE) pkg_get_variable(AL4SAN_INCLUDE_DIRS al4san includedir) endif() set(AL4SAN_FOUND_WITH_PKGCONFIG "TRUE") - find_pkgconfig_libraries_absolute_path(AL4SAN) + morse_find_pkgconfig_libraries_absolute_path(AL4SAN) else() set(AL4SAN_FOUND_WITH_PKGCONFIG "FALSE") endif() - + endif(PKG_CONFIG_EXECUTABLE) if (AL4SAN_LIBRARIES) @@ -108,7 +105,7 @@ if (AL4SAN_LIBRARIES) endforeach() else() list(GET AL4SAN_LIBRARIES 0 first_lib) - get_filename_component(first_lib_path "${first_lib}" PATH) + get_filename_component(first_lib_path "${first_lib}" DIRECTORY) endif() if (${first_lib_path} MATCHES "/lib(32|64)?$") string(REGEX REPLACE "/lib(32|64)?$" "" not_cached_dir "${first_lib_path}") diff --git a/modules/find/FindBLAS.cmake b/modules/find/FindBLAS.cmake deleted file mode 100644 index 427add6ae1f0583475f4e6b17aa0a01364c3a431..0000000000000000000000000000000000000000 --- a/modules/find/FindBLAS.cmake +++ /dev/null @@ -1,1941 +0,0 @@ -### -# -# @copyright (c) 2009-2014 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. -# @copyright (c) 2012-2020 Inria. All rights reserved. -# @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. -# -### -# -# - Find BLAS library -# This module finds an installed fortran library that implements the BLAS -# linear-algebra interface (see http://www.netlib.org/blas/). -# The list of libraries searched for is taken -# from the autoconf macro file, acx_blas.m4 (distributed at -# http://ac-archive.sourceforge.net/ac-archive/acx_blas.html). -# -# This module sets the following variables: -# BLAS_FOUND - set to true if a library implementing the BLAS interface -# is found -# BLAS_LDFLAGS_OTHER - list of required linker flags (excluding -l -# and -L). -# BLAS_CFLAGS_OTHER - list of required compiler flags (excluding -I). -# BLAS_INCLUDE_DIRS - include directories -# BLAS_LIBRARIES - list of libraries (using full path name) to -# link against to use BLAS, sequential or multithreaded version depending on BLA_VENDOR -# BLAS_LIBRARIES_SEQ - list of libraries (using full path name) to -# link against to use BLAS, sequential version (Intel MKL) -# BLAS_LIBRARIES_PAR - list of libraries (using full path name) to -# link against to use BLAS, multithreaded version (Intel MKL) -# BLAS95_LIBRARIES - list of libraries (using full path name) -# to link against to use BLAS95 interface -# BLAS95_FOUND - set to true if a library implementing the BLAS 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 -# BLAS_VENDOR_FOUND stores the BLAS vendor found -# BLA_F95 if set on tries to find the f95 interfaces for BLAS/LAPACK -# -# BLA_PREFER_PKGCONFIG - try using pkg-config (ON by default) -# BLAS_FOUND_WITH_PKGCONFIG - True if found with pkg-config -# if found with pkg-config the following variables are set -# <PREFIX> = BLAS -# <XPREFIX> = <PREFIX> for common case -# <XPREFIX> = <PREFIX>_STATIC for static linking -# <XPREFIX>_FOUND ... set to 1 if module(s) exist -# <XPREFIX>_LIBRARIES ... only the libraries (w/o the '-l') -# <XPREFIX>_LIBRARY_DIRS ... the paths of the libraries (w/o the '-L') -# <XPREFIX>_LDFLAGS ... all required linker flags -# <XPREFIX>_LDFLAGS_OTHER ... all other linker flags -# <XPREFIX>_INCLUDE_DIRS ... the '-I' preprocessor flags (w/o the '-I') -# <XPREFIX>_CFLAGS ... all required cflags -# <XPREFIX>_CFLAGS_OTHER ... the other compiler flags -# -# The user can give specific paths where to find the libraries adding cmake -# options at configure (ex: cmake path/to/project -DBLAS_DIR=path/to/blas): -# BLAS_DIR - Where to find the base directory of blas -# BLAS_INCDIR - Where to find the header files -# BLAS_LIBDIR - Where to find the library files -# The module can also look for the following environment variables if paths -# are not given as cmake variable: BLAS_DIR, BLAS_INCDIR, BLAS_LIBDIR -# For MKL case and if no paths are given as hints, we will try to use the MKLROOT -# environment variable -# The user can also give directly the BLAS libraries to be used with -# BLAS_LIBRARIES_USER. If BLA_STATIC is ON users may also give some additional -# libraries to resolve dependencies with BLAS_LDFLAGS_USER -# BLAS_VERBOSE Print some additional information during BLAS libraries detection -########## -### List of vendors (BLA_VENDOR) valid in this module -########## List of vendors (BLA_VENDOR) valid in this module -## Open (for OpenBlas), Eigen (for EigenBlas), Goto, ATLAS PhiPACK, -## CXML, DXML, SunPerf, SCSL, SGIMATH, IBMESSL, IBMESSLMT -## 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), -## ARMPL, FLAME, ACML, ACML_MP, ACML_GPU, Apple, NAS, Generic, User (see BLAS_LIBRARIES_USER) -# C/CXX should be enabled to use Intel mkl -### -# We handle different modes to find the dependency -# -# - Detection if already installed on the system -# - BLAS libraries can be detected from different ways -# Here is the order of precedence: -# 1) we look in cmake variable BLAS_LIBDIR or BLAS_DIR (we guess the libdirs) if defined -# 2) we look in environment variable BLAS_LIBDIR or BLAS_DIR (we guess the libdirs) if defined -# 3) we look in common environnment variables depending on the system (INCLUDE, C_INCLUDE_PATH, CPATH - LIB, DYLD_LIBRARY_PATH, LD_LIBRARY_PATH, LIBRARY_PATH) -# 4) we look in common system paths depending on the system, see for example paths contained in the following cmake variables: -# - CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES, CMAKE_C_IMPLICIT_LINK_DIRECTORIES -# - -#============================================================================= -# Copyright 2007-2009 Kitware, Inc. -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -# Common macros to use in finds -include(FindInit) - -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() -endif() - -option(BLAS_VERBOSE "Print some additional information during BLAS libraries detection" OFF) -mark_as_advanced(BLAS_VERBOSE) -if(NOT DEFINED BLA_PREFER_PKGCONFIG) - set(BLA_PREFER_PKGCONFIG ON CACHE BOOL "Try to find BLAS using pkg-config") -endif() -set(BLAS_LIBRARIES_USER "" CACHE STRING "BLAS libraries given by users") -set(BLAS_LIBRARIES_USER "" CACHE STRING "BLAS libraries given by users") -set(BLAS_LDFLAGS_USER "" CACHE STRING "BLAS link flags given by users") -if(BLAS_LIBRARIES_USER) - set(BLA_VENDOR "User") -endif() - -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 ) - include(CheckFortranFunctionExists) -elseif( (_LANGUAGES_ MATCHES C) OR (_LANGUAGES_ MATCHES CXX) ) - set( _CHECK_FORTRAN FALSE ) - include(CheckFunctionExists) -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() -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_ARMPL "$ENV{ARMPL_DIR}") - set(ENV_BLAS_DIR "$ENV{BLAS_DIR}") - set(ENV_BLAS_INCDIR "$ENV{BLAS_INCDIR}") - set(ENV_BLAS_LIBDIR "$ENV{BLAS_LIBDIR}") - - set(BLAS_GIVEN_BY_USER "FALSE") - if ( BLAS_DIR OR BLAS_LIBDIR OR ENV_BLAS_DIR OR ENV_BLAS_LIBDIR OR ENV_MKLROOT OR ENV_ARMPL) - set(BLAS_GIVEN_BY_USER "TRUE") - endif() - - 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 (ENV_ARMPL) - list(APPEND _libdir "${ENV_ARMPL}/lib") - endif() - list(APPEND _libdir "$ENV{LIBRARY_PATH}") - 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_C_IMPLICIT_LINK_DIRECTORIES}") - endif() - 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 () - if (EXISTS ${_library}) - set(${_prefix}_${_library}_LIBRARY ${_library}) - else() - if ( BLAS_GIVEN_BY_USER ) - find_library(${_prefix}_${_library}_LIBRARY - NAMES ${_library} - HINTS ${_libdir} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH - ) - else() - find_library(${_prefix}_${_library}_LIBRARY - NAMES ${_library} - HINTS ${_libdir} - ) - endif() - endif() - 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_INCLUDES "${BLAS_INCLUDE_DIRS}") - set(CMAKE_REQUIRED_FLAGS "${BLAS_CFLAGS_OTHER}") - 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) - 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) - -endmacro(Check_Fortran_Libraries) - - -set(BLAS_LDFLAGS_OTHER) -set(BLAS_LIBRARIES) -set(BLAS95_LIBRARIES) -if ($ENV{BLA_VENDOR} MATCHES ".+") - set(BLA_VENDOR $ENV{BLA_VENDOR}) -else () - if(NOT BLA_VENDOR) - set(BLA_VENDOR "All") - endif() -endif () - -# Optionally use pkg-config to detect include/library dirs (if pkg-config is available) -# ------------------------------------------------------------------------------------- -include(FindPkgConfig) -find_package(PkgConfig QUIET) -if( PKG_CONFIG_EXECUTABLE AND NOT BLAS_GIVEN_BY_USER AND BLA_PREFER_PKGCONFIG) - if (BLA_STATIC) - set(MKL_STR_BLA_STATIC "static") - else() - set(MKL_STR_BLA_STATIC "dynamic") - endif() - # try different blas - if ( (BLA_VENDOR MATCHES "Intel*") AND - (NOT BLA_F95) AND NOT ((_LANGUAGES_ MATCHES Fortran) AND - (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")) AND NOT (CMAKE_C_COMPILER_ID - STREQUAL "GNU")) - if (BLA_VENDOR STREQUAL "Intel10_64lp") - pkg_search_module(BLAS mkl-${MKL_STR_BLA_STATIC}-lp64-seq) - if (BLAS_FOUND) - set (BLAS_VENDOR_FOUND "Intel MKL Sequential") - set (BLAS_LIBRARIES_SEQ "${BLAS_LIBRARIES}") - endif() - pkg_search_module(BLAS mkl-${MKL_STR_BLA_STATIC}-lp64-iomp) - if (BLAS_FOUND) - set (BLAS_VENDOR_FOUND "Intel MKL Multithreaded") - set (BLAS_LIBRARIES_PAR "${BLAS_LIBRARIES}") - endif() - elseif(BLA_VENDOR STREQUAL "Intel10_64lp_seq") - pkg_search_module(BLAS mkl-${MKL_STR_BLA_STATIC}-lp64-seq) - if (BLAS_FOUND) - set (BLAS_VENDOR_FOUND "Intel MKL") - set (BLAS_LIBRARIES_SEQ "${BLAS_LIBRARIES}") - endif() - endif() - elseif(BLA_VENDOR STREQUAL "Open") - pkg_search_module(BLAS openblas) - if (BLAS_FOUND) - set (BLAS_VENDOR_FOUND "Openblas") - endif() - elseif(BLA_VENDOR STREQUAL "Generic") - pkg_search_module(BLAS blas) - if (BLAS_FOUND) - set (BLAS_VENDOR_FOUND "Netlib or other Generic libblas") - endif() - elseif(BLA_VENDOR STREQUAL "All") - if ((NOT BLAS_FOUND) AND (NOT BLA_F95) AND NOT ((_LANGUAGES_ MATCHES - Fortran) AND (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")) AND NOT - (CMAKE_C_COMPILER_ID STREQUAL "GNU")) - pkg_search_module(BLAS mkl-${MKL_STR_BLA_STATIC}-lp64-iomp) - if (BLAS_FOUND) - set (BLAS_VENDOR_FOUND "Intel MKL Multithreaded") - set (BLAS_LIBRARIES_PAR "${BLAS_LIBRARIES}") - endif() - pkg_search_module(BLAS mkl-${MKL_STR_BLA_STATIC}-lp64-seq) - if (BLAS_FOUND) - set (BLAS_VENDOR_FOUND "Intel MKL Sequential") - set (BLAS_LIBRARIES_SEQ "${BLAS_LIBRARIES}") - endif() - endif() - if (NOT BLAS_FOUND) - pkg_search_module(BLAS openblas) - if (BLAS_FOUND) - set (BLAS_VENDOR_FOUND "Openblas") - endif() - endif() - if (NOT BLAS_FOUND) - pkg_search_module(BLAS blas) - if (BLAS_FOUND) - set (BLAS_VENDOR_FOUND "Netlib or other Generic libblas") - endif() - endif() - endif() - - if (NOT BLAS_FIND_QUIETLY) - if (BLAS_FOUND AND BLAS_LIBRARIES) - message(STATUS "Looking for BLAS - found using PkgConfig") - else() - message(STATUS "${Magenta}Looking for BLAS - not found using PkgConfig." - "\n Perhaps you should add the directory containing blas.pc to" - "\n the PKG_CONFIG_PATH environment variable.${ColourReset}") - endif() - endif() - - if (BLAS_FOUND AND BLAS_LIBRARIES) - set(BLAS_FOUND_WITH_PKGCONFIG "TRUE") - find_pkgconfig_libraries_absolute_path(BLAS) - else() - set(BLAS_FOUND_WITH_PKGCONFIG "FALSE") - endif() - -endif() - -if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) - #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_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 mkl 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} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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" - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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() - - list(APPEND _libdir "$ENV{LIBRARY_PATH}") - 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_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 "${M_LIBRARY}") - else() - set(LM "") - endif() - # dl - find_library( - DL_LIBRARY - NAMES dl - HINTS ${_libdir} - ) - mark_as_advanced(DL_LIBRARY) - if(DL_LIBRARY) - set(LDL "${DL_LIBRARY}") - else() - set(LDL "") - 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_CFLAGS_OTHER "") - # OpenMP - if (BLA_VENDOR STREQUAL "Intel10_64lp") - find_package(OpenMP REQUIRED) - endif() - if(OPENMP_C_FLAGS) - list(APPEND BLAS_CFLAGS_OTHER "${OPENMP_C_FLAGS}") - endif() - if (CMAKE_C_COMPILER_ID STREQUAL "GNU") - if (BLA_VENDOR STREQUAL "Intel10_32") - list(APPEND BLAS_CFLAGS_OTHER "-m32") - else() - list(APPEND BLAS_CFLAGS_OTHER "-m64") - 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) - find_package(Threads) - if( THREADS_FOUND ) - libraries_absolute_path(CMAKE_THREAD_LIBS_INIT "") - endif () - - set(BLAS_SEARCH_LIBS "") - - if(BLA_F95) - - set(BLAS_mkl_SEARCH_SYMBOL sgemm_f95) - 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 - # sequential version - list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD - "mkl_sequential${BLAS_mkl_DLL_SUFFIX}") - # multithreaded version - 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( _LANGUAGES_ MATCHES Fortran ) - if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT APPLE) - set(BLAS_mkl_intface "gf") - else() - set(BLAS_mkl_intface "intel") - endif() - else() - set(BLAS_mkl_intface "intel") - endif() - - if (CMAKE_C_COMPILER_ID STREQUAL "GNU") - set(BLAS_mkl_threading "gnu") - else() - set(BLAS_mkl_threading "intel") - endif() - - if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS - "mkl_blas95 mkl_${BLAS_mkl_intface} mkl_${BLAS_mkl_threading}_thread mkl_core") - endif () - if (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All") - # old version - list(APPEND BLAS_SEARCH_LIBS - "mkl_blas95 mkl_${BLAS_mkl_intface}_lp64 mkl_${BLAS_mkl_threading}_thread mkl_core guide") - # mkl >= 10.3 - # sequential version - list(APPEND BLAS_SEARCH_LIBS - "mkl_blas95_lp64 mkl_${BLAS_mkl_intface}_lp64 mkl_sequential mkl_core") - # multithreaded version - list(APPEND BLAS_SEARCH_LIBS - "mkl_blas95_lp64 mkl_${BLAS_mkl_intface}_lp64 mkl_${BLAS_mkl_threading}_thread mkl_core") - endif () - if (BLA_VENDOR STREQUAL "Intel10_64lp_seq" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS - "mkl_blas95_lp64 mkl_${BLAS_mkl_intface}_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 - # sequential version - list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD - "mkl_sequential${BLAS_mkl_DLL_SUFFIX}") - # multithreaded version - 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( _LANGUAGES_ MATCHES Fortran ) - if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT APPLE) - set(BLAS_mkl_intface "gf") - else() - set(BLAS_mkl_intface "intel") - endif() - else() - set(BLAS_mkl_intface "intel") - endif() - - if (CMAKE_C_COMPILER_ID STREQUAL "GNU") - set(BLAS_mkl_threading "gnu") - else() - set(BLAS_mkl_threading "intel") - endif() - - if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS - "mkl_${BLAS_mkl_intface} mkl_${BLAS_mkl_threading}_thread mkl_core") - endif () - if (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All") - # old version - list(APPEND BLAS_SEARCH_LIBS - "mkl_${BLAS_mkl_intface}_lp64 mkl_${BLAS_mkl_threading}_thread mkl_core guide") - # mkl >= 10.3 - # sequential version - list(APPEND BLAS_SEARCH_LIBS - "mkl_${BLAS_mkl_intface}_lp64 mkl_sequential mkl_core") - # multithreaded version - list(APPEND BLAS_SEARCH_LIBS - "mkl_${BLAS_mkl_intface}_lp64 mkl_${BLAS_mkl_threading}_thread mkl_core") - endif () - if (BLA_VENDOR STREQUAL "Intel10_64lp_seq" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS - "mkl_${BLAS_mkl_intface}_lp64 mkl_sequential mkl_core") - if (BLA_VENDOR STREQUAL "Intel10_64lp_seq") - set(OMP_LIB "") - endif() - endif () - #older versions 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}) - # determine if we look at a sequential or multithreaded version - set(MKL_MT OFF) - foreach(_lib ${SEARCH_LIBS}) - if (${_lib} MATCHES "thread") - set (MKL_MT ON) - endif() - endforeach() - if (MKL_MT) - check_fortran_libraries( - ${_LIBRARIES} - BLAS - ${BLAS_mkl_SEARCH_SYMBOL} - "${additional_flags}" - "${SEARCH_LIBS}" - "${OMP_LIB};${CMAKE_THREAD_LIBS_INIT};${LM};${LDL}" - ) - else() - check_fortran_libraries( - ${_LIBRARIES} - BLAS - ${BLAS_mkl_SEARCH_SYMBOL} - "${additional_flags}" - "${SEARCH_LIBS}" - "${CMAKE_THREAD_LIBS_INIT};${LM};${LDL}" - ) - endif() - if(${_LIBRARIES}) - set(BLAS_LDFLAGS_OTHER "${additional_flags}") - if (MKL_MT) - set (BLAS_LIBRARIES_PAR "${${_LIBRARIES}}") - else() - set (BLAS_LIBRARIES_SEQ "${${_LIBRARIES}}") - endif() - set(${_LIBRARIES}_COPY "${${_LIBRARIES}}") - endif() - endforeach () - if (${_LIBRARIES}_COPY) - set(${_LIBRARIES} "${${_LIBRARIES}_COPY}") - endif() - 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() - if (${_LIBRARIES}) - set (BLAS_VENDOR_FOUND "Intel MKL") - endif() - endif (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX) - endif(NOT BLAS_LIBRARIES OR BLA_VENDOR MATCHES "Intel*") - if (NOT BLAS_LIBRARIES) - set(BLAS_INCLUDE_DIRS "") - set(BLAS_CFLAGS_OTHER "") - set(BLAS_LDFLAGS_OTHER "") - endif() - unset(BLAS_mkl_intface) - unset(BLAS_mkl_threading) - endif (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All") - - if (BLA_VENDOR MATCHES "ARMPL*" OR BLA_VENDOR STREQUAL "All") - if(NOT BLAS_LIBRARIES OR BLA_VENDOR MATCHES "ARMPL*") - # Looking for include - # ------------------- - - # Add system include paths to search include - # ------------------------------------------ - unset(_inc_env) - set(ENV_ARMPL "$ENV{ARMPL_DIR}") - 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_ARMPL) - list(APPEND _inc_env "${ENV_ARMPL}/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_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 armpl header in the given paths - # ------------------------------------------------- - # call cmake macro to find the header path - if(BLAS_INCDIR) - set(BLAS_armpl.h_DIRS "BLAS_armpl.h_DIRS-NOTFOUND") - find_path(BLAS_armpl.h_DIRS - NAMES armpl.h - HINTS ${BLAS_INCDIR} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - if(BLAS_DIR) - set(BLAS_armpl.h_DIRS "BLAS_armpl.h_DIRS-NOTFOUND") - find_path(BLAS_armpl.h_DIRS - NAMES armpl.h - HINTS ${BLAS_DIR} - PATH_SUFFIXES "include" - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - set(BLAS_armpl.h_DIRS "BLAS_armpl.h_DIRS-NOTFOUND") - find_path(BLAS_armpl.h_DIRS - NAMES armpl.h - HINTS ${PATH_TO_LOOK_FOR}) - endif() - endif() - mark_as_advanced(BLAS_armpl.h_DIRS) - - # If found, add path to cmake variable - # ------------------------------------ - if (BLAS_armpl.h_DIRS) - set(BLAS_INCLUDE_DIRS "${BLAS_armpl.h_DIRS}") - else () - set(BLAS_INCLUDE_DIRS "BLAS_INCLUDE_DIRS-NOTFOUND") - if(NOT BLAS_FIND_QUIETLY) - message(STATUS "Looking for BLAS -- armpl.h not found") - endif() - endif() - - find_package(Threads) - if( THREADS_FOUND ) - libraries_absolute_path(CMAKE_THREAD_LIBS_INIT "") - endif () - - if(NOT BLAS_LIBRARIES) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "armpl" - "${CMAKE_THREAD_LIBS_INIT}" - ) - endif() - - if(NOT BLAS_FIND_QUIETLY) - if(BLAS_LIBRARIES) - message(STATUS "Looking for ARMPL BLAS: found") - else() - message(STATUS "Looking for ARMPL BLAS: not found") - endif() - endif() - if (BLAS_LIBRARIES) - set (BLAS_VENDOR_FOUND "ARMPL") - endif() - - endif (NOT BLAS_LIBRARIES OR BLA_VENDOR MATCHES "ARMPL*") - endif (BLA_VENDOR MATCHES "ARMPL*" OR BLA_VENDOR STREQUAL "All") - - # FLAME's blis library? (https://github.com/flame/blis) - if(BLA_VENDOR STREQUAL "FLAME" OR BLA_VENDOR STREQUAL "All") - if(NOT BLAS_LIBRARIES OR BLA_VENDOR MATCHES "FLAME") - # Looking for include - # ------------------- - - # Add system include paths to search include - # ------------------------------------------ - unset(_inc_env) - set(ENV_FLAME "$ENV{FLAME_DIR}") - 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_FLAME) - list(APPEND _inc_env "${ENV_FLAME}/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_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 blis header in the given paths - # ------------------------------------------------- - # call cmake macro to find the header path - if(BLAS_INCDIR) - set(BLAS_blis.h_DIRS "BLAS_blis.h_DIRS-NOTFOUND") - find_path(BLAS_blis.h_DIRS - NAMES blis.h - HINTS ${BLAS_INCDIR} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - if(BLAS_DIR) - set(BLAS_blis.h_DIRS "BLAS_blis.h_DIRS-NOTFOUND") - find_path(BLAS_blis.h_DIRS - NAMES blis.h - HINTS ${BLAS_DIR} - PATH_SUFFIXES "include" - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - set(BLAS_blis.h_DIRS "BLAS_blis.h_DIRS-NOTFOUND") - find_path(BLAS_blis.h_DIRS - NAMES blis.h - HINTS ${PATH_TO_LOOK_FOR}) - endif() - endif() - mark_as_advanced(BLAS_blis.h_DIRS) - - # If found, add path to cmake variable - # ------------------------------------ - if (BLAS_blis.h_DIRS) - set(BLAS_INCLUDE_DIRS "${BLAS_blis.h_DIRS}") - else () - set(BLAS_INCLUDE_DIRS "BLAS_INCLUDE_DIRS-NOTFOUND") - if(NOT BLAS_FIND_QUIETLY) - message(STATUS "Looking for BLAS -- blis.h not found") - endif() - endif() - - find_package(Threads) - if( THREADS_FOUND ) - libraries_absolute_path(CMAKE_THREAD_LIBS_INIT "") - endif () - - if(NOT BLAS_LIBRARIES) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "blis" - "${CMAKE_THREAD_LIBS_INIT}" - ) - endif() - if(NOT BLAS_FIND_QUIETLY) - if(BLAS_LIBRARIES) - message(STATUS "Looking for FLAME (blis) BLAS: found") - else() - message(STATUS "Looking for FLAME (blis) BLAS: not found") - endif() - endif() - if (BLAS_LIBRARIES) - set (BLAS_VENDOR_FOUND "FLAME") - endif() - endif(NOT BLAS_LIBRARIES OR BLA_VENDOR MATCHES "FLAME") - endif(BLA_VENDOR STREQUAL "FLAME" 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 (BLAS_LIBRARIES) - set (BLAS_VENDOR_FOUND "Goto") - endif() - endif() - - 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) - - # Looking for include - # ------------------- - - # Add system include paths to search include - # ------------------------------------------ - unset(_inc_env) - set(ENV_OPENBLAS "$ENV{OPENBLAS_DIR}") - 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_OPENBLAS) - list(APPEND _inc_env "${ENV_OPENBLAS}/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_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 openblas header in the given paths - # -------------------------------------------------- - # call cmake macro to find the header path - if(BLAS_INCDIR) - set(BLAS_cblas.h_DIRS "BLAS_cblas.h_DIRS-NOTFOUND") - find_path(BLAS_cblas.h_DIRS - NAMES cblas.h - HINTS ${BLAS_INCDIR} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - if(BLAS_DIR) - set(BLAS_cblas.h_DIRS "BLAS_cblas.h_DIRS-NOTFOUND") - find_path(BLAS_cblas.h_DIRS - NAMES cblas.h - HINTS ${BLAS_DIR} - PATH_SUFFIXES "include" - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - set(BLAS_cblas.h_DIRS "BLAS_cblas.h_DIRS-NOTFOUND") - find_path(BLAS_cblas.h_DIRS - NAMES cblas.h - HINTS ${PATH_TO_LOOK_FOR}) - endif() - endif() - mark_as_advanced(BLAS_cblas.h_DIRS) - - # If found, add path to cmake variable - # ------------------------------------ - if (BLAS_cblas.h_DIRS) - set(BLAS_INCLUDE_DIRS "${BLAS_cblas.h_DIRS}") - else () - set(BLAS_INCLUDE_DIRS "BLAS_INCLUDE_DIRS-NOTFOUND") - if(NOT BLAS_FIND_QUIETLY) - message(STATUS "Looking for BLAS -- cblas.h not found") - endif() - endif() - - # 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 (BLAS_LIBRARIES) - set (BLAS_VENDOR_FOUND "Openblas") - endif() - endif() - - 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() - 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() - if (BLAS_LIBRARIES) - set (BLAS_VENDOR_FOUND "Eigen") - 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 (BLAS_LIBRARIES) - set (BLAS_VENDOR_FOUND "Atlas") - endif() - endif() - - 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 (BLAS_LIBRARIES) - set (BLAS_VENDOR_FOUND "PhiPACK") - endif() - endif() - - 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 (BLAS_LIBRARIES) - set (BLAS_VENDOR_FOUND "CXML") - endif() - endif() - - 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 (BLAS_LIBRARIES) - set (BLAS_VENDOR_FOUND "DXML") - endif() - endif() - - 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_LDFLAGS_OTHER "-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 (BLAS_LIBRARIES) - set (BLAS_VENDOR_FOUND "SunPerf") - endif() - endif() - - 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 (BLAS_LIBRARIES) - set (BLAS_VENDOR_FOUND "SunPerf") - endif() - endif() - - 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 (BLAS_LIBRARIES) - set (BLAS_VENDOR_FOUND "SGIMATH") - endif() - endif() - - 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" - "" - ) - 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 (BLAS_LIBRARIES) - set (BLAS_VENDOR_FOUND "IBM ESSL") - 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" - "" - ) - 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 (BLAS_LIBRARIES) - set (BLAS_VENDOR_FOUND "IBM ESSL MT") - endif() - endif() - - 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}) - - 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 ) - set (BLAS_VENDOR_FOUND "ACML_MP") - 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 ) - set (BLAS_VENDOR_FOUND "ACML_GPU") - 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 ) - set (BLAS_VENDOR_FOUND "ACML") - 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 (BLAS_LIBRARIES) - set (BLAS_VENDOR_FOUND "ACML") - 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 (BLAS_LIBRARIES) - set (BLAS_VENDOR_FOUND "ACML") - 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() - if (BLAS_LIBRARIES) - set (BLAS_VENDOR_FOUND "ACML") - endif() - endif() - - 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 (BLAS_LIBRARIES) - set (BLAS_VENDOR_FOUND "Apple Accelerate") - 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() - if (BLAS_LIBRARIES) - set (BLAS_VENDOR_FOUND "NAS") - endif() - endif () - - 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() - if (BLAS_LIBRARIES) - set (BLAS_VENDOR_FOUND "Netlib or other Generic libblas") - endif() - endif() - endforeach () - - endif (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All") - - # BLAS given user, we need to test it - if (BLA_VENDOR STREQUAL "User" AND BLAS_LIBRARIES_USER) - check_fortran_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "${BLAS_LIBRARIES_USER}" - "${BLAS_LDFLAGS_USER}" - ) - if(NOT BLAS_FIND_QUIETLY) - if(BLAS_LIBRARIES) - message(STATUS "Looking for User's BLAS: found") - else() - message(STATUS "Looking for User's BLAS: not found") - endif() - endif() - if (BLAS_LIBRARIES) - set (BLAS_VENDOR_FOUND "User") - endif() - endif() - - 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 (LIBRARY_PATH or 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) - if (NOT BLAS_LIBRARIES_DEP) - set(BLAS_LIBRARIES_DEP "${BLAS_LIBRARIES}") - endif() - 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 (LIBRARY_PATH or 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) -endif( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) - -set(CMAKE_FIND_LIBRARY_SUFFIXES ${_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) - -if (BLAS_FOUND) - # set BLAS_LIBRARY_DIRS and BLAS_DIR_FOUND - list(GET BLAS_LIBRARIES 0 first_lib) - # first lib may be -Wl,--start-group (MKL) which is not a lib - if (NOT EXISTS ${first_lib}) - list(GET BLAS_LIBRARIES 1 first_lib) - endif() - get_filename_component(first_lib_path "${first_lib}" PATH) - if (NOT BLAS_LIBRARY_DIRS) - set(BLAS_LIBRARY_DIRS "${first_lib_path}") - endif() - 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() - # give additional info about mangling available - if (NOT BLAS_FIND_QUIETLY) - message(STATUS "Check Fortran mangling for BLAS symbols") - endif() - set(CMAKE_REQUIRED_LIBRARIES "${BLAS_LIBRARIES}") - check_function_exists(sgemm BLAS_NOCHANGE) - check_function_exists(sgemm_ BLAS_ADD_) - check_function_exists(SGEMM BLAS_UPCASE) -endif() - -if(BLAS_FOUND) - if(NOT TARGET blas::blas AND BLAS_LIBRARIES) - add_library(blas::blas INTERFACE IMPORTED) - set_property(TARGET blas::blas APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${BLAS_LDFLAGS_OTHER}") - set_property(TARGET blas::blas APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${BLAS_LIBRARIES}") - set_property(TARGET blas::blas APPEND PROPERTY INTERFACE_COMPILE_OPTIONS "${BLAS_CFLAGS_OTHER}") - set_property(TARGET blas::blas APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${BLAS_INCLUDE_DIRS}") - if (NOT BLAS_FIND_QUIETLY) - message(STATUS "Morse : target blas::blas available") - endif() - endif() - if(NOT TARGET blas::blas_seq AND BLAS_LIBRARIES_SEQ) - add_library(blas::blas_seq INTERFACE IMPORTED) - set_property(TARGET blas::blas_seq APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${BLAS_LDFLAGS_OTHER}") - set_property(TARGET blas::blas_seq APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${BLAS_LIBRARIES_SEQ}") - set_property(TARGET blas::blas_seq APPEND PROPERTY INTERFACE_COMPILE_OPTIONS "${BLAS_CFLAGS_OTHER}") - set_property(TARGET blas::blas_seq APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${BLAS_INCLUDE_DIRS}") - if (NOT BLAS_FIND_QUIETLY) - message(STATUS "Morse : target blas::blas_seq available") - endif() - endif() - if(NOT TARGET blas::blas_par AND BLAS_LIBRARIES_PAR) - add_library(blas::blas_par INTERFACE IMPORTED) - set_property(TARGET blas::blas_par APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${BLAS_LDFLAGS_OTHER}") - set_property(TARGET blas::blas_par APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${BLAS_LIBRARIES_PAR}") - set_property(TARGET blas::blas_par APPEND PROPERTY INTERFACE_COMPILE_OPTIONS "${BLAS_CFLAGS_OTHER}") - set_property(TARGET blas::blas_par APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${BLAS_INCLUDE_DIRS}") - if (NOT BLAS_FIND_QUIETLY) - message(STATUS "Morse : target blas::blas_par available") - endif() - endif() - if(NOT TARGET blas::blas_95 AND BLAS95_LIBRARIES AND BLAS95_FOUND) - add_library(blas::blas_95 INTERFACE IMPORTED) - set_property(TARGET blas::blas_95 APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${BLAS_LDFLAGS_OTHER}") - set_property(TARGET blas::blas_95 APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${BLAS95_LIBRARIES}") - set_property(TARGET blas::blas_95 APPEND PROPERTY INTERFACE_COMPILE_OPTIONS "${BLAS_CFLAGS_OTHER}") - set_property(TARGET blas::blas_95 APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${BLAS_INCLUDE_DIRS}") - if (NOT BLAS_FIND_QUIETLY) - message(STATUS "Morse : target blas::blas_95 available") - endif() - endif() -endif() - -mark_as_advanced(BLAS_DIR) -mark_as_advanced(BLAS_DIR_FOUND) diff --git a/modules/find/FindBLASEXT.cmake b/modules/find/FindBLASEXT.cmake deleted file mode 100644 index f22d9351a054981e12ccf491027aa7e4f0f890c8..0000000000000000000000000000000000000000 --- a/modules/find/FindBLASEXT.cmake +++ /dev/null @@ -1,390 +0,0 @@ -### -# -# @copyright (c) 2009-2014 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. -# @copyright (c) 2012-2019 Inria. All rights reserved. -# @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. -# -### -# -# - Find BLAS EXTENDED for MORSE projects: find include dirs and libraries -# -# This module allows to find BLAS libraries by calling the official FindBLAS module -# and handles the creation of different library lists whether the user wishes to link -# with a sequential BLAS or a multihreaded (BLAS_SEQ_LIBRARIES and BLAS_PAR_LIBRARIES). -# BLAS is detected with a FindBLAS call then if the BLAS vendor is Intel10_64lp, ACML -# or IBMESSLMT then the module attempts to find the corresponding multithreaded libraries. -# -# The following variables have been added to manage links with sequential or multithreaded -# versions: -# BLAS_INCLUDE_DIRS - BLAS include directories -# BLAS_LIBRARY_DIRS - Link directories for BLAS libraries -# BLAS_SEQ_LIBRARIES - BLAS component libraries to be linked (sequential) -# BLAS_SEQ_CFLAGS_OTHER - compiler flags without headers paths -# BLAS_SEQ_LDFLAGS_OTHER - linker flags without libraries -# BLAS_PAR_LIBRARIES - BLAS component libraries to be linked (multithreaded) -# BLAS_PAR_CFLAGS_OTHER - compiler flags without headers paths -# BLAS_PAR_LDFLAGS_OTHER - linker flags without libraries -# BLASEXT_FOUND - if a BLAS has been found -# BLASEXT_LIBRARIES - Idem BLAS_LIBRARIES -# BLASEXT_INCLUDE_DIRS - Idem BLAS_INCLUDE_DIRS -# BLASEXT_LIBRARY_DIRS - Idem BLAS_LIBRARY_DIRS - -#============================================================================= -# Copyright 2012-2019 Inria -# Copyright 2012-2013 Emmanuel Agullo -# Copyright 2012-2013 Mathieu Faverge -# Copyright 2012 Cedric Castagnede -# Copyright 2013-2017 Florent Pruvost -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file MORSE-Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of Morse, substitute the full -# License text for the above reference.) - -# Macro to factorize this call. required arguments allows to decide if -# the REQUIRED option must be given to find_package calls -macro(find_package_blas required) - if(BLASEXT_FIND_REQUIRED AND required) - if(BLASEXT_FIND_QUIETLY) - find_package(BLAS REQUIRED QUIET) - else() - 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 -set(BLA_VENDOR "" CACHE STRING "list of possible BLAS vendor: - Open, Eigen, Goto, ATLAS PhiPACK, CXML, DXML, SunPerf, SCSL, SGIMATH, IBMESSL, IBMESSLMT, - 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(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") -endif() - -# First blas detection in order to decide if we should look for a -# multitheaded version -find_package_blas(0) - -# 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 "") -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 "") -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 "") -endif() - -# Intel case -if(BLA_VENDOR MATCHES "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_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 - 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} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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 - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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}" ) - endif() - - ### - # look for libs - ### - - ## 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(0) - if(BLAS_FOUND) - set(BLAS_SEQ_LIBRARIES "${BLAS_LIBRARIES}") - if (BLAS_CFLAGS_OTHER) - set (BLAS_SEQ_CFLAGS_OTHER "${BLAS_CFLAGS_OTHER}") - endif() - if (BLAS_LDFLAGS_OTHER) - set (BLAS_SEQ_LDFLAGS_OTHER "${BLAS_LDFLAGS_OTHER}") - endif() - 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(0) - if(BLAS_FOUND) - set(BLAS_PAR_LIBRARIES "${BLAS_LIBRARIES}") - if (BLAS_CFLAGS_OTHER) - set (BLAS_PAR_CFLAGS_OTHER "${BLAS_CFLAGS_OTHER}") - endif() - if (BLAS_LDFLAGS_OTHER) - set (BLAS_PAR_LDFLAGS_OTHER "${BLAS_LDFLAGS_OTHER}") - 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 the sequential version - set(BLA_VENDOR "ACML") - find_package_blas(0) - 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(0) - 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(0) - 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(0) - 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() - -# Reset pure BLAS cmake variables to the sequential case (arbitrary default) -if(BLAS_SEQ_LIBRARIES) - set(BLAS_LIBRARIES "${BLAS_SEQ_LIBRARIES}") - set(BLAS_CFLAGS_OTHER "${BLAS_SEQ_CFLAGS_OTHER}") - set(BLAS_LDFLAGS_OTHER "${BLAS_SEQ_LDFLAGS_OTHER}") -endif() - -# extract libs paths if not given by find_package(BLAS) -if (NOT BLAS_LIBRARY_DIRS) - 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}") - 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() - endif() - endforeach() - if (BLAS_LIBRARY_DIRS) - list(REMOVE_DUPLICATES BLAS_LIBRARY_DIRS) - endif () -endif(NOT BLAS_LIBRARY_DIRS) - -# check that BLASEXT has been found -# --------------------------------- -include(FindPackageHandleStandardArgs) -if(BLA_VENDOR MATCHES "Intel*") - if(NOT BLASEXT_FIND_QUIETLY) - message(STATUS "BLAS found is Intel MKL") - message(STATUS "BLAS sequential libraries stored in BLAS_SEQ_LIBRARIES") - endif() - find_package_handle_standard_args(BLASEXT DEFAULT_MSG - BLAS_SEQ_LIBRARIES - BLAS_LIBRARY_DIRS - BLAS_INCLUDE_DIRS) - if(BLA_VENDOR MATCHES "Intel10_64lp*" AND BLAS_PAR_LIBRARIES) - if(NOT BLASEXT_FIND_QUIETLY) - message(STATUS "BLAS parallel libraries stored in BLAS_PAR_LIBRARIES") - endif() - find_package_handle_standard_args(BLASEXT DEFAULT_MSG - BLAS_PAR_LIBRARIES) - endif() -elseif(BLA_VENDOR MATCHES "ACML*") - if(NOT BLASEXT_FIND_QUIETLY) - message(STATUS "BLAS found is ACML") - message(STATUS "BLAS sequential libraries stored in BLAS_SEQ_LIBRARIES") - endif() - find_package_handle_standard_args(BLASEXT 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(BLASEXT DEFAULT_MSG - BLAS_PAR_LIBRARIES) - endif() -elseif(BLA_VENDOR MATCHES "IBMESSL*") - if(NOT BLASEXT_FIND_QUIETLY) - message(STATUS "BLAS found is ESSL") - message(STATUS "BLAS sequential libraries stored in BLAS_SEQ_LIBRARIES") - endif() - find_package_handle_standard_args(BLASEXT 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(BLASEXT 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(BLASEXT DEFAULT_MSG - BLAS_SEQ_LIBRARIES - BLAS_LIBRARY_DIRS) -endif() - -if (BLAS_LIBRARIES) - set(BLASEXT_LIBRARIES ${BLAS_LIBRARIES}) -endif() -if (BLAS_INCLUDE_DIRS) - set(BLASEXT_INCLUDE_DIRS ${BLAS_INCLUDE_DIRS}) -endif() -if (BLAS_LIBRARY_DIRS) - set(BLASEXT_LIBRARY_DIRS ${BLAS_LIBRARY_DIRS}) -endif() diff --git a/modules/find/FindCBLAS.cmake b/modules/find/FindCBLAS.cmake index c2cbcb0c5148ed81ffd1aa6fe1b856ebf294b121..9bed675edbcddd0690bcde547dcc3afe8dec2e53 100644 --- a/modules/find/FindCBLAS.cmake +++ b/modules/find/FindCBLAS.cmake @@ -1,11 +1,22 @@ ### # -# @copyright (c) 2009-2014 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. # @copyright (c) 2012-2020 Inria. All rights reserved. # @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. # +# Copyright 2012-2013 Emmanuel Agullo +# Copyright 2012-2013 Mathieu Faverge +# Copyright 2012 Cedric Castagnede +# Copyright 2013-2020 Florent Pruvost +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file MORSE-Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of Morse, substitute the full +# License text for the above reference.) ### # # - Find CBLAS include dirs and libraries @@ -18,23 +29,11 @@ # CBLAS depends on the following libraries: # - BLAS # -# This module finds headers and cblas library. -# Results are reported in variables: -# CBLAS_FOUND - True if headers and requested libraries were found -# CBLAS_CFLAGS_OTHER - cblas compiler flags without headers paths -# CBLAS_LDFLAGS_OTHER - cblas linker flags without libraries -# CBLAS_INCLUDE_DIRS - cblas include directories -# CBLAS_LIBRARY_DIRS - cblas link directories -# CBLAS_LIBRARIES - cblas libraries to be linked (absolute path) -# CBLAS_CFLAGS_OTHER_DEP - cblas + dependencies compiler flags without headers paths -# CBLAS_LDFLAGS_OTHER_DEP - cblas + dependencies linker flags without libraries -# CBLAS_INCLUDE_DIRS_DEP - cblas + dependencies include directories -# CBLAS_LIBRARY_DIRS_DEP - cblas + dependencies link directories -# CBLAS_LIBRARIES_DEP - cblas + dependencies libraries # CBLAS_HAS_ZGEMM3M - True if cblas contains zgemm3m fast complex mat-mat product # # CBLAS_FOUND_WITH_PKGCONFIG - True if found with pkg-config -# if found with pkg-config the following variables are set +# if found the following variables are set +# CBLAS_PREFIX - installation path of the lib found # <PREFIX> = CBLAS # <XPREFIX> = <PREFIX> for common case # <XPREFIX> = <PREFIX>_STATIC for static linking @@ -47,6 +46,13 @@ # <XPREFIX>_CFLAGS ... all required cflags # <XPREFIX>_CFLAGS_OTHER ... the other compiler flags # +# Set CBLAS_STATIC to 1 to force using static libraries if exist. +# +# This module defines the following :prop_tgt:`IMPORTED` target: +# +# ``MORSE::CBLAS`` +# The headers and libraries to use for CBLAS, if found. +# # The user can give specific paths where to find the libraries adding cmake # options at configure (ex: cmake path/to/project -DCBLAS_DIR=path/to/cblas): # CBLAS_DIR - Where to find the base directory of cblas @@ -71,26 +77,10 @@ # 4) we look in common system paths depending on the system, see for example paths contained in the following cmake variables: # - CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES, CMAKE_C_IMPLICIT_LINK_DIRECTORIES # - -#============================================================================= -# Copyright 2012-2019 Inria -# Copyright 2012-2013 Emmanuel Agullo -# Copyright 2012-2013 Mathieu Faverge -# Copyright 2012 Cedric Castagnede -# Copyright 2013-2018 Florent Pruvost -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file MORSE-Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. #============================================================================= -# (To distribute this file outside of Morse, substitute the full -# License text for the above reference.) # Common macros to use in finds -include(FindInit) +include(FindMorseInit) if (NOT CBLAS_FOUND) set(CBLAS_DIR "" CACHE PATH "Installation directory of CBLAS library") @@ -138,10 +128,83 @@ if (BLAS_FOUND) # test succeeds: CBLAS is in BLAS set(CBLAS_LIBRARIES "${BLAS_LIBRARIES}") set(CBLAS_INCLUDE_DIRS "${BLAS_INCLUDE_DIRS}") - set(CBLAS_CFLAGS_OTHER "${BLAS_CFLAGS_OTHER}") set(CBLAS_LIBRARY_DIRS "${BLAS_LIBRARY_DIRS}") + set(CBLAS_CFLAGS_OTHER "${BLAS_CFLAGS_OTHER}") set(CBLAS_LDFLAGS_OTHER "${BLAS_LDFLAGS_OTHER}") + if (NOT CBLAS_INCLUDE_DIRS) + # 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_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} + NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) + 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" + NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) + 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() + endif() endif (NOT CBLAS_STANDALONE) @@ -150,7 +213,7 @@ if (BLAS_FOUND) 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") + message(STATUS "Looking for cblas : test with blas fails or CBLAS_STANDALONE enabled") endif() # try with pkg-config @@ -163,7 +226,6 @@ if (BLAS_FOUND) set(CBLAS_GIVEN_BY_USER "TRUE") endif() - include(FindPkgConfig) find_package(PkgConfig QUIET) if( PKG_CONFIG_EXECUTABLE AND NOT CBLAS_GIVEN_BY_USER) @@ -177,7 +239,7 @@ if (BLAS_FOUND) pkg_search_module(CBLAS mkl-${MKL_STR_BLA_STATIC}-lp64-iomp) elseif(BLA_VENDOR STREQUAL "Intel10_64lp_seq") pkg_search_module(CBLAS mkl-${MKL_STR_BLA_STATIC}-lp64-seq) - elseif(BLA_VENDOR STREQUAL "Open") + elseif(BLA_VENDOR STREQUAL "OpenBLAS") pkg_search_module(CBLAS openblas) elseif(BLA_VENDOR STREQUAL "Generic") pkg_search_module(CBLAS cblas) @@ -199,11 +261,21 @@ if (BLAS_FOUND) if (CBLAS_FOUND AND CBLAS_LIBRARIES) set(CBLAS_FOUND_WITH_PKGCONFIG "TRUE") - find_pkgconfig_libraries_absolute_path(CBLAS) + morse_find_pkgconfig_libraries_absolute_path(CBLAS) else() set(CBLAS_FOUND_WITH_PKGCONFIG "FALSE") endif() + if (CBLAS_STATIC AND CBLAS_STATIC_LIBRARIES) + set (CBLAS_DEPENDENCIES ${CBLAS_STATIC_LIBRARIES}) + list (REMOVE_ITEM CBLAS_DEPENDENCIES "cblas") + list (APPEND CBLAS_LIBRARIES ${CBLAS_DEPENDENCIES}) + set(CBLAS_CFLAGS_OTHER ${CBLAS_STATIC_CFLAGS_OTHER}) + set(CBLAS_LDFLAGS_OTHER ${CBLAS_STATIC_LDFLAGS_OTHER}) + if (NOT CBLAS_FIND_QUIETLY) + message(STATUS "CBLAS_STATIC set to 1 by user, CBLAS_LIBRARIES: ${CBLAS_LIBRARIES}.") + endif() + endif() endif() if (NOT CBLAS_FOUND_WITH_PKGCONFIG OR CBLAS_GIVEN_BY_USER) @@ -311,6 +383,11 @@ if (BLAS_FOUND) # Try to find the cblas lib in the given paths # ---------------------------------------------- + if (CBLAS_STATIC) + set (CMAKE_FIND_LIBRARY_SUFFIXES_COPY ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set (CMAKE_FIND_LIBRARY_SUFFIXES ".a") + endif() + # call cmake macro to find the lib path if(CBLAS_LIBDIR) set(CBLAS_cblas_LIBRARY "CBLAS_cblas_LIBRARY-NOTFOUND") @@ -335,6 +412,10 @@ if (BLAS_FOUND) endif() mark_as_advanced(CBLAS_cblas_LIBRARY) + if (CBLAS_STATIC) + set (CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_COPY}) + endif() + # If found, add path to cmake variable # ------------------------------------ if (CBLAS_cblas_LIBRARY) @@ -356,11 +437,17 @@ if (BLAS_FOUND) # check a function to validate the find if(CBLAS_LIBRARIES) + # check if static or dynamic lib + morse_check_static_or_dynamic(CBLAS CBLAS_LIBRARIES) + if(CBLAS_STATIC) + set(STATIC "_STATIC") + endif() + set(REQUIRED_INCDIRS) - set(REQUIRED_FLAGS) - set(REQUIRED_LDFLAGS) set(REQUIRED_LIBDIRS) set(REQUIRED_LIBS) + set(REQUIRED_FLAGS) + set(REQUIRED_LDFLAGS) # CBLAS if (CBLAS_INCLUDE_DIRS) @@ -405,7 +492,7 @@ if (BLAS_FOUND) list(APPEND REQUIRED_FLAGS "${_flag}") endforeach() endif() - finds_remove_duplicates() + morse_finds_remove_duplicates() set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) @@ -428,12 +515,14 @@ if (BLAS_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_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}") - set(CBLAS_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}") + set(CBLAS_LIBRARY_DIRS "${REQUIRED_LIBDIRS}") + set(CBLAS_INCLUDE_DIRS "${REQUIRED_INCDIRS}") + if (CBLAS_STATIC OR BLA_STATIC) + # save link with dependencies + set(CBLAS_LIBRARIES "${REQUIRED_LIBS}") + set(CBLAS_CFLAGS_OTHER "${REQUIRED_FLAGS}") + set(CBLAS_LDFLAGS_OTHER "${REQUIRED_LDFLAGS}") + endif() else() if(NOT CBLAS_FIND_QUIETLY) message(STATUS "Looking for cblas : test of cblas_dscal with cblas and blas libraries fails") @@ -446,6 +535,26 @@ if (BLAS_FOUND) set(CMAKE_REQUIRED_INCLUDES) set(CMAKE_REQUIRED_FLAGS) set(CMAKE_REQUIRED_LIBRARIES) + + list(GET CBLAS_LIBRARIES 0 first_lib) + get_filename_component(first_lib_path "${first_lib}" DIRECTORY) + if (NOT CBLAS_LIBRARY_DIRS) + set(CBLAS_LIBRARY_DIRS "${first_lib_path}") + endif() + 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_PREFIX "${not_cached_dir}" CACHE PATH "Installation directory of CBLAS library" FORCE) + else() + set(CBLAS_PREFIX "${first_lib_path}" CACHE PATH "Installation directory of CBLAS library" FORCE) + endif() + if (NOT CBLAS_INCLUDE_DIRS) + if (EXISTS "${CBLAS_PREFIX}/include") + set(CBLAS_INCLUDE_DIRS "${CBLAS_PREFIX}/include") + endif() + endif() + mark_as_advanced(CBLAS_DIR) + mark_as_advanced(CBLAS_PREFIX) + endif(CBLAS_LIBRARIES) else(BLAS_FOUND) @@ -457,25 +566,14 @@ else(BLAS_FOUND) endif(BLAS_FOUND) -if (CBLAS_LIBRARIES) - list(GET CBLAS_LIBRARIES 0 first_lib) - get_filename_component(first_lib_path "${first_lib}" PATH) - if (NOT CBLAS_LIBRARY_DIRS) - set(CBLAS_LIBRARY_DIRS "${first_lib_path}") - endif() - 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) - # check that CBLAS has been found # ------------------------------- include(FindPackageHandleStandardArgs) find_package_handle_standard_args(CBLAS DEFAULT_MSG CBLAS_LIBRARIES CBLAS_WORKS) + +# Add imported target +if (CBLAS_FOUND) + morse_create_imported_target(CBLAS) +endif() diff --git a/modules/find/FindCHAMELEON.cmake b/modules/find/FindCHAMELEON.cmake deleted file mode 100644 index a3d632050e2e6e5b9571c6b766a7afa44b438d20..0000000000000000000000000000000000000000 --- a/modules/find/FindCHAMELEON.cmake +++ /dev/null @@ -1,784 +0,0 @@ -### -# -# @copyright (c) 2009-2014 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. -# @copyright (c) 2012-2020 Inria. All rights reserved. -# @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. -# -### -# -# - Find CHAMELEON include dirs and libraries -# Use this module by invoking find_package with the form: -# find_package(CHAMELEON -# [REQUIRED] # Fail with error if chameleon is not found -# [COMPONENTS <comp1> <comp2> ...] # dependencies -# ) -# -# CHAMELEON depends on the following libraries: -# - Threads, m, rt -# - HWLOC -# - CBLAS -# - LAPACKE -# - TMG -# - At least one runtime, default is StarPU -# (For QUARK, use COMPONENTS QUARK) -# -# COMPONENTS are optional libraries CHAMELEON could be linked with, -# Use it to drive detection of a specific compilation chain -# COMPONENTS can be some of the following: -# - STARPU (default): to activate detection of Chameleon linked with StarPU -# - QUARK (STARPU will be deactivated): to activate detection of Chameleon linked with QUARK -# - CUDA (comes with cuBLAS): to activate detection of Chameleon linked with CUDA -# - MPI: to activate detection of Chameleon linked with MPI -# - FXT: to activate detection of Chameleon linked with StarPU+FXT -# -# This module finds headers and chameleon library. -# Results are reported in variables: -# CHAMELEON_FOUND - True if headers and requested libraries were found -# CHAMELEON_CFLAGS_OTHER - chameleon compiler flags without headers paths -# CHAMELEON_LDFLAGS_OTHER - chameleon linker flags without libraries -# CHAMELEON_INCLUDE_DIRS - chameleon include directories -# CHAMELEON_LIBRARY_DIRS - chameleon link directories -# CHAMELEON_LIBRARIES - chameleon libraries to be linked (absolute path) -# CHAMELEON_CFLAGS_OTHER_DEP - chameleon + dependencies compiler flags without headers paths -# CHAMELEON_LDFLAGS_OTHER_DEP - chameleon + dependencies linker flags without libraries -# CHAMELEON_INCLUDE_DIRS_DEP - chameleon + dependencies include directories -# CHAMELEON_LIBRARY_DIRS_DEP - chameleon + dependencies link directories -# CHAMELEON_LIBRARIES_DEP - chameleon + dependencies libraries -# -# CHAMELEON_FOUND_WITH_PKGCONFIG - True if found with pkg-config -# if found with pkg-config the following variables are set -# <PREFIX> = CHAMELEON -# <XPREFIX> = <PREFIX> for common case -# <XPREFIX> = <PREFIX>_STATIC for static linking -# <XPREFIX>_FOUND ... set to 1 if module(s) exist -# <XPREFIX>_LIBRARIES ... only the libraries (w/o the '-l') -# <XPREFIX>_LIBRARY_DIRS ... the paths of the libraries (w/o the '-L') -# <XPREFIX>_LDFLAGS ... all required linker flags -# <XPREFIX>_LDFLAGS_OTHER ... all other linker flags -# <XPREFIX>_INCLUDE_DIRS ... the '-I' preprocessor flags (w/o the '-I') -# <XPREFIX>_CFLAGS ... all required cflags -# <XPREFIX>_CFLAGS_OTHER ... the other compiler flags -# -# The user can give specific paths where to find the libraries adding cmake -# options at configure (ex: cmake path/to/project -DCHAMELEON_DIR=path/to/chameleon): -# CHAMELEON_DIR - Where to find the base directory of chameleon -# CHAMELEON_INCDIR - Where to find the header files -# CHAMELEON_LIBDIR - Where to find the library files -# The module can also look for the following environment variables if paths -# are not given as cmake variable: CHAMELEON_DIR, CHAMELEON_INCDIR, CHAMELEON_LIBDIR - -#============================================================================= -# Copyright 2012-2019 Inria -# Copyright 2012-2013 Emmanuel Agullo -# Copyright 2012-2013 Mathieu Faverge -# Copyright 2012 Cedric Castagnede -# Copyright 2013-2018 Florent Pruvost -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file MORSE-Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of Morse, substitute the full -# License text for the above reference.) - -# Common macros to use in finds -include(FindInit) - -if (NOT CHAMELEON_FOUND) - set(CHAMELEON_DIR "" CACHE PATH "Installation directory of CHAMELEON library") - 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 -set(CHAMELEON_LOOK_FOR_STARPU ON) -set(CHAMELEON_LOOK_FOR_QUARK OFF) -set(CHAMELEON_LOOK_FOR_CUDA OFF) -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 "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}") -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") -endif() - -# Optionally use pkg-config to detect include/library dirs (if pkg-config is available) -# ------------------------------------------------------------------------------------- -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") - 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() - 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() - - if (CHAMELEON_FOUND AND CHAMELEON_LIBRARIES) - if (NOT CHAMELEON_INCLUDE_DIRS) - pkg_get_variable(CHAMELEON_INCLUDE_DIRS chameleon includedir) - endif() - set(CHAMELEON_FOUND_WITH_PKGCONFIG "TRUE") - find_pkgconfig_libraries_absolute_path(CHAMELEON) - else() - set(CHAMELEON_FOUND_WITH_PKGCONFIG "FALSE") - endif() - -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") - 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 ) - libraries_absolute_path(CMAKE_THREAD_LIBS_INIT "") - 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) - 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(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) - libraries_absolute_path(CUDA_LIBRARIES "$ENV{CUDA_ROOT}/lib64") - 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") - 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_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_chameleon.h_DIRS "CHAMELEON_chameleon.h_DIRS-NOTFOUND") - find_path(CHAMELEON_chameleon.h_DIRS - NAMES chameleon.h - HINTS ${CHAMELEON_INCDIR} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - if(CHAMELEON_DIR) - set(CHAMELEON_chameleon.h_DIRS "CHAMELEON_chameleon.h_DIRS-NOTFOUND") - find_path(CHAMELEON_chameleon.h_DIRS - NAMES chameleon.h - HINTS ${CHAMELEON_DIR} - PATH_SUFFIXES "include" "include/chameleon" - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - set(CHAMELEON_chameleon.h_DIRS "CHAMELEON_chameleon.h_DIRS-NOTFOUND") - find_path(CHAMELEON_chameleon.h_DIRS - NAMES chameleon.h - HINTS ${_inc_env} - PATH_SUFFIXES "chameleon") - endif() - endif() - mark_as_advanced(CHAMELEON_chameleon.h_DIRS) - - # If found, add path to cmake variable - # ------------------------------------ - if (CHAMELEON_chameleon.h_DIRS) - set(CHAMELEON_INCLUDE_DIRS "${CHAMELEON_chameleon.h_DIRS}") - else () - set(CHAMELEON_INCLUDE_DIRS "CHAMELEON_INCLUDE_DIRS-NOTFOUND") - if(NOT CHAMELEON_FIND_QUIETLY) - message(STATUS "Looking for chameleon -- chameleon.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() - list(APPEND _lib_env "$ENV{LIBRARY_PATH}") - if(WIN32) - string(REPLACE ":" ";" _lib_env2 "$ENV{LIB}") - elseif(APPLE) - string(REPLACE ":" ";" _lib_env2 "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env2 "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${_lib_env2}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - 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") - if (CHAMELEON_LOOK_FOR_CUDA) - list(APPEND CHAMELEON_libs_to_find "cudablas") - endif() - - # 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} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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 - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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 - # ------------------------------------ - foreach(chameleon_lib ${CHAMELEON_libs_to_find}) - - 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}) - -endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR (CHAMELEON_GIVEN_BY_USER) ) - -# check a function to validate the find -if(CHAMELEON_LIBRARIES) - - set(REQUIRED_INCDIRS) - set(REQUIRED_FLAGS) - set(REQUIRED_LDFLAGS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) - - # CHAMELEON - if (CHAMELEON_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${CHAMELEON_INCLUDE_DIRS}") - endif() - if (CHAMELEON_CFLAGS_OTHER) - list(APPEND REQUIRED_FLAGS "${CHAMELEON_CFLAGS_OTHER}") - endif() - if (CHAMELEON_LDFLAGS_OTHER) - list(APPEND REQUIRED_LDFLAGS "${CHAMELEON_LDFLAGS_OTHER}") - 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}") - endif() - if (STARPU_CFLAGS_OTHER_DEP) - list(APPEND REQUIRED_FLAGS "${STARPU_CFLAGS_OTHER_DEP}") - endif() - if (STARPU_LDFLAGS_OTHER_DEP) - list(APPEND REQUIRED_LDFLAGS "${STARPU_LDFLAGS_OTHER_DEP}") - endif() - if(STARPU_LIBRARY_DIRS_DEP) - list(APPEND REQUIRED_LIBDIRS "${STARPU_LIBRARY_DIRS_DEP}") - endif() - if (STARPU_LIBRARIES_DEP) - list(APPEND REQUIRED_LIBS "${STARPU_LIBRARIES_DEP}") - endif() - endif() - # QUARK - if (QUARK_FOUND AND CHAMELEON_LOOK_FOR_QUARK) - if (QUARK_INCLUDE_DIRS_DEP) - list(APPEND REQUIRED_INCDIRS "${QUARK_INCLUDE_DIRS_DEP}") - endif() - if (QUARK_CFLAGS_OTHER_DEP) - list(APPEND REQUIRED_FLAGS "${QUARK_CFLAGS_OTHER_DEP}") - endif() - if (QUARK_LDFLAGS_OTHER_DEP) - list(APPEND REQUIRED_LDFLAGS "${QUARK_LDFLAGS_OTHER_DEP}") - endif() - if(QUARK_LIBRARY_DIRS_DEP) - list(APPEND REQUIRED_LIBDIRS "${QUARK_LIBRARY_DIRS_DEP}") - endif() - if (QUARK_LIBRARY_DIRS_DEP) - list(APPEND REQUIRED_LIBS "${QUARK_LIBRARIES_DEP}") - 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() - # 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() - if (HWLOC_CFLAGS_OTHER) - list(APPEND REQUIRED_FLAGS "${HWLOC_CFLAGS_OTHER}") - endif() - if (HWLOC_LDFLAGS_OTHER) - list(APPEND REQUIRED_LDFLAGS "${HWLOC_LDFLAGS_OTHER}") - endif() - if (HWLOC_LIBRARY_DIRS) - list(APPEND REQUIRED_LIBDIRS "${HWLOC_LIBRARY_DIRS}") - endif() - list(APPEND REQUIRED_LIBS "${HWLOC_LIBRARIES}") - endif() - # TMG - if (TMG_FOUND) - if (TMG_INCLUDE_DIRS_DEP) - list(APPEND REQUIRED_INCDIRS "${TMG_INCLUDE_DIRS_DEP}") - endif() - if (TMG_CFLAGS_OTHER_DEP) - list(APPEND REQUIRED_FLAGS "${TMG_CFLAGS_OTHER_DEP}") - endif() - if (TMG_LDFLAGS_OTHER_DEP) - list(APPEND REQUIRED_LDFLAGS "${TMG_LDFLAGS_OTHER_DEP}") - endif() - if(TMG_LIBRARY_DIRS_DEP) - list(APPEND REQUIRED_LIBDIRS "${TMG_LIBRARY_DIRS_DEP}") - endif() - if (TMG_LIBRARIES_DEP) - list(APPEND REQUIRED_LIBS "${TMG_LIBRARIES_DEP}") - endif() - endif() - # LAPACKE - if (LAPACKE_FOUND) - if (LAPACKE_INCLUDE_DIRS_DEP) - list(APPEND REQUIRED_INCDIRS "${LAPACKE_INCLUDE_DIRS_DEP}") - endif() - if (LAPACKE_CFLAGS_OTHER_DEP) - list(APPEND REQUIRED_FLAGS "${LAPACKE_CFLAGS_OTHER_DEP}") - endif() - if (LAPACKE_LDFLAGS_OTHER_DEP) - list(APPEND REQUIRED_LDFLAGS "${LAPACKE_LDFLAGS_OTHER_DEP}") - endif() - if(LAPACKE_LIBRARY_DIRS_DEP) - list(APPEND REQUIRED_LIBDIRS "${LAPACKE_LIBRARY_DIRS_DEP}") - endif() - if (LAPACKE_LIBRARIES_DEP) - list(APPEND REQUIRED_LIBS "${LAPACKE_LIBRARIES_DEP}") - endif() - endif() - # CBLAS - if (CBLAS_FOUND) - if (CBLAS_INCLUDE_DIRS_DEP) - list(APPEND REQUIRED_INCDIRS "${CBLAS_INCLUDE_DIRS_DEP}") - endif() - if (CBLAS_CFLAGS_OTHER_DEP) - list(APPEND REQUIRED_FLAGS "${CBLAS_CFLAGS_OTHER_DEP}") - endif() - if (CBLAS_LDFLAGS_OTHER_DEP) - list(APPEND REQUIRED_LDFLAGS "${CBLAS_LDFLAGS_OTHER_DEP}") - endif() - if(CBLAS_LIBRARY_DIRS_DEP) - list(APPEND REQUIRED_LIBDIRS "${CBLAS_LIBRARY_DIRS_DEP}") - endif() - if (CBLAS_LIBRARIES_DEP) - list(APPEND REQUIRED_LIBS "${CBLAS_LIBRARIES_DEP}") - 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}") - if (REQUIRED_FLAGS) - set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}") - set(REQUIRED_FLAGS) - set(REQUIRED_DEFINITIONS) - foreach(_flag ${REQUIRED_FLAGS_COPY}) - if (_flag MATCHES "^-D") - list(APPEND REQUIRED_DEFINITIONS "${_flag}") - endif() - string(REGEX REPLACE "^-D.*" "" _flag "${_flag}") - list(APPEND REQUIRED_FLAGS "${_flag}") - endforeach() - endif() - finds_remove_duplicates() - set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") - set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") - set(CMAKE_REQUIRED_LIBRARIES) - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}") - 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(CHAMELEON_Version 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_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}") - set(CHAMELEON_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}") - else() - if(NOT CHAMELEON_FIND_QUIETLY) - message(STATUS "Looking for chameleon : test of CHAMELEON_Version fails") - message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") - message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") - message(STATUS "CMAKE_REQUIRED_FLAGS: ${CMAKE_REQUIRED_FLAGS}") - message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") - message(STATUS "Maybe CHAMELEON is linked with specific libraries. " - "Have you tried with COMPONENTS (STARPU/QUARK, CUDA, 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) - -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) - set(CHAMELEON_LIBRARY_DIRS "${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) - -# check that CHAMELEON has been found -# --------------------------------- -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(CHAMELEON DEFAULT_MSG - CHAMELEON_LIBRARIES - CHAMELEON_WORKS) diff --git a/modules/find/FindCommon.cmake b/modules/find/FindCommon.cmake deleted file mode 100644 index f0c1d9192387d5ecea66002220238c8b3321bac6..0000000000000000000000000000000000000000 --- a/modules/find/FindCommon.cmake +++ /dev/null @@ -1,47 +0,0 @@ -### -# -# @copyright (c) 2019 Inria. All rights reserved. -# -### -# -# @file FindCommon.cmake -# -# @project MORSE -# MORSE is a software package provided by: -# Inria Bordeaux - Sud-Ouest, -# Univ. of Tennessee, -# King Abdullah Univesity of Science and Technology -# Univ. of California Berkeley, -# Univ. of Colorado Denver. -# -# @version 1.0.0 -# @author Florent Pruvost -# @date 13-04-2018 -# -### - -# clean these variables before using them in CMAKE_REQUIRED_* variables in -# check_function_exists -macro(finds_remove_duplicates) - if (REQUIRED_DEFINITIONS) - list(REMOVE_DUPLICATES REQUIRED_DEFINITIONS) - endif() - if (REQUIRED_INCDIRS) - list(REMOVE_DUPLICATES REQUIRED_INCDIRS) - endif() - if (REQUIRED_FLAGS) - list(REMOVE_DUPLICATES REQUIRED_FLAGS) - endif() - if (REQUIRED_LDFLAGS) - list(REMOVE_DUPLICATES REQUIRED_LDFLAGS) - endif() - if (REQUIRED_LIBS) - list(REVERSE REQUIRED_LIBS) - list(REMOVE_DUPLICATES REQUIRED_LIBS) - list(REVERSE REQUIRED_LIBS) - endif() -endmacro() - -## -## @end file FindCommon -## diff --git a/modules/find/FindEZTRACE.cmake b/modules/find/FindEZTRACE.cmake index b0a3427553d3dc308aad2fde104178ddb2a3c33f..259818e31f12201e4c6fde70987476331c8b74b5 100644 --- a/modules/find/FindEZTRACE.cmake +++ b/modules/find/FindEZTRACE.cmake @@ -1,11 +1,23 @@ ### # -# @copyright (c) 2009-2014 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. # @copyright (c) 2012-2020 Inria. All rights reserved. # @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. # +# Copyright 2012-2013 Emmanuel Agullo +# Copyright 2012-2013 Mathieu Faverge +# Copyright 2012 Cedric Castagnede +# Copyright 2013-2020 Florent Pruvost +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file MORSE-Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of Morse, substitute the full +# License text for the above reference.) +# ### # # - Find EZTRACE include dirs and libraries @@ -14,19 +26,17 @@ # [REQUIRED]) # Fail with error if eztrace is not found # # EZTRACE depends on the following libraries: -# - libbfd.so -# - libiberty.so (optional) -# -# This module finds headers and eztrace library. -# Results are reported in variables: -# EZTRACE_FOUND - True if headers and requested libraries were found -# EZTRACE_INCLUDE_DIRS - eztrace include directories -# EZTRACE_LIBRARY_DIRS - Link directories for eztrace libraries -# EZTRACE_LIBRARIES - eztrace component libraries to be linked +# - threads (e.g. pthreads) +# - bfd +# - cuda (optional) +# - iberty (optional) +# - mpi (optional) # -# EZTRACE_FOUND_WITH_PKGCONFIG - True if found with pkg-config +# This module finds headers and eztrace library using pkg-config file. # if found with pkg-config the following variables are set # <PREFIX> = EZTRACE +# <PREFIX>_PREFIX ... installation path of the lib found +# <PREFIX>_VERSION ... version of the lib # <XPREFIX> = <PREFIX> for common case # <XPREFIX> = <PREFIX>_STATIC for static linking # <XPREFIX>_FOUND ... set to 1 if module(s) exist @@ -38,55 +48,26 @@ # <XPREFIX>_CFLAGS ... all required cflags # <XPREFIX>_CFLAGS_OTHER ... the other compiler flags # -# The user can give specific paths where to find the libraries adding cmake -# options at configure (ex: cmake path/to/project -DEZTRACE_DIR=path/to/eztrace): -# EZTRACE_DIR - Where to find the base directory of eztrace -# EZTRACE_INCDIR - Where to find the header files -# EZTRACE_LIBDIR - Where to find the library files -# The module can also look for the following environment variables if paths -# are not given as cmake variable: EZTRACE_DIR, EZTRACE_INCDIR, EZTRACE_LIBDIR - -#============================================================================= -# Copyright 2012-2019 Inria -# Copyright 2012-2013 Emmanuel Agullo -# Copyright 2012-2013 Mathieu Faverge -# Copyright 2012 Cedric Castagnede -# Copyright 2013-2018 Florent Pruvost +# Set EZTRACE_STATIC to 1 to force using static libraries if exist. # -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file MORSE-Copyright.txt for details. +# This module defines the following :prop_tgt:`IMPORTED` target: +# +# ``MORSE::EZTRACE`` +# The headers and libraries to use for EZTRACE, if found. # -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. #============================================================================= -# (To distribute this file outside of Morse, substitute the full -# License text for the above reference.) # Common macros to use in finds -include(FindInit) - -if (NOT EZTRACE_FOUND) - set(EZTRACE_DIR "" CACHE PATH "Installation directory of EZTRACE library") - if (NOT EZTRACE_FIND_QUIETLY) - message(STATUS "A cache variable, namely EZTRACE_DIR, has been set to specify the install directory of EZTRACE") - endif() -endif() +include(FindMorseInit) -set(ENV_EZTRACE_DIR "$ENV{EZTRACE_DIR}") -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") +if (NOT EZTRACE_FIND_QUIETLY) + message(STATUS "FindEZTRACE needs pkg-config program and PKG_CONFIG_PATH set with eztrace.pc file path.") endif() -# Optionally use pkg-config to detect include/library dirs (if pkg-config is available) -# ------------------------------------------------------------------------------------- -include(FindPkgConfig) -find_package(PkgConfig QUIET) -if( PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_GIVEN_BY_USER ) - +# Use pkg-config to detect include/library dirs +# --------------------------------------------- +if (PKG_CONFIG_EXECUTABLE) + unset(EZTRACE_FOUND CACHE) pkg_search_module(EZTRACE eztrace) if (NOT EZTRACE_FIND_QUIETLY) @@ -97,256 +78,42 @@ if( PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_GIVEN_BY_USER ) "\n Perhaps you should add the directory containing eztrace.pc to" "\n the PKG_CONFIG_PATH environment variable.${ColourReset}") endif() - if (EZTRACE_FOUND AND EZTRACE_LIBRARIES) - if (NOT EZTRACE_INCLUDE_DIRS) - pkg_get_variable(EZTRACE_INCLUDE_DIRS eztrace includedir) - endif() - set(EZTRACE_FOUND_WITH_PKGCONFIG "TRUE") - find_pkgconfig_libraries_absolute_path(EZTRACE) - else() - set(EZTRACE_FOUND_WITH_PKGCONFIG "FALSE") - 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") - endif() - - # Looking for libbfd - # ------------------ - - # Add system library paths to search lib - # -------------------------------------- - unset(_lib_env) - list(APPEND _lib_env "$ENV{LIBRARY_PATH}") - if(WIN32) - string(REPLACE ":" ";" _lib_env2 "$ENV{LIB}") - elseif(APPLE) - string(REPLACE ":" ";" _lib_env2 "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env2 "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${_lib_env2}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - 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_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} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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" - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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") + if (EZTRACE_FOUND AND EZTRACE_LIBRARIES) + if (NOT EZTRACE_INCLUDE_DIRS) + pkg_get_variable(EZTRACE_INCLUDE_DIRS eztrace includedir) endif() - endif () - - if (EZTRACE_INCLUDE_DIRS) - list(REMOVE_DUPLICATES EZTRACE_INCLUDE_DIRS) - endif () - - - # Looking for lib - # --------------- - - # 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") + set(EZTRACE_FOUND_WITH_PKGCONFIG "TRUE") + morse_find_pkgconfig_libraries_absolute_path(EZTRACE) 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_C_IMPLICIT_LINK_DIRECTORIES}") - endif() + set(EZTRACE_FOUND_WITH_PKGCONFIG "FALSE") 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} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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 - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - set(EZTRACE_eztrace_LIBRARY "EZTRACE_eztrace_LIBRARY-NOTFOUND") - find_library(EZTRACE_eztrace_LIBRARY - NAMES eztrace - HINTS ${PATH_TO_LOOK_FOR}) + if (EZTRACE_STATIC AND EZTRACE_STATIC_LIBRARIES) + set (EZTRACE_DEPENDENCIES ${EZTRACE_STATIC_LIBRARIES}) + list (REMOVE_ITEM EZTRACE_DEPENDENCIES "eztrace") + list (APPEND EZTRACE_LIBRARIES ${EZTRACE_DEPENDENCIES}) + set(EZTRACE_CFLAGS_OTHER ${EZTRACE_STATIC_CFLAGS_OTHER}) + set(EZTRACE_LDFLAGS_OTHER ${EZTRACE_STATIC_LDFLAGS_OTHER}) + if (NOT EZTRACE_FIND_QUIETLY) + message(STATUS "EZTRACE_STATIC set to 1 by user, EZTRACE_LIBRARIES: ${EZTRACE_LIBRARIES}.") 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() - endif () - - if (EZTRACE_LIBRARY_DIRS) - list(REMOVE_DUPLICATES EZTRACE_LIBRARY_DIRS) - endif () - -endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_FOUND) OR (EZTRACE_GIVEN_BY_USER) ) +endif() # check a function to validate the find -if(EZTRACE_LIBRARIES) - - set(REQUIRED_INCDIRS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) +if(EZTRACE_FOUND AND EZTRACE_LIBRARIES) - # EZTRACE - if (EZTRACE_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${EZTRACE_INCLUDE_DIRS}") - endif() - if (EZTRACE_CFLAGS_OTHER) - set(REQUIRED_FLAGS "${EZTRACE_CFLAGS_OTHER}") - endif() - if (EZTRACE_LDFLAGS_OTHER) - set(REQUIRED_LDFLAGS "${EZTRACE_LDFLAGS_OTHER}") - endif() - if (EZTRACE_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${EZTRACE_LIBRARY_DIRS}") + # check if static or dynamic lib + morse_check_static_or_dynamic(EZTRACE EZTRACE_LIBRARIES) + if(EZTRACE_STATIC) + set(STATIC "_STATIC") + else() + set(STATIC "") endif() - set(REQUIRED_LIBS "${EZTRACE_LIBRARIES}") # set required libraries for link - set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") - if (REQUIRED_FLAGS) - set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}") - set(REQUIRED_FLAGS) - set(REQUIRED_DEFINITIONS) - foreach(_flag ${REQUIRED_FLAGS_COPY}) - if (_flag MATCHES "^-D") - list(APPEND REQUIRED_DEFINITIONS "${_flag}") - endif() - string(REGEX REPLACE "^-D.*" "" _flag "${_flag}") - list(APPEND REQUIRED_FLAGS "${_flag}") - endforeach() - endif() - finds_remove_duplicates() - set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") - set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") - set(CMAKE_REQUIRED_LIBRARIES) - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}") - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + morse_set_required_test_lib_link(EZTRACE) # test link unset(EZTRACE_WORKS CACHE) @@ -366,25 +133,8 @@ if(EZTRACE_LIBRARIES) set(CMAKE_REQUIRED_INCLUDES) set(CMAKE_REQUIRED_FLAGS) set(CMAKE_REQUIRED_LIBRARIES) -endif(EZTRACE_LIBRARIES) -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) - set(EZTRACE_LIBRARY_DIRS "${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) +endif(EZTRACE_FOUND AND EZTRACE_LIBRARIES) # check that EZTRACE has been found # ------------------------------- @@ -392,3 +142,8 @@ include(FindPackageHandleStandardArgs) find_package_handle_standard_args(EZTRACE DEFAULT_MSG EZTRACE_LIBRARIES EZTRACE_WORKS) + +# Add imported targe +if (EZTRACE_FOUND) + morse_create_imported_target(EZTRACE) +endif() \ No newline at end of file diff --git a/modules/find/FindFABULOUS.cmake b/modules/find/FindFABULOUS.cmake deleted file mode 100644 index f9d37cc16b720cf561cc941159fd956d6d7fbb6d..0000000000000000000000000000000000000000 --- a/modules/find/FindFABULOUS.cmake +++ /dev/null @@ -1,446 +0,0 @@ -### -# -# @copyright (c) 2019-2020 Inria. All rights reserved. -# -### -# -# - Find FABULOUS include dirs and libraries -# Use this module by invoking find_package with the form: -# find_package(FABULOUS -# [REQUIRED]) # Fail with error if fabulous is not found -# -# FABULOUS depends on the following libraries: -# - CBLAS -# - LAPACKE -# -# This module finds headers and fabulous library. -# Results are reported in variables: -# FABULOUS_FOUND - True if headers and requested libraries were found -# FABULOUS_CFLAGS_OTHER - fabulous compiler flags without headers paths -# FABULOUS_LDFLAGS_OTHER - fabulous linker flags without libraries -# FABULOUS_INCLUDE_DIRS - fabulous include directories -# FABULOUS_MODULE_DIRS - fabulous module directories for Fortran API -# FABULOUS_LIBRARY_DIRS - fabulous link directories -# FABULOUS_LIBRARIES - fabulous libraries to be linked (absolute path) -# FABULOUS_CFLAGS_OTHER_DEP - fabulous + dependencies compiler flags without headers paths -# FABULOUS_LDFLAGS_OTHER_DEP - fabulous + dependencies linker flags without libraries -# FABULOUS_INCLUDE_DIRS_DEP - fabulous + dependencies include directories -# FABULOUS_LIBRARY_DIRS_DEP - fabulous + dependencies link directories -# FABULOUS_LIBRARIES_DEP - fabulous + dependencies libraries -# -# FABULOUS_FOUND_WITH_PKGCONFIG - True if found with pkg-config -# if found with pkg-config the following variables are set -# <PREFIX> = FABULOUS -# <XPREFIX> = <PREFIX> for common case -# <XPREFIX> = <PREFIX>_STATIC for static linking -# <XPREFIX>_FOUND ... set to 1 if module(s) exist -# <XPREFIX>_LIBRARIES ... only the libraries (w/o the '-l') -# <XPREFIX>_LIBRARY_DIRS ... the paths of the libraries (w/o the '-L') -# <XPREFIX>_LDFLAGS ... all required linker flags -# <XPREFIX>_LDFLAGS_OTHER ... all other linker flags -# <XPREFIX>_INCLUDE_DIRS ... the '-I' preprocessor flags (w/o the '-I') -# <XPREFIX>_CFLAGS ... all required cflags -# <XPREFIX>_CFLAGS_OTHER ... the other compiler flags -# -# The user can give specific paths where to find the libraries adding cmake -# options at configure (ex: cmake path/to/project -DFABULOUS_DIR=path/to/fabulous): -# FABULOUS_DIR - Where to find the base directory of fabulous -# FABULOUS_INCDIR - Where to find the header files -# FABULOUS_LIBDIR - Where to find the library files -# The module can also look for the following environment variables if paths -# are not given as cmake variable: FABULOUS_DIR, FABULOUS_INCDIR, FABULOUS_LIBDIR - -#============================================================================= -# Copyright 2012-2019 Inria -# Copyright 2013-2018 Florent Pruvost -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file MORSE-Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of Morse, substitute the full -# License text for the above reference.) - -# Common macros to use in finds -include(FindInit) - -if (NOT FABULOUS_FOUND) - set(FABULOUS_DIR "" CACHE PATH "Installation directory of FABULOUS library") - if (NOT FABULOUS_FIND_QUIETLY) - message(STATUS "A cache variable, namely FABULOUS_DIR, has been set to specify the install directory of FABULOUS") - endif() -endif() - -# FABULOUS depends on CBLAS -#--------------------------- -if (NOT FABULOUS_FIND_QUIETLY) - message(STATUS "Looking for FABULOUS - Try to detect CBLAS (depends on BLAS)") -endif() -if (FABULOUS_FIND_REQUIRED) - find_package(CBLAS REQUIRED) -else() - find_package(CBLAS) -endif() - -# FABULOUS depends on LAPACKE -#----------------------------- -if (NOT FABULOUS_FIND_QUIETLY) - message(STATUS "Looking for FABULOUS - Try to detect LAPACKE (depends on LAPACK)") -endif() -if (FABULOUS_FIND_REQUIRED) - find_package(LAPACKE REQUIRED) -else() - find_package(LAPACKE) -endif() - -set(ENV_FABULOUS_DIR "$ENV{FABULOUS_DIR}") -set(ENV_FABULOUS_INCDIR "$ENV{FABULOUS_INCDIR}") -set(ENV_FABULOUS_LIBDIR "$ENV{FABULOUS_LIBDIR}") -set(FABULOUS_GIVEN_BY_USER "FALSE") -if ( FABULOUS_DIR OR ( FABULOUS_INCDIR AND FABULOUS_LIBDIR) OR ENV_FABULOUS_DIR OR (ENV_FABULOUS_INCDIR AND ENV_FABULOUS_LIBDIR) ) - set(FABULOUS_GIVEN_BY_USER "TRUE") -endif() - -# Optionally use pkg-config to detect include/library dirs (if pkg-config is available) -# ------------------------------------------------------------------------------------- -include(FindPkgConfig) -find_package(PkgConfig QUIET) -if( PKG_CONFIG_EXECUTABLE AND NOT FABULOUS_GIVEN_BY_USER ) - - pkg_search_module(FABULOUS fabulous_c_api) - - if (NOT FABULOUS_FIND_QUIETLY) - if (FABULOUS_FOUND AND FABULOUS_LIBRARIES) - message(STATUS "Looking for FABULOUS - found using PkgConfig") - else() - message(STATUS "${Magenta}Looking for FABULOUS - not found using PkgConfig." - "\n Perhaps you should add the directory containing fabulous.pc to" - "\n the PKG_CONFIG_PATH environment variable.${ColourReset}") - endif() - endif() - - if (FABULOUS_FOUND AND FABULOUS_LIBRARIES) - if (NOT FABULOUS_INCLUDE_DIRS) - pkg_get_variable(FABULOUS_INCLUDE_DIRS fabulous_c_api includedir) - endif() - set(FABULOUS_FOUND_WITH_PKGCONFIG "TRUE") - find_pkgconfig_libraries_absolute_path(FABULOUS) - else() - set(FABULOUS_FOUND_WITH_PKGCONFIG "FALSE") - endif() - -endif( PKG_CONFIG_EXECUTABLE AND NOT FABULOUS_GIVEN_BY_USER ) - -if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT FABULOUS_FOUND) OR (FABULOUS_GIVEN_BY_USER) ) - - if (NOT FABULOUS_FIND_QUIETLY) - message(STATUS "Looking for FABULOUS - PkgConfig not used") - endif() - - # Looking for include - # ------------------- - - # Add system include paths to search include - # ------------------------------------------ - unset(_inc_env) - if(ENV_FABULOUS_INCDIR) - list(APPEND _inc_env "${ENV_FABULOUS_INCDIR}") - elseif(ENV_FABULOUS_DIR) - list(APPEND _inc_env "${ENV_FABULOUS_DIR}") - list(APPEND _inc_env "${ENV_FABULOUS_DIR}/include") - list(APPEND _inc_env "${ENV_FABULOUS_DIR}/include/fabulous") - 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_C_IMPLICIT_INCLUDE_DIRECTORIES}") - list(REMOVE_DUPLICATES _inc_env) - - # set paths where to look for - set(PATH_TO_LOOK_FOR "${_inc_env}") - - # List of files to find - set(FABULOUS_hdrs_to_find "fabulous.h;fabulous_mod.mod") - - # Try to find the fabulous header in the given paths - # ------------------------------------------------- - # call cmake macro to find the header path - if(FABULOUS_INCDIR) - foreach(_file ${FABULOUS_hdrs_to_find}) - set(FABULOUS_${_file}_DIRS "FABULOUS_${_file}_DIRS-NOTFOUND") - find_path(FABULOUS_${_file}_DIRS - NAMES ${_file} - HINTS "${FABULOUS_INCDIR}" "${FABULOUS_INCDIR}/fabulous" - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - mark_as_advanced(FABULOUS_${_file}_DIRS) - endforeach() - else() - if(FABULOUS_DIR) - foreach(_file ${FABULOUS_hdrs_to_find}) - set(FABULOUS_${_file}_DIRS "FABULOUS_${_file}_DIRS-NOTFOUND") - find_path(FABULOUS_${_file}_DIRS - NAMES ${_file} - HINTS ${FABULOUS_DIR} - PATH_SUFFIXES "include" "include/fabulous" - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - mark_as_advanced(FABULOUS_${_file}_DIRS) - endforeach() - else() - foreach(_file ${FABULOUS_hdrs_to_find}) - set(FABULOUS_${_file}_DIRS "FABULOUS_${_file}_DIRS-NOTFOUND") - find_path(FABULOUS_${_file}_DIRS - NAMES ${_file} - HINTS ${PATH_TO_LOOK_FOR} - PATH_SUFFIXES "fabulous") - mark_as_advanced(FABULOUS_${_file}_DIRS) - endforeach() - endif() - endif() - - # Add path to cmake variable - # ------------------------------------ - if (FABULOUS_fabulous.h_DIRS) - set(FABULOUS_INCLUDE_DIRS "${FABULOUS_fabulous.h_DIRS}") - else () - set(FABULOUS_INCLUDE_DIRS "FABULOUS_INCLUDE_DIRS-NOTFOUND") - if(NOT FABULOUS_FIND_QUIETLY) - message(STATUS "Looking for fabulous -- fabulous.h not found") - endif() - endif () - if (FABULOUS_fabulous_mod.mod_DIRS) - set(FABULOUS_MODULE_DIRS "${FABULOUS_fabulous_mod.mod_DIRS}") - else () - set(FABULOUS_MODULE_DIRS "FABULOUS_MODULE_DIRS-NOTFOUND") - if(NOT FABULOUS_FIND_QUIETLY) - message(STATUS "Looking for fabulous -- fabulous_mod.mod not found") - endif() - endif () - - if (FABULOUS_INCLUDE_DIRS) - list(REMOVE_DUPLICATES FABULOUS_INCLUDE_DIRS) - endif () - - - # Looking for lib - # --------------- - - # Add system library paths to search lib - # -------------------------------------- - unset(_lib_env) - if(ENV_FABULOUS_LIBDIR) - list(APPEND _lib_env "${ENV_FABULOUS_LIBDIR}") - elseif(ENV_FABULOUS_DIR) - list(APPEND _lib_env "${ENV_FABULOUS_DIR}") - list(APPEND _lib_env "${ENV_FABULOUS_DIR}/lib") - else() - list(APPEND _lib_env "$ENV{LIBRARY_PATH}") - if(WIN32) - string(REPLACE ":" ";" _lib_env2 "$ENV{LIB}") - elseif(APPLE) - string(REPLACE ":" ";" _lib_env2 "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env2 "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${_lib_env2}") - 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 fabulous lib in the given paths - # ---------------------------------------------- - - # call cmake macro to find the lib path - if(FABULOUS_LIBDIR) - set(FABULOUS_fabulous_LIBRARY "FABULOUS_fabulous_LIBRARY-NOTFOUND") - find_library(FABULOUS_fabulous_LIBRARY - NAMES fabulous - HINTS ${FABULOUS_LIBDIR} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - if(FABULOUS_DIR) - set(FABULOUS_fabulous_LIBRARY "FABULOUS_fabulous_LIBRARY-NOTFOUND") - find_library(FABULOUS_fabulous_LIBRARY - NAMES fabulous - HINTS ${FABULOUS_DIR} - PATH_SUFFIXES lib lib32 lib64 - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - set(FABULOUS_fabulous_LIBRARY "FABULOUS_fabulous_LIBRARY-NOTFOUND") - find_library(FABULOUS_fabulous_LIBRARY - NAMES fabulous - HINTS ${PATH_TO_LOOK_FOR}) - endif() - endif() - mark_as_advanced(FABULOUS_fabulous_LIBRARY) - - # If found, add path to cmake variable - # ------------------------------------ - if (FABULOUS_fabulous_LIBRARY) - get_filename_component(fabulous_lib_path ${FABULOUS_fabulous_LIBRARY} PATH) - # set cmake variables (respects naming convention) - set(FABULOUS_LIBRARIES "${FABULOUS_fabulous_LIBRARY}") - set(FABULOUS_LIBRARY_DIRS "${fabulous_lib_path}") - else () - set(FABULOUS_LIBRARIES "FABULOUS_LIBRARIES-NOTFOUND") - set(FABULOUS_LIBRARY_DIRS "FABULOUS_LIBRARY_DIRS-NOTFOUND") - if(NOT FABULOUS_FIND_QUIETLY) - message(STATUS "Looking for fabulous -- lib fabulous not found") - endif() - endif () - - if (FABULOUS_LIBRARY_DIRS) - list(REMOVE_DUPLICATES FABULOUS_LIBRARY_DIRS) - endif () - -endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT FABULOUS_FOUND) OR (FABULOUS_GIVEN_BY_USER) ) - -# check a function to validate the find -if(FABULOUS_LIBRARIES) - - set(REQUIRED_INCDIRS) - set(REQUIRED_FLAGS) - set(REQUIRED_LDFLAGS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) - - # FABULOUS - if (FABULOUS_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${FABULOUS_INCLUDE_DIRS}") - endif() - if (FABULOUS_CFLAGS_OTHER) - set(REQUIRED_FLAGS "${FABULOUS_CFLAGS_OTHER}") - endif() - if (FABULOUS_LDFLAGS_OTHER) - set(REQUIRED_LDFLAGS "${FABULOUS_LDFLAGS_OTHER}") - endif() - if (FABULOUS_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${FABULOUS_LIBRARY_DIRS}") - endif() - set(REQUIRED_LIBS "${FABULOUS_LIBRARIES}") - # LAPACKE - if (LAPACKE_FOUND) - if (LAPACKE_INCLUDE_DIRS_DEP) - list(APPEND REQUIRED_INCDIRS "${LAPACKE_INCLUDE_DIRS_DEP}") - endif() - if (LAPACKE_CFLAGS_OTHER_DEP) - list(APPEND REQUIRED_FLAGS "${LAPACKE_CFLAGS_OTHER_DEP}") - endif() - if (LAPACKE_LDFLAGS_OTHER_DEP) - list(APPEND REQUIRED_LDFLAGS "${LAPACKE_LDFLAGS_OTHER_DEP}") - endif() - if(LAPACKE_LIBRARY_DIRS_DEP) - list(APPEND REQUIRED_LIBDIRS "${LAPACKE_LIBRARY_DIRS_DEP}") - endif() - if (LAPACKE_LIBRARIES_DEP) - list(APPEND REQUIRED_LIBS "${LAPACKE_LIBRARIES_DEP}") - endif() - endif() - # CBLAS - if (CBLAS_FOUND) - if (CBLAS_INCLUDE_DIRS_DEP) - list(APPEND REQUIRED_INCDIRS "${CBLAS_INCLUDE_DIRS_DEP}") - endif() - if (CBLAS_CFLAGS_OTHER_DEP) - list(APPEND REQUIRED_FLAGS "${CBLAS_CFLAGS_OTHER_DEP}") - endif() - if (CBLAS_LDFLAGS_OTHER_DEP) - list(APPEND REQUIRED_LDFLAGS "${CBLAS_LDFLAGS_OTHER_DEP}") - endif() - if(CBLAS_LIBRARY_DIRS_DEP) - list(APPEND REQUIRED_LIBDIRS "${CBLAS_LIBRARY_DIRS_DEP}") - endif() - if (CBLAS_LIBRARIES_DEP) - list(APPEND REQUIRED_LIBS "${CBLAS_LIBRARIES_DEP}") - endif() - endif() - - # set required libraries for link - set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") - if (REQUIRED_FLAGS) - set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}") - set(REQUIRED_FLAGS) - set(REQUIRED_DEFINITIONS) - foreach(_flag ${REQUIRED_FLAGS_COPY}) - if (_flag MATCHES "^-D") - list(APPEND REQUIRED_DEFINITIONS "${_flag}") - endif() - string(REGEX REPLACE "^-D.*" "" _flag "${_flag}") - list(APPEND REQUIRED_FLAGS "${_flag}") - endforeach() - endif() - finds_remove_duplicates() - set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") - set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") - set(CMAKE_REQUIRED_LIBRARIES) - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}") - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - - # test link - unset(FABULOUS_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(fabulous_solve FABULOUS_WORKS) - mark_as_advanced(FABULOUS_WORKS) - - if(FABULOUS_WORKS) - # save link with dependencies - set(FABULOUS_LIBRARIES_DEP "${REQUIRED_LIBS}") - set(FABULOUS_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}") - set(FABULOUS_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") - set(FABULOUS_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}") - set(FABULOUS_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}") - else() - if(NOT FABULOUS_FIND_QUIETLY) - message(STATUS "Looking for fabulous : test of fabulous_topology_init with fabulous library fails") - message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") - message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") - message(STATUS "CMAKE_REQUIRED_FLAGS: ${CMAKE_REQUIRED_FLAGS}") - message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") - endif() - endif() - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_LIBRARIES) -endif(FABULOUS_LIBRARIES) - -if (FABULOUS_LIBRARIES) - if (FABULOUS_LIBRARY_DIRS) - list(GET FABULOUS_LIBRARY_DIRS 0 first_lib_path) - else() - list(GET FABULOUS_LIBRARIES 0 first_lib) - get_filename_component(first_lib_path "${first_lib}" PATH) - set(FABULOUS_LIBRARY_DIRS "${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(FABULOUS_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of FABULOUS library" FORCE) - else() - set(FABULOUS_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of FABULOUS library" FORCE) - endif() -endif() -mark_as_advanced(FABULOUS_DIR) -mark_as_advanced(FABULOUS_DIR_FOUND) - -# check that FABULOUS has been found -# ------------------------------- -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(FABULOUS DEFAULT_MSG - FABULOUS_LIBRARIES - FABULOUS_WORKS) - diff --git a/modules/find/FindFFTW.cmake b/modules/find/FindFFTW.cmake index e4e8b41228b9b02306f2b3190e9f330c2075c1a2..24b27ccd20be5dae913fcd3225f633c175a024e6 100644 --- a/modules/find/FindFFTW.cmake +++ b/modules/find/FindFFTW.cmake @@ -1,11 +1,23 @@ ### # -# @copyright (c) 2009-2014 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. # @copyright (c) 2012-2020 Inria. All rights reserved. # @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. # +# Copyright 2012-2019 Inria +# Copyright 2012-2013 Emmanuel Agullo +# Copyright 2012-2013 Mathieu Faverge +# Copyright 2012 Cedric Castagnede +# Copyright 2013-2020 Florent Pruvost +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file MORSE-Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of Morse, substitute the full +# License text for the above reference.) ### # # - Find FFTW Version 3 include dirs and libraries @@ -27,17 +39,13 @@ # # This module finds headers and fftw library. # Results are reported in variables: -# FFTW_FOUND - True if headers and requested libraries were found +# FFTW_FOUND - True if headers and requested libraries were found +# FFTW_PREFIX - installation path of the lib found # FFTW_CFLAGS_OTHER - fftw compiler flags without headers paths # FFTW_LDFLAGS_OTHER - fftw linker flags without libraries # FFTW_INCLUDE_DIRS - fftw include directories # FFTW_LIBRARY_DIRS - fftw link directories # FFTW_LIBRARIES - fftw libraries to be linked (absolute path) -# FFTW_CFLAGS_OTHER_DEP - fftw + dependencies compiler flags without headers paths -# FFTW_LDFLAGS_OTHER_DEP - fftw + dependencies linker flags without libraries -# FFTW_INCLUDE_DIRS_DEP - fftw + dependencies include directories -# FFTW_LIBRARY_DIRS_DEP - fftw + dependencies link directories -# FFTW_LIBRARIES_DEP - fftw + dependencies libraries # # FFTW_FOUND_WITH_PKGCONFIG - True if found with pkg-config # if found with pkg-config the following variables are set @@ -53,6 +61,11 @@ # <XPREFIX>_CFLAGS ... all required cflags # <XPREFIX>_CFLAGS_OTHER ... the other compiler flags # +# This module defines the following :prop_tgt:`IMPORTED` target: +# +# ``MORSE::FFTW`` +# The headers and libraries to use for FFTW, if found. +# # The user can give specific paths where to find the libraries adding cmake # options at configure (ex: cmake path/to/project -DFFTW_DIR=path/to/fftw): # FFTW_DIR - Where to find the base directory of fftw @@ -64,24 +77,9 @@ # environment variable #============================================================================= -# Copyright 2012-2019 Inria -# Copyright 2012-2013 Emmanuel Agullo -# Copyright 2012-2013 Mathieu Faverge -# Copyright 2012 Cedric Castagnede -# Copyright 2013-2018 Florent Pruvost -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file MORSE-Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of Morse, substitute the full -# License text for the above reference.) # Common macros to use in finds -include(FindInit) +include(FindMorseInit) if (NOT FFTW_FOUND) set(FFTW_DIR "" CACHE PATH "Installation directory of FFTW library given by user") @@ -241,7 +239,6 @@ endif() # Optionally use pkg-config to detect include/library dirs (if pkg-config is available) # ------------------------------------------------------------------------------------- if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL) - include(FindPkgConfig) find_package(PkgConfig QUIET) if( PKG_CONFIG_EXECUTABLE AND NOT FFTW_GIVEN_BY_USER ) @@ -260,7 +257,7 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL) message(STATUS "Looking for FFTW3F - found using PkgConfig") endif() if (FFTW3F_LIBRARIES) - find_pkgconfig_libraries_absolute_path(FFTW3F) + morse_find_pkgconfig_libraries_absolute_path(FFTW3F) list(APPEND FFTW_LIBRARIES "${FFTW3F_LIBRARIES}") endif() if(FFTW3F_INCLUDE_DIRS) @@ -293,7 +290,7 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL) message(STATUS "Looking for FFTW3L - found using PkgConfig") endif() if (FFTW3L_LIBRARIES) - find_pkgconfig_libraries_absolute_path(FFTW3L) + morse_find_pkgconfig_libraries_absolute_path(FFTW3L) list(APPEND FFTW_LIBRARIES "${FFTW3L_LIBRARIES}") endif() if(FFTW3L_INCLUDE_DIRS) @@ -326,7 +323,7 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL) message(STATUS "Looking for FFTW3Q - found using PkgConfig") endif() if (FFTW3Q_LIBRARIES) - find_pkgconfig_libraries_absolute_path(FFTW3Q) + morse_find_pkgconfig_libraries_absolute_path(FFTW3Q) list(APPEND FFTW_LIBRARIES "${FFTW3Q_LIBRARIES}") endif() if(FFTW3Q_INCLUDE_DIRS) @@ -351,7 +348,7 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL) else() pkg_search_module(FFTW3 fftw3) if (FFTW3_FOUND AND FFTW3_LIBRARIES) - find_pkgconfig_libraries_absolute_path(FFTW3) + morse_find_pkgconfig_libraries_absolute_path(FFTW3) endif() endif() if (FFTW3_FOUND) @@ -362,7 +359,7 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL) pkg_get_variable(FFTW3_INCLUDE_DIRS fftw3 includedir) endif() if (FFTW3_LIBRARIES) - find_pkgconfig_libraries_absolute_path(FFTW3) + morse_find_pkgconfig_libraries_absolute_path(FFTW3) list(APPEND FFTW_LIBRARIES "${FFTW3_LIBRARIES}") endif() if(FFTW3_INCLUDE_DIRS) @@ -728,11 +725,11 @@ endif( (NOT PKG_CONFIG_EXECUTABLE) OR # check a function to validate the find if(FFTW_LIBRARIES) - set(REQUIRED_FLAGS) - set(REQUIRED_LDFLAGS) set(REQUIRED_INCDIRS) set(REQUIRED_LIBDIRS) set(REQUIRED_LIBS) + set(REQUIRED_FLAGS) + set(REQUIRED_LDFLAGS) # FFTW if (FFTW_INCLUDE_DIRS) @@ -784,7 +781,7 @@ if(FFTW_LIBRARIES) list(APPEND REQUIRED_FLAGS "${_flag}") endforeach() endif() - finds_remove_duplicates() + morse_finds_remove_duplicates() set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) @@ -805,11 +802,11 @@ if(FFTW_LIBRARIES) if(FFTW_WORKS) # save link with dependencies - set(FFTW_LIBRARIES_DEP "${REQUIRED_LIBS}") - set(FFTW_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}") - set(FFTW_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") - set(FFTW_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}") - set(FFTW_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}") + set(FFTW_LIBRARIES "${REQUIRED_LIBS}") + set(FFTW_LIBRARY_DIRS "${REQUIRED_LIBDIRS}") + set(FFTW_INCLUDE_DIRS "${REQUIRED_INCDIRS}") + set(FFTW_CFLAGS_OTHER "${REQUIRED_FLAGS}") + set(FFTW_LDFLAGS_OTHER "${REQUIRED_LDFLAGS}") else() if(NOT FFTW_FIND_QUIETLY) message(STATUS "Looking for FFTW : test of ${FFTW_PREC_TESTFUNC}fftw_execute_ with fftw library fails") @@ -822,31 +819,22 @@ if(FFTW_LIBRARIES) set(CMAKE_REQUIRED_INCLUDES) set(CMAKE_REQUIRED_FLAGS) set(CMAKE_REQUIRED_LIBRARIES) -endif(FFTW_LIBRARIES) -if (FFTW_LIBRARIES) list(GET FFTW_LIBRARIES 0 first_lib) - get_filename_component(first_lib_path "${first_lib}" PATH) + get_filename_component(first_lib_path "${first_lib}" DIRECTORY) if (NOT FFTW_LIBRARY_DIRS) set(FFTW_LIBRARY_DIRS "${first_lib_path}") endif() if (${first_lib_path} MATCHES "(/lib(32|64)?$)|(/lib/intel64$|/lib/ia32$)") string(REGEX REPLACE "(/lib(32|64)?$)|(/lib/intel64$|/lib/ia32$)" "" not_cached_dir "${first_lib_path}") - set(FFTW_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of FFTW library" FORCE) + set(FFTW_PREFIX "${not_cached_dir}" CACHE PATH "Installation directory of FFTW library" FORCE) else() - set(FFTW_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of FFTW library" FORCE) - endif() - - if(NOT TARGET fftw::fftw) - add_library(fftw::fftw INTERFACE IMPORTED) - set_property(TARGET fftw::fftw APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${FFTW_LIBRARIES_DEP}") - set_property(TARGET fftw::fftw APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS_DEP}") - set_property(TARGET fftw::fftw APPEND PROPERTY INTERFACE_COMPILE_OPTIONS "${FFTW_C_FLAGS}") + set(FFTW_PREFIX "${first_lib_path}" CACHE PATH "Installation directory of FFTW library" FORCE) endif() + mark_as_advanced(FFTW_DIR) + mark_as_advanced(FFTW_PREFIX) -endif() -mark_as_advanced(FFTW_DIR) -mark_as_advanced(FFTW_DIR_FOUND) +endif(FFTW_LIBRARIES) # check that FFTW has been found # ------------------------------- @@ -854,3 +842,16 @@ include(FindPackageHandleStandardArgs) find_package_handle_standard_args(FFTW DEFAULT_MSG FFTW_LIBRARIES FFTW_WORKS) + +# Add imported target +if (FFTW_FOUND) + if(NOT TARGET FFTW::FFTW) + add_library(FFTW::FFTW INTERFACE IMPORTED) + set_property(TARGET FFTW::FFTW APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}") + set_property(TARGET FFTW::FFTW APPEND PROPERTY INTERFACE_LINK_DIRECTORIES "${FFTW_LIBRARY_DIRS}") + set_property(TARGET FFTW::FFTW APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${FFTW_LIBRARIES}") + set_property(TARGET FFTW::FFTW APPEND PROPERTY INTERFACE_COMPILE_OPTIONS "${FFTW_CFLAGS_OTHER}") + set_property(TARGET FFTW::FFTW APPEND PROPERTY INTERFACE_LINNK_OPTIONS "${FFTW_LDFLAGS_OTHER}") + endif() + morse_create_imported_target(FFTW) +endif() \ No newline at end of file diff --git a/modules/find/FindFXT.cmake b/modules/find/FindFXT.cmake index 6df6a8a6943d0dd2a164bcc0b641fe1c1b69aff2..785efbbf466a18514da7f45ec44121d86186c468 100644 --- a/modules/find/FindFXT.cmake +++ b/modules/find/FindFXT.cmake @@ -1,11 +1,23 @@ ### # -# @copyright (c) 2009-2014 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. # @copyright (c) 2012-2020 Inria. All rights reserved. # @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. # +# Copyright 2012-2013 Emmanuel Agullo +# Copyright 2012-2013 Mathieu Faverge +# Copyright 2012 Cedric Castagnede +# Copyright 2013-2020 Florent Pruvost +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file MORSE-Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of Morse, substitute the full +# License text for the above reference.) +# ### # # - Find FXT include dirs and libraries @@ -13,16 +25,12 @@ # find_package(FXT # [REQUIRED]) # Fail with error if fxt is not found # -# This module finds headers and fxt library. -# Results are reported in variables: -# FXT_FOUND - True if headers and requested libraries were found -# FXT_INCLUDE_DIRS - fxt include directories -# FXT_LIBRARY_DIRS - fxt link directories -# FXT_LIBRARIES - fxt libraries to be linked (absolute path) +# This module finds headers and FXT library using pkg-config file. # -# FXT_FOUND_WITH_PKGCONFIG - True if found with pkg-config # if found with pkg-config the following variables are set # <PREFIX> = FXT +# <PREFIX>_PREFIX ... installation path of the lib found +# <PREFIX>_VERSION ... version of the lib # <XPREFIX> = <PREFIX> for common case # <XPREFIX> = <PREFIX>_STATIC for static linking # <XPREFIX>_FOUND ... set to 1 if module(s) exist @@ -34,57 +42,31 @@ # <XPREFIX>_CFLAGS ... all required cflags # <XPREFIX>_CFLAGS_OTHER ... the other compiler flags # -# The user can give specific paths where to find the libraries adding cmake -# options at configure (ex: cmake path/to/project -DFXT_DIR=path/to/fxt): -# FXT_DIR - Where to find the base directory of fxt -# FXT_INCDIR - Where to find the header files -# FXT_LIBDIR - Where to find the library files -# The module can also look for the following environment variables if paths -# are not given as cmake variable: FXT_DIR, FXT_INCDIR, FXT_LIBDIR - -#============================================================================= -# Copyright 2012-2019 Inria -# Copyright 2012-2013 Emmanuel Agullo -# Copyright 2012-2013 Mathieu Faverge -# Copyright 2012 Cedric Castagnede -# Copyright 2013-2018 Florent Pruvost +# Set FXT_STATIC to 1 to force using static libraries if exist. # -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file MORSE-Copyright.txt for details. +# This module defines the following :prop_tgt:`IMPORTED` target: +# +# ``MORSE::FXT`` +# The headers and libraries to use for FXT, if found. # -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. #============================================================================= -# (To distribute this file outside of Morse, substitute the full -# License text for the above reference.) # Common macros to use in finds -include(FindInit) - -if (NOT FXT_FOUND) - set(FXT_DIR "" CACHE PATH "Installation directory of FXT library") - if (NOT FXT_FIND_QUIETLY) - message(STATUS "A cache variable, namely FXT_DIR, has been set to specify the install directory of FXT") - endif() -endif() +include(FindMorseInit) -set(ENV_FXT_DIR "$ENV{FXT_DIR}") -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") +if (NOT FXT_FIND_QUIETLY) + message(STATUS "FindFXT needs pkg-config program and PKG_CONFIG_PATH set with fxt.pc file path.") endif() -# Optionally use pkg-config to detect include/library dirs (if pkg-config is available) +# use pkg-config to detect include/library dirs (if pkg-config is available) # ------------------------------------------------------------------------------------- -include(FindPkgConfig) -find_package(PkgConfig QUIET) -if(PKG_CONFIG_EXECUTABLE AND NOT FXT_GIVEN_BY_USER) - +if (PKG_CONFIG_EXECUTABLE) + unset(FXT_FOUND CACHE) pkg_search_module(FXT fxt) + message(STATUS "FXT_LIBRARY_DIRS ${FXT_LIBRARY_DIRS}") + message(STATUS "FXT_LIBDIR ${FXT_LIBDIR}") + if (NOT FXT_FIND_QUIETLY) if (FXT_FOUND AND FXT_LIBRARIES) message(STATUS "Looking for FXT - found using PkgConfig") @@ -94,218 +76,42 @@ if(PKG_CONFIG_EXECUTABLE AND NOT FXT_GIVEN_BY_USER) "\n PKG_CONFIG_PATH environment variable.${ColourReset}") endif() endif() - if (FXT_FOUND AND FXT_LIBRARIES) if (NOT FXT_INCLUDE_DIRS) pkg_get_variable(FXT_INCLUDE_DIRS fxt includedir) endif() set(FXT_FOUND_WITH_PKGCONFIG "TRUE") - find_pkgconfig_libraries_absolute_path(FXT) + morse_find_pkgconfig_libraries_absolute_path(FXT) else() set(FXT_FOUND_WITH_PKGCONFIG "FALSE") 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() - - # 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") - 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_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} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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" - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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") + if (FXT_STATIC AND FXT_STATIC_LIBRARIES) + set (FXT_DEPENDENCIES ${FXT_STATIC_LIBRARIES}) + list (REMOVE_ITEM FXT_DEPENDENCIES "fxt") + list (APPEND FXT_LIBRARIES ${FXT_DEPENDENCIES}) + set(FXT_CFLAGS_OTHER ${FXT_STATIC_CFLAGS_OTHER}) + set(FXT_LDFLAGS_OTHER ${FXT_STATIC_LDFLAGS_OTHER}) + if (NOT FXT_FIND_QUIETLY) + message(STATUS "FXT_STATIC set to 1 by user, FXT_LIBRARIES: ${FXT_LIBRARIES}.") endif() 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 () - - if (FXT_INCLUDE_DIRS) - list(REMOVE_DUPLICATES FXT_INCLUDE_DIRS) - endif () - - - # 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") - else() - list(APPEND _lib_env "$ENV{LIBRARY_PATH}") - if(WIN32) - string(REPLACE ":" ";" _lib_env2 "$ENV{LIB}") - elseif(APPLE) - string(REPLACE ":" ";" _lib_env2 "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env2 "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${_lib_env2}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - endif() - list(REMOVE_DUPLICATES _lib_env) - - # 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} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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 - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - set(FXT_fxt_LIBRARY "FXT_fxt_LIBRARY-NOTFOUND") - find_library(FXT_fxt_LIBRARY - NAMES fxt - HINTS ${_lib_env}) - endif() - 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 (FXT_LIBRARY_DIRS) - list(REMOVE_DUPLICATES FXT_LIBRARY_DIRS) - endif () +endif() -endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT FXT_FOUND) OR (FXT_GIVEN_BY_USER) ) # check a function to validate the find -if(FXT_LIBRARIES) - - set(REQUIRED_INCDIRS) - set(REQUIRED_FLAGS) - set(REQUIRED_LDFLAGS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) +if(FXT_FOUND AND FXT_LIBRARIES) - # FXT - if (FXT_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${FXT_INCLUDE_DIRS}") - endif() - if (FXT_CFLAGS_OTHER) - set(REQUIRED_FLAGS "${FXT_CFLAGS_OTHER}") - endif() - if (FXT_LDFLAGS_OTHER) - set(REQUIRED_LDFLAGS "${FXT_LDFLAGS_OTHER}") - endif() - if (FXT_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${FXT_LIBRARY_DIRS}") + # check if static or dynamic lib + morse_check_static_or_dynamic(FXT FXT_LIBRARIES) + if(FXT_STATIC) + set(STATIC "_STATIC") + else() + set(STATIC "") endif() - set(REQUIRED_LIBS "${FXT_LIBRARIES}") # set required libraries for link - set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") - if (REQUIRED_FLAGS) - set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}") - set(REQUIRED_FLAGS) - set(REQUIRED_DEFINITIONS) - foreach(_flag ${REQUIRED_FLAGS_COPY}) - if (_flag MATCHES "^-D") - list(APPEND REQUIRED_DEFINITIONS "${_flag}") - endif() - string(REGEX REPLACE "^-D.*" "" _flag "${_flag}") - list(APPEND REQUIRED_FLAGS "${_flag}") - endforeach() - endif() - finds_remove_duplicates() - set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") - set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") - set(CMAKE_REQUIRED_LIBRARIES) - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}") - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + morse_set_required_test_lib_link(FXT) # test link unset(FXT_WORKS CACHE) @@ -325,25 +131,8 @@ if(FXT_LIBRARIES) set(CMAKE_REQUIRED_INCLUDES) set(CMAKE_REQUIRED_FLAGS) set(CMAKE_REQUIRED_LIBRARIES) -endif(FXT_LIBRARIES) -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) - set(FXT_LIBRARY_DIRS "${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) +endif(FXT_FOUND AND FXT_LIBRARIES) # check that FXT has been found # ------------------------------- @@ -351,3 +140,8 @@ include(FindPackageHandleStandardArgs) find_package_handle_standard_args(FXT DEFAULT_MSG FXT_LIBRARIES FXT_WORKS) + +# Add imported targe +if (FXT_FOUND) + morse_create_imported_target(FXT) +endif() \ No newline at end of file diff --git a/modules/find/FindGTG.cmake b/modules/find/FindGTG.cmake index e3af84090d3b119b3e02c351a740a7ba8a932479..109118ba035b51442c7955dac5e11c424eddf20b 100644 --- a/modules/find/FindGTG.cmake +++ b/modules/find/FindGTG.cmake @@ -1,11 +1,23 @@ ### # -# @copyright (c) 2009-2014 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. # @copyright (c) 2012-2020 Inria. All rights reserved. # @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. # +# Copyright 2012-2013 Emmanuel Agullo +# Copyright 2012-2013 Mathieu Faverge +# Copyright 2012 Cedric Castagnede +# Copyright 2013-2020 Florent Pruvost +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file MORSE-Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of Morse, substitute the full +# License text for the above reference.) +# ### # # - Find GTG include dirs and libraries @@ -13,16 +25,11 @@ # find_package(GTG # [REQUIRED]) # Fail with error if gtg is not found # -# This module finds headers and gtg library. -# Results are reported in variables: -# GTG_FOUND - True if headers and requested libraries were found -# GTG_INCLUDE_DIRS - gtg include directories -# GTG_LIBRARY_DIRS - Link directories for gtg libraries -# GTG_LIBRARIES - gtg component libraries to be linked -# -# GTG_FOUND_WITH_PKGCONFIG - True if found with pkg-config +# This module finds headers and gtg library using pkg-config file. # if found with pkg-config the following variables are set # <PREFIX> = GTG +# <PREFIX>_PREFIX ... installation path of the lib found +# <PREFIX>_VERSION ... version of the lib # <XPREFIX> = <PREFIX> for common case # <XPREFIX> = <PREFIX>_STATIC for static linking # <XPREFIX>_FOUND ... set to 1 if module(s) exist @@ -34,55 +41,26 @@ # <XPREFIX>_CFLAGS ... all required cflags # <XPREFIX>_CFLAGS_OTHER ... the other compiler flags # -# The user can give specific paths where to find the libraries adding cmake -# options at configure (ex: cmake path/to/project -DGTG_DIR=path/to/gtg): -# GTG_DIR - Where to find the base directory of gtg -# GTG_INCDIR - Where to find the header files -# GTG_LIBDIR - Where to find the library files -# The module can also look for the following environment variables if paths -# are not given as cmake variable: GTG_DIR, GTG_INCDIR, GTG_LIBDIR - -#============================================================================= -# Copyright 2012-2019 Inria -# Copyright 2012-2013 Emmanuel Agullo -# Copyright 2012-2013 Mathieu Faverge -# Copyright 2012 Cedric Castagnede -# Copyright 2013-2018 Florent Pruvost +# Set GTG_STATIC to 1 to force using static libraries if exist. # -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file MORSE-Copyright.txt for details. +# This module defines the following :prop_tgt:`IMPORTED` target: +# +# ``MORSE::GTG`` +# The headers and libraries to use for GTG, if found. # -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. #============================================================================= -# (To distribute this file outside of Morse, substitute the full -# License text for the above reference.) # Common macros to use in finds -include(FindInit) - -if (NOT GTG_FOUND) - set(GTG_DIR "" CACHE PATH "Installation directory of GTG library") - if (NOT GTG_FIND_QUIETLY) - message(STATUS "A cache variable, namely GTG_DIR, has been set to specify the install directory of GTG") - endif() -endif() +include(FindMorseInit) -set(ENV_GTG_DIR "$ENV{GTG_DIR}") -set(ENV_GTG_INCDIR "$ENV{GTG_INCDIR}") -set(ENV_GTG_LIBDIR "$ENV{GTG_LIBDIR}") -set(GTG_GIVEN_BY_USER "FALSE") -if ( GTG_DIR OR ( GTG_INCDIR AND GTG_LIBDIR) OR ENV_GTG_DIR OR (ENV_GTG_INCDIR AND ENV_GTG_LIBDIR) ) - set(GTG_GIVEN_BY_USER "TRUE") +if (NOT GTG_FIND_QUIETLY) + message(STATUS "FindGTG needs pkg-config program and PKG_CONFIG_PATH set with gtg.pc file path.") endif() -# Optionally use pkg-config to detect include/library dirs (if pkg-config is available) +# use pkg-config to detect include/library dirs (if pkg-config is available) # ------------------------------------------------------------------------------------- -include(FindPkgConfig) -find_package(PkgConfig QUIET) -if(PKG_CONFIG_EXECUTABLE AND NOT GTG_GIVEN_BY_USER) - +if (PKG_CONFIG_EXECUTABLE) + unset(GTG_FOUND CACHE) pkg_search_module(GTG gtg) if (NOT GTG_FIND_QUIETLY) @@ -94,218 +72,41 @@ if(PKG_CONFIG_EXECUTABLE AND NOT GTG_GIVEN_BY_USER) "\n PKG_CONFIG_PATH environment variable.${ColourReset}") endif() endif() - if (GTG_FOUND AND GTG_LIBRARIES) if (NOT GTG_INCLUDE_DIRS) pkg_get_variable(GTG_INCLUDE_DIRS gtg includedir) endif() set(GTG_FOUND_WITH_PKGCONFIG "TRUE") - find_pkgconfig_libraries_absolute_path(GTG) + morse_find_pkgconfig_libraries_absolute_path(GTG) else() set(GTG_FOUND_WITH_PKGCONFIG "FALSE") endif() -endif(PKG_CONFIG_EXECUTABLE AND NOT GTG_GIVEN_BY_USER) - -if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT GTG_FOUND) OR (GTG_GIVEN_BY_USER) ) - - if (NOT GTG_FIND_QUIETLY) - message(STATUS "Looking for GTG - PkgConfig not used") - endif() - - # Looking for include - # ------------------- - - # Add system include paths to search include - # ------------------------------------------ - unset(_inc_env) - set(ENV_GTG_DIR "$ENV{GTG_DIR}") - set(ENV_GTG_INCDIR "$ENV{GTG_INCDIR}") - if(ENV_GTG_INCDIR) - list(APPEND _inc_env "${ENV_GTG_INCDIR}") - elseif(ENV_GTG_DIR) - list(APPEND _inc_env "${ENV_GTG_DIR}") - list(APPEND _inc_env "${ENV_GTG_DIR}/include") - list(APPEND _inc_env "${ENV_GTG_DIR}/include/gtg") - 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_C_IMPLICIT_INCLUDE_DIRECTORIES}") - list(REMOVE_DUPLICATES _inc_env) - - # Try to find the gtg header in the given paths - # ------------------------------------------------- - # call cmake macro to find the header path - if(GTG_INCDIR) - set(GTG_GTG.h_DIRS "GTG_GTG.h_DIRS-NOTFOUND") - find_path(GTG_GTG.h_DIRS - NAMES GTG.h - HINTS ${GTG_INCDIR} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - if(GTG_DIR) - set(GTG_GTG.h_DIRS "GTG_GTG.h_DIRS-NOTFOUND") - find_path(GTG_GTG.h_DIRS - NAMES GTG.h - HINTS ${GTG_DIR} - PATH_SUFFIXES "include" "include/gtg" - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - set(GTG_GTG.h_DIRS "GTG_GTG.h_DIRS-NOTFOUND") - find_path(GTG_GTG.h_DIRS - NAMES GTG.h - HINTS ${_inc_env} - PATH_SUFFIXES "gtg") - endif() - endif() - mark_as_advanced(GTG_GTG.h_DIRS) - - # Add path to cmake variable - # ------------------------------------ - if (GTG_GTG.h_DIRS) - set(GTG_INCLUDE_DIRS "${GTG_GTG.h_DIRS}") - else () - set(GTG_INCLUDE_DIRS "GTG_INCLUDE_DIRS-NOTFOUND") - if(NOT GTG_FIND_QUIETLY) - message(STATUS "Looking for gtg -- GTG.h not found") - endif() - endif () - - if (GTG_INCLUDE_DIRS) - list(REMOVE_DUPLICATES GTG_INCLUDE_DIRS) - endif () - - - # Looking for lib - # --------------- - - # Add system library paths to search lib - # -------------------------------------- - unset(_lib_env) - set(ENV_GTG_LIBDIR "$ENV{GTG_LIBDIR}") - if(ENV_GTG_LIBDIR) - list(APPEND _lib_env "${ENV_GTG_LIBDIR}") - elseif(ENV_GTG_DIR) - list(APPEND _lib_env "${ENV_GTG_DIR}") - list(APPEND _lib_env "${ENV_GTG_DIR}/lib") - else() - list(APPEND _lib_env "$ENV{LIBRARY_PATH}") - if(WIN32) - string(REPLACE ":" ";" _lib_env2 "$ENV{LIB}") - elseif(APPLE) - string(REPLACE ":" ";" _lib_env2 "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env2 "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${_lib_env2}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - endif() - list(REMOVE_DUPLICATES _lib_env) - - # Try to find the gtg lib in the given paths - # ---------------------------------------------- - - # call cmake macro to find the lib path - if(GTG_LIBDIR) - set(GTG_gtg_LIBRARY "GTG_gtg_LIBRARY-NOTFOUND") - find_library(GTG_gtg_LIBRARY - NAMES gtg - HINTS ${GTG_LIBDIR} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - if(GTG_DIR) - set(GTG_gtg_LIBRARY "GTG_gtg_LIBRARY-NOTFOUND") - find_library(GTG_gtg_LIBRARY - NAMES gtg - HINTS ${GTG_DIR} - PATH_SUFFIXES lib lib32 lib64 - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - set(GTG_gtg_LIBRARY "GTG_gtg_LIBRARY-NOTFOUND") - find_library(GTG_gtg_LIBRARY - NAMES gtg - HINTS ${_lib_env}) + if (GTG_STATIC AND GTG_STATIC_LIBRARIES) + set (GTG_DEPENDENCIES ${GTG_STATIC_LIBRARIES}) + list (REMOVE_ITEM GTG_DEPENDENCIES "gtg") + list (APPEND GTG_LIBRARIES ${GTG_DEPENDENCIES}) + set(GTG_CFLAGS_OTHER ${GTG_STATIC_CFLAGS_OTHER}) + set(GTG_LDFLAGS_OTHER ${GTG_STATIC_LDFLAGS_OTHER}) + if (NOT GTG_FIND_QUIETLY) + message(STATUS "GTG_STATIC set to 1 by user, GTG_LIBRARIES: ${GTG_LIBRARIES}.") endif() endif() - mark_as_advanced(GTG_gtg_LIBRARY) - - # If found, add path to cmake variable - # ------------------------------------ - if (GTG_gtg_LIBRARY) - get_filename_component(gtg_lib_path ${GTG_gtg_LIBRARY} PATH) - # set cmake variables (respects naming convention) - set(GTG_LIBRARIES "${GTG_gtg_LIBRARY}") - set(GTG_LIBRARY_DIRS "${gtg_lib_path}") - else () - set(GTG_LIBRARIES "GTG_LIBRARIES-NOTFOUND") - set(GTG_LIBRARY_DIRS "GTG_LIBRARY_DIRS-NOTFOUND") - if(NOT GTG_FIND_QUIETLY) - message(STATUS "Looking for gtg -- lib gtg not found") - endif() - endif () - - if (GTG_LIBRARY_DIRS) - list(REMOVE_DUPLICATES GTG_LIBRARY_DIRS) - endif () - -endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT GTG_FOUND) OR (GTG_GIVEN_BY_USER) ) +endif() # check a function to validate the find -if(GTG_LIBRARIES) - - set(REQUIRED_INCDIRS) - set(REQUIRED_FLAGS) - set(REQUIRED_LDFLAGS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) +if(GTG_FOUND AND GTG_LIBRARIES) - # GTG - if (GTG_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${GTG_INCLUDE_DIRS}") - endif() - if (GTG_CFLAGS_OTHER) - set(REQUIRED_FLAGS "${GTG_CFLAGS_OTHER}") - endif() - if (GTG_LDFLAGS_OTHER) - set(REQUIRED_LDFLAGS "${GTG_LDFLAGS_OTHER}") - endif() - if (GTG_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${GTG_LIBRARY_DIRS}") - endif() - set(REQUIRED_LIBS "${GTG_LIBRARIES}") + # check if static or dynamic lib + morse_check_static_or_dynamic(GTG GTG_LIBRARIES) + if(GTG_STATIC) + set(STATIC "_STATIC") + else() + set(STATIC "") + endif() # set required libraries for link - set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") - if (REQUIRED_FLAGS) - set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}") - set(REQUIRED_FLAGS) - set(REQUIRED_DEFINITIONS) - foreach(_flag ${REQUIRED_FLAGS_COPY}) - if (_flag MATCHES "^-D") - list(APPEND REQUIRED_DEFINITIONS "${_flag}") - endif() - string(REGEX REPLACE "^-D.*" "" _flag "${_flag}") - list(APPEND REQUIRED_FLAGS "${_flag}") - endforeach() - endif() - finds_remove_duplicates() - set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") - set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") - set(CMAKE_REQUIRED_LIBRARIES) - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}") - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + morse_set_required_test_lib_link(GTG) # test link unset(GTG_WORKS CACHE) @@ -325,25 +126,8 @@ if(GTG_LIBRARIES) set(CMAKE_REQUIRED_INCLUDES) set(CMAKE_REQUIRED_FLAGS) set(CMAKE_REQUIRED_LIBRARIES) -endif(GTG_LIBRARIES) -if (GTG_LIBRARIES) - if (GTG_LIBRARY_DIRS) - list(GET GTG_LIBRARY_DIRS 0 first_lib_path) - else() - list(GET GTG_LIBRARIES 0 first_lib) - get_filename_component(first_lib_path "${first_lib}" PATH) - set(GTG_LIBRARY_DIRS "${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(GTG_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of GTG library" FORCE) - else() - set(GTG_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of GTG library" FORCE) - endif() -endif() -mark_as_advanced(GTG_DIR) -mark_as_advanced(GTG_DIR_FOUND) +endif(GTG_FOUND AND GTG_LIBRARIES) # check that GTG has been found # ------------------------------- @@ -351,3 +135,8 @@ include(FindPackageHandleStandardArgs) find_package_handle_standard_args(GTG DEFAULT_MSG GTG_LIBRARIES GTG_WORKS) + +# Add imported targe +if (GTG_FOUND) + morse_create_imported_target(GTG) +endif() \ No newline at end of file diff --git a/modules/find/FindHQR.cmake b/modules/find/FindHQR.cmake deleted file mode 100644 index dbc1176a4a05b95450dce7d0d18aa6db65caa9f1..0000000000000000000000000000000000000000 --- a/modules/find/FindHQR.cmake +++ /dev/null @@ -1,348 +0,0 @@ -### -# -# @copyright (c) 2009-2014 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. -# @copyright (c) 2012-2020 Inria. All rights reserved. -# @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. -# -### -# -# - Find HQR include dirs and libraries -# Use this module by invoking find_package with the form: -# find_package(HQR -# [REQUIRED]) # Fail with error if hqr is not found -# -# This module finds headers and hqr library. -# Results are reported in variables: -# HQR_FOUND - True if headers and requested libraries were found -# HQR_INCLUDE_DIRS - hqr include directories -# HQR_LIBRARY_DIRS - Link directories for hqr libraries -# HQR_LIBRARIES - hqr component libraries to be linked -# -# HQR_FOUND_WITH_PKGCONFIG - True if found with pkg-config -# if found with pkg-config the following variables are set -# <PREFIX> = HQR -# <XPREFIX> = <PREFIX> for common case -# <XPREFIX> = <PREFIX>_STATIC for static linking -# <XPREFIX>_FOUND ... set to 1 if module(s) exist -# <XPREFIX>_LIBRARIES ... only the libraries (w/o the '-l') -# <XPREFIX>_LIBRARY_DIRS ... the paths of the libraries (w/o the '-L') -# <XPREFIX>_LDFLAGS ... all required linker flags -# <XPREFIX>_LDFLAGS_OTHER ... all other linker flags -# <XPREFIX>_INCLUDE_DIRS ... the '-I' preprocessor flags (w/o the '-I') -# <XPREFIX>_CFLAGS ... all required cflags -# <XPREFIX>_CFLAGS_OTHER ... the other compiler flags -# -# The user can give specific paths where to find the libraries adding cmake -# options at configure (ex: cmake path/to/project -DHQR_DIR=path/to/hqr): -# HQR_DIR - Where to find the base directory of hqr -# HQR_INCDIR - Where to find the header files -# HQR_LIBDIR - Where to find the library files -# The module can also look for the following environment variables if paths -# are not given as cmake variable: HQR_DIR, HQR_INCDIR, HQR_LIBDIR - -#============================================================================= -# Copyright 2012-2019 Inria -# Copyright 2012-2013 Emmanuel Agullo -# Copyright 2012-2013 Mathieu Faverge -# Copyright 2012 Cedric Castagnede -# Copyright 2013-2018 Florent Pruvost -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file MORSE-Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of Morse, substitute the full -# License text for the above reference.) - -# Common macros to use in finds -include(FindInit) - -if (NOT HQR_FOUND) - set(HQR_DIR "" CACHE PATH "Installation directory of HQR library") - if (NOT HQR_FIND_QUIETLY) - message(STATUS "A cache variable, namely HQR_DIR, has been set to specify the install directory of HQR") - endif() -endif() - -set(ENV_HQR_DIR "$ENV{HQR_DIR}") -set(ENV_HQR_INCDIR "$ENV{HQR_INCDIR}") -set(ENV_HQR_LIBDIR "$ENV{HQR_LIBDIR}") -set(HQR_GIVEN_BY_USER "FALSE") -if ( HQR_DIR OR ( HQR_INCDIR AND HQR_LIBDIR) OR ENV_HQR_DIR OR (ENV_HQR_INCDIR AND ENV_HQR_LIBDIR) ) - set(HQR_GIVEN_BY_USER "TRUE") -endif() - -# Optionally use pkg-config to detect include/library dirs (if pkg-config is available) -# ------------------------------------------------------------------------------------- -include(FindPkgConfig) -find_package(PkgConfig QUIET) -if(PKG_CONFIG_EXECUTABLE AND NOT HQR_GIVEN_BY_USER) - - pkg_search_module(HQR hqr) - - if (NOT HQR_FIND_QUIETLY) - if (HQR_FOUND AND HQR_LIBRARIES) - message(STATUS "Looking for HQR - found using PkgConfig") - else() - message(STATUS "${Magenta}Looking for HQR - not found using PkgConfig." - "\n Perhaps you should add the directory containing hqr.pc to the" - "\n PKG_CONFIG_PATH environment variable.${ColourReset}") - endif() - endif() - if (HQR_FOUND AND HQR_LIBRARIES) - if (NOT HQR_INCLUDE_DIRS) - pkg_get_variable(HQR_INCLUDE_DIRS hqr includedir) - endif() - set(HQR_FOUND_WITH_PKGCONFIG "TRUE") - find_pkgconfig_libraries_absolute_path(HQR) - else() - set(HQR_FOUND_WITH_PKGCONFIG "FALSE") - endif() -endif(PKG_CONFIG_EXECUTABLE AND NOT HQR_GIVEN_BY_USER) - -if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT HQR_FOUND) OR (HQR_GIVEN_BY_USER) ) - - if (NOT HQR_FIND_QUIETLY) - message(STATUS "Looking for HQR - PkgConfig not used") - endif() - - # Looking for include - # ------------------- - - # Add system include paths to search include - # ------------------------------------------ - unset(_inc_env) - set(ENV_HQR_DIR "$ENV{HQR_DIR}") - set(ENV_HQR_INCDIR "$ENV{HQR_INCDIR}") - if(ENV_HQR_INCDIR) - list(APPEND _inc_env "${ENV_HQR_INCDIR}") - elseif(ENV_HQR_DIR) - list(APPEND _inc_env "${ENV_HQR_DIR}") - list(APPEND _inc_env "${ENV_HQR_DIR}/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() - endif() - list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}") - list(REMOVE_DUPLICATES _inc_env) - - # Try to find the hqr header in the given paths - # ------------------------------------------------- - # call cmake macro to find the header path - if(HQR_INCDIR) - set(HQR_HQR.h_DIRS "HQR_libhqr.h_DIRS-NOTFOUND") - find_path(HQR_libhqr.h_DIRS - NAMES libhqr.h - HINTS ${HQR_INCDIR} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - if(HQR_DIR) - set(HQR_libhqr.h_DIRS "HQR_libhqr.h_DIRS-NOTFOUND") - find_path(HQR_libhqr.h_DIRS - NAMES libhqr.h - HINTS ${HQR_DIR} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - set(HQR_libhqr.h_DIRS "HQR_libhqr.h_DIRS-NOTFOUND") - find_path(HQR_libhqr.h_DIRS - NAMES libhqr.h - HINTS ${_inc_env} - PATH_SUFFIXES "hqr") - endif() - endif() - mark_as_advanced(HQR_libhqr.h_DIRS) - - # Add path to cmake variable - # ------------------------------------ - if (HQR_libhqr.h_DIRS) - set(HQR_INCLUDE_DIRS "${HQR_libhqr.h_DIRS}") - else () - set(HQR_INCLUDE_DIRS "HQR_INCLUDE_DIRS-NOTFOUND") - if(NOT HQR_FIND_QUIETLY) - message(STATUS "Looking for hqr -- libhqr.h not found") - endif() - endif () - - if (HQR_INCLUDE_DIRS) - list(REMOVE_DUPLICATES HQR_INCLUDE_DIRS) - endif () - - # Looking for lib - # --------------- - - # Add system library paths to search lib - # -------------------------------------- - unset(_lib_env) - set(ENV_HQR_LIBDIR "$ENV{HQR_LIBDIR}") - if(ENV_HQR_LIBDIR) - list(APPEND _lib_env "${ENV_HQR_LIBDIR}") - elseif(ENV_HQR_DIR) - list(APPEND _lib_env "${ENV_HQR_DIR}") - list(APPEND _lib_env "${ENV_HQR_DIR}/lib") - else() - list(APPEND _lib_env "$ENV{LIBRARY_PATH}") - if(WIN32) - string(REPLACE ":" ";" _lib_env2 "$ENV{LIB}") - elseif(APPLE) - string(REPLACE ":" ";" _lib_env2 "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env2 "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${_lib_env2}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - endif() - list(REMOVE_DUPLICATES _lib_env) - - # Try to find the hqr lib in the given paths - # ---------------------------------------------- - - # call cmake macro to find the lib path - if(HQR_LIBDIR) - set(HQR_hqr_LIBRARY "HQR_hqr_LIBRARY-NOTFOUND") - find_library(HQR_hqr_LIBRARY - NAMES hqr - HINTS ${HQR_LIBDIR} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - if(HQR_DIR) - set(HQR_hqr_LIBRARY "HQR_hqr_LIBRARY-NOTFOUND") - find_library(HQR_hqr_LIBRARY - NAMES hqr - HINTS ${HQR_DIR} - PATH_SUFFIXES lib lib32 lib64 - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - set(HQR_hqr_LIBRARY "HQR_hqr_LIBRARY-NOTFOUND") - find_library(HQR_hqr_LIBRARY - NAMES hqr - HINTS ${_lib_env}) - endif() - endif() - mark_as_advanced(HQR_hqr_LIBRARY) - - # If found, add path to cmake variable - # ------------------------------------ - if (HQR_hqr_LIBRARY) - get_filename_component(hqr_lib_path ${HQR_hqr_LIBRARY} PATH) - # set cmake variables (respects naming convention) - set(HQR_LIBRARIES "${HQR_hqr_LIBRARY}") - set(HQR_LIBRARY_DIRS "${hqr_lib_path}") - else () - set(HQR_LIBRARIES "HQR_LIBRARIES-NOTFOUND") - set(HQR_LIBRARY_DIRS "HQR_LIBRARY_DIRS-NOTFOUND") - if(NOT HQR_FIND_QUIETLY) - message(STATUS "Looking for hqr -- lib hqr not found") - endif() - endif () - - if (HQR_LIBRARY_DIRS) - list(REMOVE_DUPLICATES HQR_LIBRARY_DIRS) - endif () - -endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT HQR_FOUND) OR (HQR_GIVEN_BY_USER) ) - -# check a function to validate the find -if(HQR_LIBRARIES) - - set(REQUIRED_INCDIRS) - set(REQUIRED_FLAGS) - set(REQUIRED_LDFLAGS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) - - # HQR - if (HQR_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${HQR_INCLUDE_DIRS}") - endif() - if (HQR_CFLAGS_OTHER) - set(REQUIRED_FLAGS "${HQR_CFLAGS_OTHER}") - endif() - if (HQR_LDFLAGS_OTHER) - set(REQUIRED_LDFLAGS "${HQR_LDFLAGS_OTHER}") - endif() - if (HQR_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${HQR_LIBRARY_DIRS}") - endif() - set(REQUIRED_LIBS "${HQR_LIBRARIES}") - - # set required libraries for link - set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") - if (REQUIRED_FLAGS) - set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}") - set(REQUIRED_FLAGS) - set(REQUIRED_DEFINITIONS) - foreach(_flag ${REQUIRED_FLAGS_COPY}) - if (_flag MATCHES "^-D") - list(APPEND REQUIRED_DEFINITIONS "${_flag}") - endif() - string(REGEX REPLACE "^-D.*" "" _flag "${_flag}") - list(APPEND REQUIRED_FLAGS "${_flag}") - endforeach() - endif() - finds_remove_duplicates() - set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") - set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") - set(CMAKE_REQUIRED_LIBRARIES) - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}") - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - - # test link - unset(HQR_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(libhqr_init_hqr HQR_WORKS) - mark_as_advanced(HQR_WORKS) - - if(NOT HQR_WORKS) - if(NOT HQR_FIND_QUIETLY) - message(STATUS "Looking for hqr : test of libhqr_hqr_init with hqr library fails") - message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") - message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") - message(STATUS "CMAKE_REQUIRED_FLAGS: ${CMAKE_REQUIRED_FLAGS}") - message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") - endif() - endif() - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_LIBRARIES) -endif(HQR_LIBRARIES) - -if (HQR_LIBRARIES) - if (HQR_LIBRARY_DIRS) - list(GET HQR_LIBRARY_DIRS 0 first_lib_path) - else() - list(GET HQR_LIBRARIES 0 first_lib) - get_filename_component(first_lib_path "${first_lib}" PATH) - set(HQR_LIBRARY_DIRS "${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(HQR_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of HQR library" FORCE) - else() - set(HQR_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of HQR library" FORCE) - endif() -endif() -mark_as_advanced(HQR_DIR) -mark_as_advanced(HQR_DIR_FOUND) - -# check that HQR has been found -# ------------------------------- -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(HQR DEFAULT_MSG - HQR_LIBRARIES - HQR_WORKS) diff --git a/modules/find/FindHWLOC.cmake b/modules/find/FindHWLOC.cmake index c42f9ed07c5ecfa7f332b9ce1d2d73cc59959a71..5a063e933b3fa472322786516ea1c1b1691bc1ed 100644 --- a/modules/find/FindHWLOC.cmake +++ b/modules/find/FindHWLOC.cmake @@ -1,11 +1,23 @@ ### # -# @copyright (c) 2009-2014 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. # @copyright (c) 2012-2020 Inria. All rights reserved. # @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. # +# Copyright 2012-2013 Emmanuel Agullo +# Copyright 2012-2013 Mathieu Faverge +# Copyright 2012 Cedric Castagnede +# Copyright 2013-2020 Florent Pruvost +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file MORSE-Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of Morse, substitute the full +# License text for the above reference.) +# ### # # - Find HWLOC include dirs and libraries @@ -13,16 +25,11 @@ # find_package(HWLOC # [REQUIRED]) # Fail with error if hwloc is not found # -# This module finds headers and hwloc library. -# Results are reported in variables: -# HWLOC_FOUND - True if headers and requested libraries were found -# HWLOC_INCLUDE_DIRS - hwloc include directories -# HWLOC_LIBRARY_DIRS - Link directories for hwloc libraries -# HWLOC_LIBRARIES - hwloc component libraries to be linked -# -# HWLOC_FOUND_WITH_PKGCONFIG - True if found with pkg-config +# This module finds headers and hwloc library using pkg-config file. # if found with pkg-config the following variables are set # <PREFIX> = HWLOC +# <PREFIX>_PREFIX ... installation path of the lib found +# <PREFIX>_VERSION ... version of the lib # <XPREFIX> = <PREFIX> for common case # <XPREFIX> = <PREFIX>_STATIC for static linking # <XPREFIX>_FOUND ... set to 1 if module(s) exist @@ -34,58 +41,29 @@ # <XPREFIX>_CFLAGS ... all required cflags # <XPREFIX>_CFLAGS_OTHER ... the other compiler flags # -# The user can give specific paths where to find the libraries adding cmake -# options at configure (ex: cmake path/to/project -DHWLOC_DIR=path/to/hwloc): -# HWLOC_DIR - Where to find the base directory of hwloc -# HWLOC_INCDIR - Where to find the header files -# HWLOC_LIBDIR - Where to find the library files -# The module can also look for the following environment variables if paths -# are not given as cmake variable: HWLOC_DIR, HWLOC_INCDIR, HWLOC_LIBDIR - -#============================================================================= -# Copyright 2012-2019 Inria -# Copyright 2012-2013 Emmanuel Agullo -# Copyright 2012-2013 Mathieu Faverge -# Copyright 2012 Cedric Castagnede -# Copyright 2013-2018 Florent Pruvost +# Set HWLOC_STATIC to 1 to force using static libraries if exist. # -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file MORSE-Copyright.txt for details. +# This module defines the following :prop_tgt:`IMPORTED` target: +# +# ``MORSE::HWLOC`` +# The headers and libraries to use for HWLOC, if found. # -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. #============================================================================= -# (To distribute this file outside of Morse, substitute the full -# License text for the above reference.) # Common macros to use in finds -include(FindInit) +include(FindMorseInit) 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() -endif() - -set(ENV_HWLOC_DIR "$ENV{HWLOC_DIR}") -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") +if (NOT HWLOC_FIND_QUIETLY) + message(STATUS "FindHWLOC needs pkg-config program and PKG_CONFIG_PATH set HWLOC.pc file path.") endif() -# Optionally use pkg-config to detect include/library dirs (if pkg-config is available) -# ------------------------------------------------------------------------------------- -include(FindPkgConfig) -find_package(PkgConfig QUIET) -if( PKG_CONFIG_EXECUTABLE AND NOT HWLOC_GIVEN_BY_USER ) - +# use pkg-config to detect include/library dirs (if pkg-config is available) +# -------------------------------------------------------------------------- +if (PKG_CONFIG_EXECUTABLE) + unset(HWLOC_FOUND CACHE) pkg_search_module(HWLOC hwloc) if (NOT HWLOC_FIND_QUIETLY) @@ -97,221 +75,41 @@ if( PKG_CONFIG_EXECUTABLE AND NOT HWLOC_GIVEN_BY_USER ) "\n the PKG_CONFIG_PATH environment variable.${ColourReset}") endif() endif() - if (HWLOC_FOUND AND HWLOC_LIBRARIES) if (NOT HWLOC_INCLUDE_DIRS) pkg_get_variable(HWLOC_INCLUDE_DIRS hwloc includedir) endif() set(HWLOC_FOUND_WITH_PKGCONFIG "TRUE") - find_pkgconfig_libraries_absolute_path(HWLOC) + morse_find_pkgconfig_libraries_absolute_path(HWLOC) else() set(HWLOC_FOUND_WITH_PKGCONFIG "FALSE") 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") - 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}") + if (HWLOC_STATIC AND HWLOC_STATIC_LIBRARIES) + set (HWLOC_DEPENDENCIES ${HWLOC_STATIC_LIBRARIES}) + list (REMOVE_ITEM HWLOC_DEPENDENCIES "hwloc") + list (APPEND HWLOC_LIBRARIES ${HWLOC_DEPENDENCIES}) + set(HWLOC_CFLAGS_OTHER ${HWLOC_STATIC_CFLAGS_OTHER}) + set(HWLOC_LDFLAGS_OTHER ${HWLOC_STATIC_LDFLAGS_OTHER}) + if (NOT HWLOC_FIND_QUIETLY) + message(STATUS "HWLOC_STATIC set to 1 by user, HWLOC_LIBRARIES: ${HWLOC_LIBRARIES}.") endif() endif() - 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} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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" - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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() - 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") - else() - list(APPEND _lib_env "$ENV{LIBRARY_PATH}") - if(WIN32) - string(REPLACE ":" ";" _lib_env2 "$ENV{LIB}") - elseif(APPLE) - string(REPLACE ":" ";" _lib_env2 "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env2 "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${_lib_env2}") - 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 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} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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 - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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 () - - if (HWLOC_LIBRARY_DIRS) - list(REMOVE_DUPLICATES HWLOC_LIBRARY_DIRS) - endif () - -endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT HWLOC_FOUND) OR (HWLOC_GIVEN_BY_USER) ) +endif() # check a function to validate the find -if(HWLOC_LIBRARIES) +if(HWLOC_FOUND AND HWLOC_LIBRARIES) - set(REQUIRED_INCDIRS) - set(REQUIRED_FLAGS) - set(REQUIRED_LDFLAGS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) - - # HWLOC - if (HWLOC_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${HWLOC_INCLUDE_DIRS}") - endif() - if (HWLOC_CFLAGS_OTHER) - set(REQUIRED_FLAGS "${HWLOC_CFLAGS_OTHER}") - endif() - if (HWLOC_LDFLAGS_OTHER) - set(REQUIRED_LDFLAGS "${HWLOC_LDFLAGS_OTHER}") - endif() - if (HWLOC_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${HWLOC_LIBRARY_DIRS}") + # check if static or dynamic lib + morse_check_static_or_dynamic(HWLOC HWLOC_LIBRARIES) + if(HWLOC_STATIC) + set(STATIC "_STATIC") + else() + set(STATIC "") endif() - set(REQUIRED_LIBS "${HWLOC_LIBRARIES}") # set required libraries for link - set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") - if (REQUIRED_FLAGS) - set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}") - set(REQUIRED_FLAGS) - set(REQUIRED_DEFINITIONS) - foreach(_flag ${REQUIRED_FLAGS_COPY}) - if (_flag MATCHES "^-D") - list(APPEND REQUIRED_DEFINITIONS "${_flag}") - endif() - string(REGEX REPLACE "^-D.*" "" _flag "${_flag}") - list(APPEND REQUIRED_FLAGS "${_flag}") - endforeach() - endif() - finds_remove_duplicates() - set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") - set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") - set(CMAKE_REQUIRED_LIBRARIES) - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}") - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + morse_set_required_test_lib_link(HWLOC) # test link unset(HWLOC_WORKS CACHE) @@ -331,25 +129,11 @@ if(HWLOC_LIBRARIES) set(CMAKE_REQUIRED_INCLUDES) set(CMAKE_REQUIRED_FLAGS) set(CMAKE_REQUIRED_LIBRARIES) -endif(HWLOC_LIBRARIES) -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) - set(HWLOC_LIBRARY_DIRS "${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) + # Add imported target + morse_create_imported_target(HWLOC) + +endif(HWLOC_FOUND AND HWLOC_LIBRARIES) # check that HWLOC has been found # ------------------------------- @@ -358,29 +142,7 @@ find_package_handle_standard_args(HWLOC DEFAULT_MSG HWLOC_LIBRARIES HWLOC_WORKS) +# Add imported targe if (HWLOC_FOUND) - set(HWLOC_SAVE_CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES}) - list(APPEND CMAKE_REQUIRED_INCLUDES ${HWLOC_INCLUDE_DIRS}) - set(CMAKE_REQUIRED_LIBRARIES) - if (HWLOC_LIBRARY_DIRS) - set (LIBDIR ${HWLOC_LIBRARY_DIRS}) - elseif(HWLOC_LIBDIR) - set (LIBDIR ${HWLOC_LIBDIR}) - endif() - if (LIBDIR) - foreach(lib_dir ${LIBDIR}) - list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}") - endforeach() - endif() - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - - # 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() + morse_create_imported_target(HWLOC) +endif() \ No newline at end of file diff --git a/modules/find/FindHYPRE.cmake b/modules/find/FindHYPRE.cmake index 5e2b5001c2158fefc50e3d66f40144ae30dc31be..b715bf439a1a6d8f5a5b46417d91774b907130f2 100644 --- a/modules/find/FindHYPRE.cmake +++ b/modules/find/FindHYPRE.cmake @@ -3,12 +3,19 @@ # it is surely too simple, must be completed ### # -# @copyright (c) 2009-2014 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. -# @copyright (c) 2012-2019 Inria. All rights reserved. -# @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. +# @copyright (c) 2016-2020 Inria. All rights reserved. # +# Copyright 2016-2020 Florent Pruvost +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file MORSE-Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of Morse, substitute the full +# License text for the above reference.) ### # # - Find HYPRE include dirs and libraries @@ -25,9 +32,13 @@ # HYPRE_INCLUDE_DIRS - hypre include directories # HYPRE_LIBRARY_DIRS - Link directories for hypre libraries # HYPRE_LIBRARIES - hypre component libraries to be linked -# HYPRE_INCLUDE_DIRS_DEP - hypre + dependencies include directories -# HYPRE_LIBRARY_DIRS_DEP - hypre + dependencies link directories -# HYPRE_LIBRARIES_DEP - hypre + dependencies libraries +# +# Set HYPRE_STATIC to 1 to force using static libraries if exist. +# +# This module defines the following :prop_tgt:`IMPORTED` target: +# +# ``MORSE::HYPRE`` +# The headers and libraries to use for HYPRE, if found. # # The user can give specific paths where to find the libraries adding cmake # options at configure (ex: cmake path/to/project -DHYPRE_DIR=path/to/hypre): @@ -38,21 +49,9 @@ # are not given as cmake variable: HYPRE_DIR, HYPRE_INCDIR, HYPRE_LIBDIR #============================================================================= -# Copyright 2016-2019 Inria -# Copyright 2016-2018 Florent Pruvost -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file MORSE-Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of Morse, substitute the full -# License text for the above reference.) # Common macros to use in finds -include(FindInit) +include(FindMorseInit) if (NOT HYPRE_FOUND) set(HYPRE_DIR "" CACHE PATH "Installation directory of HYPRE library") @@ -182,6 +181,11 @@ set(PATH_TO_LOOK_FOR "${_lib_env}") # Try to find the hypre lib in the given paths # ---------------------------------------------- +if (HYPRE_STATIC) + set (CMAKE_FIND_LIBRARY_SUFFIXES_COPY ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set (CMAKE_FIND_LIBRARY_SUFFIXES ".a") +endif() + # call cmake macro to find the lib path if(HYPRE_LIBDIR) set(HYPRE_HYPRE_LIBRARY "HYPRE_HYPRE_LIBRARY-NOTFOUND") @@ -206,6 +210,10 @@ else() endif() mark_as_advanced(HYPRE_HYPRE_LIBRARY) +if (HYPRE_STATIC) + set (CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_COPY}) +endif() + # If found, add path to cmake variable # ------------------------------------ if (HYPRE_HYPRE_LIBRARY) @@ -228,9 +236,17 @@ endif () # check a function to validate the find if(HYPRE_LIBRARIES) + # check if static or dynamic lib + morse_check_static_or_dynamic(HYPRE HYPRE_LIBRARIES) + if(HYPRE_STATIC) + set(STATIC "_STATIC") + endif() + set(REQUIRED_INCDIRS) set(REQUIRED_LIBDIRS) set(REQUIRED_LIBS) + set(REQUIRED_FLAGS) + set(REQUIRED_LDFLAGS) # HYPRE if (HYPRE_INCLUDE_DIRS) @@ -269,7 +285,7 @@ if(HYPRE_LIBRARIES) endif() # set required libraries for link - finds_remove_duplicates() + morse_finds_remove_duplicates() set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") set(CMAKE_REQUIRED_LIBRARIES) foreach(lib_dir ${REQUIRED_LIBDIRS}) @@ -285,10 +301,12 @@ if(HYPRE_LIBRARIES) mark_as_advanced(HYPRE_WORKS) if(HYPRE_WORKS) - # save link with dependencies - set(HYPRE_LIBRARIES_DEP "${REQUIRED_LIBS}") - set(HYPRE_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}") - set(HYPRE_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") + if (HYPRE_STATIC) + # save link with dependencies + set(HYPRE_LIBRARIES "${REQUIRED_LIBS}") + set(HYPRE_LIBRARY_DIRS "${REQUIRED_LIBDIRS}") + set(HYPRE_INCLUDE_DIRS "${REQUIRED_INCDIRS}") + endif() else() if(NOT HYPRE_FIND_QUIETLY) message(STATUS "Looking for HYPRE : test of HYPRE_StructGridCreate with HYPRE library fails") @@ -300,24 +318,23 @@ if(HYPRE_LIBRARIES) 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) + get_filename_component(first_lib_path "${first_lib}" DIRECTORY) 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) + set(HYPRE_PREFIX "${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) + set(HYPRE_PREFIX "${first_lib_path}" CACHE PATH "Installation directory of HYPRE library" FORCE) endif() -endif() -mark_as_advanced(HYPRE_DIR) -mark_as_advanced(HYPRE_DIR_FOUND) + mark_as_advanced(HYPRE_DIR) + mark_as_advanced(HYPRE_PREFIX) + +endif(HYPRE_LIBRARIES) # check that HYPRE has been found # ------------------------------- @@ -325,3 +342,8 @@ include(FindPackageHandleStandardArgs) find_package_handle_standard_args(HYPRE DEFAULT_MSG HYPRE_LIBRARIES HYPRE_WORKS) + +# Add imported target +if (HYPRE_FOUND) + morse_create_imported_target(HYPRE) +endif() diff --git a/modules/find/FindLAPACK.cmake b/modules/find/FindLAPACK.cmake deleted file mode 100644 index b571d0d0149b9f996fc243fc2e4c7488a2e0e8bb..0000000000000000000000000000000000000000 --- a/modules/find/FindLAPACK.cmake +++ /dev/null @@ -1,1241 +0,0 @@ -### -# -# @copyright (c) 2009-2014 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. -# @copyright (c) 2012-2020 Inria. All rights reserved. -# @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. -# -### -# -# - Find LAPACK library -# This module finds an installed fortran library that implements the LAPACK -# linear-algebra interface (see http://www.netlib.org/lapack/). -# -# The approach follows that taken for the autoconf macro file, acx_lapack.m4 -# (distributed at http://ac-archive.sourceforge.net/ac-archive/acx_lapack.html). -# -# This module sets the following variables: -# LAPACK_FOUND - set to true if a library implementing the LAPACK interface -# is found -# LAPACK_CFLAGS_OTHER - lapack compiler flags without headers paths -# LAPACK_LDFLAGS_OTHER - lapack linker flags without libraries -# LAPACK_INCLUDE_DIRS - lapack include directories -# LAPACK_LIBRARY_DIRS - lapack link directories -# LAPACK_LIBRARIES - lapack libraries to be linked (absolute path) -# LAPACK_LIBRARIES_SEQ - lapack libraries to be linked (absolute path), sequential version (Intel MKL) -# LAPACK_LIBRARIES_PAR - lapack libraries to be linked (absolute path), multithreaded version (Intel MKL) -# LAPACK_CFLAGS_OTHER_DEP - lapack + dependencies compiler flags without headers paths -# LAPACK_LDFLAGS_OTHER_DEP - lapack + dependencies linker flags without libraries -# LAPACK_INCLUDE_DIRS_DEP - lapack + dependencies include directories -# LAPACK_LIBRARY_DIRS_DEP - lapack + dependencies link directories -# LAPACK_LIBRARIES_DEP - lapack + dependencies libraries -# LAP_STATIC if set on this determines what kind of linkage we do (static) -# LAP_VENDOR if set checks only the specified vendor, if not set checks -# all the possibilities -# LAPACK_VENDOR_FOUND stores the LAPACK vendor found -# LAP_F95 if set on tries to find the f95 interfaces for BLAS/LAPACK -# LAP_PREFER_PKGCONFIG - try using pkg-config (ON by default) -# -# LAPACK_FOUND_WITH_PKGCONFIG - True if found with pkg-config -# if found with pkg-config the following variables are set -# <PREFIX> = LAPACK -# <XPREFIX> = <PREFIX> for common case -# <XPREFIX> = <PREFIX>_STATIC for static linking -# <XPREFIX>_FOUND ... set to 1 if module(s) exist -# <XPREFIX>_LIBRARIES ... only the libraries (w/o the '-l') -# <XPREFIX>_LIBRARY_DIRS ... the paths of the libraries (w/o the '-L') -# <XPREFIX>_LDFLAGS ... all required linker flags -# <XPREFIX>_LDFLAGS_OTHER ... all other linker flags -# <XPREFIX>_INCLUDE_DIRS ... the '-I' preprocessor flags (w/o the '-I') -# <XPREFIX>_CFLAGS ... all required cflags -# <XPREFIX>_CFLAGS_OTHER ... the other compiler flags -# -# The user can give specific paths where to find the libraries adding cmake -# options at configure (ex: cmake path/to/project -DLAPACK_DIR=path/to/lapack): -# LAPACK_DIR - Where to find the base directory of lapack -# LAPACK_INCDIR - Where to find the header files -# LAPACK_LIBDIR - Where to find the library files -# The module can also look for the following environment variables if paths -# are not given as cmake variable: LAPACK_DIR, LAPACK_INCDIR, LAPACK_LIBDIR -# For MKL case and if no paths are given as hints, we will try to use the MKLROOT -# environment variable -# Note that if BLAS_DIR is set, it will also look for lapack in it -# The user can also give directly the LAPACK libraries to be used with: -# LAPACK_LIBRARIES_USER -### List of vendors (LAP_VENDOR) valid in this module -## Intel(mkl), ARMPL, FLAME, ACML, Apple, NAS, Generic, User (See LAPACK_LIBRARIES_USER) -# LAPACK could be directly embedded in BLAS library (ex: Intel MKL) so that -# we test a lapack function with the blas libraries found. To skip this feature -# and look for a stand alone lapack, please set LAPACK_STANDALONE to TRUE - -#============================================================================= -# Copyright 2007-2009 Kitware, Inc. -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -# Common macros to use in finds -include(FindInit) - -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() -endif (NOT LAPACK_FOUND) - -option(LAPACK_VERBOSE "Print some additional information during LAPACK libraries detection" OFF) -if(NOT DEFINED LAP_PREFER_PKGCONFIG) - set(LAP_PREFER_PKGCONFIG ON CACHE BOOL "Try to find LAPACK using pkg-config") -endif() - -mark_as_advanced(LAPACK_VERBOSE) -if (BLAS_VERBOSE) - set(LAPACK_VERBOSE ON) -endif () -set(_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) - -set(LAPACK_LIBRARIES_USER "" CACHE STRING "LAPACK libraries given by users") -if(LAPACK_LIBRARIES_USER) - set(LAP_VENDOR "User") -endif() - -# Check the language being used -get_property( _LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES ) -if( _LANGUAGES_ MATCHES Fortran ) - set( _CHECK_FORTRAN TRUE ) - include(CheckFortranFunctionExists) -elseif( (_LANGUAGES_ MATCHES C) OR (_LANGUAGES_ MATCHES CXX) ) - set( _CHECK_FORTRAN FALSE ) - include(CheckFunctionExists) -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() -endif() - -set(LAPACK_FOUND FALSE) -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_ARMPL "$ENV{ARMPL_DIR}") - set(ENV_BLAS_DIR "$ENV{BLAS_DIR}") - set(ENV_BLAS_LIBDIR "$ENV{BLAS_LIBDIR}") - set(ENV_LAPACK_DIR "$ENV{LAPACK_DIR}") - set(ENV_LAPACK_INCDIR "$ENV{LAPACK_INCDIR}") - set(ENV_LAPACK_LIBDIR "$ENV{LAPACK_LIBDIR}") - - set(LAPACK_GIVEN_BY_USER "FALSE") - if ( LAPACK_DIR OR LAPACK_LIBDIR OR ENV_LAPACK_DIR OR ENV_LAPACK_LIBDIR OR ENV_MKLROOT OR ENV_ARMPL ) - set(LAPACK_GIVEN_BY_USER "TRUE") - endif() - - 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() - 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) - list(APPEND _libdir "${ENV_LAPACK_LIBDIR}") - 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") - else() - 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 (ENV_ARMPL) - list(APPEND _libdir "${ENV_ARMPL}/lib") - endif() - list(APPEND _libdir "$ENV{LIBRARY_PATH}") - 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_C_IMPLICIT_LINK_DIRECTORIES}") - endif () - endif () - - if (LAPACK_VERBOSE) - message("${Cyan}Try to find LAPACK libraries: ${_list}") - endif () - - foreach(_library ${_list}) - set(_combined_name ${_combined_name}_${_library}) - - if(_libraries_work) - if (LAP_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 (LAP_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 (LAP_STATIC) - if (EXISTS ${_library}) - set(${_prefix}_${_library}_LIBRARY ${_library}) - else() - if ( LAPACK_GIVEN_BY_USER ) - find_library(${_prefix}_${_library}_LIBRARY - NAMES ${_library} - HINTS ${_libdir} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH - ) - else() - find_library(${_prefix}_${_library}_LIBRARY - NAMES ${_library} - HINTS ${_libdir} - ) - endif() - endif() - 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) - # Test this combination of libraries. - if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND LAP_STATIC) - list(INSERT ${LIBRARIES} 0 "-Wl,--start-group") - list(APPEND ${LIBRARIES} "-Wl,--end-group") - endif() - if(UNIX AND LAP_STATIC) - set(CMAKE_REQUIRED_LIBRARIES ${_flags} "-Wl,--start-group" ${${LIBRARIES}} ${_blas} "-Wl,--end-group" ${_threads}) - else(UNIX AND LAP_STATIC) - set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blas} ${_threads}) - endif(UNIX AND LAP_STATIC) - set(CMAKE_REQUIRED_INCLUDES "${LAPACK_INCLUDE_DIRS}") - set(CMAKE_REQUIRED_FLAGS "${LAPACK_CFLAGS_OTHER}") - 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 (_CHECK_FORTRAN) - check_fortran_function_exists(${_name} ${_prefix}${_combined_name}_WORKS) - else () - check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS) - endif () - 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) - set(${LIBRARIES} FALSE) - endif(_libraries_work) - -endmacro(Check_Lapack_Libraries) - - -set(LAPACK_LDFLAGS_OTHER) -set(LAPACK_LIBRARIES) -set(LAPACK95_LIBRARIES) - -if (NOT BLAS_FOUND) - if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED) - find_package(BLAS) - else() - find_package(BLAS REQUIRED) - endif() -endif() - -if(BLAS_FOUND) - set(LAPACK_INCLUDE_DIRS ${BLAS_INCLUDE_DIRS}) - if ($ENV{LAP_VENDOR} MATCHES ".+") - set(LAP_VENDOR $ENV{LAP_VENDOR}) - else ($ENV{LAP_VENDOR} MATCHES ".+") - if(NOT LAP_VENDOR) - set(LAP_VENDOR "All") - endif(NOT LAP_VENDOR) - endif ($ENV{LAP_VENDOR} MATCHES ".+") - - if (UNIX AND NOT WIN32) - # m - find_library(M_LIBRARY NAMES m) - mark_as_advanced(M_LIBRARY) - if(M_LIBRARY) - set(LM "${M_LIBRARY}") - else() - set(LM "") - endif() - # dl - find_library( - DL_LIBRARY - NAMES dl - HINTS ${_libdir} - ) - mark_as_advanced(DL_LIBRARY) - if(DL_LIBRARY) - set(LDL "${DL_LIBRARY}") - else() - set(LDL "") - endif() - endif() - - # check if blas found contains lapack symbols - if (BLAS_LIBRARIES AND NOT LAPACK_STANDALONE) - if (BLAS_LIBRARIES_DEP) - set(LIBRARIES ${BLAS_LIBRARIES_DEP}) - else() - set(LIBRARIES ${BLAS_LIBRARIES}) - endif() - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - "cheev" - "" - "" - "${LIBRARIES}" - "" - ) - if (LAPACK_LIBRARIES) - if (BLAS_LIBRARIES_SEQ) - set(LAPACK_LIBRARIES_SEQ "${BLAS_LIBRARIES_SEQ}") - endif() - if (BLAS_LIBRARIES_PAR) - set(LAPACK_LIBRARIES_PAR "${BLAS_LIBRARIES_PAR}") - endif() - set(LAPACK_INCLUDE_DIRS "${BLAS_INCLUDE_DIRS}") - set(LAPACK_CFLAGS_OTHER "${BLAS_CFLAGS_OTHER}") - set(LAPACK_LIBRARY_DIRS "${BLAS_LIBRARY_DIRS}") - set(LAPACK_LDFLAGS_OTHER "${BLAS_LDFLAGS_OTHER}") - if(NOT LAPACK_FIND_QUIETLY) - if(LAPACK_LIBRARIES) - message(STATUS "Looking for LAPACK in BLAS: found") - else() - message(STATUS "Looking for LAPACK in BLAS: not found") - endif() - endif() - if (LAPACK_LIBRARIES) - set (LAPACK_VENDOR_FOUND "${BLAS_VENDOR_FOUND}") - endif() - endif() - endif(BLAS_LIBRARIES AND NOT LAPACK_STANDALONE) - - # if not lapack in blas libs, try to find lapack with pkg-config - - # Optionally use pkg-config to detect include/library dirs (if pkg-config is available) - # ------------------------------------------------------------------------------------- - include(FindPkgConfig) - find_package(PkgConfig QUIET) - if( PKG_CONFIG_EXECUTABLE AND NOT LAPACK_GIVEN_BY_USER AND LAP_VENDOR STREQUAL "All" - AND NOT LAPACK_LIBRARIES AND LAP_PREFER_PKGCONFIG ) - - if (LAP_STATIC) - set(MKL_STR_LAP_STATIC "static") - else() - set(MKL_STR_LAP_STATIC "dynamic") - endif() - # try different blas - if (LAP_VENDOR STREQUAL "Intel10_64lp") - pkg_search_module(LAPACK mkl-${MKL_STR_LAP_STATIC}-lp64-seq) - if (LAPACK_FOUND) - set (LAPACK_VENDOR_FOUND "Intel MKL Sequential") - set (LAPACK_LIBRARIES_SEQ "${LAPACK_LIBRARIES}") - endif() - pkg_search_module(LAPACK mkl-${MKL_STR_LAP_STATIC}-lp64-iomp) - if (LAPACK_FOUND) - set (LAPACK_VENDOR_FOUND "Intel MKL Multithreaded") - set (LAPACK_LIBRARIES_PAR "${LAPACK_LIBRARIES}") - endif() - elseif(LAP_VENDOR STREQUAL "Intel10_64lp_seq") - pkg_search_module(LAPACK mkl-${MKL_STR_LAP_STATIC}-lp64-seq) - if (LAPACK_FOUND) - set (LAPACK_VENDOR_FOUND "Intel MKL") - set (LAPACK_LIBRARIES_SEQ "${LAPACK_LIBRARIES}") - endif() - elseif(LAP_VENDOR STREQUAL "Open") - pkg_search_module(LAPACK openblas) - if (LAPACK_FOUND) - set (LAPACK_VENDOR_FOUND "Openblas") - endif() - elseif(LAP_VENDOR STREQUAL "Generic") - pkg_search_module(LAPACK lapack) - if (LAPACK_FOUND) - set (LAPACK_VENDOR_FOUND "Netlib or other Generic liblapack") - endif() - elseif(BLA_VENDOR STREQUAL "All") - if (NOT LAPACK_FOUND) - pkg_search_module(LAPACK mkl-${MKL_STR_LAP_STATIC}-lp64-iomp) - if (LAPACK_FOUND) - set (LAPACK_VENDOR_FOUND "Intel MKL Multithreaded") - set (LAPACK_LIBRARIES_PAR "${LAPACK_LIBRARIES}") - endif() - pkg_search_module(LAPACK mkl-${MKL_STR_LAP_STATIC}-lp64-seq) - if (LAPACK_FOUND) - set (LAPACK_VENDOR_FOUND "Intel MKL") - set (LAPACK_LIBRARIES_SEQ "${LAPACK_LIBRARIES}") - endif() - endif() - if (NOT LAPACK_FOUND) - pkg_search_module(LAPACK openblas) - if (LAPACK_FOUND) - set (LAPACK_VENDOR_FOUND "Openblas") - endif() - endif() - if (NOT LAPACK_FOUND) - pkg_search_module(LAPACK lapack) - if (LAPACK_FOUND) - set (LAPACK_VENDOR_FOUND "Netlib or other Generic liblapack") - endif() - endif() - endif() - - if (NOT LAPACK_FIND_QUIETLY) - if (LAPACK_FOUND AND LAPACK_LIBRARIES) - message(STATUS "Looking for LAPACK - found using PkgConfig") - else() - message(STATUS "${Magenta}Looking for LAPACK - not found using PkgConfig." - "\n Perhaps you should add the directory containing lapack.pc to" - "\n the PKG_CONFIG_PATH environment variable.${ColourReset}") - endif() - endif() - - if (LAPACK_FOUND AND LAPACK_LIBRARIES) - set(LAPACK_FOUND_WITH_PKGCONFIG "TRUE") - find_pkgconfig_libraries_absolute_path(LAPACK) - else() - set(LAPACK_FOUND_WITH_PKGCONFIG "FALSE") - endif() - - endif( PKG_CONFIG_EXECUTABLE AND NOT LAPACK_GIVEN_BY_USER AND LAP_VENDOR STREQUAL "All" - AND NOT LAPACK_LIBRARIES AND LAP_PREFER_PKGCONFIG ) - - if( (NOT LAPACK_FOUND_WITH_PKGCONFIG) OR LAPACK_GIVEN_BY_USER ) - #intel lapack - if (LAP_VENDOR MATCHES "Intel" OR LAP_VENDOR STREQUAL "All") - - if(NOT LAPACK_LIBRARIES) - 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( THREADS_FOUND ) - libraries_absolute_path(CMAKE_THREAD_LIBS_INIT "") - endif () - - 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() - - if (BLA_F95) - set(LAPACK_mkl_SEARCH_SYMBOL "cheev_f95") - 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(BLA_F95) - set(LAPACK_mkl_SEARCH_SYMBOL "cheev") - set(_LIBRARIES LAPACK_LIBRARIES) - set(_BLAS_LIBRARIES ${BLAS_LIBRARIES}) - - # old - list(APPEND LAPACK_SEARCH_LIBS "mkl_lapack") - endif(BLA_F95) - - # 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};${LDL}" - ) - if(_LIBRARIES) - set(LAPACK_LDFLAGS_OTHER "${additional_flags}") - endif() - 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};${LDL}" - ) - if(_LIBRARIES) - set(LAPACK_LDFLAGS_OTHER "${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(NOT LAPACK_FIND_QUIETLY) - if(${_LIBRARIES}) - set (LAPACK_VENDOR_FOUND "Intel MKL") - endif() - - endif (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX) - endif(NOT LAPACK_LIBRARIES) - endif(LAP_VENDOR MATCHES "Intel" OR LAP_VENDOR STREQUAL "All") - - if (BLA_VENDOR MATCHES "ARMPL*" OR BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES OR BLA_VENDOR MATCHES "ARMPL*") - # Looking for include - # ------------------- - - # Add system include paths to search include - # ------------------------------------------ - unset(_inc_env) - set(ENV_ARMPL "$ENV{ARMPL_DIR}") - set(ENV_LAPACK_DIR "$ENV{LAPACK_DIR}") - set(ENV_LAPACK_INCDIR "$ENV{LAPACK_INCDIR}") - if(ENV_LAPACK_INCDIR) - list(APPEND _inc_env "${ENV_LAPACK_INCDIR}") - elseif(ENV_LAPACK_DIR) - list(APPEND _inc_env "${ENV_LAPACK_DIR}") - list(APPEND _inc_env "${ENV_LAPACK_DIR}/include") - else() - if (ENV_ARMPL) - list(APPEND _inc_env "${ENV_ARMPL}/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_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 armpl header in the given paths - # ------------------------------------------------- - # call cmake macro to find the header path - if(LAPACK_INCDIR) - set(LAPACK_armpl.h_DIRS "LAPACK_armpl.h_DIRS-NOTFOUND") - find_path(LAPACK_armpl.h_DIRS - NAMES armpl.h - HINTS ${LAPACK_INCDIR} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - if(LAPACK_DIR) - set(LAPACK_armpl.h_DIRS "LAPACK_armpl.h_DIRS-NOTFOUND") - find_path(LAPACK_armpl.h_DIRS - NAMES armpl.h - HINTS ${LAPACK_DIR} - PATH_SUFFIXES "include" - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - set(LAPACK_armpl.h_DIRS "LAPACK_armpl.h_DIRS-NOTFOUND") - find_path(LAPACK_armpl.h_DIRS - NAMES armpl.h - HINTS ${PATH_TO_LOOK_FOR}) - endif() - endif() - mark_as_advanced(LAPACK_armpl.h_DIRS) - - # If found, add path to cmake variable - # ------------------------------------ - if (LAPACK_armpl.h_DIRS) - set(LAPACK_INCLUDE_DIRS "${LAPACK_armpl.h_DIRS}") - else () - set(LAPACK_INCLUDE_DIRS "LAPACK_INCLUDE_DIRS-NOTFOUND") - if(NOT LAPACK_FIND_QUIETLY) - message(STATUS "Looking for LAPACK -- armpl.h not found") - endif() - endif() - - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "armpl" - "${BLAS_LIBRARIES}" - "" - ) - endif() - if(NOT LAPACK_FIND_QUIETLY) - if(LAPACK_LIBRARIES) - message(STATUS "Looking for ARMPL LAPACK: found") - else() - message(STATUS "Looking for ARMPL LAPACK: not found") - endif() - endif() - if (LAPACK_LIBRARIES) - set (LAPACK_VENDOR_FOUND "ARMPL") - endif() - endif (NOT LAPACK_LIBRARIES OR BLA_VENDOR MATCHES "ARMPL*") - endif (BLA_VENDOR MATCHES "ARMPL*" OR BLA_VENDOR STREQUAL "All") - - # FLAME's blis library? (https://github.com/flame/blis) - if(BLA_VENDOR STREQUAL "FLAME" OR BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES OR BLA_VENDOR MATCHES "FLAME") - # Looking for include - # ------------------- - - # Add system include paths to search include - # ------------------------------------------ - unset(_inc_env) - set(ENV_FLAME "$ENV{FLAME_DIR}") - set(ENV_LAPACK_DIR "$ENV{LAPACK_DIR}") - set(ENV_LAPACK_INCDIR "$ENV{LAPACK_INCDIR}") - if(ENV_LAPACK_INCDIR) - list(APPEND _inc_env "${ENV_LAPACK_INCDIR}") - elseif(ENV_LAPACK_DIR) - list(APPEND _inc_env "${ENV_LAPACK_DIR}") - list(APPEND _inc_env "${ENV_LAPACK_DIR}/include") - else() - if (ENV_FLAME) - list(APPEND _inc_env "${ENV_FLAME}/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_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 FLAME header in the given paths - # ------------------------------------------------- - # call cmake macro to find the header path - if(LAPACK_INCDIR) - set(LAPACK_FLAME.h_DIRS "LAPACK_FLAME.h_DIRS-NOTFOUND") - find_path(LAPACK_FLAME.h_DIRS - NAMES FLAME.h - HINTS ${LAPACK_INCDIR} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - if(LAPACK_DIR) - set(LAPACK_FLAME.h_DIRS "LAPACK_FLAME.h_DIRS-NOTFOUND") - find_path(LAPACK_FLAME.h_DIRS - NAMES FLAME.h - HINTS ${LAPACK_DIR} - PATH_SUFFIXES "include" - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - set(LAPACK_FLAME.h_DIRS "LAPACK_FLAME.h_DIRS-NOTFOUND") - find_path(LAPACK_FLAME.h_DIRS - NAMES FLAME.h - HINTS ${PATH_TO_LOOK_FOR}) - endif() - endif() - mark_as_advanced(LAPACK_FLAME.h_DIRS) - - # If found, add path to cmake variable - # ------------------------------------ - if (LAPACK_FLAME.h_DIRS) - set(LAPACK_INCLUDE_DIRS "${LAPACK_FLAME.h_DIRS}") - else () - set(LAPACK_INCLUDE_DIRS "LAPACK_INCLUDE_DIRS-NOTFOUND") - if(NOT LAPACK_FIND_QUIETLY) - message(STATUS "Looking for LAPACK -- FLAME.h not found") - endif() - endif() - - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "flame" - "${BLAS_LIBRARIES}" - "" - ) - endif() - if(NOT LAPACK_FIND_QUIETLY) - if(LAPACK_LIBRARIES) - message(STATUS "Looking for FLAME LAPACK: found") - else() - message(STATUS "Looking for FLAME LAPACK: not found") - endif() - endif() - if (LAPACK_LIBRARIES) - set (LAPACK_VENDOR_FOUND "FLAME") - endif() - endif(NOT LAPACK_LIBRARIES OR BLA_VENDOR MATCHES "FLAME") - endif(BLA_VENDOR STREQUAL "FLAME" OR BLA_VENDOR STREQUAL "All") - - #goto lapack - if (LAP_VENDOR STREQUAL "Goto" OR LAP_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() - if (LAPACK_LIBRARIES) - set (LAPACK_VENDOR_FOUND "Goto") - endif() - endif(NOT LAPACK_LIBRARIES) - endif (LAP_VENDOR STREQUAL "Goto" OR LAP_VENDOR STREQUAL "All") - - #open lapack - if (LAP_VENDOR STREQUAL "Open" OR LAP_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - - # Looking for include - # ------------------- - - # Add system include paths to search include - # ------------------------------------------ - unset(_inc_env) - set(ENV_OPENBLAS "$ENV{OPENBLAS_DIR}") - set(ENV_LAPACK_DIR "$ENV{LAPACK_DIR}") - set(ENV_LAPACK_INCDIR "$ENV{LAPACK_INCDIR}") - if(ENV_LAPACK_INCDIR) - list(APPEND _inc_env "${ENV_LAPACK_INCDIR}") - elseif(ENV_LAPACK_DIR) - list(APPEND _inc_env "${ENV_LAPACK_DIR}") - list(APPEND _inc_env "${ENV_LAPACK_DIR}/include") - else() - if (ENV_OPENBLAS) - list(APPEND _inc_env "${ENV_OPENBLAS}/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_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 openblas header in the given paths - # -------------------------------------------------- - # call cmake macro to find the header path - if(LAPACK_INCDIR) - set(LAPACK_lapacke.h_DIRS "LAPACK_lapacke.h_DIRS-NOTFOUND") - find_path(LAPACK_lapacke.h_DIRS - NAMES lapacke.h - HINTS ${LAPACK_INCDIR} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - if(LAPACK_DIR) - set(LAPACK_lapacke.h_DIRS "LAPACK_lapacke.h_DIRS-NOTFOUND") - find_path(LAPACK_lapacke.h_DIRS - NAMES lapacke.h - HINTS ${LAPACK_DIR} - PATH_SUFFIXES "include" - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - set(LAPACK_lapacke.h_DIRS "LAPACK_lapacke.h_DIRS-NOTFOUND") - find_path(LAPACK_lapacke.h_DIRS - NAMES lapacke.h - HINTS ${PATH_TO_LOOK_FOR}) - endif() - endif() - mark_as_advanced(LAPACK_lapacke.h_DIRS) - - # If found, add path to cmake variable - # ------------------------------------ - if (LAPACK_lapacke.h_DIRS) - set(LAPACK_INCLUDE_DIRS "${LAPACK_lapacke.h_DIRS}") - else () - set(LAPACK_INCLUDE_DIRS "LAPACK_INCLUDE_DIRS-NOTFOUND") - if(NOT LAPACK_FIND_QUIETLY) - message(STATUS "Looking for LAPACK -- lapacke.h not found") - endif() - endif() - - 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() - if (LAPACK_LIBRARIES) - set (LAPACK_VENDOR_FOUND "Openblas") - endif() - endif(NOT LAPACK_LIBRARIES) - endif (LAP_VENDOR STREQUAL "Open" OR LAP_VENDOR STREQUAL "All") - - # LAPACK in IBM ESSL library (requires generic lapack lib, too) - if (LAP_VENDOR STREQUAL "IBMESSL" OR LAP_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheevd - "" - "essl" - "${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() - if (LAPACK_LIBRARIES) - set (LAPACK_VENDOR_FOUND "IBM ESSL") - endif() - endif() - endif () - - # LAPACK in IBM ESSL_MT library (requires generic lapack lib, too) - if (LAP_VENDOR STREQUAL "IBMESSLMT" OR LAP_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheevd - "" - "esslsmp" - "${BLAS_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() - if (LAPACK_LIBRARIES) - set (LAPACK_VENDOR_FOUND "IBM ESSL MT") - endif() - endif() - endif () - - #acml lapack - if (LAP_VENDOR MATCHES "ACML.*" OR LAP_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() - if (LAPACK_LIBRARIES) - set (LAPACK_VENDOR_FOUND "ACML") - endif() - endif () - endif () - - # Apple LAPACK library? - if (LAP_VENDOR STREQUAL "Apple" OR LAP_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() - if (LAPACK_LIBRARIES) - set (LAPACK_VENDOR_FOUND "Apple Accelerate") - endif() - endif(NOT LAPACK_LIBRARIES) - endif (LAP_VENDOR STREQUAL "Apple" OR LAP_VENDOR STREQUAL "All") - - if (LAP_VENDOR STREQUAL "NAS" OR LAP_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() - if (LAPACK_LIBRARIES) - set (LAPACK_VENDOR_FOUND "NAS") - endif() - endif ( NOT LAPACK_LIBRARIES ) - endif (LAP_VENDOR STREQUAL "NAS" OR LAP_VENDOR STREQUAL "All") - - # Generic LAPACK library? - if (LAP_VENDOR STREQUAL "Generic" OR - LAP_VENDOR STREQUAL "ATLAS" OR - LAP_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() - if (LAPACK_LIBRARIES) - set (LAPACK_VENDOR_FOUND "Netlib or other Generic liblapack") - endif() - endif ( NOT LAPACK_LIBRARIES ) - endif () - - # LAPACK given user, we need to test it - if (LAP_VENDOR STREQUAL "User" AND LAPACK_LIBRARIES_USER) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "${LAPACK_LIBRARIES_USER}" - "${BLAS_LIBRARIES}" - "" - ) - if(NOT LAPACK_FIND_QUIETLY) - if(LAPACK_LIBRARIES) - message(STATUS "Looking for User's LAPACK: found") - else() - message(STATUS "Looking for User's LAPACK: not found") - endif() - endif() - if (LAPACK_LIBRARIES) - set (LAPACK_VENDOR_FOUND "User") - endif() - endif(LAP_VENDOR STREQUAL "User" AND LAPACK_LIBRARIES_USER) - - endif( (NOT LAPACK_FOUND_WITH_PKGCONFIG) OR LAPACK_GIVEN_BY_USER ) - -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 "LAP_VENDOR has been set to ${LAP_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 -DLAP_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 "LAP_VENDOR has been set to ${LAP_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 -DLAP_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) - # first lib may be -Wl,--start-group (MKL) which is not a lib - if (NOT EXISTS ${first_lib}) - list(GET LAPACK_LIBRARIES 1 first_lib) - endif() - get_filename_component(first_lib_path "${first_lib}" PATH) - if (NOT LAPACK_LIBRARY_DIRS) - set(LAPACK_LIBRARY_DIRS "${first_lib_path}") - endif() - 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() - set(LAPACK_CFLAGS_OTHER_DEP "${LAPACK_CFLAGS_OTHER}" "${BLAS_CFLAGS_OTHER}") - set(LAPACK_LDFLAGS_OTHER_DEP "${LAPACK_LDFLAGS_OTHER}" "${BLAS_LDFLAGS_OTHER}") - set(LAPACK_INCLUDE_DIRS_DEP "${LAPACK_INCLUDE_DIRS}" "${BLAS_INCLUDE_DIRS}") - set(LAPACK_LIBRARY_DIRS_DEP "${LAPACK_LIBRARY_DIRS}" "${BLAS_LIBRARY_DIRS}") - set(LAPACK_LIBRARIES_DEP "${LAPACK_LIBRARIES}" "${BLAS_LIBRARIES}") - list(REMOVE_DUPLICATES LAPACK_CFLAGS_OTHER_DEP) - list(REMOVE_DUPLICATES LAPACK_LDFLAGS_OTHER_DEP) - list(REMOVE_DUPLICATES LAPACK_INCLUDE_DIRS_DEP) - list(REMOVE_DUPLICATES LAPACK_LIBRARY_DIRS_DEP) - -endif() - -if(LAPACK_FOUND) - if(NOT TARGET lapack::lapack AND LAPACK_LIBRARIES) - add_library(lapack::lapack INTERFACE IMPORTED) - set_property(TARGET lapack::lapack APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${LAPACK_LDFLAGS_OTHER}") - set_property(TARGET lapack::lapack APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${LAPACK_LIBRARIES}") - set_property(TARGET lapack::lapack APPEND PROPERTY INTERFACE_COMPILE_OPTIONS "${LAPACK_CFLAGS_OTHER}") - set_property(TARGET lapack::lapack APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${LAPACK_INCLUDE_DIRS}") - set_property(TARGET lapack::lapack APPEND PROPERTY INTERFACE_LINK_DIRECTORIES "${LAPACK_LYBRARY_DIRS}") - message(STATUS "Morse : target lapack::lapack available") - endif() - - if(NOT TARGET lapack::lapack_seq AND LAPACK_LIBRARIES_SEQ) - add_library(lapack::lapack_seq INTERFACE IMPORTED) - set_property(TARGET lapack::lapack_seq APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${LAPACK_LDFLAGS_OTHER}") - set_property(TARGET lapack::lapack_seq APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${LAPACK_LIBRARIES_SEQ}") - set_property(TARGET lapack::lapack_seq APPEND PROPERTY INTERFACE_COMPILE_OPTIONS "${LAPACK_CFLAGS_OTHER}") - set_property(TARGET lapack::lapack_seq APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${LAPACK_INCLUDE_DIRS}") - set_property(TARGET lapack::lapack_seq APPEND PROPERTY INTERFACE_LINK_DIRECTORIES "${LAPACK_LYBRARY_DIRS}") - if (NOT LAPACK_FIND_QUIETLY) - message(STATUS "Morse : target lapack::lapack_seq available") - endif() - endif() - - if(NOT TARGET lapack::lapack_par AND LAPACK_LIBRARIES_PAR) - add_library(lapack::lapack_par INTERFACE IMPORTED) - set_property(TARGET lapack::lapack_par APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${LAPACK_LDFLAGS_OTHER}") - set_property(TARGET lapack::lapack_par APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${LAPACK_LIBRARIES_PAR}") - set_property(TARGET lapack::lapack_par APPEND PROPERTY INTERFACE_COMPILE_OPTIONS "${LAPACK_CFLAGS_OTHER}") - set_property(TARGET lapack::lapack_par APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${LAPACK_INCLUDE_DIRS}") - set_property(TARGET lapack::lapack_par APPEND PROPERTY INTERFACE_LINK_DIRECTORIES "${LAPACK_LYBRARY_DIRS}") - if (NOT LAPACK_FIND_QUIETLY) - message(STATUS "Morse : target lapack::lapack_par available") - endif() - endif() - - if(NOT TARGET lapack::lapack_dep AND LAPACK_LIBRARIES_DEP) - add_library(lapack::lapack_dep INTERFACE IMPORTED) - set_property(TARGET lapack::lapack_dep APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${LAPACK_LDFLAGS_OTHER_DEP}") - set_property(TARGET lapack::lapack_dep APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${LAPACK_LIBRARIES_DEP}") - set_property(TARGET lapack::lapack_dep APPEND PROPERTY INTERFACE_COMPILE_OPTIONS "${LAPACK_CFLAGS_OTHER_DEP}") - set_property(TARGET lapack::lapack_dep APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${LAPACK_INCLUDE_DIRS_DEP}") - set_property(TARGET lapack::lapack_dep APPEND PROPERTY INTERFACE_LINK_DIRECTORIES "${LAPACK_LYBRARY_DIRS_DEP}") - if (NOT LAPACK_FIND_QUIETLY) - message(STATUS "Morse : target lapack::lapack_dep available") - endif() - endif() -endif() - -mark_as_advanced(LAPACK_DIR) -mark_as_advanced(LAPACK_DIR_FOUND) diff --git a/modules/find/FindLAPACKE.cmake b/modules/find/FindLAPACKE.cmake index 3d06f2ece141e54de46da3dbb9882ce9e2e511b6..d633ac8a0c1c42314002c71c20524d0a5219795e 100644 --- a/modules/find/FindLAPACKE.cmake +++ b/modules/find/FindLAPACKE.cmake @@ -1,11 +1,22 @@ ### # -# @copyright (c) 2009-2014 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. # @copyright (c) 2012-2020 Inria. All rights reserved. # @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. # +# Copyright 2012-2013 Emmanuel Agullo +# Copyright 2012-2013 Mathieu Faverge +# Copyright 2012 Cedric Castagnede +# Copyright 2013-2020 Florent Pruvost +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file MORSE-Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of Morse, substitute the full +# License text for the above reference.) ### # # - Find LAPACKE include dirs and libraries @@ -23,22 +34,9 @@ # COMPONENTS can be some of the following: # - TMG: to check that LAPACKE provides the tmglib interface # -# This module finds headers and lapacke library. -# Results are reported in variables: -# LAPACKE_FOUND - True if headers and requested libraries were found -# LAPACKE_CFLAGS_OTHER - lapacke compiler flags without headers paths -# LAPACKE_LDFLAGS_OTHER - lapacke linker flags without libraries -# LAPACKE_INCLUDE_DIRS - lapacke include directories -# LAPACKE_LIBRARY_DIRS - lapacke link directories -# LAPACKE_LIBRARIES - lapacke libraries to be linked (absolute path) -# LAPACKE_CFLAGS_OTHER_DEP - lapacke + dependencies compiler flags without headers paths -# LAPACKE_LDFLAGS_OTHER_DEP - lapacke + dependencies linker flags without libraries -# LAPACKE_INCLUDE_DIRS_DEP - lapacke + dependencies include directories -# LAPACKE_LIBRARY_DIRS_DEP - lapacke + dependencies link directories -# LAPACKE_LIBRARIES_DEP - lapacke + dependencies libraries -# # LAPACKE_FOUND_WITH_PKGCONFIG - True if found with pkg-config -# if found with pkg-config the following variables may be set +# if found the following variables may be set +# LAPACKE_PREFIX - installation path of the lib found # <PREFIX> = LAPACKE # <XPREFIX> = <PREFIX> for common case # <XPREFIX> = <PREFIX>_STATIC for static linking @@ -51,6 +49,13 @@ # <XPREFIX>_CFLAGS ... all required cflags # <XPREFIX>_CFLAGS_OTHER ... the other compiler flags # +# Set LAPACKE_STATIC to 1 to force using static libraries if exist. +# +# This module defines the following :prop_tgt:`IMPORTED` target: +# +# ``MORSE::LAPACKE`` +# The headers and libraries to use for LAPACKE, if found. +# # The user can give specific paths where to find the libraries adding cmake # options at configure (ex: cmake path/to/project -DLAPACKE_DIR=path/to/lapacke): # LAPACKE_DIR - Where to find the base directory of lapacke @@ -65,24 +70,9 @@ # look for a stand alone lapacke, please set LAPACKE_STANDALONE to TRUE #============================================================================= -# Copyright 2012-2019 Inria -# Copyright 2012-2013 Emmanuel Agullo -# Copyright 2012-2013 Mathieu Faverge -# Copyright 2012 Cedric Castagnede -# Copyright 2013-2018 Florent Pruvost -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file MORSE-Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of Morse, substitute the full -# License text for the above reference.) # Common macros to use in finds -include(FindInit) +include(FindMorseInit) if (NOT LAPACKE_FOUND) set(LAPACKE_DIR "" CACHE PATH "Installation directory of LAPACKE library") @@ -123,9 +113,9 @@ if (LAPACK_FOUND) if (NOT LAPACKE_STANDALONE) # check if a lapacke function exists in the LAPACK lib include(CheckFunctionExists) - set(CMAKE_REQUIRED_LIBRARIES "${LAPACK_LDFLAGS_OTHER_DEP};${LAPACK_LIBRARIES_DEP}") - set(CMAKE_REQUIRED_INCLUDES "${LAPACK_INCLUDE_DIRS_DEP}") - set(CMAKE_REQUIRED_FLAGS "${LAPACK_CFLAGS_OTHER_DEP}") + set(CMAKE_REQUIRED_LIBRARIES "${LAPACK_LDFLAGS_OTHER};${LAPACK_LIBRARIES}") + set(CMAKE_REQUIRED_INCLUDES "${LAPACK_INCLUDE_DIRS}") + set(CMAKE_REQUIRED_FLAGS "${LAPACK_CFLAGS_OTHER}") unset(LAPACKE_WORKS CACHE) check_function_exists(LAPACKE_dgeqrf LAPACKE_WORKS) mark_as_advanced(LAPACKE_WORKS) @@ -144,6 +134,77 @@ if (LAPACK_FOUND) set(LAPACKE_CFLAGS_OTHER "${LAPACK_CFLAGS_OTHER}") set(LAPACKE_LIBRARY_DIRS "${LAPACK_LIBRARY_DIRS}") set(LAPACKE_LDFLAGS_OTHER "${LAPACK_LDFLAGS_OTHER}") + + if (NOT LAPACKE_INCLUDE_DIRS) + # 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_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} + NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) + 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" + NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) + 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() + endif() endif() endif (NOT LAPACKE_STANDALONE) @@ -164,8 +225,6 @@ if (LAPACK_FOUND) set(LAPACKE_GIVEN_BY_USER "TRUE") endif() - include(FindPkgConfig) - find_package(PkgConfig QUIET) if( PKG_CONFIG_EXECUTABLE AND NOT LAPACKE_GIVEN_BY_USER) if (BLA_STATIC) @@ -200,11 +259,22 @@ if (LAPACK_FOUND) if (LAPACKE_FOUND AND LAPACKE_LIBRARIES) set(LAPACKE_FOUND_WITH_PKGCONFIG "TRUE") - find_pkgconfig_libraries_absolute_path(LAPACKE) + morse_find_pkgconfig_libraries_absolute_path(LAPACKE) else() set(LAPACKE_FOUND_WITH_PKGCONFIG "FALSE") endif() + if (LAPACKE_STATIC AND LAPACKE_STATIC_LIBRARIES) + set (LAPACKE_DEPENDENCIES ${LAPACKE_STATIC_LIBRARIES}) + list (REMOVE_ITEM LAPACKE_DEPENDENCIES "lapacke") + list (APPEND LAPACKE_LIBRARIES ${LAPACKE_DEPENDENCIES}) + set(LAPACKE_CFLAGS_OTHER ${LAPACKE_STATIC_CFLAGS_OTHER}) + set(LAPACKE_LDFLAGS_OTHER ${LAPACKE_STATIC_LDFLAGS_OTHER}) + if (NOT LAPACKE_FIND_QUIETLY) + message(STATUS "LAPACKE_STATIC set to 1 by user, LAPACKE_LIBRARIES: ${LAPACKE_LIBRARIES}.") + endif() + endif() + endif() if (NOT LAPACKE_FOUND_WITH_PKGCONFIG OR LAPACKE_GIVEN_BY_USER) @@ -311,6 +381,11 @@ if (LAPACK_FOUND) # Try to find the lapacke lib in the given paths # ---------------------------------------------- + if (LAPACKE_STATIC) + set (CMAKE_FIND_LIBRARY_SUFFIXES_COPY ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set (CMAKE_FIND_LIBRARY_SUFFIXES ".a") + endif() + # call cmake macro to find the lib path if(LAPACKE_LIBDIR) set(LAPACKE_lapacke_LIBRARY "LAPACKE_lapacke_LIBRARY-NOTFOUND") @@ -335,6 +410,10 @@ if (LAPACK_FOUND) endif() mark_as_advanced(LAPACKE_lapacke_LIBRARY) + if (LAPACKE_STATIC) + set (CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_COPY}) + endif() + # If found, add path to cmake variable # ------------------------------------ if (LAPACKE_lapacke_LIBRARY) @@ -357,11 +436,17 @@ if (LAPACK_FOUND) # check a function to validate the find if(LAPACKE_LIBRARIES) + # check if static or dynamic lib + morse_check_static_or_dynamic(LAPACKE LAPACKE_LIBRARIES) + if(LAPACKE_STATIC) + set(STATIC "_STATIC") + endif() + set(REQUIRED_INCDIRS) - set(REQUIRED_FLAGS) - set(REQUIRED_LDFLAGS) set(REQUIRED_LIBDIRS) set(REQUIRED_LIBS) + set(REQUIRED_FLAGS) + set(REQUIRED_LDFLAGS) # LAPACKE if (LAPACKE_INCLUDE_DIRS) @@ -379,34 +464,34 @@ if (LAPACK_FOUND) set(REQUIRED_LIBS "${LAPACKE_LIBRARIES}") # TMG if (LAPACKE_WITH_TMG) - if (TMG_INCLUDE_DIRS_DEP) - list(APPEND REQUIRED_INCDIRS "${TMG_INCLUDE_DIRS_DEP}") + if (TMG_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${TMG_INCLUDE_DIRS}") endif() - if (TMG_CFLAGS_OTHER_DEP) - list(APPEND REQUIRED_FLAGS "${TMG_CFLAGS_OTHER_DEP}") + if (TMG_CFLAGS_OTHER) + list(APPEND REQUIRED_FLAGS "${TMG_CFLAGS_OTHER}") endif() - if (TMG_LDFLAGS_OTHER_DEP) - list(APPEND REQUIRED_LDFLAGS "${TMG_LDFLAGS_OTHER_DEP}") + if (TMG_LDFLAGS_OTHER) + list(APPEND REQUIRED_LDFLAGS "${TMG_LDFLAGS_OTHER}") endif() - if (TMG_LIBRARY_DIRS_DEP) - list(APPEND REQUIRED_LIBDIRS "${TMG_LIBRARY_DIRS_DEP}") + if (TMG_LIBRARY_DIRS) + list(APPEND REQUIRED_LIBDIRS "${TMG_LIBRARY_DIRS}") endif() - list(APPEND REQUIRED_LIBS "${TMG_LIBRARIES_DEP}") + list(APPEND REQUIRED_LIBS "${TMG_LIBRARIES}") endif() # LAPACK - if (LAPACK_INCLUDE_DIRS_DEP) - list(APPEND REQUIRED_INCDIRS "${LAPACK_INCLUDE_DIRS_DEP}") + if (LAPACK_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${LAPACK_INCLUDE_DIRS}") endif() - if (LAPACK_CFLAGS_OTHER_DEP) - list(APPEND REQUIRED_FLAGS "${LAPACK_CFLAGS_OTHER_DEP}") + if (LAPACK_CFLAGS_OTHER) + list(APPEND REQUIRED_FLAGS "${LAPACK_CFLAGS_OTHER}") endif() - if (LAPACK_LDFLAGS_OTHER_DEP) - list(APPEND REQUIRED_LDFLAGS "${LAPACK_LDFLAGS_OTHER_DEP}") + if (LAPACK_LDFLAGS_OTHER) + list(APPEND REQUIRED_LDFLAGS "${LAPACK_LDFLAGS_OTHER}") endif() - if (LAPACK_LIBRARY_DIRS_DEP) - list(APPEND REQUIRED_LIBDIRS "${LAPACK_LIBRARY_DIRS_DEP}") + if (LAPACK_LIBRARY_DIRS) + list(APPEND REQUIRED_LIBDIRS "${LAPACK_LIBRARY_DIRS}") endif() - list(APPEND REQUIRED_LIBS "${LAPACK_LIBRARIES_DEP}") + list(APPEND REQUIRED_LIBS "${LAPACK_LIBRARIES}") # m find_library(M_LIBRARY NAMES m HINTS ${_lib_env}) mark_as_advanced(M_LIBRARY) @@ -427,7 +512,7 @@ if (LAPACK_FOUND) list(APPEND REQUIRED_FLAGS "${_flag}") endforeach() endif() - finds_remove_duplicates() + morse_finds_remove_duplicates() set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) @@ -455,12 +540,14 @@ if (LAPACK_FOUND) mark_as_advanced(LAPACKE_WITH_LASCL) 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_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}") - set(LAPACKE_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}") + set(LAPACKE_LIBRARY_DIRS "${REQUIRED_LIBDIRS}") + set(LAPACKE_INCLUDE_DIRS "${REQUIRED_INCDIRS}") + if (LAPACKE_STATIC OR CBLAS_STATIC OR BLA_STATIC) + # save link with dependencies + set(LAPACKE_LIBRARIES "${REQUIRED_LIBS}") + set(LAPACKE_CFLAGS_OTHER "${REQUIRED_FLAGS}") + set(LAPACKE_LDFLAGS_OTHER "${REQUIRED_LDFLAGS}") + endif() else() if(NOT LAPACKE_FIND_QUIETLY) message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") @@ -472,6 +559,26 @@ if (LAPACK_FOUND) set(CMAKE_REQUIRED_INCLUDES) set(CMAKE_REQUIRED_FLAGS) set(CMAKE_REQUIRED_LIBRARIES) + + list(GET LAPACKE_LIBRARIES 0 first_lib) + get_filename_component(first_lib_path "${first_lib}" DIRECTORY) + if (NOT LAPACKE_LIBRARY_DIRS) + set(LAPACKE_LIBRARY_DIRS "${first_lib_path}") + endif() + 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_PREFIX "${not_cached_dir}" CACHE PATH "Installation directory of LAPACKE library" FORCE) + else() + set(LAPACKE_PREFIX "${first_lib_path}" CACHE PATH "Installation directory of LAPACKE library" FORCE) + endif() + if (NOT LAPACKE_INCLUDE_DIRS) + if (EXISTS "${LAPACKE_PREFIX}/include") + set(LAPACKE_INCLUDE_DIRS "${LAPACKE_PREFIX}/include") + endif() + endif() + mark_as_advanced(LAPACKE_DIR) + mark_as_advanced(LAPACKE_PREFIX) + endif(LAPACKE_LIBRARIES) else(LAPACK_FOUND) @@ -483,25 +590,14 @@ else(LAPACK_FOUND) endif(LAPACK_FOUND) -if (LAPACKE_LIBRARIES) - list(GET LAPACKE_LIBRARIES 0 first_lib) - get_filename_component(first_lib_path "${first_lib}" PATH) - if (NOT LAPACKE_LIBRARY_DIRS) - set(LAPACKE_LIBRARY_DIRS "${first_lib_path}") - endif() - 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) - # check that LAPACKE has been found # --------------------------------- include(FindPackageHandleStandardArgs) find_package_handle_standard_args(LAPACKE DEFAULT_MSG LAPACKE_LIBRARIES LAPACKE_WORKS) + +# Add imported target +if (LAPACKE_FOUND) + morse_create_imported_target(LAPACKE) +endif() diff --git a/modules/find/FindLAPACKEXT.cmake b/modules/find/FindLAPACKEXT.cmake deleted file mode 100644 index e869f1b589072d9b59c68c254e9908d9cb2845fe..0000000000000000000000000000000000000000 --- a/modules/find/FindLAPACKEXT.cmake +++ /dev/null @@ -1,336 +0,0 @@ -### -# -# @copyright (c) 2009-2014 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. -# @copyright (c) 2012-2019 Inria. All rights reserved. -# @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. -# -### -# -# - Find LAPACK EXTENDED for MORSE projects: find include dirs and libraries -# -# This module allows to find LAPACK libraries by calling the official FindLAPACK module -# and handles the creation of different library lists whether the user wishes to link -# with a sequential LAPACK or a multihreaded (LAPACK_SEQ_LIBRARIES and LAPACK_PAR_LIBRARIES). -# LAPACK is detected with a FindLAPACK call and if the BLAS vendor is in the following list, -# Intel mkl, ACML then the module tries find the corresponding multithreaded libraries -# -# The following variables have been added to manage links with sequential or multithreaded -# versions: -# LAPACK_INCLUDE_DIRS - LAPACK include directories -# LAPACK_LIBRARY_DIRS - Link directories for LAPACK libraries -# LAPACK_SEQ_LIBRARIES - LAPACK component libraries to be linked (sequential) -# LAPACK_PAR_LIBRARIES - LAPACK component libraries to be linked (multithreaded) -# LAPACKEXT_FOUND - if a LAPACK has been found -# LAPACKEXT_LIBRARIES - Idem LAPACK_LIBRARIES -# LAPACKEXT_INCLUDE_DIRS - Idem LAPACK_INCLUDE_DIRS -# LAPACKEXT_LIBRARY_DIRS - Idem LAPACK_LIBRARY_DIRS - -#============================================================================= -# Copyright 2012-2019 Inria -# Copyright 2012-2013 Emmanuel Agullo -# Copyright 2012-2013 Mathieu Faverge -# Copyright 2012 Cedric Castagnede -# Copyright 2013-2018 Florent Pruvost -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file MORSE-Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of Morse, substitute the full -# License text for the above reference.) - -# Macro to factorize this call. required arguments allows to decide if -# the REQUIRED option must be given to find_package calls -macro(find_package_lapack required) - if(LAPACKEXT_FIND_REQUIRED AND required) - if(LAPACKEXT_FIND_QUIETLY) - find_package(LAPACK REQUIRED QUIET) - else() - find_package(LAPACK REQUIRED) - endif() - else() - if(LAPACKEXT_FIND_QUIETLY) - find_package(LAPACK QUIET) - else() - find_package(LAPACK) - endif() - endif() -endmacro() - -# LAPACKEXT depends on BLAS -if(LAPACKEXT_FIND_QUIETLY) - find_package(BLASEXT QUIET) -else() - find_package(BLASEXT) -endif() - -if(NOT LAPACKEXT_FIND_QUIETLY) - message(STATUS "In FindLAPACKEXT") -endif() - -if(BLA_VENDOR MATCHES "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_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} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - if(LAPACK_DIR) - find_path(LAPACK_mkl_lapack.h_INCLUDE_DIRS - NAMES mkl_lapack.h - HINTS ${LAPACK_DIR} - PATH_SUFFIXES include - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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}" ) - endif() - - ### - # look for libs - ### - - if (BLA_VENDOR MATCHES "Intel10_64lp*") - ## look for the sequential version - set(BLA_VENDOR "Intel10_64lp_seq") - endif() - find_package_lapack(0) - - 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(0) - - 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(0) - - 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(0) - - 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_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(0) - - 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}") -endif() - -# extract libs paths if not given by find_package(LAPACK) -if (NOT LAPACK_LIBRARY_DIRS) - 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}") - 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() - endif() - endforeach() - if (LAPACK_LIBRARY_DIRS) - list(REMOVE_DUPLICATES LAPACK_LIBRARY_DIRS) - endif () -endif (NOT LAPACK_LIBRARY_DIRS) - -# check that LAPACKEXT has been found -# ----------------------------------- -include(FindPackageHandleStandardArgs) -if(BLA_VENDOR MATCHES "Intel*") - if(NOT LAPACKEXT_FIND_QUIETLY) - message(STATUS "LAPACK found is Intel MKL") - message(STATUS "LAPACK sequential libraries stored in LAPACK_SEQ_LIBRARIES") - endif() - find_package_handle_standard_args(LAPACKEXT DEFAULT_MSG - LAPACK_SEQ_LIBRARIES - LAPACK_LIBRARY_DIRS - LAPACK_INCLUDE_DIRS) - if(BLA_VENDOR MATCHES "Intel10_64lp*" AND LAPACK_PAR_LIBRARIES) - if(NOT LAPACKEXT_FIND_QUIETLY) - message(STATUS "LAPACK parallel libraries stored in LAPACK_PAR_LIBRARIES") - endif() - find_package_handle_standard_args(LAPACKEXT DEFAULT_MSG - LAPACK_PAR_LIBRARIES) - endif() -elseif(BLA_VENDOR MATCHES "ACML*") - if(NOT LAPACKEXT_FIND_QUIETLY) - message(STATUS "LAPACK found is ACML") - message(STATUS "LAPACK sequential libraries stored in LAPACK_SEQ_LIBRARIES") - endif() - find_package_handle_standard_args(LAPACKEXT 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(LAPACKEXT DEFAULT_MSG - LAPACK_PAR_LIBRARIES) - endif() -elseif(BLA_VENDOR MATCHES "IBMESSL*") - if(NOT LAPACKEXT_FIND_QUIETLY) - message(STATUS "LAPACK found is IBMESSL") - message(STATUS "LAPACK sequential libraries stored in LAPACK_SEQ_LIBRARIES") - endif() - find_package_handle_standard_args(LAPACKEXT 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(LAPACKEXT 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(LAPACKEXT DEFAULT_MSG - LAPACK_SEQ_LIBRARIES - LAPACK_LIBRARY_DIRS) -endif() - -if (LAPACK_LIBRARIES) - set(LAPACKEXT_LIBRARIES ${LAPACK_LIBRARIES}) -endif() -if (LAPACK_INCLUDE_DIRS) - set(LAPACKEXT_INCLUDE_DIRS ${LAPACK_INCLUDE_DIRS}) -endif() -if (LAPACK_LIBRARY_DIRS) - set(LAPACKEXT_LIBRARY_DIRS ${LAPACK_LIBRARY_DIRS}) -endif() diff --git a/modules/find/FindMAGMA.cmake b/modules/find/FindMAGMA.cmake deleted file mode 100644 index d476e892125558031c39c11d66208a4c4a0d347a..0000000000000000000000000000000000000000 --- a/modules/find/FindMAGMA.cmake +++ /dev/null @@ -1,441 +0,0 @@ -### -# WARNING: not maintained anymore -### -# -# @copyright (c) 2009-2014 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. -# @copyright (c) 2012-2019 Inria. All rights reserved. -# @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. -# -### -# -# - Find MAGMA include dirs and libraries -# Use this module by invoking find_package with the form: -# find_package(MAGMA -# [REQUIRED] # Fail with error if magma is not found -# [COMPONENTS <comp1> <comp2> ...] # dependencies -# ) -# -# MAGMA depends on the following libraries: -# - CUDA/cuBLAS -# - LAPACK -# - CBLAS -# -# COMPONENTS are optional libraries MAGMA could be linked with, -# Use it to drive detection of a specific compilation chain -# COMPONENTS can be some of the following: -# - no components are available for now: maybe PLASMA in the future? -# -# Results are reported in variables: -# MAGMA_FOUND - True if headers and requested libraries were found -# MAGMA_C_FLAGS - list of required compilation flags (excluding -I) -# MAGMA_LINKER_FLAGS - list of required linker flags (excluding -l and -L) -# MAGMA_INCLUDE_DIRS - magma include directories -# MAGMA_LIBRARY_DIRS - Link directories for magma libraries -# MAGMA_LIBRARIES - magma libraries -# MAGMA_INCLUDE_DIRS_DEP - magma + dependencies include directories -# MAGMA_LIBRARY_DIRS_DEP - magma + dependencies link directories -# MAGMA_LIBRARIES_DEP - magma libraries + dependencies -# -# The user can give specific paths where to find the libraries adding cmake -# options at configure (ex: cmake path/to/project -DMAGMA_DIR=path/to/magma): -# MAGMA_DIR - Where to find the base directory of magma -# MAGMA_INCDIR - Where to find the header files -# MAGMA_LIBDIR - Where to find the library files -# The module can also look for the following environment variables if paths -# are not given as cmake variable: MAGMA_DIR, MAGMA_INCDIR, MAGMA_LIBDIR -# -#============================================================================= -# Copyright 2012-2019 Inria -# Copyright 2012-2013 Emmanuel Agullo -# Copyright 2012-2013 Mathieu Faverge -# Copyright 2012 Cedric Castagnede -# Copyright 2013-2016 Florent Pruvost -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file MORSE-Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of Morse, substitute the full -# License text for the above reference.) - -# Common macros to use in finds -include(FindInit) - -if(NOT MAGMA_FOUND) - set(MAGMA_DIR "" CACHE PATH "Installation directory of MAGMA library") - 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(MAGMA_FIND_REQUIRED) - find_package(CUDA REQUIRED) -else() - find_package(CUDA) -endif() -if( CUDA_FOUND ) - libraries_absolute_path(CUDA_LIBRARIES "$ENV{CUDA_ROOT}/lib64") -endif () -# MAGMA depends on cuBLAS which should come with CUDA, if not found -> error -if (NOT CUDA_CUBLAS_LIBRARIES) - if(MAGMA_FIND_REQUIRED) - message(FATAL_ERROR "Looking for MAGMA - MAGMA depends on cuBLAS which has " - "not been found (should come with cuda install)") - endif() -endif() -# MAGMA depends on LAPACK anyway, try to find it -if(MAGMA_FIND_REQUIRED) - find_package(LAPACK REQUIRED) -else() - find_package(LAPACK) -endif() -# MAGMA depends on CBLAS anyway, try to find it -if(MAGMA_FIND_REQUIRED) - find_package(CBLAS REQUIRED) -else() - find_package(CBLAS) -endif() - -set(ENV_MAGMA_DIR "$ENV{MAGMA_DIR}") -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") -endif() - -# Optionally use pkg-config to detect include/library dirs (if pkg-config is available) -# ------------------------------------------------------------------------------------- -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() - 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_STATIC_INCLUDE_DIRS}") - set(MAGMA_LIBRARY_DIRS_DEP "${MAGMA_STATIC_LIBRARY_DIRS}") - set(MAGMA_LIBRARIES_DEP "${MAGMA_STATIC_LIBRARIES}") - set(MAGMA_C_FLAGS "${MAGMA_CFLAGS_OTHER}") - -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() - - # 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") - 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_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} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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" - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - set(MAGMA_magma.h_DIRS "MAGMA_magma.h_DIRS-NOTFOUND") - find_path(MAGMA_magma.h_DIRS - NAMES magma.h - HINTS ${_inc_env}) - endif() - 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() - endif() - - - # 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") - else() - list(APPEND _lib_env "$ENV{LIBRARY_PATH}") - if(WIN32) - string(REPLACE ":" ";" _lib_env2 "$ENV{LIB}") - elseif(APPLE) - string(REPLACE ":" ";" _lib_env2 "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env2 "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${_lib_env2}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - endif() - list(REMOVE_DUPLICATES _lib_env) - - # 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} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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 - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - set(MAGMA_magma_LIBRARY "MAGMA_magma_LIBRARY-NOTFOUND") - find_library(MAGMA_magma_LIBRARY - NAMES magma - HINTS ${_lib_env}) - endif() - 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 () - - # check a function to validate the find - if (MAGMA_LIBRARIES) - - 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}") - finds_remove_duplicates() - # 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) - - 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}") - 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) - set(MAGMA_LIBRARY_DIRS "${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) - -# check that MAGMA has been found -# ------------------------------- -include(FindPackageHandleStandardArgs) -if (PKG_CONFIG_EXECUTABLE AND MAGMA_FOUND) - find_package_handle_standard_args(MAGMA DEFAULT_MSG - MAGMA_LIBRARIES) -else() - find_package_handle_standard_args(MAGMA DEFAULT_MSG - MAGMA_LIBRARIES - MAGMA_WORKS) -endif() diff --git a/modules/find/FindMETIS.cmake b/modules/find/FindMETIS.cmake index d5cb3c98eccb51ba8b52544771d13517aa9aa46f..7ad762811fe2198a32c15acd0a063eb1a7fe2f26 100644 --- a/modules/find/FindMETIS.cmake +++ b/modules/find/FindMETIS.cmake @@ -1,11 +1,23 @@ ### # -# @copyright (c) 2009-2014 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. -# @copyright (c) 2012-2019 Inria. All rights reserved. +# @copyright (c) 2012-2020 Inria. All rights reserved. # @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. # +# Copyright 2012-2013 Emmanuel Agullo +# Copyright 2012-2013 Mathieu Faverge +# Copyright 2012 Cedric Castagnede +# Copyright 2013-2020 Florent Pruvost +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file MORSE-Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of Morse, substitute the full +# License text for the above reference.) +# ### # # - Find METIS include dirs and libraries @@ -17,6 +29,7 @@ # This module finds headers and metis library. # Results are reported in variables: # METIS_FOUND - True if headers and requested libraries were found +# METIS_PREFIX - installation path of the lib found # METIS_INCLUDE_DIRS - metis include directories # METIS_LIBRARY_DIRS - Link directories for metis libraries # METIS_LIBRARIES - metis component libraries to be linked @@ -29,26 +42,18 @@ # METIS_LIBDIR - Where to find the library files # The module can also look for the following environment variables if paths # are not given as cmake variable: METIS_DIR, METIS_INCDIR, METIS_LIBDIR - -#============================================================================= -# Copyright 2012-2019 Inria -# Copyright 2012-2013 Emmanuel Agullo -# Copyright 2012-2013 Mathieu Faverge -# Copyright 2012 Cedric Castagnede -# Copyright 2013 Florent Pruvost # -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file MORSE-Copyright.txt for details. +# Set METIS_STATIC to 1 to force using static libraries if exist. +# +# This module defines the following :prop_tgt:`IMPORTED` target: +# +# ``MORSE::METIS`` +# The headers and libraries to use for METIS, if found. # -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. #============================================================================= -# (To distribute this file outside of Morse, substitute the full -# License text for the above reference.) # Common macros to use in finds -include(FindInit) +include(FindMorseInit) if (NOT METIS_FOUND) set(METIS_DIR "" CACHE PATH "Installation directory of METIS library") @@ -156,6 +161,12 @@ list(REMOVE_DUPLICATES _lib_env) # Try to find the metis lib in the given paths # ---------------------------------------------- + +if (METIS_STATIC) + set (CMAKE_FIND_LIBRARY_SUFFIXES_COPY ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set (CMAKE_FIND_LIBRARY_SUFFIXES ".a") +endif() + # call cmake macro to find the lib path if(METIS_LIBDIR) set(METIS_metis_LIBRARY "METIS_metis_LIBRARY-NOTFOUND") @@ -180,6 +191,9 @@ else() endif() mark_as_advanced(METIS_metis_LIBRARY) +if (METIS_STATIC) + set (CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_COPY}) +endif() # If found, add path to cmake variable # ------------------------------------ @@ -199,30 +213,16 @@ endif () # check a function to validate the find if(METIS_LIBRARIES) - 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 "${M_LIBRARY}") + # check if static or dynamic lib + morse_check_static_or_dynamic(METIS METIS_LIBRARIES) + if(METIS_STATIC) + set(STATIC "_STATIC") + else() + set(STATIC "") endif() - finds_remove_duplicates() + # set required libraries for link - set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") - set(CMAKE_REQUIRED_LIBRARIES) - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + morse_set_required_test_lib_link(METIS) # test link unset(METIS_WORKS CACHE) @@ -242,23 +242,22 @@ if(METIS_LIBRARIES) 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) + get_filename_component(first_lib_path "${first_lib}" DIRECTORY) if (NOT METIS_LIBRARY_DIRS) set(METIS_LIBRARY_DIRS "${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(METIS_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of METIS library" FORCE) + set(METIS_PREFIX "${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) + set(METIS_PREFIX "${first_lib_path}" CACHE PATH "Installation directory of METIS library" FORCE) endif() -endif() -mark_as_advanced(METIS_DIR) -mark_as_advanced(METIS_DIR_FOUND) + mark_as_advanced(METIS_DIR) + mark_as_advanced(METIS_PREFIX) + +endif(METIS_LIBRARIES) # Check the size of METIS_Idx # --------------------------------- @@ -310,6 +309,8 @@ include(FindPackageHandleStandardArgs) find_package_handle_standard_args(METIS DEFAULT_MSG METIS_LIBRARIES METIS_WORKS) -# -# TODO: Add possibility to check for specific functions in the library -# + +# Add imported target +if (METIS_FOUND) + morse_create_imported_target(METIS) +endif() \ No newline at end of file diff --git a/modules/find/FindMUMPS.cmake b/modules/find/FindMUMPS.cmake index 9e8f9a470de26f2dc4e5a7b078555d47199de163..332d05c5ed1c5cc5eae914c929a1acb00da93585 100644 --- a/modules/find/FindMUMPS.cmake +++ b/modules/find/FindMUMPS.cmake @@ -1,11 +1,18 @@ ### # -# @copyright (c) 2009-2014 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. -# @copyright (c) 2012-2019 Inria. All rights reserved. -# @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. +# @copyright (c) 2013-2020 Inria. All rights reserved. # +# Copyright 2013-2020 Florent Pruvost +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file MORSE-Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of Morse, substitute the full +# License text for the above reference.) ### # # - Find MUMPS include dirs and libraries @@ -40,37 +47,23 @@ # MUMPS_INCLUDE_DIRS - mumps include directories # MUMPS_LIBRARY_DIRS - mumps link directories # MUMPS_LIBRARIES - mumps libraries to be linked (absolute path) -# MUMPS_CFLAGS_OTHER_DEP - mumps + dependencies compiler flags without headers paths -# MUMPS_LDFLAGS_OTHER_DEP - mumps + dependencies linker flags without libraries -# MUMPS_INCLUDE_DIRS_DEP - mumps + dependencies include directories -# MUMPS_LIBRARY_DIRS_DEP - mumps + dependencies link directories -# MUMPS_LIBRARIES_DEP - mumps + dependencies libraries +# +# Set MUMPS_STATIC to 1 to force using static libraries if exist. +# +# This module defines the following :prop_tgt:`IMPORTED` target: +# +# ``MORSE::MUMPS`` +# The headers and libraries to use for MUMPS, if found. # # The user can give specific paths where to find the libraries adding cmake # options at configure (ex: cmake path/to/project -DMUMPS_DIR=path/to/mumps): # MUMPS_DIR - Where to find the base directory of mumps # The module can also look for the following environment variables if paths # are not given as cmake variable: MUMPS_DIR - #============================================================================= -# Copyright 2012-2019 Inria -# Copyright 2012-2013 Emmanuel Agullo -# Copyright 2012-2013 Mathieu Faverge -# Copyright 2012 Cedric Castagnede -# Copyright 2013 Florent Pruvost -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file MORSE-Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of Morse, substitute the full -# License text for the above reference.) # Common macros to use in finds -include(FindInit) +include(FindMorseInit) if (NOT MUMPS_FOUND) set(MUMPS_DIR "" CACHE PATH "Installation directory of MUMPS library") @@ -407,6 +400,11 @@ endif() # Looking for lib # --------------- +if (MUMPS_STATIC) + set (CMAKE_FIND_LIBRARY_SUFFIXES_COPY ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set (CMAKE_FIND_LIBRARY_SUFFIXES ".a") +endif() + # create list of libs to find set(MUMPS_libs_to_find "mumps_common;pord") if (MUMPS_LOOK_FOR_SEQ) @@ -454,6 +452,10 @@ else() endif() endif() +if (MUMPS_STATIC) + set (CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_COPY}) +endif() + # If found, add path to cmake variable # ------------------------------------ set(MUMPS_LIBRARIES "") @@ -570,11 +572,17 @@ list(REMOVE_DUPLICATES MUMPS_INCLUDE_DIRS) # check a function to validate the find if(MUMPS_LIBRARIES) + # check if static or dynamic lib + morse_check_static_or_dynamic(MUMPS MUMPS_LIBRARIES) + if(MUMPS_STATIC) + set(STATIC "_STATIC") + endif() + set(REQUIRED_INCDIRS) - set(REQUIRED_FLAGS) - set(REQUIRED_LDFLAGS) set(REQUIRED_LIBDIRS) set(REQUIRED_LIBS) + set(REQUIRED_FLAGS) + set(REQUIRED_LDFLAGS) # MUMPS if (MUMPS_INCLUDE_DIRS) @@ -592,20 +600,20 @@ if(MUMPS_LIBRARIES) set(REQUIRED_LIBS "${MUMPS_LIBRARIES}") # SCALAPACK if (MUMPS_LOOK_FOR_MPI AND SCALAPACK_FOUND) - if (SCALAPACK_INCLUDE_DIRS_DEP) - list(APPEND REQUIRED_INCDIRS "${SCALAPACK_INCLUDE_DIRS_DEP}") + if (SCALAPACK_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${SCALAPACK_INCLUDE_DIRS}") endif() - if (SCALAPACK_CFLAGS_OTHER_DEP) - list(APPEND REQUIRED_FLAGS "${SCALAPACK_CFLAGS_OTHER_DEP}") + if (SCALAPACK_CFLAGS_OTHER) + list(APPEND REQUIRED_FLAGS "${SCALAPACK_CFLAGS_OTHER}") endif() - if (SCALAPACK_LDFLAGS_OTHER_DEP) - list(APPEND REQUIRED_LDFLAGS "${SCALAPACK_LDFLAGS_OTHER_DEP}") + if (SCALAPACK_LDFLAGS_OTHER) + list(APPEND REQUIRED_LDFLAGS "${SCALAPACK_LDFLAGS_OTHER}") endif() - if(SCALAPACK_LIBRARY_DIRS_DEP) - list(APPEND REQUIRED_LIBDIRS "${SCALAPACK_LIBRARY_DIRS_DEP}") + if(SCALAPACK_LIBRARY_DIRS) + list(APPEND REQUIRED_LIBDIRS "${SCALAPACK_LIBRARY_DIRS}") endif() - if (SCALAPACK_LIBRARIES_DEP) - list(APPEND REQUIRED_LIBS "${SCALAPACK_LIBRARIES_DEP}") + if (SCALAPACK_LIBRARIES) + list(APPEND REQUIRED_LIBS "${SCALAPACK_LIBRARIES}") endif() endif() # MPI @@ -659,20 +667,20 @@ if(MUMPS_LIBRARIES) endif() # PARMETIS if (MUMPS_LOOK_FOR_PARMETIS AND PARMETIS_FOUND) - if (PARMETIS_INCLUDE_DIRS_DEP) - list(APPEND REQUIRED_INCDIRS "${PARMETIS_INCLUDE_DIRS_DEP}") + if (PARMETIS_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${PARMETIS_INCLUDE_DIRS}") endif() - if (PARMETIS_CFLAGS_OTHER_DEP) - list(APPEND REQUIRED_FLAGS "${PARMETIS_CFLAGS_OTHER_DEP}") + if (PARMETIS_CFLAGS_OTHER) + list(APPEND REQUIRED_FLAGS "${PARMETIS_CFLAGS_OTHER}") endif() - if (PARMETIS_LDFLAGS_OTHER_DEP) - list(APPEND REQUIRED_LDFLAGS "${PARMETIS_LDFLAGS_OTHER_DEP}") + if (PARMETIS_LDFLAGS_OTHER) + list(APPEND REQUIRED_LDFLAGS "${PARMETIS_LDFLAGS_OTHER}") endif() - if(PARMETIS_LIBRARY_DIRS_DEP) - list(APPEND REQUIRED_LIBDIRS "${PARMETIS_LIBRARY_DIRS_DEP}") + if(PARMETIS_LIBRARY_DIRS) + list(APPEND REQUIRED_LIBDIRS "${PARMETIS_LIBRARY_DIRS}") endif() - if (PARMETIS_LIBRARIES_DEP) - list(APPEND REQUIRED_LIBS "${PARMETIS_LIBRARIES_DEP}") + if (PARMETIS_LIBRARIES) + list(APPEND REQUIRED_LIBS "${PARMETIS_LIBRARIES}") endif() endif() # OpenMP @@ -718,7 +726,7 @@ if(MUMPS_LIBRARIES) list(APPEND REQUIRED_FLAGS "${_flag}") endforeach() endif() - finds_remove_duplicates() + morse_finds_remove_duplicates() set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) @@ -747,12 +755,14 @@ if(MUMPS_LIBRARIES) 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_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}") - set(MUMPS_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}") + set(MUMPS_LIBRARY_DIRS "${REQUIRED_LIBDIRS}") + set(MUMPS_INCLUDE_DIRS "${REQUIRED_INCDIRS}") + if (MUMPS_STATIC OR BLA_STATIC OR SCOTCH_STATIC OR PTSCOTCH_STATIC OR METIS_STATIC OR PARMETIS_STATIC) + # save link with dependencies + set(MUMPS_LIBRARIES "${REQUIRED_LIBS}") + set(MUMPS_CFLAGS_OTHER "${REQUIRED_FLAGS}") + set(MUMPS_LDFLAGS_OTHER "${REQUIRED_LDFLAGS}") + endif() else() if(NOT MUMPS_FIND_QUIETLY) message(STATUS "Looking for MUMPS : test of [sdcz]mumps() fails") @@ -769,23 +779,21 @@ if(MUMPS_LIBRARIES) 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) + get_filename_component(first_lib_path "${first_lib}" DIRECTORY) if (NOT MUMPS_LIBRARY_DIRS) set(MUMPS_LIBRARY_DIRS "${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(MUMPS_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of MUMPS library" FORCE) + set(MUMPS_PREFIX "${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) + set(MUMPS_PREFIX "${first_lib_path}" CACHE PATH "Installation directory of MUMPS library" FORCE) endif() -endif() -mark_as_advanced(MUMPS_DIR) -mark_as_advanced(MUMPS_DIR_FOUND) + mark_as_advanced(MUMPS_DIR) + mark_as_advanced(MUMPS_PREFIX) + +endif(MUMPS_LIBRARIES) # check that MUMPS has been found # ------------------------------- @@ -793,3 +801,8 @@ include(FindPackageHandleStandardArgs) find_package_handle_standard_args(MUMPS DEFAULT_MSG MUMPS_LIBRARIES MUMPS_WORKS) + +# Add imported target +if (MUMPS_FOUND) + morse_create_imported_target(MUMPS) +endif() \ No newline at end of file diff --git a/modules/find/FindMorseCommon.cmake b/modules/find/FindMorseCommon.cmake new file mode 100644 index 0000000000000000000000000000000000000000..be1aa41f16a4cc33c73320405dcfa6b71447185b --- /dev/null +++ b/modules/find/FindMorseCommon.cmake @@ -0,0 +1,246 @@ +### +# +# @copyright (c) 2019 Inria. All rights reserved. +# +### +# +# @file FindMorseCommon.cmake +# +# @project MORSE +# MORSE is a software package provided by: +# Inria Bordeaux - Sud-Ouest, +# Univ. of Tennessee, +# King Abdullah Univesity of Science and Technology +# Univ. of California Berkeley, +# Univ. of Colorado Denver. +# +# @version 1.0.0 +# @author Florent Pruvost +# @date 13-04-2018 +# +### + +# clean these variables before using them in CMAKE_REQUIRED_* variables in +# check_function_exists +macro(morse_finds_remove_duplicates) + if (REQUIRED_DEFINITIONS) + list(REMOVE_DUPLICATES REQUIRED_DEFINITIONS) + endif() + if (REQUIRED_INCDIRS) + list(REMOVE_DUPLICATES REQUIRED_INCDIRS) + endif() + if (REQUIRED_FLAGS) + list(REMOVE_DUPLICATES REQUIRED_FLAGS) + endif() + if (REQUIRED_LDFLAGS) + list(REMOVE_DUPLICATES REQUIRED_LDFLAGS) + endif() + if (REQUIRED_LIBS) + list(REVERSE REQUIRED_LIBS) + list(REMOVE_DUPLICATES REQUIRED_LIBS) + list(REVERSE REQUIRED_LIBS) + endif() +endmacro() + +# add imported target for non-cmake projects or projects which do not provide +# "PROJECT"Config.cmake file at installation +macro(morse_check_static_or_dynamic package libraries) + list(GET ${libraries} 0 _first_lib) + get_filename_component(_suffix ${_first_lib} EXT) + #message(STATUS "package ${package}") + #message(STATUS "libraries ${libraries} ${${libraries}}") + #message(STATUS "_suffix ${_suffix} ${_first_lib}") + if (NOT _suffix) + unset (_lib_path CACHE) + find_library(_lib_path ${_first_lib} HINTS ${${package}_LIBDIR} ${${package}_LIBRARY_DIRS} NO_DEFAULT_PATH) + #message(STATUS "_first_lib ${_first_lib}") + #message(STATUS "${${package}_LIBRARY_DIRS}") + #message(STATUS "_lib_path ${_lib_path}") + get_filename_component(_suffix ${_lib_path} EXT) + endif() + if (_suffix) + if(${_suffix} MATCHES ".so$" OR ${_suffix} MATCHES ".dylib$" OR ${_suffix} MATCHES ".dll$") + set(${package}_STATIC 0) + elseif(${_suffix} MATCHES ".a$") + set(${package}_STATIC 1) + else() + message(FATAL_ERROR "${package} library extension not in list .a, .so, .dylib, .dll") + endif() + else() + message(FATAL_ERROR "${package} could not detect library extension") + endif() +endmacro() + +# add imported target for non-cmake projects or projects which do not provide +# "PROJECT"Config.cmake file at installation +macro(morse_create_imported_target name) + + if(NOT TARGET MORSE::${name}) + + # initialize imported target + add_library(MORSE::${name} INTERFACE IMPORTED) + + if (TARGET PkgConfig::${name}) + get_target_property(_INCLUDES PkgConfig::${name} INTERFACE_INCLUDE_DIRECTORIES) + get_target_property(_LIBDIRS PkgConfig::${name} INTERFACE_LINK_DIRECTORIES) + get_target_property(_LIBRARIES PkgConfig::${name} INTERFACE_LINK_LIBRARIES) + get_target_property(_CFLAGS PkgConfig::${name} INTERFACE_COMPILE_OPTIONS) + get_target_property(_LDFLAGS PkgConfig::${name} INTERFACE_LINK_OPTIONS) + set_target_properties(MORSE::${name} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${_INCLUDES}") + set_target_properties(MORSE::${name} PROPERTIES INTERFACE_LINK_DIRECTORIES "${_LIBDIRS}") + set_target_properties(MORSE::${name} PROPERTIES INTERFACE_LINK_LIBRARIES "${_LIBRARIES}") + set_target_properties(MORSE::${name} PROPERTIES INTERFACE_COMPILE_OPTIONS "${_CFLAGS}") + set_target_properties(MORSE::${name} PROPERTIES INTERFACE_LINK_OPTIONS "${_LDFLAGS}") + else () + if (${name}_INCLUDE_DIRS) + set_target_properties(MORSE::${name} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${${name}_INCLUDE_DIRS}") + endif() + if (${name}_LIBRARY_DIRS) + set_target_properties(MORSE::${name} PROPERTIES INTERFACE_LINK_DIRECTORIES "${${name}_LIBRARY_DIRS}") + elseif (${name}_LIBDIR) + set_target_properties(MORSE::${name} PROPERTIES INTERFACE_LINK_DIRECTORIES "${${name}_LIBDIR}") + set (${name}_LIBRARY_DIRS ${${name}_LIBDIR}) + endif() + if (${name}_LIBRARIES) + set_target_properties(MORSE::${name} PROPERTIES INTERFACE_LINK_LIBRARIES "${${name}_LIBRARIES}") + endif() + if (${name}_CFLAGS_OTHER) + set_target_properties(MORSE::${name} PROPERTIES INTERFACE_COMPILE_OPTIONS "${${name}_CFLAGS_OTHER}") + endif() + if (${name}_LDFLAGS_OTHER) + set_target_properties(MORSE::${name} PROPERTIES INTERFACE_LINK_OPTIONS "${${name}_LDFLAGS_OTHER}") + endif() + endif() + + endif (NOT TARGET MORSE::${name}) + + set(debug_morse_create_imported_target "FALSE") + if (debug_morse_create_imported_target) + if (TARGET MORSE::${name}) + get_target_property(_INCLUDES MORSE::${name} INTERFACE_INCLUDE_DIRECTORIES) + get_target_property(_DIRECTORIES MORSE::${name} INTERFACE_LINK_DIRECTORIES) + get_target_property(_LIBRARIES MORSE::${name} INTERFACE_LINK_LIBRARIES) + get_target_property(_CFLAGS MORSE::${name} INTERFACE_COMPILE_OPTIONS) + get_target_property(_LDFLAGS MORSE::${name} INTERFACE_LINK_OPTIONS) + message(STATUS "IMPORTED TARGET ${name}: + _INCLUDES ${_INCLUDES} + _DIRECTORIES ${_DIRECTORIES} + _LIBRARIES ${_LIBRARIES} + _CFLAGS ${_CFLAGS} + _LDFLAGS ${_LDFLAGS}") + endif() + endif() + +endmacro() + +# set required libraries for link test +macro(morse_set_required_test_lib_link name) + set(CMAKE_REQUIRED_INCLUDES "${${name}${STATIC}_INCLUDE_DIRS}") + if (${name}${STATIC}_CFLAGS_OTHER) + set(REQUIRED_FLAGS_COPY "${${name}${STATIC}_CFLAGS_OTHER}") + set(REQUIRED_FLAGS) + set(REQUIRED_DEFINITIONS) + foreach(_flag ${REQUIRED_FLAGS_COPY}) + if (_flag MATCHES "^-D") + list(APPEND REQUIRED_DEFINITIONS "${_flag}") + endif() + string(REGEX REPLACE "^-D.*" "" _flag "${_flag}") + list(APPEND REQUIRED_FLAGS "${_flag}") + endforeach() + endif() + morse_finds_remove_duplicates() + set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") + set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") + set(CMAKE_REQUIRED_LIBRARIES) + list(APPEND CMAKE_REQUIRED_LIBRARIES "${${name}${STATIC}_LDFLAGS_OTHER}") + list(APPEND CMAKE_REQUIRED_LIBRARIES "${${name}${STATIC}_LIBRARIES}") + string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") +endmacro() + +# Transform relative path into absolute path for libraries found with the +# pkg_search_module cmake macro +# _prefix: the name of the CMake variable used when pkg_search_module was called +# e.g. for pkg_search_module(BLAS blas) _prefix would be BLAS +macro(morse_find_pkgconfig_libraries_absolute_path _prefix) + list(APPEND _lib_env "$ENV{LIBRARY_PATH}") + if(WIN32) + string(REPLACE ":" ";" _lib_env2 "$ENV{LIB}") + elseif(APPLE) + string(REPLACE ":" ";" _lib_env2 "$ENV{DYLD_LIBRARY_PATH}") + else() + string(REPLACE ":" ";" _lib_env2 "$ENV{LD_LIBRARY_PATH}") + endif() + list(APPEND _lib_env "${_lib_env2}") + list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + set(${_prefix}_LIBRARIES_COPY "${${_prefix}_LIBRARIES}") + set(${_prefix}_LIBRARIES "") + foreach(_library ${${_prefix}_LIBRARIES_COPY}) + if(EXISTS "${_library}") + list(APPEND ${_prefix}_LIBRARIES ${_library}) + else() + get_filename_component(_ext "${_library}" EXT) + set(_lib_extensions ".a" ".so" ".dyld" ".dll") + list(FIND _lib_extensions "${_ext}" _index) + if (${_index} GREATER -1) + get_filename_component(_library "${_library}" NAME_WE) + endif() + if (${_prefix}_STATIC) + set (CMAKE_FIND_LIBRARY_SUFFIXES_COPY ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set (CMAKE_FIND_LIBRARY_SUFFIXES ".a") + endif() + find_library(_library_path NAMES ${_library} + HINTS ${${_prefix}_LIBDIR} ${${_prefix}_LIBRARY_DIRS} ${_lib_env} + ) + if (_library_path) + list(APPEND ${_prefix}_LIBRARIES ${_library_path}) + else() + if (${_prefix}_STATIC) + message(STATUS "${_prefix}_STATIC ${${_prefix}_STATIC}") + endif() + message(FATAL_ERROR "Dependency of ${_prefix} '${_library}' NOT FOUND with suffixes ${CMAKE_FIND_LIBRARY_SUFFIXES} in ${${_prefix}_LIBDIR} ${${_prefix}_LIBRARY_DIRS}") + endif() + unset(_library_path CACHE) + if (${_prefix}_STATIC) + set (CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_COPY}) + endif() + endif() + endforeach() + set (${_prefix}_LIBRARIES "${${_prefix}_LIBRARIES}" CACHE INTERNAL "" FORCE) + ## static case + #set(${_prefix}_STATIC_LIBRARIES_COPY "${${_prefix}_STATIC_LIBRARIES}") + #set(${_prefix}_STATIC_LIBRARIES "") + #foreach(_library ${${_prefix}_STATIC_LIBRARIES_COPY}) + # if(EXISTS "${_library}") + # list(APPEND ${_prefix}_STATIC_LIBRARIES ${_library}) + # else() + # get_filename_component(_ext "${_library}" EXT) + # set(_lib_extensions ".a" ".so" ".dyld" ".dll") + # list(FIND _lib_extensions "${_ext}" _index) + # if (${_index} GREATER -1) + # get_filename_component(_library "${_library}" NAME_WE) + # endif() + # # try static first + # set (default_find_library_suffixes ${CMAKE_FIND_LIBRARY_SUFFIXES}) + # set (CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX}) + # find_library(_library_path NAMES ${_library} + # HINTS ${${_prefix}_STATIC_LIBDIR} ${${_prefix}_STATIC_LIBRARY_DIRS} ${_lib_env}) + # set (CMAKE_FIND_LIBRARY_SUFFIXES ${default_find_library_suffixes}) + # # if not found try dynamic + # if (NOT _library_path) + # find_library(_library_path NAMES ${_library} + # HINTS ${${_prefix}_STATIC_LIBDIR} ${${_prefix}_STATIC_LIBRARY_DIRS} ${_lib_env}) + # endif() + # if (_library_path) + # list(APPEND ${_prefix}_STATIC_LIBRARIES ${_library_path}) + # else() + # message(FATAL_ERROR "Dependency of ${_prefix} '${_library}' NOT FOUND") + # endif() + # unset(_library_path CACHE) + # endif() + #endforeach() + #set (${_prefix}_STATIC_LIBRARIES "${${_prefix}_STATIC_LIBRARIES}" CACHE INTERNAL "" FORCE) +endmacro() + +## +## @end file FindMorseCommon +## diff --git a/modules/find/FindInit.cmake b/modules/find/FindMorseInit.cmake similarity index 73% rename from modules/find/FindInit.cmake rename to modules/find/FindMorseInit.cmake index 949db4b4c2e140e7e322450120d80440547b5c7b..12a7d2c74910a090a8ac6d30a067c86334a44eff 100644 --- a/modules/find/FindInit.cmake +++ b/modules/find/FindMorseInit.cmake @@ -4,7 +4,7 @@ # ### # -# @file FindInit.cmake +# @file FindMorseInit.cmake # # @project MORSE # MORSE is a software package provided by: @@ -28,18 +28,22 @@ include(CheckFunctionExists) include(CheckIncludeFiles) # Factorize some piece of code -include(FindCommon) +include(FindMorseCommon) # To find headers and libs include(FindHeadersAndLibs) # To transform relative path into absolute for a list of libraries include(LibrariesAbsolutePath) -include(FindPkgconfigLibrariesAbsolutePath) # Some macros to print status when search for headers and libs include(PrintFindStatus) +# To use pkg_search_module macro +set(FPHSA_NAME_MISMATCHED 1) # Suppress warnings, see https://cmake.org/cmake/help/latest/module/FindPackageHandleStandardArgs.html +include(FindPkgConfig) +unset(FPHSA_NAME_MISMATCHED) + ## -## @end file FindInit.cmake +## @end file FindMorseInit.cmake ## diff --git a/modules/find/FindPAMPA.cmake b/modules/find/FindPAMPA.cmake index 9725aaa7dbbb9ab697c9bce3d8fc0fe2fd9e3b79..6e959ef08c5f55207344fd0bba598ef3baf65d25 100644 --- a/modules/find/FindPAMPA.cmake +++ b/modules/find/FindPAMPA.cmake @@ -1,11 +1,23 @@ ### # -# @copyright (c) 2009-2014 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. -# @copyright (c) 2012-2019 Inria. All rights reserved. +# @copyright (c) 2012-2020 Inria. All rights reserved. # @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. # +# Copyright 2012-2013 Emmanuel Agullo +# Copyright 2012-2013 Mathieu Faverge +# Copyright 2012 Cedric Castagnede +# Copyright 2013-2020 Florent Pruvost +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file MORSE-Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of Morse, substitute the full +# License text for the above reference.) +# ### # # - Find PAMPA include dirs and libraries @@ -21,16 +33,12 @@ # This module finds headers and pampa library. # Results are reported in variables: # PAMPA_FOUND - True if headers and requested libraries were found +# PAMPA_PREFIX - installation path of the lib found # PAMPA_CFLAGS_OTHER - pampa compiler flags without headers paths # PAMPA_LDFLAGS_OTHER - pampa linker flags without libraries # PAMPA_INCLUDE_DIRS - pampa include directories # PAMPA_LIBRARY_DIRS - pampa link directories # PAMPA_LIBRARIES - pampa libraries to be linked (absolute path) -# PAMPA_CFLAGS_OTHER_DEP - pampa + dependencies compiler flags without headers paths -# PAMPA_LDFLAGS_OTHER_DEP - pampa + dependencies linker flags without libraries -# PAMPA_INCLUDE_DIRS_DEP - pampa + dependencies include directories -# PAMPA_LIBRARY_DIRS_DEP - pampa + dependencies link directories -# PAMPA_LIBRARIES_DEP - pampa + dependencies libraries # PAMPA_INTSIZE - Number of octets occupied by a PAMPA_Num # # The user can give specific paths where to find the libraries adding cmake @@ -40,26 +48,18 @@ # PAMPA_LIBDIR - Where to find the library files # The module can also look for the following environment variables if paths # are not given as cmake variable: PAMPA_DIR, PAMPA_INCDIR, PAMPA_LIBDIR - -#============================================================================= -# Copyright 2012-2019 Inria -# Copyright 2012-2013 Emmanuel Agullo -# Copyright 2012-2013 Mathieu Faverge -# Copyright 2012 Cedric Castagnede -# Copyright 2013-2018 Florent Pruvost # -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file MORSE-Copyright.txt for details. +# Set PAMPA_STATIC to 1 to force using static libraries if exist. +# +# This module defines the following :prop_tgt:`IMPORTED` target: +# +# ``MORSE::PAMPA`` +# The headers and libraries to use for PAMPA, if found. # -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. #============================================================================= -# (To distribute this file outside of Morse, substitute the full -# License text for the above reference.) # Common macros to use in finds -include(FindInit) +include(FindMorseInit) if (NOT PAMPA_FOUND) set(PAMPA_DIR "" CACHE PATH "Installation directory of PAMPA library") @@ -191,9 +191,15 @@ else() endif() list(REMOVE_DUPLICATES _lib_env) + # Try to find the ptscotch lib in the given paths # ---------------------------------------------- +if (PAMPA_STATIC) + set (CMAKE_FIND_LIBRARY_SUFFIXES_COPY ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set (CMAKE_FIND_LIBRARY_SUFFIXES ".a") +endif() + set(PAMPA_libs_to_find "pampa;pampaerr") # call cmake macro to find the lib path @@ -225,6 +231,10 @@ else() endif() endif() +if (PAMPA_STATIC) + set (CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_COPY}) +endif() + set(PAMPA_LIBRARIES "") set(PAMPA_LIBRARY_DIRS "") # If found, add path to cmake variable @@ -251,11 +261,17 @@ list(REMOVE_DUPLICATES PAMPA_LIBRARY_DIRS) # check a function to validate the find if(PAMPA_LIBRARIES) + # check if static or dynamic lib + morse_check_static_or_dynamic(PAMPA PAMPA_LIBRARIES) + if(PAMPA_STATIC) + set(STATIC "_STATIC") + endif() + set(REQUIRED_INCDIRS) - set(REQUIRED_FLAGS) - set(REQUIRED_LDFLAGS) set(REQUIRED_LIBDIRS) set(REQUIRED_LIBS) + set(REQUIRED_FLAGS) + set(REQUIRED_LDFLAGS) # PAMPA if (PAMPA_INCLUDE_DIRS) @@ -281,21 +297,21 @@ if(PAMPA_LIBRARIES) list(APPEND REQUIRED_LIBS "${MPI_C_LIBRARIES}") endif() # PTSCOTCH - if (PTSCOTCH_INCLUDE_DIRS_DEP) - list(APPEND REQUIRED_INCDIRS "${PTSCOTCH_INCLUDE_DIRS_DEP}") + if (PTSCOTCH_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${PTSCOTCH_INCLUDE_DIRS}") endif() - if (PTSCOTCH_CFLAGS_OTHER_DEP) - list(APPEND REQUIRED_FLAGS "${PTSCOTCH_CFLAGS_OTHER_DEP}") + if (PTSCOTCH_CFLAGS_OTHER) + list(APPEND REQUIRED_FLAGS "${PTSCOTCH_CFLAGS_OTHER}") endif() - if (PTSCOTCH_LDFLAGS_OTHER_DEP) - list(APPEND REQUIRED_LDFLAGS "${PTSCOTCH_LDFLAGS_OTHER_DEP}") + if (PTSCOTCH_LDFLAGS_OTHER) + list(APPEND REQUIRED_LDFLAGS "${PTSCOTCH_LDFLAGS_OTHER}") endif() foreach(libdir ${PTSCOTCH_LIBRARY_DIRS_DEP}) if (libdir) list(APPEND REQUIRED_LIBDIRS "${libdir}") endif() endforeach() - list(APPEND REQUIRED_LIBS "${PTSCOTCH_LIBRARIES_DEP}") + list(APPEND REQUIRED_LIBS "${PTSCOTCH_LIBRARIES}") # set required libraries for link set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") if (REQUIRED_FLAGS) @@ -310,7 +326,7 @@ if(PAMPA_LIBRARIES) list(APPEND REQUIRED_FLAGS "${_flag}") endforeach() endif() - finds_remove_duplicates() + morse_finds_remove_duplicates() set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) @@ -325,12 +341,14 @@ if(PAMPA_LIBRARIES) 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_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}") - set(PAMPA_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}") + set(PAMPA_INCLUDE_DIRS "${REQUIRED_INCDIRS}") + set(PAMPA_LIBRARY_DIRS "${REQUIRED_LIBDIRS}") + if (PAMPA_STATIC OR PTSCOTCH_STATIC) + # save link with dependencies + set(PAMPA_LIBRARIES "${REQUIRED_LIBS}") + set(PAMPA_CFLAGS_OTHER "${REQUIRED_FLAGS}") + set(PAMPA_LDFLAGS_OTHER "${REQUIRED_LDFLAGS}") + endif() else() if(NOT PAMPA_FIND_QUIETLY) message(STATUS "Looking for PAMPA : test of PAMPA_dmeshInit with PAMPA library fails") @@ -343,23 +361,22 @@ if(PAMPA_LIBRARIES) 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) + get_filename_component(first_lib_path "${first_lib}" DIRECTORY) if (NOT PAMPA_LIBRARY_DIRS) set(PAMPA_LIBRARY_DIRS "${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(PAMPA_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of PAMPA library" FORCE) + set(PAMPA_PREFIX "${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) + set(PAMPA_PREFIX "${first_lib_path}" CACHE PATH "Installation directory of PAMPA library" FORCE) endif() -endif() -mark_as_advanced(PAMPA_DIR) -mark_as_advanced(PAMPA_DIR_FOUND) + mark_as_advanced(PAMPA_DIR) + mark_as_advanced(PAMPA_PREFIX) + +endif(PAMPA_LIBRARIES) # Check the size of PAMPA_Num # --------------------------------- @@ -370,6 +387,7 @@ include(CheckCSourceRuns) set(PAMPA_C_TEST_PAMPA_Num_4 " #include <stdio.h> #include <stdint.h> +#include <mpi.h> #include <pampa.h> int main(int argc, char **argv) { if (sizeof(PAMPA_Num) == 4) @@ -382,6 +400,7 @@ int main(int argc, char **argv) { set(PAMPA_C_TEST_PAMPA_Num_8 " #include <stdio.h> #include <stdint.h> +#include <mpi.h> #include <pampa.h> int main(int argc, char **argv) { if (sizeof(PAMPA_Num) == 8) @@ -409,3 +428,8 @@ include(FindPackageHandleStandardArgs) find_package_handle_standard_args(PAMPA DEFAULT_MSG PAMPA_LIBRARIES PAMPA_WORKS) + +# Add imported target +if (PAMPA_FOUND) + morse_create_imported_target(PAMPA) +endif() diff --git a/modules/find/FindPAPI.cmake b/modules/find/FindPAPI.cmake index fe3702c15e8872b4ed48799ce869b41fd0be5280..78b45dc6fbc7e4f46f953ad38bc2ee4b06ea7739 100644 --- a/modules/find/FindPAPI.cmake +++ b/modules/find/FindPAPI.cmake @@ -1,11 +1,23 @@ ### # -# @copyright (c) 2009-2014 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. # @copyright (c) 2012-2020 Inria. All rights reserved. # @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. # +# Copyright 2012-2013 Emmanuel Agullo +# Copyright 2012-2013 Mathieu Faverge +# Copyright 2012 Cedric Castagnede +# Copyright 2013-2020 Florent Pruvost +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file MORSE-Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of Morse, substitute the full +# License text for the above reference.) +# ### # # - Find PAPI include dirs and libraries @@ -13,16 +25,11 @@ # find_package(PAPI # [REQUIRED]) # Fail with error if papi is not found # -# This module finds headers and papi library. -# Results are reported in variables: -# PAPI_FOUND - True if headers and requested libraries were found -# PAPI_INCLUDE_DIRS - papi include directories -# PAPI_LIBRARY_DIRS - Link directories for papi libraries -# PAPI_LIBRARIES - papi component libraries to be linked -# -# PAPI_FOUND_WITH_PKGCONFIG - True if found with pkg-config +# This module finds headers and papi library using pkg-config file. # if found with pkg-config the following variables are set # <PREFIX> = PAPI +# <PREFIX>_PREFIX ... installation path of the lib found +# <PREFIX>_VERSION ... version of the lib # <XPREFIX> = <PREFIX> for common case # <XPREFIX> = <PREFIX>_STATIC for static linking # <XPREFIX>_FOUND ... set to 1 if module(s) exist @@ -34,55 +41,26 @@ # <XPREFIX>_CFLAGS ... all required cflags # <XPREFIX>_CFLAGS_OTHER ... the other compiler flags # -# The user can give specific paths where to find the libraries adding cmake -# options at configure (ex: cmake path/to/project -DPAPI_DIR=path/to/papi): -# PAPI_DIR - Where to find the base directory of papi -# PAPI_INCDIR - Where to find the header files -# PAPI_LIBDIR - Where to find the library files -# The module can also look for the following environment variables if paths -# are not given as cmake variable: PAPI_DIR, PAPI_INCDIR, PAPI_LIBDIR - -#============================================================================= -# Copyright 2012-2019 Inria -# Copyright 2012-2013 Emmanuel Agullo -# Copyright 2012-2013 Mathieu Faverge -# Copyright 2012 Cedric Castagnede -# Copyright 2013-2018 Florent Pruvost +# Set PAPI_STATIC to 1 to force using static libraries if exist. # -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file MORSE-Copyright.txt for details. +# This module defines the following :prop_tgt:`IMPORTED` target: +# +# ``MORSE::PAPI`` +# The headers and libraries to use for PAPI, if found. # -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. #============================================================================= -# (To distribute this file outside of Morse, substitute the full -# License text for the above reference.) # Common macros to use in finds -include(FindInit) +include(FindMorseInit) -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() +if (NOT PAPI_FIND_QUIETLY) + message(STATUS "FindPAPI needs pkg-config program and PKG_CONFIG_PATH set with papi.pc file path.") endif() -set(ENV_PAPI_DIR "$ENV{PAPI_DIR}") -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") -endif() - -# Optionally use pkg-config to detect include/library dirs (if pkg-config is available) -# ------------------------------------------------------------------------------------- -include(FindPkgConfig) -find_package(PkgConfig QUIET) -if(PKG_CONFIG_EXECUTABLE AND NOT PAPI_GIVEN_BY_USER) - +# use pkg-config to detect include/library dirs (if pkg-config is available) +# -------------------------------------------------------------------------- +if (PKG_CONFIG_EXECUTABLE) + unset(PAPI_FOUND CACHE) pkg_search_module(PAPI papi) if (NOT PAPI_FIND_QUIETLY) @@ -94,218 +72,41 @@ if(PKG_CONFIG_EXECUTABLE AND NOT PAPI_GIVEN_BY_USER) "\n PKG_CONFIG_PATH environment variable.${ColourReset}") endif() endif() - if (PAPI_FOUND AND PAPI_LIBRARIES) if (NOT PAPI_INCLUDE_DIRS) pkg_get_variable(PAPI_INCLUDE_DIRS papi includedir) endif() set(PAPI_FOUND_WITH_PKGCONFIG "TRUE") - find_pkgconfig_libraries_absolute_path(PAPI) + morse_find_pkgconfig_libraries_absolute_path(PAPI) else() set(PAPI_FOUND_WITH_PKGCONFIG "FALSE") 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() - - # 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") - 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_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} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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" - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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() - 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 () - - if (PAPI_INCLUDE_DIRS) - list(REMOVE_DUPLICATES PAPI_INCLUDE_DIRS) - endif () - - - # 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") - else() - list(APPEND _lib_env "$ENV{LIBRARY_PATH}") - if(WIN32) - string(REPLACE ":" ";" _lib_env2 "$ENV{LIB}") - elseif(APPLE) - string(REPLACE ":" ";" _lib_env2 "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env2 "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${_lib_env2}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - endif() - list(REMOVE_DUPLICATES _lib_env) - - # 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} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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 - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - set(PAPI_papi_LIBRARY "PAPI_papi_LIBRARY-NOTFOUND") - find_library(PAPI_papi_LIBRARY - NAMES papi - HINTS ${_lib_env}) + if (PAPI_STATIC AND PAPI_STATIC_LIBRARIES) + set (PAPI_DEPENDENCIES ${PAPI_STATIC_LIBRARIES}) + list (REMOVE_ITEM PAPI_DEPENDENCIES "papi") + list (APPEND PAPI_LIBRARIES ${PAPI_DEPENDENCIES}) + set(PAPI_CFLAGS_OTHER ${PAPI_STATIC_CFLAGS_OTHER}) + set(PAPI_LDFLAGS_OTHER ${PAPI_STATIC_LDFLAGS_OTHER}) + if (NOT PAPI_FIND_QUIETLY) + message(STATUS "PAPI_STATIC set to 1 by user, PAPI_LIBRARIES: ${PAPI_LIBRARIES}.") endif() 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 (PAPI_LIBRARY_DIRS) - list(REMOVE_DUPLICATES PAPI_LIBRARY_DIRS) - endif () - -endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT PAPI_FOUND) OR (PAPI_GIVEN_BY_USER) ) +endif() # check a function to validate the find -if(PAPI_LIBRARIES) - - set(REQUIRED_INCDIRS) - set(REQUIRED_FLAGS) - set(REQUIRED_LDFLAGS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) +if(PAPI_FOUND AND PAPI_LIBRARIES) - # PAPI - if (PAPI_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${PAPI_INCLUDE_DIRS}") - endif() - if (PAPI_CFLAGS_OTHER) - set(REQUIRED_FLAGS "${PAPI_CFLAGS_OTHER}") - endif() - if (PAPI_LDFLAGS_OTHER) - set(REQUIRED_LDFLAGS "${PAPI_LDFLAGS_OTHER}") - endif() - if (PAPI_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${PAPI_LIBRARY_DIRS}") + # check if static or dynamic lib + morse_check_static_or_dynamic(PAPI PAPI_LIBRARIES) + if(PAPI_STATIC) + set(STATIC "_STATIC") + else() + set(STATIC "") endif() - set(REQUIRED_LIBS "${PAPI_LIBRARIES}") # set required libraries for link - set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") - if (REQUIRED_FLAGS) - set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}") - set(REQUIRED_FLAGS) - set(REQUIRED_DEFINITIONS) - foreach(_flag ${REQUIRED_FLAGS_COPY}) - if (_flag MATCHES "^-D") - list(APPEND REQUIRED_DEFINITIONS "${_flag}") - endif() - string(REGEX REPLACE "^-D.*" "" _flag "${_flag}") - list(APPEND REQUIRED_FLAGS "${_flag}") - endforeach() - endif() - finds_remove_duplicates() - set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") - set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") - set(CMAKE_REQUIRED_LIBRARIES) - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}") - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + morse_set_required_test_lib_link(PAPI) # test link unset(PAPI_WORKS CACHE) @@ -313,7 +114,16 @@ if(PAPI_LIBRARIES) check_function_exists(PAPI_start PAPI_WORKS) mark_as_advanced(PAPI_WORKS) - if(NOT PAPI_WORKS) + if(PAPI_WORKS) + if (PAPI_STATIC) + # save link with dependencies + set(PAPI_STATIC_LIBRARIES "${REQUIRED_LIBS}") + set(PAPI_STATIC_LIBRARY_DIRS "${REQUIRED_LIBDIRS}") + set(PAPI_STATIC_INCLUDE_DIRS "${REQUIRED_INCDIRS}") + set(PAPI_STATIC_CFLAGS_OTHER "${REQUIRED_FLAGS}") + set(PAPI_STATIC_LDFLAGS_OTHER "${REQUIRED_LDFLAGS}") + endif() + else() 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}") @@ -325,25 +135,8 @@ if(PAPI_LIBRARIES) set(CMAKE_REQUIRED_INCLUDES) set(CMAKE_REQUIRED_FLAGS) set(CMAKE_REQUIRED_LIBRARIES) -endif(PAPI_LIBRARIES) -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) - set(PAPI_LIBRARY_DIRS "${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) +endif(PAPI_FOUND AND PAPI_LIBRARIES) # check that PAPI has been found # ------------------------------- @@ -351,3 +144,8 @@ include(FindPackageHandleStandardArgs) find_package_handle_standard_args(PAPI DEFAULT_MSG PAPI_LIBRARIES PAPI_WORKS) + + # Add imported targe +if (PAPI_FOUND) + morse_create_imported_target(PAPI) +endif() diff --git a/modules/find/FindPARMETIS.cmake b/modules/find/FindPARMETIS.cmake index d6e18928bc30640ce532d4f947e42d70707752dc..79fbfc7408136be036c598312a6f59179d55e2c7 100644 --- a/modules/find/FindPARMETIS.cmake +++ b/modules/find/FindPARMETIS.cmake @@ -1,11 +1,23 @@ ### # -# @copyright (c) 2009-2014 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. -# @copyright (c) 2012-2019 Inria. All rights reserved. +# @copyright (c) 2012-2020 Inria. All rights reserved. # @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. # +# Copyright 2012-2013 Emmanuel Agullo +# Copyright 2012-2013 Mathieu Faverge +# Copyright 2012 Cedric Castagnede +# Copyright 2013-2020 Florent Pruvost +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file MORSE-Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of Morse, substitute the full +# License text for the above reference.) +# ### # # - Find PARMETIS include dirs and libraries @@ -21,16 +33,12 @@ # This module finds headers and parmetis library. # Results are reported in variables: # PARMETIS_FOUND - True if headers and requested libraries were found +# PARMETIS_PREFIX - installation path of the lib found # PARMETIS_CFLAGS_OTHER - parmetis compiler flags without headers paths # PARMETIS_LDFLAGS_OTHER - parmetis linker flags without libraries # PARMETIS_INCLUDE_DIRS - parmetis include directories # PARMETIS_LIBRARY_DIRS - parmetis link directories # PARMETIS_LIBRARIES - parmetis libraries to be linked (absolute path) -# PARMETIS_CFLAGS_OTHER_DEP - parmetis + dependencies compiler flags without headers paths -# PARMETIS_LDFLAGS_OTHER_DEP - parmetis + dependencies linker flags without libraries -# PARMETIS_INCLUDE_DIRS_DEP - parmetis + dependencies include directories -# PARMETIS_LIBRARY_DIRS_DEP - parmetis + dependencies link directories -# PARMETIS_LIBRARIES_DEP - parmetis + dependencies libraries # # The user can give specific paths where to find the libraries adding cmake # options at configure (ex: cmake path/to/project -DPARMETIS_DIR=path/to/parmetis): @@ -39,26 +47,18 @@ # PARMETIS_LIBDIR - Where to find the library files # The module can also look for the following environment variables if paths # are not given as cmake variable: PARMETIS_DIR, PARMETIS_INCDIR, PARMETIS_LIBDIR - -#============================================================================= -# Copyright 2012-2019 Inria -# Copyright 2012-2013 Emmanuel Agullo -# Copyright 2012-2013 Mathieu Faverge -# Copyright 2012 Cedric Castagnede -# Copyright 2013-2018 Florent Pruvost # -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file MORSE-Copyright.txt for details. +# Set METIS_STATIC to 1 to force using static libraries if exist. +# +# This module defines the following :prop_tgt:`IMPORTED` target: +# +# ``MORSE::PARMETIS`` +# The headers and libraries to use for PARMETIS, if found. # -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. #============================================================================= -# (To distribute this file outside of Morse, substitute the full -# License text for the above reference.) # Common macros to use in finds -include(FindInit) +include(FindMorseInit) if (NOT PARMETIS_FOUND) set(PARMETIS_DIR "" CACHE PATH "Installation directory of PARMETIS library") @@ -180,6 +180,12 @@ list(REMOVE_DUPLICATES _lib_env) # Try to find the parmetis lib in the given paths # ---------------------------------------------- + +if (PARMETIS_STATIC) + set (CMAKE_FIND_LIBRARY_SUFFIXES_COPY ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set (CMAKE_FIND_LIBRARY_SUFFIXES ".a") +endif() + # call cmake macro to find the lib path if(PARMETIS_LIBDIR) set(PARMETIS_parmetis_LIBRARY "PARMETIS_parmetis_LIBRARY-NOTFOUND") @@ -204,6 +210,10 @@ else() endif() mark_as_advanced(PARMETIS_parmetis_LIBRARY) +if (PARMETIS_STATIC) + set (CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_COPY}) +endif() + # If found, add path to cmake variable # ------------------------------------ if (PARMETIS_parmetis_LIBRARY) @@ -222,11 +232,17 @@ endif () # check a function to validate the find if(PARMETIS_LIBRARIES) + # check if static or dynamic lib + morse_check_static_or_dynamic(PARMETIS PARMETIS_LIBRARIES) + if(PARMETIS_STATIC) + set(STATIC "_STATIC") + endif() + set(REQUIRED_INCDIRS) - set(REQUIRED_FLAGS) - set(REQUIRED_LDFLAGS) set(REQUIRED_LIBDIRS) set(REQUIRED_LIBS) + set(REQUIRED_FLAGS) + set(REQUIRED_LDFLAGS) # PARMETIS if (PARMETIS_INCLUDE_DIRS) @@ -282,7 +298,7 @@ if(PARMETIS_LIBRARIES) list(APPEND REQUIRED_FLAGS "${_flag}") endforeach() endif() - finds_remove_duplicates() + morse_finds_remove_duplicates() set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) @@ -297,12 +313,14 @@ if(PARMETIS_LIBRARIES) mark_as_advanced(PARMETIS_WORKS) if(PARMETIS_WORKS) - # save link with dependencies - set(PARMETIS_LIBRARIES_DEP "${REQUIRED_LIBS}") - set(PARMETIS_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}") - set(PARMETIS_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") - set(PARMETIS_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}") - set(PARMETIS_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}") + set(PARMETIS_INCLUDE_DIRS "${REQUIRED_INCDIRS}") + set(PARMETIS_LIBRARY_DIRS "${REQUIRED_LIBDIRS}") + if (PARMETIS_STATIC OR METIS_STATIC) + # save link with dependencies + set(PARMETIS_LIBRARIES "${REQUIRED_LIBS}") + set(PARMETIS_CFLAGS_OTHER "${REQUIRED_FLAGS}") + set(PARMETIS_LDFLAGS_OTHER "${REQUIRED_LDFLAGS}") + endif() else() if(NOT PARMETIS_FIND_QUIETLY) message(STATUS "Looking for PARMETIS : test of ParMETIS_V3_NodeND with PARMETIS library fails") @@ -315,23 +333,22 @@ if(PARMETIS_LIBRARIES) 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) + get_filename_component(first_lib_path "${first_lib}" DIRECTORY) if (NOT PARMETIS_LIBRARY_DIRS) set(PARMETIS_LIBRARY_DIRS "${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(PARMETIS_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of PARMETIS library" FORCE) + set(PARMETIS_PREFIX "${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) + set(PARMETIS_PREFIX "${first_lib_path}" CACHE PATH "Installation directory of PARMETIS library" FORCE) endif() -endif() -mark_as_advanced(PARMETIS_DIR) -mark_as_advanced(PARMETIS_DIR_FOUND) + mark_as_advanced(PARMETIS_DIR) + mark_as_advanced(PARMETIS_PREFIX) + +endif(PARMETIS_LIBRARIES) # check that PARMETIS has been found # ---------------------------------- @@ -339,6 +356,8 @@ include(FindPackageHandleStandardArgs) find_package_handle_standard_args(PARMETIS DEFAULT_MSG PARMETIS_LIBRARIES PARMETIS_WORKS) -# -# TODO: Add possibility to check for specific functions in the library -# + +# Add imported target +if (PARMETIS_FOUND) + morse_create_imported_target(PARMETIS) +endif() \ No newline at end of file diff --git a/modules/find/FindPARSEC.cmake b/modules/find/FindPARSEC.cmake index 4946ce785ccec1ac44f7640c9b0906c99734b45d..b336f9545573de905575942dd798d9c09cdaa76c 100644 --- a/modules/find/FindPARSEC.cmake +++ b/modules/find/FindPARSEC.cmake @@ -1,11 +1,24 @@ ### # -# @copyright (c) 2009-2015 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. # @copyright (c) 2012-2020 Inria. All rights reserved. # @copyright (c) 2012-2015 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. # +# Copyright 2012-2019 Inria +# Copyright 2012-2013 Emmanuel Agullo +# Copyright 2012-2013 Mathieu Faverge +# Copyright 2012 Cedric Castagnede +# Copyright 2013-2018 Florent Pruvost +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file MORSE-Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of Morse, substitute the full +# License text for the above reference.) +# ### # # - Find PARSEC include dirs and libraries @@ -13,36 +26,21 @@ # find_package(PARSEC # [version] [EXACT] # Minimum or EXACT version e.g. 1.1 # [REQUIRED] # Fail with error if parsec is not found -# [COMPONENTS <comp1> <comp2> ...] # dependencies # ) # # PARSEC depends on the following libraries: # - Threads, m, rt -# -# COMPONENTS are optional libraries PARSEC could be linked with, -# Use it to drive detection of a specific compilation chain -# COMPONENTS can be some of the following: -# - HWLOC: to activate the detection of PARSEC linked with HWLOC -# - CUDA: to activate the detection of PARSEC linked with CUDA -# - MPI: to activate the detection of PARSEC linked with MPI +# Optional dependencies # - AYUDAME: ?? -# -# Results are reported in variables: -# PARSEC_FOUND - True if headers and requested libraries were found -# PARSEC_CFLAGS_OTHER - parsec compiler flags without headers paths -# PARSEC_LDFLAGS_OTHER - parsec linker flags without libraries -# PARSEC_INCLUDE_DIRS - parsec include directories -# PARSEC_LIBRARY_DIRS - parsec link directories -# PARSEC_LIBRARIES - parsec libraries to be linked (absolute path) -# PARSEC_CFLAGS_OTHER_DEP - parsec + dependencies compiler flags without headers paths -# PARSEC_LDFLAGS_OTHER_DEP - parsec + dependencies linker flags without libraries -# PARSEC_INCLUDE_DIRS_DEP - parsec + dependencies include directories -# PARSEC_LIBRARY_DIRS_DEP - parsec + dependencies link directories -# PARSEC_LIBRARIES_DEP - parsec + dependencies libraries +# - CUDA +# - HWLOC +# - MPI # # PARSEC_FOUND_WITH_PKGCONFIG - True if found with pkg-config # if found with pkg-config the following variables are set # <PREFIX> = PARSEC +# <PREFIX>_PREFIX ... installation path of the lib found +# <PREFIX>_VERSION ... version of the lib # <XPREFIX> = <PREFIX> for common case # <XPREFIX> = <PREFIX>_STATIC for static linking # <XPREFIX>_FOUND ... set to 1 if module(s) exist @@ -54,192 +52,28 @@ # <XPREFIX>_CFLAGS ... all required cflags # <XPREFIX>_CFLAGS_OTHER ... the other compiler flags # -# The user can give specific paths where to find the libraries adding cmake -# options at configure (ex: cmake path/to/project -DPARSEC=path/to/parsec): -# PARSEC_DIR - Where to find the base directory of parsec -# PARSEC_INCDIR - Where to find the header files -# PARSEC_LIBDIR - Where to find the library files -# The module can also look for the following environment variables if paths -# are not given as cmake variable: PARSEC_DIR, PARSEC_INCDIR, PARSEC_LIBDIR - -#============================================================================= -# Copyright 2012-2019 Inria -# Copyright 2012-2013 Emmanuel Agullo -# Copyright 2012-2013 Mathieu Faverge -# Copyright 2012 Cedric Castagnede -# Copyright 2013-2018 Florent Pruvost +# Set PARSEC_STATIC to 1 to force using static libraries if exist. # -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file MORSE-Copyright.txt for details. +# This module defines the following :prop_tgt:`IMPORTED` target: +# +# ``MORSE::PARSEC`` +# The headers and libraries to use for PARSEC if found. # -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. #============================================================================= -# (To distribute this file outside of Morse, substitute the full -# License text for the above reference.) # Common macros to use in finds -include(FindInit) +include(FindMorseInit) 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() -endif() - -# PARSEC may depend on other packages (HWLOC, MPI, CUDA, ...) -# try to find them if specified as COMPONENTS during the call -set(PARSEC_LOOK_FOR_HWLOC FALSE) -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() -endif() - -# Required dependencies -# --------------------- - -if (NOT PARSEC_FIND_QUIETLY) - message(STATUS "Looking for PARSEC - Try to detect pthread") -endif() -if (PARSEC_FIND_REQUIRED) - find_package(Threads REQUIRED) -else() - find_package(Threads) -endif() -if( THREADS_FOUND ) - libraries_absolute_path(CMAKE_THREAD_LIBS_INIT "") -endif () -set(PARSEC_EXTRA_LIBRARIES "") -if( THREADS_FOUND ) - 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") -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() - 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") -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() - endif() -endif() - -# Try to find libdl if (NOT PARSEC_FIND_QUIETLY) - message(STATUS "Looking for PARSEC - Try to detect libdl") -endif() -find_library( - DL_LIBRARY - NAMES dl - ) -mark_as_advanced(DL_LIBRARY) -if (DL_LIBRARY) - list(APPEND PARSEC_EXTRA_LIBRARIES "${DL_LIBRARY}") -endif() - -# PARSEC may depend on HWLOC, try to find it -if (PARSEC_LOOK_FOR_HWLOC) - if (PARSEC_FIND_REQUIRED) - find_package(HWLOC REQUIRED) - else() - find_package(HWLOC) - endif() -endif() - -# PARSEC may depend on CUDA, try to find it -if (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) - libraries_absolute_path(CUDA_LIBRARIES "$ENV{CUDA_ROOT}/lib64") - endif() -endif() - -# PARSEC may depend on MPI, try to find it -if (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() + message(STATUS "FindPARSEC needs pkg-config program and PKG_CONFIG_PATH set with parsec.pc file path.") endif() -set(ENV_PARSEC_DIR "$ENV{PARSEC_DIR}") -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") -endif() - -# Optionally use pkg-config to detect include/library dirs (if pkg-config is available) -# ------------------------------------------------------------------------------------- -include(FindPkgConfig) -find_package(PkgConfig QUIET) - -if(PKG_CONFIG_EXECUTABLE AND NOT PARSEC_GIVEN_BY_USER) - +# use pkg-config to detect include/library dirs (if pkg-config is available) +# -------------------------------------------------------------------------- +if(PKG_CONFIG_EXECUTABLE) + unset(PARSEC_FOUND CACHE) pkg_search_module(PARSEC parsec) if (NOT PARSEC_FIND_QUIETLY) @@ -252,14 +86,13 @@ if(PKG_CONFIG_EXECUTABLE AND NOT PARSEC_GIVEN_BY_USER) endif() endif() - # create list of binaries to find - set(PARSEC_bins_to_find "parsec_ptgpp") - - # call cmake macro to find the bin path - if(PARSEC_PREFIX) + # call cmake macro to find parsec bin programs + if (PARSEC_PREFIX) + # create list of binaries to find + set(PARSEC_bins_to_find "parsec_ptgpp") 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 + set(PARSEC_${parsec_bin} "PARSEC_${parsec_bin}-NOTFOUND") + find_program(PARSEC_${parsec_bin} NAMES ${parsec_bin} HINTS ${PARSEC_PREFIX} PATH_SUFFIXES "bin" @@ -276,329 +109,36 @@ if(PKG_CONFIG_EXECUTABLE AND NOT PARSEC_GIVEN_BY_USER) pkg_get_variable(PARSEC_INCLUDE_DIRS parsec includedir) endif() set(PARSEC_FOUND_WITH_PKGCONFIG "TRUE") - find_pkgconfig_libraries_absolute_path(PARSEC) + morse_find_pkgconfig_libraries_absolute_path(PARSEC) else() set(PARSEC_FOUND_WITH_PKGCONFIG "FALSE") 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/parsec") - 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_C_IMPLICIT_INCLUDE_DIRECTORIES}") - list(REMOVE_DUPLICATES _inc_env) - - # Try to find the parsec headers in the given paths - # ------------------------------------------------- - - # create list of headers to find - set(PARSEC_hdrs_to_find "parsec_config.h" "parsec.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} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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" - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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() - 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 () - - # 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() - list(APPEND _lib_env "$ENV{LIBRARY_PATH}") - if(WIN32) - string(REPLACE ":" ";" _lib_env2 "$ENV{LIB}") - elseif(APPLE) - string(REPLACE ":" ";" _lib_env2 "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env2 "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${_lib_env2}") - 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 "parsec" "parsec-base" "parsec_distribution" "parsec_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} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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 - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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() - endif() - - # If found, add path to cmake variable - # ------------------------------------ - foreach(parsec_lib ${PARSEC_libs_to_find}) - - 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}") - - else (PARSEC_${parsec_lib}_LIBRARY) - - if(NOT PARSEC_FIND_QUIETLY) - message(STATUS "Looking for parsec -- lib ${parsec_lib} not found") - endif() - - endif (PARSEC_${parsec_lib}_LIBRARY) - - mark_as_advanced(PARSEC_${parsec_lib}_LIBRARY) - - endforeach(parsec_lib ${PARSEC_libs_to_find}) - - list(REMOVE_DUPLICATES PARSEC_LIBRARIES) - if (PARSEC_LIBRARY_DIRS) - list(REMOVE_DUPLICATES PARSEC_LIBRARY_DIRS) - endif () - - # 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) - - # create list of binaries to find - set(PARSEC_bins_to_find "parsec_ptgpp") - - # 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" - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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_parsec_ptgpp_BIN_DIR) + if (PARSEC_STATIC AND PARSEC_STATIC_LIBRARIES) + set (PARSEC_DEPENDENCIES ${PARSEC_STATIC_LIBRARIES}) + list (REMOVE_ITEM PARSEC_DEPENDENCIES "parsec") + list (APPEND PARSEC_LIBRARIES ${PARSEC_DEPENDENCIES}) + set(PARSEC_CFLAGS_OTHER ${PARSEC_STATIC_CFLAGS_OTHER}) + set(PARSEC_LDFLAGS_OTHER ${PARSEC_STATIC_LDFLAGS_OTHER}) if (NOT PARSEC_FIND_QUIETLY) - message(STATUS "Look for PARSEC - compiler parsec_ptgpp found in ${PARSEC_parsec_ptgpp_BIN_DIR}") - endif() - else() - if (PARSEC_FIND_REQUIRED) - message(FATAL_ERROR "Look for PARSEC - compiler parsec_ptgpp not found while required") + message(STATUS "PARSEC_STATIC set to 1 by user, PARSEC_LIBRARIES: ${PARSEC_LIBRARIES}.") endif() endif() - -endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT PARSEC_FOUND) OR (PARSEC_GIVEN_BY_USER) ) +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) +if(PARSEC_FOUND AND PARSEC_LIBRARIES) - # PARSEC - if (PARSEC_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${PARSEC_INCLUDE_DIRS}") - endif() - if (PARSEC_CFLAGS_OTHER) - set(REQUIRED_FLAGS "${PARSEC_CFLAGS_OTHER}") - endif() - if (PARSEC_LDFLAGS_OTHER) - set(REQUIRED_LDFLAGS "${PARSEC_LDFLAGS_OTHER}") - endif() - 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_CFLAGS_OTHER) - list(APPEND REQUIRED_FLAGS "${HWLOC_CFLAGS_OTHER}") - endif() - if (HWLOC_LDFLAGS_OTHER) - list(APPEND REQUIRED_LDFLAGS "${HWLOC_LDFLAGS_OTHER}") - endif() - if (HWLOC_LIBRARY_DIRS) - list(APPEND REQUIRED_LIBDIRS "${HWLOC_LIBRARY_DIRS}") - endif() - list(APPEND REQUIRED_LIBS "${HWLOC_LIBRARIES}") - 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}") + # check if static or dynamic lib + morse_check_static_or_dynamic(PARSEC PARSEC_LIBRARIES) + if(PARSEC_STATIC) + set(STATIC "_STATIC") + else() + set(STATIC "") 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}") - if (REQUIRED_FLAGS) - set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}") - set(REQUIRED_FLAGS) - set(REQUIRED_DEFINITIONS) - foreach(_flag ${REQUIRED_FLAGS_COPY}) - if (_flag MATCHES "^-D") - list(APPEND REQUIRED_DEFINITIONS "${_flag}") - endif() - string(REGEX REPLACE "^-D.*" "" _flag "${_flag}") - list(APPEND REQUIRED_FLAGS "${_flag}") - endforeach() - endif() - finds_remove_duplicates() - set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") - set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") - set(CMAKE_REQUIRED_LIBRARIES) - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}") - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + morse_set_required_test_lib_link(PARSEC) # test link unset(PARSEC_WORKS CACHE) @@ -606,14 +146,7 @@ if(PARSEC_LIBRARIES) check_function_exists(parsec_init PARSEC_WORKS) mark_as_advanced(PARSEC_WORKS) - if(PARSEC_WORKS) - # save link with dependencies - set(PARSEC_LIBRARIES_DEP "${REQUIRED_LIBS}") - set(PARSEC_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}") - set(PARSEC_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") - set(PARSEC_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}") - set(PARSEC_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}") - else() + if(NOT PARSEC_WORKS) if(NOT PARSEC_FIND_QUIETLY) message(STATUS "Looking for parsec : test of parsec_init fails") message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") @@ -628,42 +161,18 @@ if(PARSEC_LIBRARIES) set(CMAKE_REQUIRED_INCLUDES) set(CMAKE_REQUIRED_FLAGS) set(CMAKE_REQUIRED_LIBRARIES) -endif(PARSEC_LIBRARIES) -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) - set(PARSEC_LIBRARY_DIRS "${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) +endif(PARSEC_FOUND AND PARSEC_LIBRARIES) # check that PARSEC has been found # -------------------------------- include(FindPackageHandleStandardArgs) find_package_handle_standard_args(PARSEC DEFAULT_MSG PARSEC_LIBRARIES - PARSEC_parsec_ptgpp_BIN_DIR + PARSEC_parsec_ptgpp PARSEC_WORKS) -if ( PARSEC_parsec_ptgpp_BIN_DIR ) - find_program(PARSEC_PARSEC_PTGPP - NAMES parsec_ptgpp - HINTS ${PARSEC_parsec_ptgpp_BIN_DIR}) -else() - set(PARSEC_PARSEC_PTGPP "PARSEC_PARSEC_PTGPP-NOTFOUND") -endif() +# Add imported targe +if (PARSEC_FOUND) + morse_create_imported_target(PARSEC) +endif() \ No newline at end of file diff --git a/modules/find/FindPASTIX.cmake b/modules/find/FindPASTIX.cmake deleted file mode 100644 index 7c7afbf8204bd468c810cfdec21c8f5f3359add5..0000000000000000000000000000000000000000 --- a/modules/find/FindPASTIX.cmake +++ /dev/null @@ -1,961 +0,0 @@ -### -# -# @copyright (c) 2009-2014 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. -# @copyright (c) 2012-2020 Inria. All rights reserved. -# @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. -# -### -# -# - Find PASTIX include dirs and libraries -# Use this module by invoking find_package with the form: -# find_package(PASTIX -# [REQUIRED] # Fail with error if pastix is not found -# [COMPONENTS <comp1> <comp2> ...] # dependencies -# ) -# -# PASTIX depends on the following libraries: -# - Threads, m, rt -# - MPI -# - HWLOC -# - BLAS -# - SPM (for versions >= 6) -# -# COMPONENTS are optional libraries PASTIX could be linked with, -# Use it to drive detection of a specific compilation chain -# COMPONENTS can be some of the following: -# - MPI: to activate detection of the parallel MPI version (default) -# it looks for Threads, HWLOC, BLAS, MPI and ScaLAPACK libraries -# - SEQ: to activate detection of the sequential version (exclude MPI version) -# - PARSEC: to activate detection of PASTIX with PARSEC -# - STARPU: to activate detection of StarPU version -# it looks for MPI version of StarPU (default behaviour) -# if SEQ and STARPU are given, it looks for a StarPU without MPI -# - STARPU_CUDA: to activate detection of StarPU with CUDA -# - STARPU_FXT: to activate detection of StarPU with FxT -# - SCOTCH: to activate detection of PASTIX linked with SCOTCH -# - PTSCOTCH: to activate detection of PASTIX linked with SCOTCH -# - METIS: to activate detection of PASTIX linked with SCOTCH -# - FORTRAN: to provide Fortran libraries of PASTIX in LIBRARIES -# - SPM: for PASTIX versions >=6 SPM is required so that you must add -# this component in this case -# -# This module finds headers and pastix library. -# Results are reported in variables: -# PASTIX_FOUND - True if headers and requested libraries were found -# PASTIX_CFLAGS_OTHER - pastix compiler flags without headers paths -# PASTIX_LDFLAGS_OTHER - pastix linker flags without libraries -# PASTIX_INCLUDE_DIRS - pastix include directories -# PASTIX_LIBRARY_DIRS - pastix link directories -# PASTIX_LIBRARIES - pastix libraries to be linked (absolute path) -# PASTIX_LIBRARIES_FORTRAN - pastix Fortran libraries to be linked (absolute path) -# PASTIX_CFLAGS_OTHER_DEP - pastix + dependencies compiler flags without headers paths -# PASTIX_LDFLAGS_OTHER_DEP - pastix + dependencies linker flags without libraries -# PASTIX_INCLUDE_DIRS_DEP - pastix + dependencies include directories -# PASTIX_LIBRARY_DIRS_DEP - pastix + dependencies link directories -# PASTIX_LIBRARIES_DEP - pastix + dependencies libraries -# PASTIX_INTSIZE - Number of octets occupied by a pastix_int_t -# PASTIX_VERSION_MAJOR - pastix Version, first (major) number -# -# PASTIX_FOUND_WITH_PKGCONFIG - True if found with pkg-config -# if found with pkg-config the following variables are set -# <PREFIX> = PASTIX -# <XPREFIX> = <PREFIX> for common case -# <XPREFIX> = <PREFIX>_STATIC for static linking -# <XPREFIX>_FOUND ... set to 1 if module(s) exist -# <XPREFIX>_LIBRARIES ... only the libraries (w/o the '-l') -# <XPREFIX>_LIBRARY_DIRS ... the paths of the libraries (w/o the '-L') -# <XPREFIX>_LDFLAGS ... all required linker flags -# <XPREFIX>_LDFLAGS_OTHER ... all other linker flags -# <XPREFIX>_INCLUDE_DIRS ... the '-I' preprocessor flags (w/o the '-I') -# <XPREFIX>_CFLAGS ... all required cflags -# <XPREFIX>_CFLAGS_OTHER ... the other compiler flags -# -# The user can give specific paths where to find the libraries adding cmake -# options at configure (ex: cmake path/to/project -DPASTIX_DIR=path/to/pastix): -# PASTIX_DIR - Where to find the base directory of pastix -# PASTIX_INCDIR - Where to find the header files -# PASTIX_LIBDIR - Where to find the library files -# The module can also look for the following environment variables if paths -# are not given as cmake variable: PASTIX_DIR, PASTIX_INCDIR, PASTIX_LIBDIR - -#============================================================================= -# Copyright 2012-2019 Inria -# Copyright 2012-2013 Emmanuel Agullo -# Copyright 2012-2013 Mathieu Faverge -# Copyright 2012 Cedric Castagnede -# Copyright 2013-2018 Florent Pruvost -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file MORSE-Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of Morse, substitute the full -# License text for the above reference.) - -# Common macros to use in finds -include(FindInit) - -if (NOT PASTIX_FOUND) - set(PASTIX_DIR "" CACHE PATH "Installation directory of PASTIX library") - 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 -set(PASTIX_LOOK_FOR_MPI ON) -set(PASTIX_LOOK_FOR_SEQ OFF) -set(PASTIX_LOOK_FOR_STARPU OFF) -set(PASTIX_LOOK_FOR_PARSEC OFF) -set(PASTIX_LOOK_FOR_STARPU_CUDA OFF) -set(PASTIX_LOOK_FOR_STARPU_FXT OFF) -set(PASTIX_LOOK_FOR_SCOTCH ON) -set(PASTIX_LOOK_FOR_PTSCOTCH OFF) -set(PASTIX_LOOK_FOR_METIS OFF) -set(PASTIX_LOOK_FOR_FORTRAN OFF) -set(PASTIX_LOOK_FOR_SPM 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 "PARSEC") - set(PASTIX_LOOK_FOR_PARSEC 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 "PTSCOTCH") - set(PASTIX_LOOK_FOR_PTSCOTCH ON) - endif() - if (${component} STREQUAL "METIS") - set(PASTIX_LOOK_FOR_METIS ON) - endif() - if (${component} STREQUAL "FORTRAN") - set(PASTIX_LOOK_FOR_FORTRAN ON) - endif() - if (${component} STREQUAL "SPM") - set(PASTIX_LOOK_FOR_SPM ON) - endif() - endforeach() -endif() - -# Dependencies detection -# ---------------------- - -# Required dependencies -# --------------------- - -if (NOT PASTIX_FIND_QUIETLY) - message(STATUS "Looking for PASTIX - Try to detect pthread") -endif() -if (PASTIX_FIND_REQUIRED) - find_package(Threads REQUIRED) -else() - find_package(Threads) -endif() -if( THREADS_FOUND ) - libraries_absolute_path(CMAKE_THREAD_LIBS_INIT "") -endif () -set(PASTIX_EXTRA_LIBRARIES "") -if( THREADS_FOUND ) - 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") -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() -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") -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() -endif() - -# PASTIX depends on HWLOC -#------------------------ -if (NOT PASTIX_FIND_QUIETLY) - message(STATUS "Looking for PASTIX - Try to detect HWLOC") -endif() -if (PASTIX_FIND_REQUIRED) - find_package(HWLOC REQUIRED) -else() - find_package(HWLOC) -endif() - -# PASTIX depends on BLAS -#----------------------- -if (NOT PASTIX_FIND_QUIETLY) - message(STATUS "Looking for PASTIX - Try to detect BLAS") -endif() -if (PASTIX_FIND_REQUIRED) - find_package(BLAS REQUIRED) -else() - find_package(BLAS) -endif() - - -# Optional dependencies -# --------------------- - -# PASTIX may depend on MPI -#------------------------- -if (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() -endif (PASTIX_LOOK_FOR_MPI) - -# PASTIX may depend on PARSEC -#---------------------------- -if (PASTIX_LOOK_FOR_PARSEC) - if (NOT PASTIX_FIND_QUIETLY) - message(STATUS "Looking for PASTIX - Try to detect PARSEC") - endif() - if (PASTIX_FIND_REQUIRED AND PASTIX_FIND_REQUIRED_PARSEC) - find_package(PARSEC REQUIRED) - else() - find_package(PARSEC) - endif() -endif() - -# PASTIX may depend on STARPU -#---------------------------- -if(PASTIX_LOOK_FOR_STARPU) - - 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() - -endif(PASTIX_LOOK_FOR_STARPU) - -# PASTIX may depend on SCOTCH -#----------------------------- -if (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() -endif() - -# PASTIX may depend on PTSCOTCH -#------------------------------- -if (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() -endif() - -# PASTIX may depend on METIS -#---------------------------- -if (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() -endif() - -# PASTIX may depend on SPM -#-------------------------- -if (PASTIX_LOOK_FOR_SPM) - if (NOT PASTIX_FIND_QUIETLY) - message(STATUS "Looking for PASTIX - Try to detect SPM") - endif() - set(SPM_COMPONENTS "") - if(PASTIX_LOOK_FOR_FORTRAN) - list(APPEND SPM_COMPONENTS "FORTRAN" ) - endif() - if (PASTIX_FIND_REQUIRED) - find_package(SPM REQUIRED COMPONENTS ${SPM_COMPONENTS}) - else() - find_package(SPM COMPONENTS ${SPM_COMPONENTS}) - endif() -endif() - -set(ENV_PASTIX_DIR "$ENV{PASTIX_DIR}") -set(ENV_PASTIX_INCDIR "$ENV{PASTIX_INCDIR}") -set(ENV_PASTIX_LIBDIR "$ENV{PASTIX_LIBDIR}") -set(PASTIX_GIVEN_BY_USER "FALSE") -if ( PASTIX_DIR OR ( PASTIX_INCDIR AND PASTIX_LIBDIR) OR ENV_PASTIX_DIR OR (ENV_PASTIX_INCDIR AND ENV_PASTIX_LIBDIR) ) - set(PASTIX_GIVEN_BY_USER "TRUE") -endif() - -# Optionally use pkg-config to detect include/library dirs (if pkg-config is available) -# ------------------------------------------------------------------------------------- -include(FindPkgConfig) -find_package(PkgConfig QUIET) -if(PKG_CONFIG_EXECUTABLE AND NOT PASTIX_GIVEN_BY_USER) - - pkg_search_module(PASTIX pastix) - - if (NOT PASTIX_FIND_QUIETLY) - if (PASTIX_FOUND AND PASTIX_LIBRARIES) - message(STATUS "Looking for PASTIX - found using PkgConfig") - else() - message(STATUS "${Magenta}Looking for PASTIX - not found using PkgConfig." - "\n Perhaps you should add the directory containing pastix.pc" - "\n to the PKG_CONFIG_PATH environment variable.${ColourReset}") - endif() - endif() - - if (PASTIX_FOUND AND PASTIX_LIBRARIES) - if (NOT PASTIX_INCLUDE_DIRS) - pkg_get_variable(PASTIX_INCLUDE_DIRS pastix includedir) - endif() - set(PASTIX_FOUND_WITH_PKGCONFIG "TRUE") - find_pkgconfig_libraries_absolute_path(PASTIX) - else() - set(PASTIX_FOUND_WITH_PKGCONFIG "FALSE") - endif() - - set(PASTIX_VERSION_MAJOR) - foreach(_lib ${PASTIX_LIBRARIES}) - if (_lib MATCHES "pastix_murge") - set(PASTIX_VERSION_MAJOR "5") - endif() - if (_lib MATCHES "pastix_kernels") - set(PASTIX_VERSION_MAJOR "6") - endif() - endforeach() - -endif(PKG_CONFIG_EXECUTABLE AND NOT PASTIX_GIVEN_BY_USER) - -# 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 (install scotch, ptscotch or metis)") -endif() - -if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT PASTIX_FOUND) OR (PASTIX_GIVEN_BY_USER) ) - - # Looking for PaStiX - # ------------------ - - # Looking for include - # ------------------- - - # Add system include paths to search include - # ------------------------------------------ - 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}") - 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") - 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_C_IMPLICIT_INCLUDE_DIRECTORIES}") - list(REMOVE_DUPLICATES _inc_env) - - - # Try to find the pastix header in the given paths - # --------------------------------------------------- - # 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} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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" - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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}") - else () - set(PASTIX_INCLUDE_DIRS "PASTIX_INCLUDE_DIRS-NOTFOUND") - if(NOT PASTIX_FIND_QUIETLY) - message(STATUS "Looking for pastix -- pastix.h not found") - endif() - endif() - - - # Looking for lib - # --------------- - - # Add system library paths to search lib - # -------------------------------------- - unset(_lib_env) - set(ENV_PASTIX_LIBDIR "$ENV{PASTIX_LIBDIR}") - if(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") - else() - list(APPEND _lib_env "$ENV{LIBRARY_PATH}") - if(WIN32) - string(REPLACE ":" ";" _lib_env2 "$ENV{LIB}") - elseif(APPLE) - string(REPLACE ":" ";" _lib_env2 "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env2 "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${_lib_env2}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - endif() - list(REMOVE_DUPLICATES _lib_env) - - # Try to find the pastix lib in the given paths - # ------------------------------------------------ - - # create list of libs to find - set(PASTIX_libs_to_find_v5 "pastix_murge;pastix") - set(PASTIX_libs_to_find_v6 "pastix;pastix_kernels") - if(PASTIX_LOOK_FOR_PARSEC) - list(INSERT 1 PASTIX_libs_to_find_v6 "pastix_parsec") - endif() - if(PASTIX_LOOK_FOR_STARPU) - list(INSERT 1 PASTIX_libs_to_find_v6 "pastix_starpu") - endif() - foreach(v 5 6) - set(V_FOUND TRUE) - set(PASTIX_libs_to_find ${PASTIX_libs_to_find_v${v}}) - message(STATUS "Looking for pastix -- Testing is version ${v}") - # call cmake macro to find the lib path - foreach(pastix_lib ${PASTIX_libs_to_find}) - set(PASTIX_${pastix_lib}_LIBRARY "PASTIX_${pastix_lib}_LIBRARY-NOTFOUND") - if(PASTIX_LIBDIR) - find_library(PASTIX_${pastix_lib}_LIBRARY - NAMES ${pastix_lib} - HINTS ${PASTIX_LIBDIR} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - if(PASTIX_DIR) - find_library(PASTIX_${pastix_lib}_LIBRARY - NAMES ${pastix_lib} - HINTS ${PASTIX_DIR} - PATH_SUFFIXES lib lib32 lib64 - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - find_library(PASTIX_${pastix_lib}_LIBRARY - NAMES ${pastix_lib} - HINTS ${_lib_env}) - endif() - endif() - if (NOT PASTIX_${pastix_lib}_LIBRARY) - set (V_FOUND FALSE) - break() - endif() - endforeach() - if (V_FOUND) - set(PASTIX_VERSION_MAJOR ${v}) - message(STATUS "Looking for pastix -- major version detected: ${PASTIX_VERSION_MAJOR}") - if (PASTIX_FIND_VERSION) - if (NOT ${PASTIX_VERSION_MAJOR} EQUAL ${PASTIX_FIND_VERSION_MAJOR}) - message(FATAL_ERROR "Looking for pastix -- PaStiX version found differ from required") - endif() - endif() - break() - endif() - endforeach() - - # 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) - - endforeach(pastix_lib ${PASTIX_libs_to_find}) - -endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT PASTIX_FOUND) OR (PASTIX_GIVEN_BY_USER) ) - - -# check a function to validate the find -if(PASTIX_LIBRARIES) - - set(REQUIRED_INCDIRS) - set(REQUIRED_FLAGS) - set(REQUIRED_LDFLAGS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) - - # PASTIX - if (PASTIX_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${PASTIX_INCLUDE_DIRS}") - endif() - if (PASTIX_CFLAGS_OTHER) - list(APPEND REQUIRED_FLAGS "${PASTIX_CFLAGS_OTHER}") - endif() - if (PASTIX_LDFLAGS_OTHER) - list(APPEND REQUIRED_LDFLAGS "${PASTIX_LDFLAGS_OTHER}") - endif() - foreach(libdir ${PASTIX_LIBRARY_DIRS}) - if (libdir) - list(APPEND REQUIRED_LIBDIRS "${libdir}") - endif() - endforeach() - set(REQUIRED_LIBS "${PASTIX_LIBRARIES}") - # PARSEC - if (PASTIX_LOOK_FOR_PARSEC AND PARSEC_FOUND) - if (PARSEC_INCLUDE_DIRS_DEP) - list(APPEND REQUIRED_INCDIRS "${PARSEC_INCLUDE_DIRS_DEP}") - endif() - if (PARSEC_CFLAGS_OTHER_DEP) - list(APPEND REQUIRED_FLAGS "${PARSEC_CFLAGS_OTHER_DEP}") - endif() - if (PARSEC_LDFLAGS_OTHER_DEP) - list(APPEND REQUIRED_LDFLAGS "${PARSEC_LDFLAGS_OTHER_DEP}") - endif() - if(PARSEC_LIBRARY_DIRS_DEP) - list(APPEND REQUIRED_LIBDIRS "${PARSEC_LIBRARY_DIRS_DEP}") - endif() - if (PARSEC_LIBRARIES_DEP) - list(APPEND REQUIRED_LIBS "${PARSEC_LIBRARIES_DEP}") - endif() - endif() - # STARPU - if (PASTIX_LOOK_FOR_STARPU AND STARPU_FOUND) - if (STARPU_INCLUDE_DIRS_DEP) - list(APPEND REQUIRED_INCDIRS "${STARPU_INCLUDE_DIRS_DEP}") - endif() - if (STARPU_CFLAGS_OTHER_DEP) - list(APPEND REQUIRED_FLAGS "${STARPU_CFLAGS_OTHER_DEP}") - endif() - if (STARPU_LDFLAGS_OTHER_DEP) - list(APPEND REQUIRED_LDFLAGS "${STARPU_LDFLAGS_OTHER_DEP}") - endif() - if(STARPU_LIBRARY_DIRS_DEP) - list(APPEND REQUIRED_LIBDIRS "${STARPU_LIBRARY_DIRS_DEP}") - endif() - if (STARPU_LIBRARIES_DEP) - list(APPEND REQUIRED_LIBS "${STARPU_LIBRARIES_DEP}") - 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() - if (HWLOC_CFLAGS_OTHER) - list(APPEND REQUIRED_FLAGS "${HWLOC_CFLAGS_OTHER}") - endif() - if (HWLOC_LDFLAGS_OTHER) - list(APPEND REQUIRED_LDFLAGS "${HWLOC_LDFLAGS_OTHER}") - endif() - if (HWLOC_LIBRARY_DIRS) - list(APPEND REQUIRED_LIBDIRS "${HWLOC_LIBRARY_DIRS}") - endif() - list(APPEND REQUIRED_LIBS "${HWLOC_LIBRARIES}") - endif() - # BLAS - if (BLAS_FOUND) - if (BLAS_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${BLAS_INCLUDE_DIRS}") - endif() - if (BLAS_CFLAGS_OTHER) - list(APPEND REQUIRED_FLAGS "${BLAS_CFLAGS_OTHER}") - endif() - if (BLAS_LDFLAGS_OTHER) - list(APPEND REQUIRED_LDFLAGS "${BLAS_LDFLAGS_OTHER}") - endif() - if (BLAS_LIBRARY_DIRS) - list(APPEND REQUIRED_LIBDIRS "${BLAS_LIBRARY_DIRS}") - endif() - list(APPEND REQUIRED_LIBS "${BLAS_LIBRARIES}") - endif() - # SPM - if (PASTIX_LOOK_FOR_SPM AND SPM_FOUND) - if (SPM_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${SPM_INCLUDE_DIRS}") - endif() - if (SPM_CFLAGS_OTHER) - list(APPEND REQUIRED_FLAGS "${SPM_CFLAGS_OTHER}") - endif() - if (SPM_LDFLAGS_OTHER) - list(APPEND REQUIRED_LDFLAGS "${SPM_LDFLAGS_OTHER}") - endif() - if (SPM_LIBRARY_DIRS) - list(APPEND REQUIRED_LIBDIRS "${SPM_LIBRARY_DIRS}") - endif() - list(APPEND REQUIRED_LIBS "${SPM_LIBRARIES}") - 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() - # 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}") - if (REQUIRED_FLAGS) - set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}") - set(REQUIRED_FLAGS) - set(REQUIRED_DEFINITIONS) - foreach(_flag ${REQUIRED_FLAGS_COPY}) - if (_flag MATCHES "^-D") - list(APPEND REQUIRED_DEFINITIONS "${_flag}") - endif() - string(REGEX REPLACE "^-D.*" "" _flag "${_flag}") - list(APPEND REQUIRED_FLAGS "${_flag}") - endforeach() - endif() - finds_remove_duplicates() - set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") - set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") - set(CMAKE_REQUIRED_LIBRARIES) - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}") - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") - 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_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}") - set(PASTIX_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}") - 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 "CMAKE_REQUIRED_FLAGS: ${CMAKE_REQUIRED_FLAGS}") - 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, PARSEC, 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) - - -# Check the size of pastix_int_t -# --------------------------------- -set(CMAKE_REQUIRED_INCLUDES ${PASTIX_INCLUDE_DIRS_DEP}) - -include(CheckCSourceRuns) -#mpi.h should be included by pastix.h directly -if ((PASTIX_LOOK_FOR_MPI AND MPI_FOUND) AND (${PASTIX_VERSION_MAJOR} EQUAL 5)) - set(PASTIX_C_TEST_PASTIX_INT_4 " -#include <mpi.h> -#include <pastix.h> -int main(int argc, char **argv) { - if (sizeof(pastix_int_t) == 4) - return 0; - else - return 1; -} -") - - set(PASTIX_C_TEST_PASTIX_INT_8 " -#include <mpi.h> -#include <pastix.h> -int main(int argc, char **argv) { - if (sizeof(pastix_int_t) == 8) - return 0; - else - return 1; -} -") -else() - set(PASTIX_C_TEST_PASTIX_INT_4 " -#include <pastix.h> -int main(int argc, char **argv) { - if (sizeof(pastix_int_t) == 4) - return 0; - else - return 1; -} -") - - set(PASTIX_C_TEST_PASTIX_INT_8 " -#include <pastix.h> -int main(int argc, char **argv) { - if (sizeof(pastix_int_t) == 8) - return 0; - else - return 1; -} -") -endif() - -unset(PASTIX_INT_4 CACHE) -unset(PASTIX_INT_8 CACHE) -check_c_source_runs("${PASTIX_C_TEST_PASTIX_INT_4}" PASTIX_INT_4) -check_c_source_runs("${PASTIX_C_TEST_PASTIX_INT_8}" PASTIX_INT_8) -if(NOT PASTIX_INT_4) - if(NOT PASTIX_INT_8) - set(PASTIX_INTSIZE -1) - else() - set(PASTIX_INTSIZE 8) - endif() -else() - set(PASTIX_INTSIZE 4) -endif() -set(CMAKE_REQUIRED_INCLUDES "") - - -if (PASTIX_LIBRARIES) - list(GET PASTIX_LIBRARIES 0 first_lib) - get_filename_component(first_lib_path "${first_lib}" PATH) - if (NOT PASTIX_LIBRARY_DIRS) - set(PASTIX_LIBRARY_DIRS "${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(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) - -if (PASTIX_LOOK_FOR_FORTRAN) - find_library(PASTIX_pastixf_LIBRARY - NAMES pastixf - HINTS ${PASTIX_LIBRARY_DIRS}) - mark_as_advanced(PASTIX_pastixf_LIBRARY) - if (PASTIX_pastixf_LIBRARY) - set(PASTIX_LIBRARIES_FORTRAN ${PASTIX_pastixf_LIBRARY}) - list(INSERT PASTIX_LIBRARIES 0 "${PASTIX_LIBRARIES_FORTRAN}") - list(INSERT PASTIX_LIBRARIES_DEP 0 "${PASTIX_LIBRARIES_FORTRAN}") - else() - set(PASTIX_LIBRARIES_FORTRAN "PASTIX_LIBRARIES_FORTRAN-NOTFOUND") - endif() -endif() - -# check that PASTIX has been found -# --------------------------------- -include(FindPackageHandleStandardArgs) -if (PASTIX_LOOK_FOR_FORTRAN) - find_package_handle_standard_args(PASTIX DEFAULT_MSG - PASTIX_LIBRARIES_FORTRAN - PASTIX_LIBRARIES - PASTIX_WORKS) -else() - find_package_handle_standard_args(PASTIX DEFAULT_MSG - PASTIX_LIBRARIES - PASTIX_WORKS) -endif() diff --git a/modules/find/FindPETSC.cmake b/modules/find/FindPETSC.cmake index 9d588b42cf8e6a06e2a945a0097d2ceb1495ae58..628285da2cf7206f3abe179ef6949aa24aeead54 100644 --- a/modules/find/FindPETSC.cmake +++ b/modules/find/FindPETSC.cmake @@ -50,12 +50,20 @@ # # PETSC_FOUND_WITH_PKGCONFIG - True if found with pkg-config # +# This module defines the following :prop_tgt:`IMPORTED` target: +# +# ``MORSE::PETSC`` +# The headers and libraries to use for PETSC, if found. +# # find_package(PETSC [QUIET] [REQUIRED]) # # Setting these changes the behavior of the search # PETSC_DIR - directory in which PETSC is installed # PETSC_ARCH - build architecture +# Common macros to use in finds +include(FindMorseInit) + # create a cmake cache variable set(PETSC_DIR "" CACHE PATH "Installation directory of PETSC library") if (NOT PETSC_FIND_QUIETLY AND NOT PETSC_DIR) @@ -65,8 +73,6 @@ endif() # Use pkg-config to detect include/library dirs (if pkg-config is available) # ------------------------------------------------------------------------------------- -include(FindPkgConfig) -find_package(PkgConfig QUIET) if( PKG_CONFIG_EXECUTABLE AND NOT PETSC_DIR ) pkg_search_module(PETSC PETSc) if (NOT PETSC_FIND_QUIETLY) @@ -84,10 +90,18 @@ if( PKG_CONFIG_EXECUTABLE AND NOT PETSC_DIR ) pkg_get_variable(PETSC_INCLUDE_DIRS PETSc includedir) endif() set(PETSC_FOUND_WITH_PKGCONFIG "TRUE") - find_pkgconfig_libraries_absolute_path(PETSC) + morse_find_pkgconfig_libraries_absolute_path(PETSC) else() set(PETSC_FOUND_WITH_PKGCONFIG "FALSE") endif() + if (PETSC_STATIC AND PETSC_STATIC_LIBRARIES) + set (PETSC_DEPENDENCIES ${PETSC_STATIC_LIBRARIES}) + list (REMOVE_ITEM SLEPC_DEPENDENCIES "petsc") + list (APPEND PETSC_LIBRARIES ${PETSC_DEPENDENCIES}) + if (NOT PETSC_FIND_QUIETLY) + message(STATUS "PETSC_STATIC set to 1 by user, PETSC_LIBRARIES: ${PETSC_LIBRARIES}.") + endif() + endif() endif() # consider using the env. var. PETSC_DIR if not directly given through the CMake cache var. @@ -213,3 +227,8 @@ include (FindPackageHandleStandardArgs) find_package_handle_standard_args (PETSC "PETSC could not be found. Be sure to set PETSC_DIR." PETSC_MPIEXEC PETSC_INCLUDE_DIRS PETSC_LIBRARIES PETSC_LIBRARY_DIRS) + +# Add imported target +if (PETSC_FOUND) + morse_create_imported_target(PETSC) +endif() \ No newline at end of file diff --git a/modules/find/FindPTSCOTCH.cmake b/modules/find/FindPTSCOTCH.cmake index 61794cbc294097f42529f653731bee01be27b450..4263dee4c6e216e04c4ffa023f0e3db9007d5be4 100644 --- a/modules/find/FindPTSCOTCH.cmake +++ b/modules/find/FindPTSCOTCH.cmake @@ -1,11 +1,23 @@ ### # -# @copyright (c) 2009-2014 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. -# @copyright (c) 2012-2019 Inria. All rights reserved. +# @copyright (c) 2012-2020 Inria. All rights reserved. # @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. # +# Copyright 2012-2013 Emmanuel Agullo +# Copyright 2012-2013 Mathieu Faverge +# Copyright 2012 Cedric Castagnede +# Copyright 2013-2020 Florent Pruvost +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file MORSE-Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of Morse, substitute the full +# License text for the above reference.) +# ### # # - Find PTSCOTCH include dirs and libraries @@ -24,17 +36,13 @@ # # This module finds headers and ptscotch library. # Results are reported in variables: -# PTSCOTCH_FOUND - True if headers and requested libraries were found +# PTSCOTCH_FOUND - True if headers and requested libraries were found +# PTSCOTCH_PREFIX - installation path of the lib found # PTSCOTCH_CFLAGS_OTHER - ptscotch compiler flags without headers paths # PTSCOTCH_LDFLAGS_OTHER - ptscotch linker flags without libraries # PTSCOTCH_INCLUDE_DIRS - ptscotch include directories # PTSCOTCH_LIBRARY_DIRS - ptscotch link directories # PTSCOTCH_LIBRARIES - ptscotch libraries to be linked (absolute path) -# PTSCOTCH_CFLAGS_OTHER_DEP - ptscotch + dependencies compiler flags without headers paths -# PTSCOTCH_LDFLAGS_OTHER_DEP - ptscotch + dependencies linker flags without libraries -# PTSCOTCH_INCLUDE_DIRS_DEP - ptscotch + dependencies include directories -# PTSCOTCH_LIBRARY_DIRS_DEP - ptscotch + dependencies link directories -# PTSCOTCH_LIBRARIES_DEP - ptscotch + dependencies libraries # PTSCOTCH_INTSIZE - Number of octets occupied by a SCOTCH_Num # # The user can give specific paths where to find the libraries adding cmake @@ -44,26 +52,18 @@ # PTSCOTCH_LIBDIR - Where to find the library files # The module can also look for the following environment variables if paths # are not given as cmake variable: PTSCOTCH_DIR, PTSCOTCH_INCDIR, PTSCOTCH_LIBDIR - -#============================================================================= -# Copyright 2012-2019 Inria -# Copyright 2012-2013 Emmanuel Agullo -# Copyright 2012-2013 Mathieu Faverge -# Copyright 2012 Cedric Castagnede -# Copyright 2013-2016 Florent Pruvost # -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file MORSE-Copyright.txt for details. +# Set PTSCOTCH_STATIC to 1 to force using static libraries if exist. +# +# This module defines the following :prop_tgt:`IMPORTED` target: +# +# ``MORSE::PTSCOTCH`` +# The headers and libraries to use for PTSCOTCH, if found. # -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. #============================================================================= -# (To distribute this file outside of Morse, substitute the full -# License text for the above reference.) # Common macros to use in finds -include(FindInit) +include(FindMorseInit) if (NOT PTSCOTCH_FOUND) set(PTSCOTCH_DIR "" CACHE PATH "Installation directory of PTSCOTCH library") @@ -214,6 +214,11 @@ list(REMOVE_DUPLICATES _lib_env) # Try to find the ptscotch lib in the given paths # ---------------------------------------------- +if (PTSCOTCH_STATIC) + set (CMAKE_FIND_LIBRARY_SUFFIXES_COPY ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set (CMAKE_FIND_LIBRARY_SUFFIXES ".a") +endif() + set(PTSCOTCH_libs_to_find "ptscotch;ptscotcherr") if (PTSCOTCH_LOOK_FOR_ESMUMPS) list(INSERT PTSCOTCH_libs_to_find 0 "ptesmumps") @@ -250,6 +255,10 @@ else() endif() endif() +if (PTSCOTCH_STATIC) + set (CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_COPY}) +endif() + set(PTSCOTCH_LIBRARIES "") set(PTSCOTCH_LIBRARY_DIRS "") # If found, add path to cmake variable @@ -276,11 +285,17 @@ list(REMOVE_DUPLICATES PTSCOTCH_LIBRARY_DIRS) # check a function to validate the find if(PTSCOTCH_LIBRARIES) + # check if static or dynamic lib + morse_check_static_or_dynamic(PTSCOTCH PTSCOTCH_LIBRARIES) + if(PTSCOTCH_STATIC) + set(STATIC "_STATIC") + endif() + set(REQUIRED_INCDIRS) - set(REQUIRED_FLAGS) - set(REQUIRED_LDFLAGS) set(REQUIRED_LIBDIRS) set(REQUIRED_LIBS) + set(REQUIRED_FLAGS) + set(REQUIRED_LDFLAGS) # PTSCOTCH if (PTSCOTCH_INCLUDE_DIRS) @@ -340,7 +355,7 @@ if(PTSCOTCH_LIBRARIES) list(APPEND REQUIRED_FLAGS "${_flag}") endforeach() endif() - finds_remove_duplicates() + morse_finds_remove_duplicates() set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) @@ -355,12 +370,14 @@ if(PTSCOTCH_LIBRARIES) 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_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}") - set(PTSCOTCH_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}") + set(PTSCOTCH_INCLUDE_DIRS "${REQUIRED_INCDIRS}") + set(PTSCOTCH_LIBRARY_DIRS "${REQUIRED_LIBDIRS}") + if (PTSCOTCH_STATIC) + # save link with dependencies + set(PTSCOTCH_LIBRARIES "${REQUIRED_LIBS}") + set(PTSCOTCH_CFLAGS_OTHER "${REQUIRED_FLAGS}") + set(PTSCOTCH_LDFLAGS_OTHER "${REQUIRED_LDFLAGS}") + endif() else() if(NOT PTSCOTCH_FIND_QUIETLY) message(STATUS "Looking for PTSCOTCH : test of SCOTCH_dgraphInit with PTSCOTCH library fails") @@ -373,23 +390,22 @@ if(PTSCOTCH_LIBRARIES) 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) + get_filename_component(first_lib_path "${first_lib}" DIRECTORY) if (NOT PTSCOTCH_LIBRARY_DIRS) set(PTSCOTCH_LIBRARY_DIRS "${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(PTSCOTCH_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of PTSCOTCH library" FORCE) + set(PTSCOTCH_PREFIX "${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) + set(PTSCOTCH_PREFIX "${first_lib_path}" CACHE PATH "Installation directory of PTSCOTCH library" FORCE) endif() -endif() -mark_as_advanced(PTSCOTCH_DIR) -mark_as_advanced(PTSCOTCH_DIR_FOUND) + mark_as_advanced(PTSCOTCH_DIR) + mark_as_advanced(PTSCOTCH_PREFIX) + +endif(PTSCOTCH_LIBRARIES) # Check the size of SCOTCH_Num # --------------------------------- @@ -444,6 +460,8 @@ include(FindPackageHandleStandardArgs) find_package_handle_standard_args(PTSCOTCH DEFAULT_MSG PTSCOTCH_LIBRARIES PTSCOTCH_WORKS) -# -# TODO: Add possibility to check for specific functions in the library -# + +# Add imported target +if (PTSCOTCH_FOUND) + morse_create_imported_target(PTSCOTCH) +endif() diff --git a/modules/find/FindPkgconfigLibrariesAbsolutePath.cmake b/modules/find/FindPkgconfigLibrariesAbsolutePath.cmake deleted file mode 100644 index 862739a1d9c719fdfc85d95c98062e4bc4b188ce..0000000000000000000000000000000000000000 --- a/modules/find/FindPkgconfigLibrariesAbsolutePath.cmake +++ /dev/null @@ -1,99 +0,0 @@ -### -# -# @copyright (c) 2019 Inria. All rights reserved. -# -### -# -# @file FindPkgconfigLibrariesAbsolutePath.cmake -# -# @project MORSE -# MORSE is a software package provided by: -# Inria Bordeaux - Sud-Ouest, -# Univ. of Tennessee, -# King Abdullah Univesity of Science and Technology -# Univ. of California Berkeley, -# Univ. of Colorado Denver. -# -# @version 1.0.0 -# @author Florent Pruvost -# @date 06-04-2018 -# -### - -# Transform relative path into absolute path for libraries found with the -# pkg_search_module cmake macro -# _prefix: the name of the CMake variable used when pkg_search_module was called -# e.g. for pkg_search_module(BLAS blas) _prefix would be BLAS -macro(FIND_PKGCONFIG_LIBRARIES_ABSOLUTE_PATH _prefix) - list(APPEND _lib_env "$ENV{LIBRARY_PATH}") - if(WIN32) - string(REPLACE ":" ";" _lib_env2 "$ENV{LIB}") - elseif(APPLE) - string(REPLACE ":" ";" _lib_env2 "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env2 "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${_lib_env2}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - # non static case - set(${_prefix}_LIBRARIES_COPY "${${_prefix}_LIBRARIES}") - set(${_prefix}_LIBRARIES "") - foreach(_library ${${_prefix}_LIBRARIES_COPY}) - if(EXISTS "${_library}") - list(APPEND ${_prefix}_LIBRARIES ${_library}) - else() - get_filename_component(_ext "${_library}" EXT) - set(_lib_extensions ".so" ".a" ".dyld" ".dll") - list(FIND _lib_extensions "${_ext}" _index) - if (${_index} GREATER -1) - get_filename_component(_library "${_library}" NAME_WE) - endif() - find_library(_library_path NAMES ${_library} - HINTS ${${_prefix}_LIBDIR} ${${_prefix}_LIBRARY_DIRS} ${_lib_env}) - if (_library_path) - list(APPEND ${_prefix}_LIBRARIES ${_library_path}) - else() - message(FATAL_ERROR "Dependency of ${_prefix} '${_library}' NOT FOUND") - endif() - unset(_library_path CACHE) - endif() - endforeach() - set (${_prefix}_LIBRARIES "${${_prefix}_LIBRARIES}" CACHE INTERNAL "" FORCE) - ## static case - #set(${_prefix}_STATIC_LIBRARIES_COPY "${${_prefix}_STATIC_LIBRARIES}") - #set(${_prefix}_STATIC_LIBRARIES "") - #foreach(_library ${${_prefix}_STATIC_LIBRARIES_COPY}) - # if(EXISTS "${_library}") - # list(APPEND ${_prefix}_STATIC_LIBRARIES ${_library}) - # else() - # get_filename_component(_ext "${_library}" EXT) - # set(_lib_extensions ".so" ".a" ".dyld" ".dll") - # list(FIND _lib_extensions "${_ext}" _index) - # if (${_index} GREATER -1) - # get_filename_component(_library "${_library}" NAME_WE) - # endif() - # # try static first - # set (default_find_library_suffixes ${CMAKE_FIND_LIBRARY_SUFFIXES}) - # set (CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX}) - # find_library(_library_path NAMES ${_library} - # HINTS ${${_prefix}_STATIC_LIBDIR} ${${_prefix}_STATIC_LIBRARY_DIRS} ${_lib_env}) - # set (CMAKE_FIND_LIBRARY_SUFFIXES ${default_find_library_suffixes}) - # # if not found try dynamic - # if (NOT _library_path) - # find_library(_library_path NAMES ${_library} - # HINTS ${${_prefix}_STATIC_LIBDIR} ${${_prefix}_STATIC_LIBRARY_DIRS} ${_lib_env}) - # endif() - # if (_library_path) - # list(APPEND ${_prefix}_STATIC_LIBRARIES ${_library_path}) - # else() - # message(FATAL_ERROR "Dependency of ${_prefix} '${_library}' NOT FOUND") - # endif() - # unset(_library_path CACHE) - # endif() - #endforeach() - #set (${_prefix}_STATIC_LIBRARIES "${${_prefix}_STATIC_LIBRARIES}" CACHE INTERNAL "" FORCE) -endmacro() - -## -## @end file FindPkgconfigLibrariesAbsolutePath.cmake -## diff --git a/modules/find/FindQUARK.cmake b/modules/find/FindQUARK.cmake index bc83ff5e585c243ff85d975bb4e1c4af824f7760..f512d8cbe8eb5a515943e23be08c68b0a30759da 100644 --- a/modules/find/FindQUARK.cmake +++ b/modules/find/FindQUARK.cmake @@ -1,11 +1,22 @@ ### # -# @copyright (c) 2009-2014 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. -# @copyright (c) 2012-2019 Inria. All rights reserved. +# @copyright (c) 2012-2020 Inria. All rights reserved. # @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. # +# Copyright 2012-2013 Emmanuel Agullo +# Copyright 2012-2013 Mathieu Faverge +# Copyright 2012 Cedric Castagnede +# Copyright 2013-2020 Florent Pruvost +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file MORSE-Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of Morse, substitute the full +# License text for the above reference.) ### # # - Find QUARK include dirs and libraries @@ -26,16 +37,12 @@ # This module finds headers and quark library. # Results are reported in variables: # QUARK_FOUND - True if headers and requested libraries were found +# QUARK_PREFIX - installation path of the lib found # QUARK_CFLAGS_OTHER - quark compiler flags without headers paths # QUARK_LDFLAGS_OTHER - quark linker flags without libraries # QUARK_INCLUDE_DIRS - quark include directories # QUARK_LIBRARY_DIRS - quark link directories # QUARK_LIBRARIES - quark libraries to be linked (absolute path) -# QUARK_CFLAGS_OTHER_DEP - quark + dependencies compiler flags without headers paths -# QUARK_LDFLAGS_OTHER_DEP - quark + dependencies linker flags without libraries -# QUARK_INCLUDE_DIRS_DEP - quark + dependencies include directories -# QUARK_LIBRARY_DIRS_DEP - quark + dependencies link directories -# QUARK_LIBRARIES_DEP - quark + dependencies libraries # # The user can give specific paths where to find the libraries adding cmake # options at configure (ex: cmake path/to/project -DQUARK=path/to/quark): @@ -44,26 +51,18 @@ # QUARK_LIBDIR - Where to find the library files # The module can also look for the following environment variables if paths # are not given as cmake variable: QUARK_DIR, QUARK_INCDIR, QUARK_LIBDIR - -#============================================================================= -# Copyright 2012-2019 Inria -# Copyright 2012-2013 Emmanuel Agullo -# Copyright 2012-2013 Mathieu Faverge -# Copyright 2012 Cedric Castagnede -# Copyright 2013-2018 Florent Pruvost # -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file MORSE-Copyright.txt for details. +# Set QUARK_STATIC to 1 to force using static libraries if exist. +# +# This module defines the following :prop_tgt:`IMPORTED` target: +# +# ``MORSE::QUARK`` +# The headers and libraries to use for QUARK, if found. # -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. #============================================================================= -# (To distribute this file outside of Morse, substitute the full -# License text for the above reference.) # Common macros to use in finds -include(FindInit) +include(FindMorseInit) if (NOT QUARK_FOUND) set(QUARK_DIR "" CACHE PATH "Installation directory of QUARK library") @@ -203,6 +202,11 @@ list(REMOVE_DUPLICATES _lib_env) # Try to find the quark lib in the given paths # ---------------------------------------------- +if (QUARK_STATIC) + set (CMAKE_FIND_LIBRARY_SUFFIXES_COPY ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set (CMAKE_FIND_LIBRARY_SUFFIXES ".a") +endif() + # call cmake macro to find the lib path if(QUARK_LIBDIR) set(QUARK_quark_LIBRARY "QUARK_quark_LIBRARY-NOTFOUND") @@ -227,6 +231,10 @@ else() endif() mark_as_advanced(QUARK_quark_LIBRARY) +if (QUARK_STATIC) + set (CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_COPY}) +endif() + # If found, add path to cmake variable # ------------------------------------ if (QUARK_quark_LIBRARY) @@ -245,11 +253,17 @@ endif () # check a function to validate the find if(QUARK_LIBRARIES) + # check if static or dynamic lib + morse_check_static_or_dynamic(QUARK QUARK_LIBRARIES) + if(QUARK_STATIC) + set(STATIC "_STATIC") + endif() + set(REQUIRED_INCDIRS) - set(REQUIRED_FLAGS) - set(REQUIRED_LDFLAGS) set(REQUIRED_LIBDIRS) set(REQUIRED_LIBS) + set(REQUIRED_FLAGS) + set(REQUIRED_LDFLAGS) # QUARK if (QUARK_INCLUDE_DIRS) @@ -292,7 +306,7 @@ if(QUARK_LIBRARIES) list(APPEND REQUIRED_FLAGS "${_flag}") endforeach() endif() - finds_remove_duplicates() + morse_finds_remove_duplicates() set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) @@ -307,12 +321,14 @@ if(QUARK_LIBRARIES) 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}") - set(QUARK_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}") - set(QUARK_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}") + set(QUARK_INCLUDE_DIRS "${REQUIRED_INCDIRS}") + set(QUARK_LIBRARY_DIRS "${REQUIRED_LIBDIRS}") + if (QUARK_STATIC OR HWLOC_STATIC) + # save link with dependencies + set(QUARK_LIBRARIES "${REQUIRED_LIBS}") + set(QUARK_CFLAGS_OTHER "${REQUIRED_FLAGS}") + set(QUARK_LDFLAGS_OTHER "${REQUIRED_LDFLAGS}") + endif() else() if(NOT QUARK_FIND_QUIETLY) message(STATUS "Looking for QUARK : test of QUARK_New with QUARK library fails") @@ -327,23 +343,21 @@ if(QUARK_LIBRARIES) 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) + get_filename_component(first_lib_path "${first_lib}" DIRECTORY) if (NOT QUARK_LIBRARY_DIRS) set(QUARK_LIBRARY_DIRS "${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(QUARK_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of QUARK library" FORCE) + set(QUARK_PREFIX "${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) + set(QUARK_PREFIX "${first_lib_path}" CACHE PATH "Installation directory of QUARK library" FORCE) endif() -endif() -mark_as_advanced(QUARK_DIR) -mark_as_advanced(QUARK_DIR_FOUND) + mark_as_advanced(QUARK_PREFIX) + +endif(QUARK_LIBRARIES) # check that QUARK has been found # --------------------------------- @@ -351,3 +365,8 @@ include(FindPackageHandleStandardArgs) find_package_handle_standard_args(QUARK DEFAULT_MSG QUARK_LIBRARIES QUARK_WORKS) + +# Add imported target +if (QUARK_FOUND) + morse_create_imported_target(QUARK) +endif() diff --git a/modules/find/FindSCALAPACK.cmake b/modules/find/FindSCALAPACK.cmake index 3dcc685769f977f66af2f22cf995086936c9ff9a..b0b33e23c3f4d0d514eb0ad3a29c1499607ba603 100644 --- a/modules/find/FindSCALAPACK.cmake +++ b/modules/find/FindSCALAPACK.cmake @@ -1,10 +1,18 @@ ### # -# @copyright (c) 2009-2014 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. -# @copyright (c) 2012-2019 Inria. All rights reserved. -# @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. +# @copyright (c) 2013-2020 Inria. All rights reserved. +# +# Copyright 2013-2020 Florent Pruvost +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file MORSE-Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of Morse, substitute the full +# License text for the above reference.) # ### # @@ -15,16 +23,17 @@ # This module sets the following variables: # SCALAPACK_FOUND - set to true if a library implementing the SCALAPACK interface # is found +# SCALAPACK_PREFIX - installation path of the lib found # SCALAPACK_CFLAGS_OTHER - scalapack compiler flags without headers paths # SCALAPACK_LDFLAGS_OTHER - scalapack linker flags without libraries # SCALAPACK_INCLUDE_DIRS - scalapack include directories # SCALAPACK_LIBRARY_DIRS - scalapack link directories # SCALAPACK_LIBRARIES - scalapack libraries to be linked (absolute path) -# SCALAPACK_CFLAGS_OTHER_DEP - scalapack + dependencies compiler flags without headers paths -# SCALAPACK_LDFLAGS_OTHER_DEP - scalapack + dependencies linker flags without libraries -# SCALAPACK_INCLUDE_DIRS_DEP - scalapack + dependencies include directories -# SCALAPACK_LIBRARY_DIRS_DEP - scalapack + dependencies link directories -# SCALAPACK_LIBRARIES_DEP - scalapack + dependencies libraries +# +# This module defines the following :prop_tgt:`IMPORTED` target: +# +# ``MORSE::SCALAPACK`` +# The headers and libraries to use for SCALAPACK, if found. # # SCALAPACK95_LIBRARIES - uncached list of libraries (using full path name) to # link against to use SCALAPACK95 @@ -44,22 +53,11 @@ # Note that if BLAS_DIR is set, it will also look for scalapack in it ### List of vendors (BLA_VENDOR) valid in this module ## Intel(mkl), ACML, Apple, NAS, Generic - #============================================================================= -# Copyright 2007-2009 Kitware, Inc. -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) + # Common macros to use in finds -include(FindInit) +include(FindMorseInit) if (NOT SCALAPACK_FOUND) set(SCALAPACK_DIR "" CACHE PATH "Installation directory of SCALAPACK library") @@ -293,7 +291,7 @@ else() endif() if(BLAS_FOUND AND LAPACK_FOUND AND MPI_FOUND) - set(SCALAPACK_LDFLAGS_OTHER ${LAPACK_LDFLAGS_OTHER_DEP}) + set(SCALAPACK_LDFLAGS_OTHER ${LAPACK_LDFLAGS_OTHER}) if ($ENV{BLA_VENDOR} MATCHES ".+") set(BLA_VENDOR $ENV{BLA_VENDOR}) else ($ENV{BLA_VENDOR} MATCHES ".+") @@ -468,25 +466,21 @@ 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) + get_filename_component(first_lib_path "${first_lib}" DIRECTORY) if (NOT SCALAPACK_LIBRARY_DIRS) set(SCALAPACK_LIBRARY_DIRS "${first_lib_path}") endif() 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) + set(SCALAPACK_PREFIX "${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) + set(SCALAPACK_PREFIX "${first_lib_path}" CACHE PATH "Installation directory of SCALAPACK library" FORCE) endif() - set(SCALAPACK_CFLAGS_OTHER_DEP "${SCALAPACK_CFLAGS_OTHER}" "${LAPACK_CFLAGS_OTHER_DEP}") - set(SCALAPACK_LDFLAGS_OTHER_DEP "${SCALAPACK_LDFLAGS_OTHER}" "${LAPACK_LDFLAGS_OTHER_DEP}") - set(SCALAPACK_INCLUDE_DIRS_DEP "${SCALAPACK_INCLUDE_DIRS}" "${LAPACK_INCLUDE_DIRS_DEP}") - set(SCALAPACK_LIBRARY_DIRS_DEP "${SCALAPACK_LIBRARY_DIRS}" "${LAPACK_LIBRARY_DIRS_DEP}") - set(SCALAPACK_LIBRARIES_DEP "${SCALAPACK_LIBRARIES}" "${LAPACK_LIBRARIES_DEP}" "${MPI_Fortran_LIBRARIES}") - list(REMOVE_DUPLICATES SCALAPACK_CFLAGS_OTHER_DEP) - list(REMOVE_DUPLICATES SCALAPACK_LDFLAGS_OTHER_DEP) - list(REMOVE_DUPLICATES SCALAPACK_INCLUDE_DIRS_DEP) - list(REMOVE_DUPLICATES SCALAPACK_LIBRARY_DIRS_DEP) endif() mark_as_advanced(SCALAPACK_DIR) -mark_as_advanced(SCALAPACK_DIR_FOUND) +mark_as_advanced(SCALAPACK_PREFIX) + +# Add imported target +if (SCALAPACK_FOUND) + morse_create_imported_target(SCALAPACK) +endif() diff --git a/modules/find/FindSCOTCH.cmake b/modules/find/FindSCOTCH.cmake index 86c237f8b5aa72fd7d8840f6897fb0858adbe10d..9619c6a77c0040054d24c8e631bfe9238f54f28d 100644 --- a/modules/find/FindSCOTCH.cmake +++ b/modules/find/FindSCOTCH.cmake @@ -1,11 +1,23 @@ ### # -# @copyright (c) 2009-2014 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. -# @copyright (c) 2012-2019 Inria. All rights reserved. +# @copyright (c) 2012-2020 Inria. All rights reserved. # @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. # +# Copyright 2012-2013 Emmanuel Agullo +# Copyright 2012-2013 Mathieu Faverge +# Copyright 2012 Cedric Castagnede +# Copyright 2013-2020 Florent Pruvost +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file MORSE-Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of Morse, substitute the full +# License text for the above reference.) +# ### # # - Find SCOTCH include dirs and libraries @@ -21,6 +33,7 @@ # This module finds headers and scotch library. # Results are reported in variables: # SCOTCH_FOUND - True if headers and requested libraries were found +# SCOTCH_PREFIX - installation path of the lib found # SCOTCH_INCLUDE_DIRS - scotch include directories # SCOTCH_LIBRARY_DIRS - Link directories for scotch libraries # SCOTCH_LIBRARIES - scotch component libraries to be linked @@ -33,26 +46,18 @@ # SCOTCH_LIBDIR - Where to find the library files # The module can also look for the following environment variables if paths # are not given as cmake variable: SCOTCH_DIR, SCOTCH_INCDIR, SCOTCH_LIBDIR - -#============================================================================= -# Copyright 2012-2019 Inria -# Copyright 2012-2013 Emmanuel Agullo -# Copyright 2012-2013 Mathieu Faverge -# Copyright 2012 Cedric Castagnede -# Copyright 2013-2018 Florent Pruvost # -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file MORSE-Copyright.txt for details. +# Set SCOTCH_STATIC to 1 to force using static libraries if exist. +# +# This module defines the following :prop_tgt:`IMPORTED` target: +# +# ``MORSE::SCOTCH`` +# The headers and libraries to use for SCOTCH, if found. # -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. #============================================================================= -# (To distribute this file outside of Morse, substitute the full -# License text for the above reference.) # Common macros to use in finds -include(FindInit) +include(FindMorseInit) if (NOT SCOTCH_FOUND) set(SCOTCH_DIR "" CACHE PATH "Installation directory of SCOTCH library") @@ -183,6 +188,11 @@ list(REMOVE_DUPLICATES _lib_env) # Try to find the scotch lib in the given paths # ---------------------------------------------- +if (SCOTCH_STATIC) + set (CMAKE_FIND_LIBRARY_SUFFIXES_COPY ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set (CMAKE_FIND_LIBRARY_SUFFIXES ".a") +endif() + set(SCOTCH_libs_to_find "scotch;scotcherrexit") if (SCOTCH_LOOK_FOR_ESMUMPS) list(INSERT SCOTCH_libs_to_find 0 "esmumps") @@ -217,6 +227,10 @@ else() endif() endif() +if (SCOTCH_STATIC) + set (CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_COPY}) +endif() + set(SCOTCH_LIBRARIES "") set(SCOTCH_LIBRARY_DIRS "") # If found, add path to cmake variable @@ -243,9 +257,17 @@ list(REMOVE_DUPLICATES SCOTCH_LIBRARY_DIRS) # check a function to validate the find if(SCOTCH_LIBRARIES) + # check if static or dynamic lib + morse_check_static_or_dynamic(SCOTCH SCOTCH_LIBRARIES) + if(SCOTCH_STATIC) + set(STATIC "_STATIC") + endif() + set(REQUIRED_INCDIRS) set(REQUIRED_LIBDIRS) set(REQUIRED_LIBS) + set(REQUIRED_FLAGS) + set(REQUIRED_LDFLAGS) # SCOTCH if (SCOTCH_INCLUDE_DIRS) @@ -277,7 +299,7 @@ if(SCOTCH_LIBRARIES) if(RT_LIBRARY) list(APPEND REQUIRED_LIBS "${RT_LIBRARY}") endif() - finds_remove_duplicates() + morse_finds_remove_duplicates() # set required libraries for link set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") set(CMAKE_REQUIRED_LIBRARIES) @@ -296,8 +318,14 @@ if(SCOTCH_LIBRARIES) mark_as_advanced(HAVE_SCOTCH_CONTEXT_INIT) if(SCOTCH_WORKS) - # save link with dependencies - set(SCOTCH_LIBRARIES "${REQUIRED_LIBS}") + set(SCOTCH_LIBRARY_DIRS "${REQUIRED_LIBDIRS}") + set(SCOTCH_INCLUDE_DIRS "${REQUIRED_INCDIRS}") + if (SCOTCH_STATIC) + # save link with dependencies + set(SCOTCH_LIBRARIES "${REQUIRED_LIBS}") + set(SCOTCH_CFLAGS_OTHER "${REQUIRED_FLAGS}") + set(SCOTCH_LDFLAGS_OTHER "${REQUIRED_LDFLAGS}") + endif() else() if(NOT SCOTCH_FIND_QUIETLY) message(STATUS "Looking for SCOTCH : test of SCOTCH_graphInit with SCOTCH library fails") @@ -310,23 +338,22 @@ if(SCOTCH_LIBRARIES) 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) + get_filename_component(first_lib_path "${first_lib}" DIRECTORY) if (NOT SCOTCH_LIBRARY_DIRS) set(SCOTCH_LIBRARY_DIRS "${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(SCOTCH_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of SCOTCH library" FORCE) + set(SCOTCH_PREFIX "${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) + set(SCOTCH_PREFIX "${first_lib_path}" CACHE PATH "Installation directory of SCOTCH library" FORCE) endif() -endif() -mark_as_advanced(SCOTCH_DIR) -mark_as_advanced(SCOTCH_DIR_FOUND) + mark_as_advanced(SCOTCH_DIR) + mark_as_advanced(SCOTCH_PREFIX) + +endif(SCOTCH_LIBRARIES) # Check the size of SCOTCH_Num # --------------------------------- @@ -379,6 +406,8 @@ include(FindPackageHandleStandardArgs) find_package_handle_standard_args(SCOTCH DEFAULT_MSG SCOTCH_LIBRARIES SCOTCH_WORKS) -# -# TODO: Add possibility to check for specific functions in the library -# + +# Add imported target +if (SCOTCH_FOUND) + morse_create_imported_target(SCOTCH) +endif() diff --git a/modules/find/FindSIMGRID.cmake b/modules/find/FindSIMGRID.cmake index 7e5da5785e1e381ed86849e200aa5a5e66944772..27948e18fa300c66b000ec333fdbb5cfcf85c349 100644 --- a/modules/find/FindSIMGRID.cmake +++ b/modules/find/FindSIMGRID.cmake @@ -1,11 +1,23 @@ ### # -# @copyright (c) 2009-2014 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. # @copyright (c) 2012-2020 Inria. All rights reserved. # @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. # +# Copyright 2012-2013 Emmanuel Agullo +# Copyright 2012-2013 Mathieu Faverge +# Copyright 2012 Cedric Castagnede +# Copyright 2013-2020 Florent Pruvost +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file MORSE-Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of Morse, substitute the full +# License text for the above reference.) +# ### # # - Find SIMGRID include dirs and libraries @@ -13,16 +25,11 @@ # find_package(SIMGRID # [REQUIRED]) # Fail with error if simgrid is not found # -# This module finds headers and simgrid library. -# Results are reported in variables: -# SIMGRID_FOUND - True if headers and requested libraries were found -# SIMGRID_INCLUDE_DIRS - simgrid include directories -# SIMGRID_LIBRARY_DIRS - Link directories for simgrid libraries -# SIMGRID_LIBRARIES - simgrid component libraries to be linked -# -# SIMGRID_FOUND_WITH_PKGCONFIG - True if found with pkg-config +# This module finds headers and simgrid library using pkg-config file. # if found with pkg-config the following variables are set # <PREFIX> = SIMGRID +# <PREFIX>_PREFIX ... installation path of the lib found +# <PREFIX>_VERSION ... version of the lib # <XPREFIX> = <PREFIX> for common case # <XPREFIX> = <PREFIX>_STATIC for static linking # <XPREFIX>_FOUND ... set to 1 if module(s) exist @@ -34,55 +41,26 @@ # <XPREFIX>_CFLAGS ... all required cflags # <XPREFIX>_CFLAGS_OTHER ... the other compiler flags # -# The user can give specific paths where to find the libraries adding cmake -# options at configure (ex: cmake path/to/project -DSIMGRID_DIR=path/to/simgrid): -# SIMGRID_DIR - Where to find the base directory of simgrid -# SIMGRID_INCDIR - Where to find the header files -# SIMGRID_LIBDIR - Where to find the library files -# The module can also look for the following environment variables if paths -# are not given as cmake variable: SIMGRID_DIR, SIMGRID_INCDIR, SIMGRID_LIBDIR - -#============================================================================= -# Copyright 2012-2019 Inria -# Copyright 2012-2013 Emmanuel Agullo -# Copyright 2012-2013 Mathieu Faverge -# Copyright 2012 Cedric Castagnede -# Copyright 2013-2018 Florent Pruvost +# Set SIMGRID_STATIC to 1 to force using static libraries if exist. # -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file MORSE-Copyright.txt for details. +# This module defines the following :prop_tgt:`IMPORTED` target: +# +# ``MORSE::SIMGRID`` +# The headers and libraries to use for SIMGRID, if found. # -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. #============================================================================= -# (To distribute this file outside of Morse, substitute the full -# License text for the above reference.) # Common macros to use in finds -include(FindInit) +include(FindMorseInit) -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() +if (NOT SIMGRID_FIND_QUIETLY) + message(STATUS "FindSIMGRID needs pkg-config program and PKG_CONFIG_PATH set with simgrid.pc file path.") endif() -set(ENV_SIMGRID_DIR "$ENV{SIMGRID_DIR}") -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") -endif() - -# Optionally use pkg-config to detect include/library dirs (if pkg-config is available) -# ------------------------------------------------------------------------------------- -include(FindPkgConfig) -find_package(PkgConfig QUIET) -if(PKG_CONFIG_EXECUTABLE AND NOT SIMGRID_GIVEN_BY_USER) - +# use pkg-config to detect include/library dirs (if pkg-config is available) +# -------------------------------------------------------------------------- +if (PKG_CONFIG_EXECUTABLE) + unset(SIMGRID_FOUND CACHE) pkg_search_module(SIMGRID simgrid) if (NOT SIMGRID_FIND_QUIETLY) @@ -94,227 +72,41 @@ if(PKG_CONFIG_EXECUTABLE AND NOT SIMGRID_GIVEN_BY_USER) "\n PKG_CONFIG_PATH environment variable.${ColourReset}") endif() endif() - if (SIMGRID_FOUND AND SIMGRID_LIBRARIES) if (NOT SIMGRID_INCLUDE_DIRS) pkg_get_variable(SIMGRID_INCLUDE_DIRS simgrid includedir) endif() set(SIMGRID_FOUND_WITH_PKGCONFIG "TRUE") - find_pkgconfig_libraries_absolute_path(SIMGRID) + morse_find_pkgconfig_libraries_absolute_path(SIMGRID) else() set(SIMGRID_FOUND_WITH_PKGCONFIG "FALSE") 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() - - # 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") - 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_C_IMPLICIT_INCLUDE_DIRECTORIES}") - list(REMOVE_DUPLICATES _inc_env) - - # Try to find the simgrid header in the given paths - # ------------------------------------------------- - set(SIMGRID_hdrs_to_find "xbt.h") - - # call cmake macro to find the header path - if(SIMGRID_INCDIR) - foreach(simgrid_hdr ${SIMGRID_hdrs_to_find}) - set(SIMGRID_${simgrid_hdr}_DIRS "SIMGRID_${simgrid_hdr}_DIRS-NOTFOUND") - find_path(SIMGRID_${simgrid_hdr}_DIRS - NAMES ${simgrid_hdr} - HINTS ${SIMGRID_INCDIR} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - mark_as_advanced(SIMGRID_${simgrid_hdr}_DIRS) - endforeach() - else() - if(SIMGRID_DIR) - foreach(simgrid_hdr ${SIMGRID_hdrs_to_find}) - set(SIMGRID_${simgrid_hdr}_DIRS "SIMGRID_${simgrid_hdr}_DIRS-NOTFOUND") - find_path(SIMGRID_${simgrid_hdr}_DIRS - NAMES ${simgrid_hdr} - HINTS ${SIMGRID_DIR} - PATH_SUFFIXES "include" - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - mark_as_advanced(SIMGRID_${simgrid_hdr}_DIRS) - endforeach() - else() - foreach(simgrid_hdr ${SIMGRID_hdrs_to_find}) - set(SIMGRID_${simgrid_hdr}_DIRS "SIMGRID_${simgrid_hdr}_DIRS-NOTFOUND") - find_path(SIMGRID_${simgrid_hdr}_DIRS - NAMES ${simgrid_hdr} - HINTS ${_inc_env}) - mark_as_advanced(SIMGRID_${simgrid_hdr}_DIRS) - endforeach() - endif() - endif() - - # Add path to cmake variable - # ------------------------------------ - if (SIMGRID_xbt.h_DIRS) - set(SIMGRID_INCLUDE_DIRS "${SIMGRID_xbt.h_DIRS}") - else () - set(SIMGRID_INCLUDE_DIRS "SIMGRID_INCLUDE_DIRS-NOTFOUND") - if(NOT SIMGRID_FIND_QUIETLY) - message(STATUS "Looking for simgrid -- xbt.h not found") - endif() - endif () - - if (SIMGRID_INCLUDE_DIRS) - list(REMOVE_DUPLICATES SIMGRID_INCLUDE_DIRS) - endif () - - - # 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") - else() - list(APPEND _lib_env "$ENV{LIBRARY_PATH}") - if(WIN32) - string(REPLACE ":" ";" _lib_env2 "$ENV{LIB}") - elseif(APPLE) - string(REPLACE ":" ";" _lib_env2 "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env2 "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${_lib_env2}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - endif() - list(REMOVE_DUPLICATES _lib_env) - - # 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} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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 - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - set(SIMGRID_simgrid_LIBRARY "SIMGRID_simgrid_LIBRARY-NOTFOUND") - find_library(SIMGRID_simgrid_LIBRARY - NAMES simgrid - HINTS ${_lib_env}) + if (SIMGRID_STATIC AND SIMGRID_STATIC_LIBRARIES) + set (SIMGRID_DEPENDENCIES ${SIMGRID_STATIC_LIBRARIES}) + list (REMOVE_ITEM SIMGRID_DEPENDENCIES "simgrid") + list (APPEND SIMGRID_LIBRARIES ${SIMGRID_DEPENDENCIES}) + set(SIMGRID_CFLAGS_OTHER ${SIMGRID_STATIC_CFLAGS_OTHER}) + set(SIMGRID_LDFLAGS_OTHER ${SIMGRID_STATIC_LDFLAGS_OTHER}) + if (NOT SIMGRID_FIND_QUIETLY) + message(STATUS "SIMGRID_STATIC set to 1 by user, SIMGRID_LIBRARIES: ${SIMGRID_LIBRARIES}.") endif() 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 (SIMGRID_LIBRARY_DIRS) - list(REMOVE_DUPLICATES SIMGRID_LIBRARY_DIRS) - endif () - -endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT SIMGRID_FOUND) OR (SIMGRID_GIVEN_BY_USER) ) +endif() # check a function to validate the find -if(SIMGRID_LIBRARIES) +if(SIMGRID_FOUND AND SIMGRID_LIBRARIES) - set(REQUIRED_INCDIRS) - set(REQUIRED_FLAGS) - set(REQUIRED_LDFLAGS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) - - # SIMGRID - if (SIMGRID_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${SIMGRID_INCLUDE_DIRS}") - endif() - if (SIMGRID_CFLAGS_OTHER) - set(REQUIRED_FLAGS "${SIMGRID_CFLAGS_OTHER}") - endif() - if (SIMGRID_LDFLAGS_OTHER) - set(REQUIRED_LDFLAGS "${SIMGRID_LDFLAGS_OTHER}") - endif() - if (SIMGRID_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${SIMGRID_LIBRARY_DIRS}") + # check if static or dynamic lib + morse_check_static_or_dynamic(SIMGRID SIMGRID_LIBRARIES) + if(SIMGRID_STATIC) + set(STATIC "_STATIC") + else() + set(STATIC "") endif() - set(REQUIRED_LIBS "${SIMGRID_LIBRARIES}") # set required libraries for link - set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") - if (REQUIRED_FLAGS) - set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}") - set(REQUIRED_FLAGS) - set(REQUIRED_DEFINITIONS) - foreach(_flag ${REQUIRED_FLAGS_COPY}) - if (_flag MATCHES "^-D") - list(APPEND REQUIRED_DEFINITIONS "${_flag}") - endif() - string(REGEX REPLACE "^-D.*" "" _flag "${_flag}") - list(APPEND REQUIRED_FLAGS "${_flag}") - endforeach() - endif() - finds_remove_duplicates() - set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") - set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") - set(CMAKE_REQUIRED_LIBRARIES) - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}") - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + morse_set_required_test_lib_link(SIMGRID) # test link unset(SIMGRID_WORKS CACHE) @@ -322,7 +114,16 @@ if(SIMGRID_LIBRARIES) check_function_exists(MSG_main SIMGRID_WORKS) mark_as_advanced(SIMGRID_WORKS) - if(NOT SIMGRID_WORKS) + if(SIMGRID_WORKS) + if (SIMGRID_STATIC) + # save link with dependencies + set(SIMGRID_STATIC_LIBRARIES "${REQUIRED_LIBS}") + set(SIMGRID_STATIC_LIBRARY_DIRS "${REQUIRED_LIBDIRS}") + set(SIMGRID_STATIC_INCLUDE_DIRS "${REQUIRED_INCDIRS}") + set(SIMGRID_STATIC_CFLAGS_OTHER "${REQUIRED_FLAGS}") + set(SIMGRID_STATIC_LDFLAGS_OTHER "${REQUIRED_LDFLAGS}") + endif() + else() 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}") @@ -334,25 +135,8 @@ if(SIMGRID_LIBRARIES) set(CMAKE_REQUIRED_INCLUDES) set(CMAKE_REQUIRED_FLAGS) set(CMAKE_REQUIRED_LIBRARIES) -endif(SIMGRID_LIBRARIES) -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) - set(SIMGRID_LIBRARY_DIRS "${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) +endif(SIMGRID_FOUND AND SIMGRID_LIBRARIES) # check that SIMGRID has been found # ------------------------------- @@ -360,3 +144,8 @@ include(FindPackageHandleStandardArgs) find_package_handle_standard_args(SIMGRID DEFAULT_MSG SIMGRID_LIBRARIES SIMGRID_WORKS) + + # Add imported targe +if (SIMGRID_FOUND) + morse_create_imported_target(SIMGRID) +endif() \ No newline at end of file diff --git a/modules/find/FindSLEPC.cmake b/modules/find/FindSLEPC.cmake index ae024f1d0b20d2b0529928559797bcb4e3cfd893..2ef63eadc61ebc18055fb889014d69e62f3f5cf5 100644 --- a/modules/find/FindSLEPC.cmake +++ b/modules/find/FindSLEPC.cmake @@ -2,6 +2,7 @@ # @copyright (c) 2018-2020 Inria. All rights reserved. # # Marc Fuentes +# Vincent Perrier # Florent Pruvost # # https://gitlab.inria.fr/sed-bso/findPetsc @@ -50,6 +51,11 @@ # # SLEPC_FOUND_WITH_PKGCONFIG - True if found with pkg-config # +# This module defines the following :prop_tgt:`IMPORTED` target: +# +# ``MORSE::SLEPC`` +# The headers and libraries to use for SLEPC, if found. +# # find_package(SLEPC [QUIET] [REQUIRED]) # # Setting these changes the behavior of the search @@ -64,8 +70,6 @@ endif() # Use pkg-config to detect include/library dirs (if pkg-config is available) # ------------------------------------------------------------------------------------- -include(FindPkgConfig) -find_package(PkgConfig QUIET) if( PKG_CONFIG_EXECUTABLE AND NOT SLEPC_DIR ) pkg_search_module(SLEPC SLEPc) if (NOT SLEPC_FIND_QUIETLY) @@ -83,10 +87,18 @@ if( PKG_CONFIG_EXECUTABLE AND NOT SLEPC_DIR ) pkg_get_variable(SLEPC_INCLUDE_DIRS SLEPc includedir) endif() set(SLEPC_FOUND_WITH_PKGCONFIG "TRUE") - find_pkgconfig_libraries_absolute_path(SLEPC) + morse_find_pkgconfig_libraries_absolute_path(SLEPC) else() set(SLEPC_FOUND_WITH_PKGCONFIG "FALSE") endif() + if (SLEPC_STATIC AND SLEPC_STATIC_LIBRARIES) + set (SLEPC_DEPENDENCIES ${SLEPC_STATIC_LIBRARIES}) + list (REMOVE_ITEM SLEPC_DEPENDENCIES "slepc") + list (APPEND SLEPC_LIBRARIES ${SLEPC_DEPENDENCIES}) + if (NOT SLEPC_FIND_QUIETLY) + message(STATUS "SLEPC_STATIC set to 1 by user, SLEPC_LIBRARIES: ${SLEPC_LIBRARIES}.") + endif() + endif() endif() # consider using the env. var. SLEPC_DIR if not directly given through the CMake cache var. @@ -95,21 +107,42 @@ if (NOT SLEPC_DIR AND DEFINED ENV{SLEPC_DIR}) endif() if (SLEPC_DIR) - if (EXISTS ${SLEPC_DIR}) - if (EXISTS ${SLEPC_DIR}/include/slepc.h) - if (NOT SLEPC_FIND_QUIETLY) - message(STATUS "SLEPC_DIR = ${SLEPC_DIR} contains include/slepc.h") - endif() - else() - if (SLEPC_FIND_REQUIRED) - message(FATAL_ERROR "include/slepc.h not found in SLEPC_DIR = ${SLEPC_DIR}") - endif() + if (EXISTS ${SLEPC_DIR}) + if (EXISTS ${SLEPC_DIR}/include/slepc.h) + if (NOT SLEPC_FIND_QUIETLY) + message(STATUS "SLEPC_DIR = ${SLEPC_DIR} contains include/slepc.h") + endif() + set(SLEPC_INCLUDE_DIRS "${SLEPC_DIR}/include") + else() + if (SLEPC_FIND_REQUIRED) + message(FATAL_ERROR "include/slepc.h not found in SLEPC_DIR = ${SLEPC_DIR}") + endif() + endif() + if (SLEPC_STATIC) + if(EXISTS ${SLEPC_DIR}/lib/libslepc.a) + set(SLEPC_LIBRARIES "${SLEPC_DIR}/lib/libslepc.a") + else() + if (SLEPC_FIND_REQUIRED) + message(FATAL_ERROR "lib/libslepc.a not found in SLEPC_DIR = ${SLEPC_DIR}") endif() + endif() + else() + if (EXISTS ${SLEPC_DIR}/lib/libslepc.so) + set(SLEPC_LIBRARIES "${SLEPC_DIR}/lib/libslepc.so") else() if (SLEPC_FIND_REQUIRED) - message(FATAL_ERROR "SLEPC_DIR defined, but ${SLEPC_DIR} does not exist") + message(FATAL_ERROR "lib/libslepc.so not found in SLEPC_DIR = ${SLEPC_DIR}") endif() + endif() endif() + if (SLEPC_DIR AND SLEPC_LIBRARIES) + set(SLEPC_PREFIX ${SLEPC_DIR}) + endif() + else() + if (SLEPC_FIND_REQUIRED) + message(FATAL_ERROR "SLEPC_DIR defined, but ${SLEPC_DIR} does not exist") + endif() + endif() else() if (SLEPC_FIND_REQUIRED) message(FATAL_ERROR "\ @@ -127,13 +160,12 @@ give the installation directory (contains ./include/slepc.h, ./lib/, etc): endif() endif() - -set(SLEPC_INCLUDE_DIRS "${SLEPC_DIR}/include") - -set(SLEPC_LIBRARIES "${SLEPC_DIR}/lib/libslepc.so") - - include (FindPackageHandleStandardArgs) find_package_handle_standard_args (SLEPC - "SLEPC could not be found. Be sure to set SLEPC_DIR." + "SLEPC could not be found. Be sure to set SLEPC_DIR or use with pkg-config (slepc.pc in PKG_CONFIG_PATH)." SLEPC_INCLUDE_DIRS SLEPC_LIBRARIES) + +# Add imported target +if (SLEPC_FOUND) + morse_create_imported_target(SLEPC) +endif() \ No newline at end of file diff --git a/modules/find/FindSPM.cmake b/modules/find/FindSPM.cmake deleted file mode 100644 index 27fac39b7dbd0ec7be31fa7685d3bc615cbac050..0000000000000000000000000000000000000000 --- a/modules/find/FindSPM.cmake +++ /dev/null @@ -1,506 +0,0 @@ -### -# -# @copyright (c) 2019-2020 Inria. All rights reserved. -# -### -# -# - Find SPM include dirs and libraries -# Use this module by invoking find_package with the form: -# find_package(SPM -# [REQUIRED] # Fail with error if spm is not found -# [COMPONENTS <comp1> <comp2> ...] # dependencies -# ) -# -# SPM depends on the following libraries: -# - CBLAS -# - LAPACKE -# -# COMPONENTS are options. -# Use it to drive detection of a specific compilation chain -# COMPONENTS can be some of the following: -# - FORTRAN: to provide Fortran libraries of SPM in LIBRARIES -# -## -# This module finds headers and spm library. -# Results are reported in variables: -# SPM_FOUND - True if headers and requested libraries were found -# SPM_CFLAGS_OTHER - spm compiler flags without headers paths -# SPM_LDFLAGS_OTHER - spm linker flags without libraries -# SPM_INCLUDE_DIRS - spm include directories -# SPM_LIBRARY_DIRS - spm link directories -# SPM_LIBRARIES - spm libraries to be linked (absolute path) -# SPM_LIBRARIES_FORTRAN - spm Fortran libraries to be linked (absolute path) -# SPM_CFLAGS_OTHER_DEP - spm + dependencies compiler flags without headers paths -# SPM_LDFLAGS_OTHER_DEP - spm + dependencies linker flags without libraries -# SPM_INCLUDE_DIRS_DEP - spm + dependencies include directories -# SPM_LIBRARY_DIRS_DEP - spm + dependencies link directories -# SPM_LIBRARIES_DEP - spm + dependencies libraries -# SPM_INTSIZE - Number of octets occupied by a spm_int_t -# -# SPM_FOUND_WITH_PKGCONFIG - True if found with pkg-config -# if found with pkg-config the following variables are set -# <PREFIX> = SPM -# <XPREFIX> = <PREFIX> for common case -# <XPREFIX> = <PREFIX>_STATIC for static linking -# <XPREFIX>_FOUND ... set to 1 if module(s) exist -# <XPREFIX>_LIBRARIES ... only the libraries (w/o the '-l') -# <XPREFIX>_LIBRARY_DIRS ... the paths of the libraries (w/o the '-L') -# <XPREFIX>_LDFLAGS ... all required linker flags -# <XPREFIX>_LDFLAGS_OTHER ... all other linker flags -# <XPREFIX>_INCLUDE_DIRS ... the '-I' preprocessor flags (w/o the '-I') -# <XPREFIX>_CFLAGS ... all required cflags -# <XPREFIX>_CFLAGS_OTHER ... the other compiler flags -# -# The user can give specific paths where to find the libraries adding cmake -# options at configure (ex: cmake path/to/project -DSPM_DIR=path/to/spm): -# SPM_DIR - Where to find the base directory of spm -# SPM_INCDIR - Where to find the header files -# SPM_LIBDIR - Where to find the library files -# The module can also look for the following environment variables if paths -# are not given as cmake variable: SPM_DIR, SPM_INCDIR, SPM_LIBDIR - -#============================================================================= -# Copyright 2019 Inria -# Copyright 2018 Florent Pruvost -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file MORSE-Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of Morse, substitute the full -# License text for the above reference.) - -# Common macros to use in finds -include(FindInit) - -if (NOT SPM_FOUND) - set(SPM_DIR "" CACHE PATH "Installation directory of SPM library") - if (NOT SPM_FIND_QUIETLY) - message(STATUS "A cache variable, namely SPM_DIR, has been set to specify the install directory of SPM") - endif() -endif() - -set(SPM_LOOK_FOR_FORTRAN OFF) -if( SPM_FIND_COMPONENTS ) - foreach( component ${SPM_FIND_COMPONENTS} ) - if (${component} STREQUAL "FORTRAN") - set(SPM_LOOK_FOR_FORTRAN ON) - endif() - endforeach() -endif() - -# Required dependencies -# --------------------- - -# SPM depends on CBLAS -#----------------------- -if (NOT SPM_FIND_QUIETLY) - message(STATUS "Looking for SPM - Try to detect CBLAS") -endif() -if (SPM_FIND_REQUIRED) - find_package(CBLAS REQUIRED) -else() - find_package(CBLAS) -endif() - -# SPM depends on LAPACKE -#----------------------- -if (NOT SPM_FIND_QUIETLY) - message(STATUS "Looking for SPM - Try to detect LAPACKE") -endif() -if (SPM_FIND_REQUIRED) - find_package(LAPACKE REQUIRED) -else() - find_package(LAPACKE) -endif() - -set(ENV_SPM_DIR "$ENV{SPM_DIR}") -set(ENV_SPM_INCDIR "$ENV{SPM_INCDIR}") -set(ENV_SPM_LIBDIR "$ENV{SPM_LIBDIR}") -set(SPM_GIVEN_BY_USER "FALSE") -if ( SPM_DIR OR ( SPM_INCDIR AND SPM_LIBDIR) OR ENV_SPM_DIR OR (ENV_SPM_INCDIR AND ENV_SPM_LIBDIR) ) - set(SPM_GIVEN_BY_USER "TRUE") -endif() - -# Optionally use pkg-config to detect include/library dirs (if pkg-config is available) -# ------------------------------------------------------------------------------------- -include(FindPkgConfig) -find_package(PkgConfig QUIET) -if(PKG_CONFIG_EXECUTABLE AND NOT SPM_GIVEN_BY_USER) - - pkg_search_module(SPM spm) - - if (NOT SPM_FIND_QUIETLY) - if (SPM_FOUND AND SPM_LIBRARIES) - message(STATUS "Looking for SPM - found using PkgConfig") - else() - message(STATUS "${Magenta}Looking for SPM - not found using PkgConfig." - "\n Perhaps you should add the directory containing spm.pc" - "\n to the PKG_CONFIG_PATH environment variable.${ColourReset}") - endif() - endif() - - if (SPM_FOUND AND SPM_LIBRARIES) - if (NOT SPM_INCLUDE_DIRS) - pkg_get_variable(SPM_INCLUDE_DIRS spm includedir) - endif() - set(SPM_FOUND_WITH_PKGCONFIG "TRUE") - find_pkgconfig_libraries_absolute_path(SPM) - else() - set(SPM_FOUND_WITH_PKGCONFIG "FALSE") - endif() - -endif(PKG_CONFIG_EXECUTABLE AND NOT SPM_GIVEN_BY_USER) - -if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT SPM_FOUND) OR (SPM_GIVEN_BY_USER) ) - - # Looking for SPM - # ------------------ - - # Looking for include - # ------------------- - - # Add system include paths to search include - # ------------------------------------------ - unset(_inc_env) - set(ENV_SPM_DIR "$ENV{SPM_DIR}") - set(ENV_SPM_INCDIR "$ENV{SPM_INCDIR}") - if(ENV_SPM_INCDIR) - list(APPEND _inc_env "${ENV_SPM_INCDIR}") - elseif(ENV_SPM_DIR) - list(APPEND _inc_env "${ENV_SPM_DIR}") - list(APPEND _inc_env "${ENV_SPM_DIR}/include") - list(APPEND _inc_env "${ENV_SPM_DIR}/include/spm") - 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_C_IMPLICIT_INCLUDE_DIRECTORIES}") - list(REMOVE_DUPLICATES _inc_env) - - - # Try to find the spm header in the given paths - # --------------------------------------------------- - # call cmake macro to find the header path - if(SPM_INCDIR) - set(SPM_spm.h_DIRS "SPM_spm.h_DIRS-NOTFOUND") - find_path(SPM_spm.h_DIRS - NAMES spm.h - HINTS ${SPM_INCDIR} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - if(SPM_DIR) - set(SPM_spm.h_DIRS "SPM_spm.h_DIRS-NOTFOUND") - find_path(SPM_spm.h_DIRS - NAMES spm.h - HINTS ${SPM_DIR} - PATH_SUFFIXES "include" "include/spm" - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - set(SPM_spm.h_DIRS "SPM_spm.h_DIRS-NOTFOUND") - find_path(SPM_spm.h_DIRS - NAMES spm.h - HINTS ${_inc_env} - PATH_SUFFIXES "spm") - endif() - endif() - mark_as_advanced(SPM_spm.h_DIRS) - - # If found, add path to cmake variable - # ------------------------------------ - if (SPM_spm.h_DIRS) - set(SPM_INCLUDE_DIRS "${SPM_spm.h_DIRS}") - else () - set(SPM_INCLUDE_DIRS "SPM_INCLUDE_DIRS-NOTFOUND") - if(NOT SPM_FIND_QUIETLY) - message(STATUS "Looking for spm -- spm.h not found") - endif() - endif() - - - # Looking for lib - # --------------- - - # Add system library paths to search lib - # -------------------------------------- - unset(_lib_env) - set(ENV_SPM_LIBDIR "$ENV{SPM_LIBDIR}") - if(ENV_SPM_LIBDIR) - list(APPEND _lib_env "${ENV_SPM_LIBDIR}") - elseif(ENV_SPM_DIR) - list(APPEND _lib_env "${ENV_SPM_DIR}") - list(APPEND _lib_env "${ENV_SPM_DIR}/lib") - else() - list(APPEND _lib_env "$ENV{LIBRARY_PATH}") - if(WIN32) - string(REPLACE ":" ";" _lib_env2 "$ENV{LIB}") - elseif(APPLE) - string(REPLACE ":" ";" _lib_env2 "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env2 "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${_lib_env2}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - endif() - list(REMOVE_DUPLICATES _lib_env) - - # Try to find the spm lib in the given paths - # ------------------------------------------------ - - # create list of libs to find - set(SPM_libs_to_find "spm") - # call cmake macro to find the lib path - foreach(spm_lib ${SPM_libs_to_find}) - set(SPM_${spm_lib}_LIBRARY "SPM_${spm_lib}_LIBRARY-NOTFOUND") - if(SPM_LIBDIR) - find_library(SPM_${spm_lib}_LIBRARY - NAMES ${spm_lib} - HINTS ${SPM_LIBDIR} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - if(SPM_DIR) - find_library(SPM_${spm_lib}_LIBRARY - NAMES ${spm_lib} - HINTS ${SPM_DIR} - PATH_SUFFIXES lib lib32 lib64 - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - else() - find_library(SPM_${spm_lib}_LIBRARY - NAMES ${spm_lib} - HINTS ${_lib_env}) - endif() - endif() - endforeach() - - # If found, add path to cmake variable - # ------------------------------------ - foreach(spm_lib ${SPM_libs_to_find}) - - get_filename_component(${spm_lib}_lib_path ${SPM_${spm_lib}_LIBRARY} PATH) - # set cmake variables (respects naming convention) - if (SPM_LIBRARIES) - list(APPEND SPM_LIBRARIES "${SPM_${spm_lib}_LIBRARY}") - else() - set(SPM_LIBRARIES "${SPM_${spm_lib}_LIBRARY}") - endif() - if (SPM_LIBRARY_DIRS) - list(APPEND SPM_LIBRARY_DIRS "${${spm_lib}_lib_path}") - else() - set(SPM_LIBRARY_DIRS "${${spm_lib}_lib_path}") - endif() - mark_as_advanced(SPM_${spm_lib}_LIBRARY) - - endforeach(spm_lib ${SPM_libs_to_find}) - -endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT SPM_FOUND) OR (SPM_GIVEN_BY_USER) ) - - -# check a function to validate the find -if(SPM_LIBRARIES) - - set(REQUIRED_INCDIRS) - set(REQUIRED_FLAGS) - set(REQUIRED_LDFLAGS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) - - # SPM - if (SPM_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${SPM_INCLUDE_DIRS}") - endif() - if (SPM_CFLAGS_OTHER) - list(APPEND REQUIRED_FLAGS "${SPM_CFLAGS_OTHER}") - endif() - if (SPM_LDFLAGS_OTHER) - list(APPEND REQUIRED_LDFLAGS "${SPM_LDFLAGS_OTHER}") - endif() - foreach(libdir ${SPM_LIBRARY_DIRS}) - if (libdir) - list(APPEND REQUIRED_LIBDIRS "${libdir}") - endif() - endforeach() - set(REQUIRED_LIBS "${SPM_LIBRARIES}") - # LAPACKE - if (LAPACKE_FOUND) - if (LAPACKE_INCLUDE_DIRS_DEP) - list(APPEND REQUIRED_INCDIRS "${LAPACKE_INCLUDE_DIRS_DEP}") - endif() - if (LAPACKE_CFLAGS_OTHER_DEP) - list(APPEND REQUIRED_FLAGS "${LAPACKE_CFLAGS_OTHER_DEP}") - endif() - if (LAPACKE_LDFLAGS_OTHER_DEP) - list(APPEND REQUIRED_LDFLAGS "${LAPACKE_LDFLAGS_OTHER_DEP}") - endif() - if(LAPACKE_LIBRARY_DIRS_DEP) - list(APPEND REQUIRED_LIBDIRS "${LAPACKE_LIBRARY_DIRS_DEP}") - endif() - if (LAPACKE_LIBRARIES_DEP) - list(APPEND REQUIRED_LIBS "${LAPACKE_LIBRARIES_DEP}") - endif() - endif() - # CBLAS - if (CBLAS_FOUND) - if (CBLAS_INCLUDE_DIRS_DEP) - list(APPEND REQUIRED_INCDIRS "${CBLAS_INCLUDE_DIRS_DEP}") - endif() - if (CBLAS_CFLAGS_OTHER_DEP) - list(APPEND REQUIRED_FLAGS "${CBLAS_CFLAGS_OTHER_DEP}") - endif() - if (CBLAS_LDFLAGS_OTHER_DEP) - list(APPEND REQUIRED_LDFLAGS "${CBLAS_LDFLAGS_OTHER_DEP}") - endif() - if(CBLAS_LIBRARY_DIRS_DEP) - list(APPEND REQUIRED_LIBDIRS "${CBLAS_LIBRARY_DIRS_DEP}") - endif() - if (CBLAS_LIBRARIES_DEP) - list(APPEND REQUIRED_LIBS "${CBLAS_LIBRARIES_DEP}") - endif() - endif() - - # set required libraries for link - set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") - if (REQUIRED_FLAGS) - set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}") - set(REQUIRED_FLAGS) - set(REQUIRED_DEFINITIONS) - foreach(_flag ${REQUIRED_FLAGS_COPY}) - if (_flag MATCHES "^-D") - list(APPEND REQUIRED_DEFINITIONS "${_flag}") - endif() - string(REGEX REPLACE "^-D.*" "" _flag "${_flag}") - list(APPEND REQUIRED_FLAGS "${_flag}") - endforeach() - endif() - finds_remove_duplicates() - set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") - set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") - set(CMAKE_REQUIRED_LIBRARIES) - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}") - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - - # test link - unset(SPM_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(spmInit SPM_WORKS) - mark_as_advanced(SPM_WORKS) - - if(SPM_WORKS) - # save link with dependencies - set(SPM_LIBRARIES_DEP "${REQUIRED_LIBS}") - set(SPM_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}") - set(SPM_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") - set(SPM_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}") - set(SPM_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}") - else() - if(NOT SPM_FIND_QUIETLY) - message(STATUS "Looking for SPM : test of spm() fails") - message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") - message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") - message(STATUS "CMAKE_REQUIRED_FLAGS: ${CMAKE_REQUIRED_FLAGS}") - message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") - message(STATUS "Maybe SPM is linked with specific libraries. " - "Have you tried with COMPONENTS (MPI/SEQ, PARSEC, STARPU, STARPU_CUDA, SCOTCH, PTSCOTCH, METIS)? " - "See the explanation in FindSPM.cmake.") - endif() - endif() - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_LIBRARIES) -endif(SPM_LIBRARIES) - - -# Check the size of spm_int_t -# --------------------------------- -set(CMAKE_REQUIRED_INCLUDES ${SPM_INCLUDE_DIRS_DEP}) - -include(CheckCSourceRuns) -set(SPM_C_TEST_SPM_INT_4 " -#include <spm.h> -int main(int argc, char **argv) { - if (sizeof(spm_int_t) == 4) - return 0; - else - return 1; -} -") -set(SPM_C_TEST_SPM_INT_8 " -#include <spm.h> -int main(int argc, char **argv) { - if (sizeof(spm_int_t) == 8) - return 0; - else - return 1; -} -") -unset(SPM_INT_4 CACHE) -unset(SPM_INT_8 CACHE) -check_c_source_runs("${SPM_C_TEST_SPM_INT_4}" SPM_INT_4) -check_c_source_runs("${SPM_C_TEST_SPM_INT_8}" SPM_INT_8) -if(NOT SPM_INT_4) - if(NOT SPM_INT_8) - set(SPM_INTSIZE -1) - else() - set(SPM_INTSIZE 8) - endif() -else() - set(SPM_INTSIZE 4) -endif() -set(CMAKE_REQUIRED_INCLUDES "") - -if (SPM_LIBRARIES) - list(GET SPM_LIBRARIES 0 first_lib) - get_filename_component(first_lib_path "${first_lib}" PATH) - if (NOT SPM_LIBRARY_DIRS) - set(SPM_LIBRARY_DIRS "${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(SPM_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of SPM library" FORCE) - else() - set(SPM_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of SPM library" FORCE) - endif() -endif() -mark_as_advanced(SPM_DIR) -mark_as_advanced(SPM_DIR_FOUND) - -if (SPM_LOOK_FOR_FORTRAN) - find_library(SPM_spmf_LIBRARY - NAMES spmf - HINTS ${SPM_LIBRARY_DIRS}) - mark_as_advanced(SPM_spmf_LIBRARY) - if (SPM_spmf_LIBRARY) - set(SPM_LIBRARIES_FORTRAN ${SPM_spmf_LIBRARY}) - list(INSERT SPM_LIBRARIES 0 "${SPM_LIBRARIES_FORTRAN}") - list(INSERT SPM_LIBRARIES_DEP 0 "${SPM_LIBRARIES_FORTRAN}") - else() - set(SPM_LIBRARIES_FORTRAN "SPM_LIBRARIES_FORTRAN-NOTFOUND") - endif() -endif() - -# check that SPM has been found -# --------------------------------- -include(FindPackageHandleStandardArgs) -if (SPM_LOOK_FOR_FORTRAN) - find_package_handle_standard_args(SPM DEFAULT_MSG - SPM_LIBRARIES_FORTRAN - SPM_LIBRARIES - SPM_WORKS) -else() - find_package_handle_standard_args(SPM DEFAULT_MSG - SPM_LIBRARIES - SPM_WORKS) -endif() diff --git a/modules/find/FindSTARPU.cmake b/modules/find/FindSTARPU.cmake index e781c44aea2353d4359d4a368c58f4310f87a827..4b377aa8f9cac568835c029c76a2ff59f97363d3 100644 --- a/modules/find/FindSTARPU.cmake +++ b/modules/find/FindSTARPU.cmake @@ -1,53 +1,48 @@ ### # -# @copyright (c) 2009-2014 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. # @copyright (c) 2012-2020 Inria. All rights reserved. # @copyright (c) 2012-2016 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. # +# Copyright 2012-2019 Inria +# Copyright 2012-2013 Emmanuel Agullo +# Copyright 2012-2013 Mathieu Faverge +# Copyright 2012 Cedric Castagnede +# Copyright 2013-2020 Florent Pruvost +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file MORSE-Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of Morse, substitute the full +# License text for the above reference.) ### # -# - Find STARPU include dirs and libraries +# - Find STARPU include dirs and libraries using pkg-config file. # Use this module by invoking find_package with the form: # find_package(STARPU # [version] [EXACT] # Minimum or EXACT version e.g. 1.1 # [REQUIRED] # Fail with error if starpu is not found -# [COMPONENTS <comp1> <comp2> ...] # dependencies # ) # -# COMPONENTS are optional libraries STARPU could be linked with, -# Use it to drive detection of a specific compilation chain -# COMPONENTS can be some of the following: -# - HWLOC: to activate the detection of StarPU linked with HWLOC -# - CUDA: to activate the detection of StarPU linked with CUDA -# - MPI: to activate the detection of StarPU linked with MPI -# - BLAS: to activate the detection of StarPU linked with BLAS -# - MAGMA: to activate the detection of StarPU linked with MAGMA -# - FXT: to activate the detection of StarPU linked with FxT -# - SIMGRID: to activate the detection of StarPU linked with SimGrid -# - FORTRAN: to activate the detection of the StarPU Fortran interface -# -# Results are reported in variables: -# STARPU_FOUND - True if headers and requested libraries were found -# STARPU_CFLAGS_OTHER - starpu compiler flags without headers paths -# STARPU_LDFLAGS_OTHER - starpu linker flags without libraries -# STARPU_INCLUDE_DIRS - starpu include directories -# STARPU_LIBRARY_DIRS - starpu link directories -# STARPU_LIBRARIES - starpu libraries to be linked (absolute path) -# STARPU_CFLAGS_OTHER_DEP - starpu + dependencies compiler flags without headers paths -# STARPU_LDFLAGS_OTHER_DEP - starpu + dependencies linker flags without libraries -# STARPU_INCLUDE_DIRS_DEP - starpu + dependencies include directories -# STARPU_LIBRARY_DIRS_DEP - starpu + dependencies link directories -# STARPU_LIBRARIES_DEP - starpu + dependencies libraries -# STARPU_VERSION - A human-readable string containing the version of the package found -# STARPU_VERSION_MAJOR - The major version of the package found -# STARPU_VERSION_MINOR - The minor version of the package found -# STARPU_FORTRAN_MOD - Points to the StarPU Fortran interface module fstarpu_mod.f90 +# Optional dependencies +# - BLAS +# - CUDA +# - FORTRAN interface +# - FXT +# - HDF5 +# - MAGMA +# - MPI +# - OPENCL +# - SIMGRID # # STARPU_FOUND_WITH_PKGCONFIG - True if found with pkg-config # if found with pkg-config the following variables are set # <PREFIX> = STARPU +# <PREFIX>_PREFIX ... installation path of the lib found +# <PREFIX>_VERSION ... version of the lib # <XPREFIX> = <PREFIX> for common case # <XPREFIX> = <PREFIX>_STATIC for static linking # <XPREFIX>_FOUND ... set to 1 if module(s) exist @@ -59,767 +54,78 @@ # <XPREFIX>_CFLAGS ... all required cflags # <XPREFIX>_CFLAGS_OTHER ... the other compiler flags # -# The user can give specific paths where to find the libraries adding cmake -# options at configure (ex: cmake path/to/project -DSTARPU=path/to/starpu): -# STARPU_DIR - Where to find the base directory of starpu -# STARPU_INCDIR - Where to find the header files -# STARPU_LIBDIR - Where to find the library files -# The module can also look for the following environment variables if paths -# are not given as cmake variable: STARPU_DIR, STARPU_INCDIR, STARPU_LIBDIR - -#============================================================================= -# Copyright 2012-2019 Inria -# Copyright 2012-2013 Emmanuel Agullo -# Copyright 2012-2013 Mathieu Faverge -# Copyright 2012 Cedric Castagnede -# Copyright 2013-2018 Florent Pruvost +# STARPU_FORTRAN_MOD - Points to the StarPU Fortran interface module fstarpu_mod.f90 # -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file MORSE-Copyright.txt for details. +# Set STARPU_STATIC to 1 to force using static libraries if exist. +# +# This module defines the following :prop_tgt:`IMPORTED` target: +# +# ``MORSE::STARPU`` +# The headers and libraries to use for STARPU if found. # -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. #============================================================================= -# (To distribute this file outside of Morse, substitute the full -# License text for the above reference.) # Common macros to use in finds -include(FindInit) - -if (NOT STARPU_FOUND) - set(STARPU_DIR "" CACHE PATH "Installation directory of STARPU library") - if (NOT STARPU_FIND_QUIETLY) - 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, ...) -# try to find them if specified as COMPONENTS during the call -set(STARPU_LOOK_FOR_HWLOC FALSE) -set(STARPU_LOOK_FOR_CUDA FALSE) -set(STARPU_LOOK_FOR_MPI FALSE) -set(STARPU_LOOK_FOR_BLAS FALSE) -set(STARPU_LOOK_FOR_MAGMA FALSE) -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) - elseif(${component} STREQUAL "FORTRAN") - set(STARPU_LOOK_FOR_FORTRAN TRUE) - endif() - endforeach() -endif() - -# STARPU may depend on pthread, try to find it -find_package(Threads) -if( THREADS_FOUND ) - libraries_absolute_path(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}) -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}) -endif () - -# STARPU may depend on HWLOC, try to find it -if (STARPU_LOOK_FOR_HWLOC) - 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 (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) - libraries_absolute_path(CUDA_LIBRARIES "$ENV{CUDA_ROOT}/lib64") - endif() -endif() - -# STARPU may depend on MPI, try to find it -if (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() -endif() - -# STARPU may depend on BLAS, try to find it -if (STARPU_LOOK_FOR_BLAS) - if (STARPU_FIND_REQUIRED AND STARPU_FIND_REQUIRED_BLAS) - find_package(BLAS REQUIRED) - else() - find_package(BLAS) - endif() -endif() - -# STARPU may depend on MAGMA, try to find it -if (STARPU_LOOK_FOR_MAGMA) - if (STARPU_FIND_REQUIRED AND STARPU_FIND_REQUIRED_MAGMA) - find_package(MAGMA REQUIRED) - else() - find_package(MAGMA) - endif() -endif() +include(FindMorseInit) -# STARPU may depend on FXT, try to find it -if (STARPU_LOOK_FOR_FXT) - if (STARPU_FIND_REQUIRED AND STARPU_FIND_REQUIRED_FXT) - find_package(FXT REQUIRED) - else() - find_package(FXT) - endif() +if (NOT STARPU_FIND_QUIETLY) + message(STATUS "FindSTARPU needs pkg-config program and PKG_CONFIG_PATH set with libstarpu*.pc file path.") endif() -# STARPU may depend on SIMGRID, try to find it -if (STARPU_LOOK_FOR_SIMGRID) - if (STARPU_FIND_REQUIRED AND STARPU_FIND_REQUIRED_SIMGRID) - find_package(SIMGRID REQUIRED) - else() - find_package(SIMGRID) +# use pkg-config to detect include/library dirs (if pkg-config is available) +# -------------------------------------------------------------------------- +if (PKG_CONFIG_EXECUTABLE) + unset(STARPU_FOUND CACHE) + pkg_search_module(STARPU libstarpumpi) + if (NOT STARPU_FOUND) + pkg_search_module(STARPU libstarpu) endif() -endif() -set(ENV_STARPU_DIR "$ENV{STARPU_DIR}") -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") -endif() - -# Optionally use pkg-config to detect include/library dirs (if pkg-config is available) -# ------------------------------------------------------------------------------------- -include(FindPkgConfig) -find_package(PkgConfig QUIET) - -if(PKG_CONFIG_EXECUTABLE AND NOT STARPU_GIVEN_BY_USER) - - unset(STARPU_FOUND CACHE) - set (STARPU_VERSION_LIST "1.3;1.2;1.1;1.0") - foreach(_version ${STARPU_VERSION_LIST}) - if(STARPU_LOOK_FOR_MPI) - pkg_search_module(STARPU starpumpi-${_version}) - else() - pkg_search_module(STARPU starpu-${_version}) - endif() - if (STARPU_FOUND) - set(STARPU_VERSION "${_version}" CACHE INTERNAL "StarPU version found") - break() - endif() - endforeach() if (NOT STARPU_FIND_QUIETLY) if (STARPU_FOUND AND STARPU_LIBRARIES) - if (NOT STARPU_INCLUDE_DIRS) - if(STARPU_LOOK_FOR_MPI) - pkg_get_variable(STARPU_INCLUDE_DIRS starpumpi-${_version} includedir) - else() - pkg_get_variable(STARPU_INCLUDE_DIRS starpu-${_version} includedir) - endif() - endif() message(STATUS "Looking for STARPU - found using PkgConfig") - set(STARPU_VERSION_STRING "${STARPU_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() - - # check if the version found respects the minimum required - 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(NOT STARPU_FIND_QUIETLY) - message(WARNING - "STARPU version found is ${STARPU_VERSION}" - " when required is ${STARPU_FIND_VERSION}") - endif() - endif() - else() - # check only if a version is given in the find_package by user - if(STARPU_FIND_VERSION_MAJOR) - # 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(NOT STARPU_FIND_QUIETLY) - message(WARNING - "STARPU version found is ${STARPU_VERSION}" - " when required is ${STARPU_FIND_VERSION} or newer") - endif() - endif() - endif() + "\n Perhaps you should add the directory containing libstarpumpi.pc, libstarpu.pc to" + "\n the PKG_CONFIG_PATH environment variable.${ColourReset}") endif() - - if (STARPU_FOUND AND STARPU_LIBRARIES) - set(STARPU_FOUND_WITH_PKGCONFIG "TRUE") - find_pkgconfig_libraries_absolute_path(STARPU) - else() - set(STARPU_FOUND_WITH_PKGCONFIG "FALSE") - endif() - - endif() - - if(STARPU_LOOK_FOR_MPI AND STARPU_LOOK_FOR_SIMGRID AND STARPU_FOUND) - # 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_LIBRARIES "${FXT_STATIC_LIB}") - list(APPEND STARPU_STATIC_LIBRARIES "${FXT_STATIC_LIB}") 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 - # ------------------- - - # 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}") + if (STARPU_FOUND AND STARPU_LIBRARIES) + if (NOT STARPU_INCLUDE_DIRS) + pkg_get_variable(STARPU_INCLUDE_DIRS libstarpu includedir) endif() - endif() - 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} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - endforeach() + set(STARPU_FOUND_WITH_PKGCONFIG "TRUE") + morse_find_pkgconfig_libraries_absolute_path(STARPU) 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" - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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() + set(STARPU_FOUND_WITH_PKGCONFIG "FALSE") 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 - "${${_PACKAGE}_VERSION_MAJOR}.${${_PACKAGE}_VERSION_MINOR}" CACHE INTERNAL "StarPU version found") - #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(NOT STARPU_FIND_QUIETLY) - message(WARNING - "STARPU version found is ${STARPU_VERSION} " - "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(NOT STARPU_FIND_QUIETLY) - message(WARNING - "STARPU version found is ${STARPU_VERSION} " - "when required is ${STARPU_FIND_VERSION} or newer") - endif() - endif() - endif() - endif() - else() - if(STARPU_FIND_REQUIRED) - message(FATAL_ERROR - "STARPU version has not been found using starpu_config.h" - " located in ${STARPU_starpu_config.h_INCLUDE_DIRS}") - endif() + if (STARPU_STATIC AND STARPU_STATIC_LIBRARIES) + set (STARPU_DEPENDENCIES ${STARPU_STATIC_LIBRARIES}) + list (REMOVE_ITEM STARPU_DEPENDENCIES "starpu") + list (REMOVE_ITEM STARPU_DEPENDENCIES "starpumpi") + list (APPEND STARPU_LIBRARIES ${STARPU_DEPENDENCIES}) + set(STARPU_CFLAGS_OTHER ${STARPU_STATIC_CFLAGS_OTHER}) + set(STARPU_LDFLAGS_OTHER ${STARPU_STATIC_LDFLAGS_OTHER}) + if (NOT STARPU_FIND_QUIETLY) + message(STATUS "STARPU_STATIC set to 1 by user, STARPU_LIBRARIES: ${STARPU_LIBRARIES}.") endif() - else() - if(STARPU_FIND_REQUIRED) - message(FATAL_ERROR - "starpu_config.h has not been found while required to get StarPU version") - 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) - list(APPEND STARPU_hdrs_to_find "starpu_mpi.h") - endif() - if(STARPU_LOOK_FOR_CUDA) - 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} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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" - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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() - 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}) - - if (STARPU_INCLUDE_DIRS) - list(REMOVE_DUPLICATES STARPU_INCLUDE_DIRS) - endif () - - if (STARPU_starpu_config.h_INCLUDE_DIRS) - # Looking for lib - # --------------- - - set(STARPU_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() - list(APPEND _lib_env "$ENV{LIBRARY_PATH}") - if(WIN32) - string(REPLACE ":" ";" _lib_env2 "$ENV{LIB}") - elseif(APPLE) - string(REPLACE ":" ";" _lib_env2 "$ENV{DYLD_LIBRARY_PATH}") - else() - string(REPLACE ":" ";" _lib_env2 "$ENV{LD_LIBRARY_PATH}") - endif() - list(APPEND _lib_env "${_lib_env2}") - list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - 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}") - if (STARPU_LOOK_FOR_MPI) - list(INSERT STARPU_libs_to_find 0 "starpumpi-${STARPU_VERSION}") - 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} - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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 - NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH) - 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) - list(APPEND STARPU_LIBRARIES "${STARPU_${starpu_lib}_LIBRARY}") - list(APPEND STARPU_LIBRARY_DIRS "${${starpu_lib}_lib_path}") - else (STARPU_${starpu_lib}_LIBRARY) - list(APPEND STARPU_LIBRARIES "${STARPU_${starpu_lib}_LIBRARY}") - if(NOT STARPU_FIND_QUIETLY) - message(STATUS "Looking for starpu -- lib ${starpu_lib} not found") - endif() - endif (STARPU_${starpu_lib}_LIBRARY) - - mark_as_advanced(STARPU_${starpu_lib}_LIBRARY) - - endforeach(starpu_lib ${STARPU_libs_to_find}) - - list(REMOVE_DUPLICATES STARPU_LIBRARIES) - if (STARPU_LIBRARY_DIRS) - list(REMOVE_DUPLICATES STARPU_LIBRARY_DIRS) - endif () - - if (STARPU_LIBRARIES AND STARPU_LIBRARY_DIRS AND STARPU_INCLUDE_DIRS) - set(STARPU_FOUND TRUE) - 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_LIBRARIES}) - if (NOT _lib) - set(STARPU_LIBRARIES "STARPU_LIBRARIES-NOTFOUND") - endif() - endforeach() - -endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT STARPU_FOUND) OR (STARPU_GIVEN_BY_USER) ) +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) +if(STARPU_FOUND AND STARPU_LIBRARIES) - # STARPU - if (STARPU_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${STARPU_INCLUDE_DIRS}") - endif() - if (STARPU_CFLAGS_OTHER) - set(REQUIRED_FLAGS "${STARPU_CFLAGS_OTHER}") - endif() - if (STARPU_LDFLAGS_OTHER) - set(REQUIRED_LDFLAGS "${STARPU_LDFLAGS_OTHER}") - endif() - 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_CFLAGS_OTHER) - list(APPEND REQUIRED_FLAGS "${HWLOC_CFLAGS_OTHER}") - endif() - if (HWLOC_LDFLAGS_OTHER) - list(APPEND REQUIRED_LDFLAGS "${HWLOC_LDFLAGS_OTHER}") - endif() - if (HWLOC_LIBRARY_DIRS) - list(APPEND REQUIRED_LIBDIRS "${HWLOC_LIBRARY_DIRS}") - endif() - list(APPEND REQUIRED_LIBS "${HWLOC_LIBRARIES}") - 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_CFLAGS_OTHER) - list(APPEND REQUIRED_FLAGS "${FXT_CFLAGS_OTHER}") - endif() - if (FXT_LDFLAGS_OTHER) - list(APPEND REQUIRED_LDFLAGS "${FXT_LDFLAGS_OTHER}") - endif() - if (FXT_LIBRARY_DIRS) - list(APPEND REQUIRED_LIBDIRS "${FXT_LIBRARY_DIRS}") - endif() - list(APPEND REQUIRED_LIBS "${FXT_LIBRARIES}") - endif() - # SIMGRID - if (SIMGRID_FOUND AND STARPU_LOOK_FOR_SIMGRID) - if (SIMGRID_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${SIMGRID_INCLUDE_DIRS}") - endif() - if (SIMGRID_CFLAGS_OTHER) - list(APPEND REQUIRED_FLAGS "${SIMGRID_CFLAGS_OTHER}") - endif() - if (SIMGRID_LDFLAGS_OTHER) - list(APPEND REQUIRED_LDFLAGS "${SIMGRID_LDFLAGS_OTHER}") - endif() - if (SIMGRID_LIBRARY_DIRS) - list(APPEND REQUIRED_LIBDIRS "${SIMGRID_LIBRARY_DIRS}") - endif() - list(APPEND REQUIRED_LIBS "${SIMGRID_LIBRARIES}") - endif() - # BLAS - if (BLAS_FOUND AND STARPU_LOOK_FOR_BLAS) - if (BLAS_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${BLAS_INCLUDE_DIRS}") - endif() - if (BLAS_CFLAGS_OTHER) - list(APPEND REQUIRED_FLAGS "${BLAS_CFLAGS_OTHER}") - endif() - if (BLAS_LDFLAGS_OTHER) - list(APPEND REQUIRED_LDFLAGS "${BLAS_LDFLAGS_OTHER}") - endif() - if (BLAS_LIBRARY_DIRS) - list(APPEND REQUIRED_LIBDIRS "${BLAS_LIBRARY_DIRS}") - endif() - list(APPEND REQUIRED_LIBS "${BLAS_LIBRARIES}") + # check if static or dynamic lib + morse_check_static_or_dynamic(STARPU STARPU_LIBRARIES) + if(STARPU_STATIC) + set(STATIC "_STATIC") + else() + set(STATIC "") 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}") - if (REQUIRED_FLAGS) - set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}") - set(REQUIRED_FLAGS) - set(REQUIRED_DEFINITIONS) - foreach(_flag ${REQUIRED_FLAGS_COPY}) - if (_flag MATCHES "^-D") - list(APPEND REQUIRED_DEFINITIONS "${_flag}") - endif() - string(REGEX REPLACE "^-D.*" "" _flag "${_flag}") - list(APPEND REQUIRED_FLAGS "${_flag}") - endforeach() - endif() - finds_remove_duplicates() - set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") - set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") - set(CMAKE_REQUIRED_LIBRARIES) - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}") - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + morse_set_required_test_lib_link(STARPU) # test link unset(STARPU_WORKS CACHE) @@ -828,54 +134,44 @@ if(STARPU_LIBRARIES) mark_as_advanced(STARPU_WORKS) if(STARPU_WORKS) - if(STARPU_LOOK_FOR_FORTRAN) - unset(FSTARPU_WORKS CACHE) - check_function_exists(fstarpu_task_insert FSTARPU_WORKS) - if(FSTARPU_WORKS) - set(STARPU_FMOD_DIRS "STARPU_FMOD_DIRS-NOTFOUND") - find_path(STARPU_FMOD_DIRS - NAMES "fstarpu_mod.f90" - HINTS ${STARPU_INCLUDE_DIRS}) - if(STARPU_FMOD_DIRS) - set(STARPU_FORTRAN_MOD "${STARPU_FMOD_DIRS}/fstarpu_mod.f90") - mark_as_advanced(STARPU_FORTRAN_MOD) - if (NOT STARPU_FIND_QUIETLY) - message(STATUS "Looking for starpu fstarpu_mod.f90: found") - endif() - else(STARPU_FMOD_DIRS) - set(FSTARPU_WORKS "FSTARPU_WORKS-NOTFOUND") - endif(STARPU_FMOD_DIRS) - endif(FSTARPU_WORKS) + unset(FSTARPU_WORKS CACHE) + check_function_exists(fstarpu_task_insert FSTARPU_WORKS) + if(FSTARPU_WORKS) + set(STARPU_FMOD_DIRS "STARPU_FMOD_DIRS-NOTFOUND") + find_path(STARPU_FMOD_DIRS + NAMES "fstarpu_mod.f90" + HINTS ${STARPU_INCLUDE_DIRS}) + if(STARPU_FMOD_DIRS) + set(STARPU_FORTRAN_MOD "${STARPU_FMOD_DIRS}/fstarpu_mod.f90") + mark_as_advanced(STARPU_FORTRAN_MOD) + if (NOT STARPU_FIND_QUIETLY) + message(STATUS "Looking for starpu fstarpu_mod.f90: found") + endif() + else(STARPU_FMOD_DIRS) + set(FSTARPU_WORKS "FSTARPU_WORKS-NOTFOUND") + endif(STARPU_FMOD_DIRS) + endif(FSTARPU_WORKS) - if(NOT FSTARPU_WORKS) - if(NOT STARPU_FIND_REQUIRED_FORTRAN) - if (NOT STARPU_FIND_QUIETLY) - message(STATUS "Looking for starpu Fortran interface: not found (not required)") - endif (NOT STARPU_FIND_QUIETLY) - else() - if (NOT STARPU_FIND_QUIETLY) - message(STATUS "Looking for starpu Fortran interface: not found") - endif (NOT STARPU_FIND_QUIETLY) - set(STARPU_WORKS FALSE) - set(STARPU_FOUND FALSE) - endif(NOT STARPU_FIND_REQUIRED_FORTRAN) + if(NOT FSTARPU_WORKS) + if(NOT STARPU_FIND_REQUIRED_FORTRAN) + if (NOT STARPU_FIND_QUIETLY) + message(STATUS "Looking for starpu Fortran interface: not found (not required)") + endif (NOT STARPU_FIND_QUIETLY) else() if (NOT STARPU_FIND_QUIETLY) - message(STATUS "Looking for starpu Fortran interface: found") + message(STATUS "Looking for starpu Fortran interface: not found") endif (NOT STARPU_FIND_QUIETLY) - endif(NOT FSTARPU_WORKS) - - endif(STARPU_LOOK_FOR_FORTRAN) + set(STARPU_WORKS FALSE) + set(STARPU_FOUND FALSE) + endif(NOT STARPU_FIND_REQUIRED_FORTRAN) + else() + if (NOT STARPU_FIND_QUIETLY) + message(STATUS "Looking for starpu Fortran interface: found") + endif (NOT STARPU_FIND_QUIETLY) + endif(NOT FSTARPU_WORKS) endif(STARPU_WORKS) - if(STARPU_WORKS) - # save link with dependencies - set(STARPU_LIBRARIES_DEP "${REQUIRED_LIBS}") - set(STARPU_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}") - set(STARPU_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") - set(STARPU_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}") - set(STARPU_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}") - else() + if(NOT STARPU_WORKS) if(NOT STARPU_FIND_QUIETLY) message(STATUS "Looking for starpu : test of starpu_init fails") message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") @@ -890,29 +186,8 @@ if(STARPU_LIBRARIES) set(CMAKE_REQUIRED_INCLUDES) set(CMAKE_REQUIRED_FLAGS) set(CMAKE_REQUIRED_LIBRARIES) -endif(STARPU_LIBRARIES) -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) - set(STARPU_LIBRARY_DIRS "${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) +endif(STARPU_FOUND AND STARPU_LIBRARIES) # check that STARPU has been found # -------------------------------- @@ -921,42 +196,7 @@ find_package_handle_standard_args(STARPU DEFAULT_MSG STARPU_LIBRARIES STARPU_WORKS) -if(STARPU_FOUND) - if(STARPU_MPI_LIBRARIES AND STARPU_SHM_LIBRARIES AND NOT TARGET starpu::starpu AND NOT TARGET starpu::starpu_mpi) - add_library(starpu::starpu_mpi INTERFACE IMPORTED) - set_property(TARGET starpu::starpu_mpi APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${STARPU_LINKER_FLAGS}") - set_property(TARGET starpu::starpu_mpi APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${STARPU_MPI_LIBRARIES}") - set_property(TARGET starpu::starpu_mpi APPEND PROPERTY INTERFACE_COMPILE_OPTIONS "${STARPU_C_FLAGS}") - set_property(TARGET starpu::starpu_mpi APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${STARPU_INCLUDE_DIRS}") - set_property(TARGET starpu::starpu_mpi APPEND PROPERTY INTERFACE_LINK_DIRECTORIES "${STARPU_LIBRARY_DIRS}") - - add_library(starpu::starpu INTERFACE IMPORTED) - set_property(TARGET starpu::starpu APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${STARPU_LINKER_FLAGS}") - set_property(TARGET starpu::starpu APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${STARPU_SHM_LIBRARIES}") - set_property(TARGET starpu::starpu APPEND PROPERTY INTERFACE_COMPILE_OPTIONS "${STARPU_C_FLAGS}") - set_property(TARGET starpu::starpu APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${STARPU_INCLUDE_DIRS}") - set_property(TARGET starpu::starpu APPEND PROPERTY INTERFACE_LINK_DIRECTORIES "${STARPU_LIBRARY_DIRS}") - - message(STATUS "Morse : targets starpu::starpu and starpu::starpu_mpi available") - endif() - if(STARPU_LIBRARIES_DEP AND NOT TARGET starpu::starpu_dep) - add_library(starpu::starpu_dep INTERFACE IMPORTED) - set_property(TARGET starpu::starpu_dep APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${STARPU_LINKER_FLAGS}") - set_property(TARGET starpu::starpu_dep APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${STARPU_LIBRARIES_DEP}") - set_property(TARGET starpu::starpu_dep APPEND PROPERTY INTERFACE_COMPILE_OPTIONS "${STARPU_C_FLAGS}") - set_property(TARGET starpu::starpu_dep APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${STARPU_INCLUDE_DIRS_DEP}") - set_property(TARGET starpu::starpu_dep APPEND PROPERTY INTERFACE_LINK_DIRECTORIES "${STARPU_LIBRARY_DIRS_DEP}") - - message(STATUS "Morse : target starpu::starpu_dep available") - endif() - if(STARPU_LIBRARIES AND NOT TARGET starpu::starpu) - add_library(starpu::starpu INTERFACE IMPORTED) - set_property(TARGET starpu::starpu APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${STARPU_LINKER_FLAGS}") - set_property(TARGET starpu::starpu APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${STARPU_LIBRARIES}") - set_property(TARGET starpu::starpu APPEND PROPERTY INTERFACE_COMPILE_OPTIONS "${STARPU_C_FLAGS}") - set_property(TARGET starpu::starpu APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${STARPU_INCLUDE_DIRS}") - set_property(TARGET starpu::starpu APPEND PROPERTY INTERFACE_LINK_DIRECTORIES "${STARPU_LIBRARY_DIRS}") - - message(STATUS "Morse : target starpu::starpu available") - endif() -endif() + # Add imported targe +if (STARPU_FOUND) + morse_create_imported_target(STARPU) +endif() \ No newline at end of file diff --git a/modules/find/FindSUITESPARSE.cmake b/modules/find/FindSUITESPARSE.cmake index b5b6b297ed6c0c755a4ba16a6d54492c03f62127..6e13468166e230c20be697789709927037601d40 100644 --- a/modules/find/FindSUITESPARSE.cmake +++ b/modules/find/FindSUITESPARSE.cmake @@ -1,11 +1,22 @@ ### # -# @copyright (c) 2009-2014 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. -# @copyright (c) 2012-2019 Inria. All rights reserved. +# @copyright (c) 2012-2020 Inria. All rights reserved. # @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. # +# Copyright 2012-2013 Emmanuel Agullo +# Copyright 2012-2013 Mathieu Faverge +# Copyright 2012 Cedric Castagnede +# Copyright 2013-2020 Florent Pruvost +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file MORSE-Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of Morse, substitute the full +# License text for the above reference.) ### # # - Find SUITESPARSE include dirs and libraries @@ -22,16 +33,19 @@ # This module finds headers and suitesparse library. # Results are reported in variables: # SUITESPARSE_FOUND - True if headers and requested libraries were found +# SUITESPARSE_PREFIX - installation path of the lib found # SUITESPARSE_CFLAGS_OTHER - suitesparse compiler flags without headers paths # SUITESPARSE_LDFLAGS_OTHER - suitesparse linker flags without libraries # SUITESPARSE_INCLUDE_DIRS - suitesparse include directories # SUITESPARSE_LIBRARY_DIRS - suitesparse link directories # SUITESPARSE_LIBRARIES - suitesparse libraries to be linked (absolute path) -# SUITESPARSE_CFLAGS_OTHER_DEP - suitesparse + dependencies compiler flags without headers paths -# SUITESPARSE_LDFLAGS_OTHER_DEP - suitesparse + dependencies linker flags without libraries -# SUITESPARSE_INCLUDE_DIRS_DEP - suitesparse + dependencies include directories -# SUITESPARSE_LIBRARY_DIRS_DEP - suitesparse + dependencies link directories -# SUITESPARSE_LIBRARIES_DEP - suitesparse + dependencies libraries +# +# Set SUITESPARSE_STATIC to 1 to force using static libraries if exist. +# +# This module defines the following :prop_tgt:`IMPORTED` target: +# +# ``MORSE::SUITESPARSE`` +# The headers and libraries to use for SUITESPARSE, if found. # # The user can give specific paths where to find the libraries adding cmake # options at configure (ex: cmake path/to/project -DSUITESPARSE_DIR=path/to/suitesparse): @@ -40,24 +54,9 @@ # are not given as cmake variable: SUITESPARSE_DIR #============================================================================= -# Copyright 2012-2019 Inria -# Copyright 2012-2013 Emmanuel Agullo -# Copyright 2012-2013 Mathieu Faverge -# Copyright 2012 Cedric Castagnede -# Copyright 2013-2018 Florent Pruvost -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file MORSE-Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of Morse, substitute the full -# License text for the above reference.) # Common macros to use in finds -include(FindInit) +include(FindMorseInit) if (NOT SUITESPARSE_FOUND) set(SUITESPARSE_DIR "" CACHE PATH "Installation directory of SUITESPARSE library") @@ -224,6 +223,11 @@ endforeach() # Looking for lib # --------------- +if (SUITESPARSE_STATIC) + set (CMAKE_FIND_LIBRARY_SUFFIXES_COPY ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set (CMAKE_FIND_LIBRARY_SUFFIXES ".a") +endif() + # create list of libs to find set(SUITESPARSE_libs_to_find "cholmod" @@ -273,6 +277,10 @@ else() endif() endif() +if (SUITESPARSE_STATIC) + set (CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_COPY}) +endif() + # If found, add path to cmake variable # ------------------------------------ set(SUITESPARSE_LIBRARIES "") @@ -298,11 +306,17 @@ list(REMOVE_DUPLICATES SUITESPARSE_INCLUDE_DIRS) # check a function to validate the find if(SUITESPARSE_LIBRARIES) + # check if static or dynamic lib + morse_check_static_or_dynamic(SUITESPARSE SUITESPARSE_LIBRARIES) + if(SUITESPARSE_STATIC) + set(STATIC "_STATIC") + endif() + set(REQUIRED_INCDIRS) - set(REQUIRED_FLAGS) - set(REQUIRED_LDFLAGS) set(REQUIRED_LIBDIRS) set(REQUIRED_LIBS) + set(REQUIRED_FLAGS) + set(REQUIRED_LDFLAGS) # SUITESPARSE if (SUITESPARSE_INCLUDE_DIRS) @@ -328,19 +342,19 @@ if(SUITESPARSE_LIBRARIES) endif() # LAPACK if (LAPACK_FOUND) - if (LAPACK_INCLUDE_DIRS_DEP) - list(APPEND REQUIRED_INCDIRS "${LAPACK_INCLUDE_DIRS_DEP}") + if (LAPACK_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${LAPACK_INCLUDE_DIRS}") endif() - if (LAPACK_CFLAGS_OTHER_DEP) - list(APPEND REQUIRED_FLAGS "${LAPACK_CFLAGS_OTHER_DEP}") + if (LAPACK_CFLAGS_OTHER) + list(APPEND REQUIRED_FLAGS "${LAPACK_CFLAGS_OTHER}") endif() - if (LAPACK_LDFLAGS_OTHER_DEP) - list(APPEND REQUIRED_LDFLAGS "${LAPACK_LDFLAGS_OTHER_DEP}") + if (LAPACK_LDFLAGS_OTHER) + list(APPEND REQUIRED_LDFLAGS "${LAPACK_LDFLAGS_OTHER}") endif() - if (LAPACK_LIBRARY_DIRS_DEP) - list(APPEND REQUIRED_LIBDIRS "${LAPACK_LIBRARY_DIRS_DEP}") + if (LAPACK_LIBRARY_DIRS) + list(APPEND REQUIRED_LIBDIRS "${LAPACK_LIBRARY_DIRS}") endif() - list(APPEND REQUIRED_LIBS "${LAPACK_LIBRARIES_DEP}") + list(APPEND REQUIRED_LIBS "${LAPACK_LIBRARIES}") endif() # others set(M_LIBRARY "M_LIBRARY-NOTFOUND") @@ -364,7 +378,7 @@ if(SUITESPARSE_LIBRARIES) list(APPEND REQUIRED_FLAGS "${_flag}") endforeach() endif() - finds_remove_duplicates() + morse_finds_remove_duplicates() set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) @@ -379,12 +393,14 @@ if(SUITESPARSE_LIBRARIES) 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_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}") - set(SUITESPARSE_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}") + set(SUITESPARSE_LIBRARY_DIRS "${REQUIRED_LIBDIRS}") + set(SUITESPARSE_INCLUDE_DIRS "${REQUIRED_INCDIRS}") + if (SUITESPARSE_STATIC OR METIS_STATIC OR BLA_STATIC) + # save link with dependencies + set(SUITESPARSE_LIBRARIES "${REQUIRED_LIBS}") + set(SUITESPARSE_CFLAGS_OTHER "${REQUIRED_FLAGS}") + set(SUITESPARSE_LDFLAGS_OTHER "${REQUIRED_LDFLAGS}") + endif() else() if(NOT SUITESPARSE_FIND_QUIETLY) message(STATUS "Looking for SUITESPARSE : test of symbol SuiteSparse_start fails") @@ -398,23 +414,22 @@ if(SUITESPARSE_LIBRARIES) 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) + get_filename_component(first_lib_path "${first_lib}" DIRECTORY) if (NOT SUITESPARSE_LIBRARY_DIRS) set(SUITESPARSE_LIBRARY_DIRS "${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(SUITESPARSE_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of SUITESPARSE library" FORCE) + set(SUITESPARSE_PREFIX "${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) + set(SUITESPARSE_PREFIX "${first_lib_path}" CACHE PATH "Installation directory of SUITESPARSE library" FORCE) endif() -endif() -mark_as_advanced(SUITESPARSE_DIR) -mark_as_advanced(SUITESPARSE_DIR_FOUND) + mark_as_advanced(SUITESPARSE_DIR) + mark_as_advanced(SUITESPARSE_PREFIX) + +endif(SUITESPARSE_LIBRARIES) # check that SUITESPARSE has been found # ------------------------------- @@ -422,3 +437,8 @@ include(FindPackageHandleStandardArgs) find_package_handle_standard_args(SUITESPARSE DEFAULT_MSG SUITESPARSE_LIBRARIES SUITESPARSE_WORKS) + +# Add imported target +if (SUITESPARSE_FOUND) + morse_create_imported_target(SUITESPARSE) +endif() diff --git a/modules/find/FindTMG.cmake b/modules/find/FindTMG.cmake index d1ed786929584ae1b2d4e72d132433397f95e26f..90b086c67f3ac6ea86bb99768ded3ef43e45c903 100644 --- a/modules/find/FindTMG.cmake +++ b/modules/find/FindTMG.cmake @@ -1,11 +1,22 @@ ### # -# @copyright (c) 2009-2014 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. -# @copyright (c) 2012-2019 Inria. All rights reserved. +# @copyright (c) 2012-2020 Inria. All rights reserved. # @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. # +# Copyright 2012-2013 Emmanuel Agullo +# Copyright 2012-2013 Mathieu Faverge +# Copyright 2012 Cedric Castagnede +# Copyright 2013-2020 Florent Pruvost +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file MORSE-Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of Morse, substitute the full +# License text for the above reference.) ### # # - Find TMG include dirs and libraries @@ -16,17 +27,20 @@ # # This module finds headers and tmg library. # Results are reported in variables: -# TMG_FOUND - True if headers and requested libraries were found +# TMG_FOUND - True if headers and requested libraries were found +# TMG_PREFIX - installation path of the lib found # TMG_CFLAGS_OTHER - tmglib compiler flags without headers paths # TMG_LDFLAGS_OTHER - tmglib linker flags without libraries # TMG_INCLUDE_DIRS - tmglib include directories # TMG_LIBRARY_DIRS - tmglib link directories # TMG_LIBRARIES - tmglib libraries to be linked (absolute path) -# TMG_CFLAGS_OTHER_DEP - tmglib + dependencies compiler flags without headers paths -# TMG_LDFLAGS_OTHER_DEP - tmglib + dependencies linker flags without libraries -# TMG_INCLUDE_DIRS_DEP - tmglib + dependencies include directories -# TMG_LIBRARY_DIRS_DEP - tmglib + dependencies link directories -# TMG_LIBRARIES_DEP - tmglib + dependencies libraries +# +# Set TMG_STATIC to 1 to force using static libraries if exist. +# +# This module defines the following :prop_tgt:`IMPORTED` target: +# +# ``MORSE::TMG`` +# The headers and libraries to use for TMG, if found. # # The user can give specific paths where to find the libraries adding cmake # options at configure (ex: cmake path/to/project -DTMG=path/to/tmg): @@ -37,24 +51,9 @@ # are not given as cmake variable: TMG_DIR, TMG_INCDIR, TMG_LIBDIR #============================================================================= -# Copyright 2012-2019 Inria -# Copyright 2012-2013 Emmanuel Agullo -# Copyright 2012-2013 Mathieu Faverge -# Copyright 2012 Cedric Castagnede -# Copyright 2013-2018 Florent Pruvost -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file MORSE-Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of Morse, substitute the full -# License text for the above reference.) # Common macros to use in finds -include(FindInit) +include(FindMorseInit) if (NOT TMG_FOUND) set(TMG_DIR "" CACHE PATH "Installation directory of TMG library") @@ -83,9 +82,9 @@ endif() if (LAPACK_FOUND) # check if a tmg function exists in the LAPACK lib - set(CMAKE_REQUIRED_LIBRARIES "${LAPACK_LDFLAGS_OTHER_DEP};${LAPACK_LIBRARIES_DEP}") - set(CMAKE_REQUIRED_INCLUDES "${LAPACK_INCLUDE_DIRS_DEP}") - set(CMAKE_REQUIRED_FLAGS "${LAPACK_CFLAGS_OTHER_DEP}") + set(CMAKE_REQUIRED_LIBRARIES "${LAPACK_LDFLAGS_OTHER};${LAPACK_LIBRARIES}") + set(CMAKE_REQUIRED_INCLUDES "${LAPACK_INCLUDE_DIRS}") + set(CMAKE_REQUIRED_FLAGS "${LAPACK_CFLAGS_OTHER}") include(CheckFunctionExists) include(CheckFortranFunctionExists) unset(TMG_WORKS CACHE) @@ -150,6 +149,11 @@ if (LAPACK_FOUND) # Try to find the tmg lib in the given paths # ---------------------------------------------- + if (TMG_STATIC) + set (CMAKE_FIND_LIBRARY_SUFFIXES_COPY ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set (CMAKE_FIND_LIBRARY_SUFFIXES ".a") + endif() + # call cmake macro to find the lib path if(TMG_LIBDIR) set(TMG_tmg_LIBRARY "TMG_tmg_LIBRARY-NOTFOUND") @@ -174,6 +178,10 @@ if (LAPACK_FOUND) endif() mark_as_advanced(TMG_tmg_LIBRARY) + if (TMG_STATIC) + set (CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_COPY}) + endif() + # If found, add path to cmake variable # ------------------------------------ if (TMG_tmg_LIBRARY) @@ -198,11 +206,17 @@ if (LAPACK_FOUND) # check a function to validate the find if(TMG_LIBRARIES) + # check if static or dynamic lib + morse_check_static_or_dynamic(TMG TMG_LIBRARIES) + if(TMG_STATIC) + set(STATIC "_STATIC") + endif() + set(REQUIRED_INCDIRS) - set(REQUIRED_FLAGS) - set(REQUIRED_LDFLAGS) set(REQUIRED_LIBDIRS) set(REQUIRED_LIBS) + set(REQUIRED_FLAGS) + set(REQUIRED_LDFLAGS) # TMG if (TMG_INCLUDE_DIRS) @@ -219,19 +233,19 @@ if (LAPACK_FOUND) endif() set(REQUIRED_LIBS "${TMG_LIBRARIES}") # LAPACK - if (LAPACK_INCLUDE_DIRS_DEP) - list(APPEND REQUIRED_INCDIRS "${LAPACK_INCLUDE_DIRS_DEP}") + if (LAPACK_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${LAPACK_INCLUDE_DIRS}") endif() - if (LAPACK_CFLAGS_OTHER_DEP) - list(APPEND REQUIRED_FLAGS "${LAPACK_CFLAGS_OTHER_DEP}") + if (LAPACK_CFLAGS_OTHER) + list(APPEND REQUIRED_FLAGS "${LAPACK_CFLAGS_OTHER}") endif() - if (LAPACK_LDFLAGS_OTHER_DEP) - list(APPEND REQUIRED_LDFLAGS "${LAPACK_LDFLAGS_OTHER_DEP}") + if (LAPACK_LDFLAGS_OTHER) + list(APPEND REQUIRED_LDFLAGS "${LAPACK_LDFLAGS_OTHER}") endif() - if (LAPACK_LIBRARY_DIRS_DEP) - list(APPEND REQUIRED_LIBDIRS "${LAPACK_LIBRARY_DIRS_DEP}") + if (LAPACK_LIBRARY_DIRS) + list(APPEND REQUIRED_LIBDIRS "${LAPACK_LIBRARY_DIRS}") endif() - list(APPEND REQUIRED_LIBS "${LAPACK_LIBRARIES_DEP}") + list(APPEND REQUIRED_LIBS "${LAPACK_LIBRARIES}") # set required libraries for link set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") @@ -247,7 +261,7 @@ if (LAPACK_FOUND) list(APPEND REQUIRED_FLAGS "${_flag}") endforeach() endif() - finds_remove_duplicates() + morse_finds_remove_duplicates() set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) @@ -275,12 +289,14 @@ if (LAPACK_FOUND) 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_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}") - set(TMG_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}") + set(TMG_LIBRARY_DIRS "${REQUIRED_LIBDIRS}") + set(TMG_INCLUDE_DIRS "${REQUIRED_INCDIRS}") + if (TMG_STATIC OR BLA_STATIC) + # save link with dependencies + set(TMG_LIBRARIES "${REQUIRED_LIBS}") + set(TMG_CFLAGS_OTHER "${REQUIRED_FLAGS}") + set(TMG_LDFLAGS_OTHER "${REQUIRED_LDFLAGS}") + endif() else() if(NOT TMG_FIND_QUIETLY) message(STATUS "Looking for tmg: test of dlarnv and dlagsy with tmg and lapack libraries fails") @@ -293,6 +309,21 @@ if (LAPACK_FOUND) set(CMAKE_REQUIRED_INCLUDES) set(CMAKE_REQUIRED_FLAGS) set(CMAKE_REQUIRED_LIBRARIES) + + list(GET TMG_LIBRARIES 0 first_lib) + get_filename_component(first_lib_path "${first_lib}" DIRECTORY) + if (NOT TMG_LIBRARY_DIRS) + set(TMG_LIBRARY_DIRS "${first_lib_path}") + endif() + 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_PREFIX "${not_cached_dir}" CACHE PATH "Installation directory of TMG library" FORCE) + else() + set(TMG_PREFIX "${first_lib_path}" CACHE PATH "Installation directory of TMG library" FORCE) + endif() + mark_as_advanced(TMG_DIR) + mark_as_advanced(TMG_PREFIX) + endif(TMG_LIBRARIES) else() @@ -304,25 +335,14 @@ else() endif() -if (TMG_LIBRARIES) - list(GET TMG_LIBRARIES 0 first_lib) - get_filename_component(first_lib_path "${first_lib}" PATH) - if (NOT TMG_LIBRARY_DIRS) - set(TMG_LIBRARY_DIRS "${first_lib_path}") - endif() - 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) - # check that TMG has been found # ------------------------------- include(FindPackageHandleStandardArgs) find_package_handle_standard_args(TMG DEFAULT_MSG TMG_LIBRARIES TMG_WORKS) + +# Add imported target +if (TMG_FOUND) + morse_create_imported_target(TMG) +endif() diff --git a/modules/find/MORSE-Copyright.txt b/modules/find/MORSE-Copyright.txt index c29a436d1f03cfab090a2b5e7956a8561f9117e5..3b885875f9556c32fafb21c4d9d7e4dae5a1d500 100644 --- a/modules/find/MORSE-Copyright.txt +++ b/modules/find/MORSE-Copyright.txt @@ -1,29 +1,26 @@ ### # -# @copyright (c) 2009-2014 The University of Tennessee and The University -# of Tennessee Research Foundation. -# All rights reserved. -# @copyright (c) 2012-2019 Inria. All rights reserved. -# @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. +# @copyright (c) 2012-2020 Inria. All rights reserved. +# @copyright (c) 2012-2020 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. # ### # # This software is a computer program whose purpose is to process # Matrices Over Runtime Systems @ Exascale (MORSE). More information # can be found on the following website: http://www.inria.fr/en/teams/morse. -# +# # This software is governed by the CeCILL-C license under French law and -# abiding by the rules of distribution of free software. You can use, +# abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL-C # license as circulated by CEA, CNRS and INRIA at the following URL -# "http://www.cecill.info". -# +# "http://www.cecill.info". +# # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited -# liability. -# +# liability. +# # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, @@ -31,10 +28,10 @@ # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their -# requirements in conditions enabling the security of their systems and/or -# data to be ensured and, more generally, to use and operate it in the -# same conditions as regards security. -# +# requirements in conditions enabling the security of their systems and/or +# data to be ensured and, more generally, to use and operate it in the +# same conditions as regards security. +# # The fact that you are presently reading this means that you have had # knowledge of the CeCILL-C license and that you accept its terms. # diff --git a/modules/find/morse_cmakefind_doc.html b/modules/find/morse_cmakefind_doc.html index 854c60fb0db4cfefe89283c861fb482e052c8787..f5e3fe81bab4d69b90e26f9163ab3307386938fa 100644 --- a/modules/find/morse_cmakefind_doc.html +++ b/modules/find/morse_cmakefind_doc.html @@ -3,11 +3,12 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> +<!-- 2020-12-11 ven. 10:34 --> +<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> +<meta name="viewport" content="width=device-width, initial-scale=1" /> <title>MORSE CMake "Find modules" documentation</title> -<!-- 2018-07-26 jeu. 15:38 --> -<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> -<meta name="generator" content="Org-mode" /> -<meta name="author" content="HiePACS" /> +<meta name="generator" content="Org mode" /> +<meta name="author" content="Florent Pruvost" /> <link rel="stylesheet" title="Standard" href="css/worg.css" type="text/css" /> <link rel="stylesheet" type="text/css" href="css/VisuGen.css" /> <link rel="stylesheet" type="text/css" href="css/VisuRubriqueEncadre.css" /> @@ -16,7 +17,7 @@ @licstart The following is the entire license notice for the JavaScript code in this tag. -Copyright (C) 2012-2013 Free Software Foundation, Inc. +Copyright (C) 2012-2019 Free Software Foundation, Inc. The JavaScript code in this tag is free software: you can redistribute it and/or modify it under the terms of the GNU @@ -65,15 +66,18 @@ for the JavaScript code in this tag. <h2>Table of Contents</h2> <div id="text-table-of-contents"> <ul> -<li><a href="#sec-1">1. CMake find modules: what is it, why is it useful?</a></li> -<li><a href="#sec-2">2. How CMake is aware of these specific modules?</a></li> -<li><a href="#sec-3">3. Internal mechanism: what a "find" mainly do, what are the paths scanned?</a> +<li><a href="#org6a1d49d">1. CMake find modules: what is it, why is it useful?</a></li> +<li><a href="#orgc79c433">2. How CMake is aware of these specific modules?</a></li> +<li><a href="#orgd94103a">3. Internal mechanism: what a "find" mainly do, what are the paths scanned?</a> <ul> -<li><a href="#sec-3-1">3.1. How to act on the searching process?</a></li> -<li><a href="#sec-3-2">3.2. A version of the library is found but I want another one, how to change?</a></li> +<li><a href="#org5ee891c">3.1. How to act on the searching process?</a></li> +<li><a href="#org9523cf0">3.2. A version of the library is found but I want another one, how to change?</a></li> </ul> </li> -<li><a href="#sec-4">4. How to get more information about a specific module usage?</a></li> +<li><a href="#org6d52417">4. How to get more information about a specific module usage?</a></li> +<li><a href="#org4cffe2e">5. Choose a specific BLAS/LAPACK</a></li> +<li><a href="#org9c82006">6. Hint for Intel MKL</a></li> +<li><a href="#org9f1f26c">7. To prefer static libraries if both static and dynamic are available</a></li> </ul> </div> </div> @@ -83,11 +87,15 @@ which allow to detect library dependencies on UNIX systems (mainly Linux and MAC OS X). These additional modules have been written because either, they are not distributed by the CMake community, or, they already exist but some are outdated or miss the requirements we -need. +need. The modules correspond to packages that do not fully rely on +CMake or which do not provide a "PACKAGE"Config.cmake file. Ideally +these modules should not exist and packages should be compliant with +CMake by providing the cmake config file installed in +<code><prefix>/lib/cmake/<package>/...</code>. </p> -<div id="outline-container-sec-1" class="outline-2"> -<h2 id="sec-1"><span class="section-number-2">1</span> CMake find modules: what is it, why is it useful?</h2> +<div id="outline-container-org6a1d49d" class="outline-2"> +<h2 id="org6a1d49d"><span class="section-number-2">1</span> CMake find modules: what is it, why is it useful?</h2> <div class="outline-text-2" id="text-1"> <p> The CMake modules being here can be used to "find" some installed @@ -96,22 +104,55 @@ CMake command ("MODULE" mode signature, cf. CMake documentation of <code>find_package</code> command) </p> <pre class="example"> -find_package(BLAS) # look for BLAS libraries and compiler/linker flags +find_package(STARPU) # look for STARPU libraries and compiler/linker flags add_executable(foo ${FOO_SOURCES}) # define an executable from sources -target_link_libraries(foo ${BLAS_LIBRARIES}) # add BLAS libraries for the link +target_link_libraries(foo PRIVATE MORSE::STARPU) # add STARPU libraries for the link +# target_link_libraries(foo ${STARPU_LIBRARIES}) old school cmake with variables and not target </pre> <p> -It allows to find efficiently the libraries we depend on. -The modules are generally written by the library developers or very -active users so that they know very well how the library is built how -it is installed, etc. +It allows to find efficiently the libraries we depend on. The modules +are generally written by the library developers or very active users +so that they know very well how the library is built how it is +installed, etc. </p> + +<p> +The <code>find_package(FOO)</code> command looks for the library(ies), the header +directory(ies) and compiler/linker flags. If found the following +CMake variables are set: +</p> +<ul class="org-ul"> +<li>FOO_FOUND: set if package is found</li> +<li>FOO_PREFIX: root of the package installation (usually one +directory above lib/ one)</li> +<li>FOO_VERSION: version of the package if found with pkg-config</li> +<li>FOO_INCLUDE_DIRS: path to headers</li> +<li>FOO_LIBRARY_DIRS: library directories</li> +<li>FOO_LIBRARIES: list of libraries necessary to link with the +package (absolute paths given)</li> +<li>FOO_CFLAGS_OTHER: required compiler flags</li> +<li>FOO_LDLAGS_OTHER: required linker flags</li> +<li>FOO_STATIC: to force using static libraries when exist or is set +to 1 if the only library found is static</li> +</ul> + +<p> +In addition the <i>find_package</i> command define an imported target +<b>MORSE::FOO</b> to be used in modern CMake fashion. The target defines +the following CMake properties: +</p> +<ul class="org-ul"> +<li>INTERFACE_INCLUDE_DIRECTORIES</li> +<li>INTERFACE_LINK_DIRECTORIES</li> +<li>INTERFACE_LINK_LIBRARIES</li> +<li>INTERFACE_COMPILE_OPTIONS</li> +<li>INTERFACE_LINK_OPTIONS</li> +</ul> </div> </div> - -<div id="outline-container-sec-2" class="outline-2"> -<h2 id="sec-2"><span class="section-number-2">2</span> How CMake is aware of these specific modules?</h2> +<div id="outline-container-orgc79c433" class="outline-2"> +<h2 id="orgc79c433"><span class="section-number-2">2</span> How CMake is aware of these specific modules?</h2> <div class="outline-text-2" id="text-2"> <p> To use MORSE modules you should call the <b>MorseInit</b> module as follows: @@ -125,57 +166,58 @@ include(MorseInit) </pre> </div> </div> - -<div id="outline-container-sec-3" class="outline-2"> -<h2 id="sec-3"><span class="section-number-2">3</span> Internal mechanism: what a "find" mainly do, what are the paths scanned?</h2> +<div id="outline-container-orgd94103a" class="outline-2"> +<h2 id="orgd94103a"><span class="section-number-2">3</span> Internal mechanism: what a "find" mainly do, what are the paths scanned?</h2> <div class="outline-text-2" id="text-3"> <p> -The general process consists in looking into some system paths known -from CMake to find headers and libraries and define in output some -CMake variables the user need to link with his dependency. Additionaly -to the system paths, some environment variable can also be scanned -like <code>LIBRARY_PATH</code> <code>LD_LIBRARY_PATH</code> and <code>CPATH</code>. A custom CMake cache -variable <code>LIBNAME_DIR</code> is also introduced in our modules in order to let -users indicate directly during the "configure" step a specific -installation directory for the library (e.g. where are located the -include/, lib/, etc, sub-directories). The priority order is the -following: +We try to enforce using pkg-config file if provided (update your +PKG_CONFIG_PATH environment variable). +</p> + +<p> +List of packages relying only on pkg-config file: EZTRACE, FXT, GTG, +HWLOC, PAPI, SIMGRID, PARSEC, STARPU. +</p> + +<p> +For packages which do not provide any pkg-config file the general +process consists in looking into some system paths known from CMake to +find headers and libraries and define in output some CMake variables +the user need to link with his dependency. Additionaly to the system +paths, some environment variable can also be scanned like <code>LIBRARY_PATH</code> +<code>LD_LIBRARY_PATH</code> and <code>CPATH</code>. A custom CMake cache variable <code>LIBNAME_DIR</code> +is also introduced in our modules in order to let users indicate +directly during the "configure" step a specific installation directory +for the library (e.g. where are located the include/, lib/, etc, +sub-directories). The priority order is the following: </p> <ol class="org-ol"> <li>The CMake variable <code>LIBNAME_DIR</code> is set or both <code>LIBNAME_INCDIR</code> and -<code>LIBNAME_LIBDIR</code> are set -</li> +<code>LIBNAME_LIBDIR</code> are set</li> <li>The environment variable <code>LIBNAME_DIR</code> is set or both <code>LIBNAME_INCDIR</code> and -<code>LIBNAME_LIBDIR</code> -</li> +<code>LIBNAME_LIBDIR</code></li> <li>A pkg-config .pc file (hwloc.pc) of the library is available in the -environment (cf. PKG_CONFIG_PATH environment variable) and is used -</li> -<li>Look into the following paths -<ol class="org-ol"> -<li>for headers: +environment (cf. PKG_CONFIG_PATH environment variable) and is used</li> +<li><p> +Look into the following paths +a) for headers: +</p> <ul class="org-ul"> <li>scan the paths present in the following environment variables -<code>INCLUDE</code>, <code>C_INCLUDE_PATH</code>, <code>CPATH</code>, <code>INCLUDE_PATH</code> -</li> +<code>INCLUDE</code>, <code>C_INCLUDE_PATH</code>, <code>CPATH</code>, <code>INCLUDE_PATH</code></li> <li>scan the system paths for headers: look into path present in -the CMake variable <code>CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES</code> -</li> +the CMake variable <code>CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES</code></li> </ul> -</li> -<li>for libraries: +<p> +b) for libraries: +</p> <ul class="org-ul"> <li>scan the paths present in the following environment variables <code>LIBRARY_PATH</code>, <code>LIB</code> (Windows), <code>DYLD_LIBRARY_PATH</code> (Mac OS X), -<code>LD_LIBRARY_PATH</code> (Linux) -</li> +<code>LD_LIBRARY_PATH</code> (Linux)</li> <li>scan the system paths for headers: look into path present in -the CMake variable <code>CMAKE_C_IMPLICIT_LINK_DIRECTORIES</code> -</li> -</ul> -</li> -</ol> -</li> +the CMake variable <code>CMAKE_C_IMPLICIT_LINK_DIRECTORIES</code></li> +</ul></li> </ol> <p> @@ -203,20 +245,22 @@ during the test. The precise error can also be found in the </p> </div> -<div id="outline-container-sec-3-1" class="outline-3"> -<h3 id="sec-3-1"><span class="section-number-3">3.1</span> How to act on the searching process?</h3> +<div id="outline-container-org5ee891c" class="outline-3"> +<h3 id="org5ee891c"><span class="section-number-3">3.1</span> How to act on the searching process?</h3> <div class="outline-text-3" id="text-3-1"> <p> -If the user does not change the environment (do not modify environment -variables like <code>LIBRARY_PATH</code>, <code>LD_LIBRARY_PATH</code>), and gives no hint at all about the -location of the libraries, the module will match the situation 4.2 and -will look into system paths. +If the user does not change the environment (do not modify +environment variables like <code>LIBRARY_PATH</code>, <code>LD_LIBRARY_PATH</code>), and +gives no hint at all about the location of the libraries, the +module will match the situation 4.2 and will look into system +paths. </p> <p> -To give an "exotic" locations, i.e. not in system paths, the user can -use scripts or a <code>module</code> like system to set the paths in environment -variables (<code>LD_LIBRARY_PATH</code>, <code>INCLUDE</code>, …), cf. situation 4.1 and 2. +To give an "exotic" locations, i.e. not in system paths, the user +can use scripts or a <code>module</code> like system to set the paths in +environment variables (<code>LD_LIBRARY_PATH</code>, <code>INCLUDE</code>, …), +cf. situation 4.1 and 2. </p> <p> @@ -226,48 +270,81 @@ cf. situation 3. </p> <p> -Finally, to directly give "by hand" the path, the user can set a CMake -variable <code>LIBNAME_DIR</code>, or the pair <code>LIBNAME_INCDIR</code> and <code>LIBNAME_LIBDIR</code>, -cf. situation 1. +Finally, to directly give "by hand" the path, the user can set a +CMake variable <code>LIBNAME_DIR</code>, or the pair <code>LIBNAME_INCDIR</code> and +<code>LIBNAME_LIBDIR</code>, cf. situation 1. </p> </div> </div> - -<div id="outline-container-sec-3-2" class="outline-3"> -<h3 id="sec-3-2"><span class="section-number-3">3.2</span> A version of the library is found but I want another one, how to change?</h3> +<div id="outline-container-org9523cf0" class="outline-3"> +<h3 id="org9523cf0"><span class="section-number-3">3.2</span> A version of the library is found but I want another one, how to change?</h3> <div class="outline-text-3" id="text-3-2"> <p> If a first configuration has found a library somewhere but you are not satisfied with this one and want to give some hints to look for it: </p> <ul class="org-ul"> -<li>update your environment or give the location "by hand" (<code>LIBNAME_DIR</code>) -</li> +<li>update your environment or give the location "by hand" (<code>LIBNAME_DIR</code>)</li> <li>delete the CMake cache file to make it "forget" the libraries -already found: <code>rm CMakeCache.txt</code> -</li> -<li>configure again: <code>cmake path/to/your/CMakeLists.txt ...</code> -</li> +already found: <code>rm CMakeCache.txt</code></li> +<li>configure again: <code>cmake path/to/your/CMakeLists.txt ...</code></li> </ul> </div> </div> </div> - -<div id="outline-container-sec-4" class="outline-2"> -<h2 id="sec-4"><span class="section-number-2">4</span> How to get more information about a specific module usage?</h2> +<div id="outline-container-org6d52417" class="outline-2"> +<h2 id="org6d52417"><span class="section-number-2">4</span> How to get more information about a specific module usage?</h2> <div class="outline-text-2" id="text-4"> <p> -Specific information about a precise Find module are given directly at -the head of the module file. The usage, the optional parameters that -can be used and the output variables are explained here. +Specific information about a precise Find module are given directly +at the head of the module file. The usage, the optional parameters +that can be used and the output variables are explained here. +</p> +</div> +</div> +<div id="outline-container-org4cffe2e" class="outline-2"> +<h2 id="org4cffe2e"><span class="section-number-2">5</span> Choose a specific BLAS/LAPACK</h2> +<div class="outline-text-2" id="text-5"> +<p> + See <code>cmake --help-module FindBLAS</code> or <code>cmake --help-module FindLAPACK</code> +to get all available BLA_VENDOR. +</p> +</div> +</div> +<div id="outline-container-org9c82006" class="outline-2"> +<h2 id="org9c82006"><span class="section-number-2">6</span> Hint for Intel MKL</h2> +<div class="outline-text-2" id="text-6"> +<p> +To look for the Intel MKL BLAS, LAPACK (or CBLAS, LAPACKE), one can +enforce Intel MKL search with the CMake variable <b>BLA_VENDOR</b> as it is +documented in BLAS and LAPACK officiel modules <code>cmake --help-module + FindLAPACK</code> +</p> +<pre class="example"> +# for sequential blas/lapack +cmake .. -DBLA_VENDOR=Intel10_64lp_seq +# for multithreaded blas/lapack +cmake .. -DBLA_VENDOR=Intel10_64lp +# play with MKL_NUM_THREADS env. var. to set number of threads used internally +</pre> +<p> +or set BLA_VENDOR directly in your CMake files. +</p> +</div> +</div> +<div id="outline-container-org9f1f26c" class="outline-2"> +<h2 id="org9f1f26c"><span class="section-number-2">7</span> To prefer static libraries if both static and dynamic are available</h2> +<div class="outline-text-2" id="text-7"> +<p> +Set "PACKAGE"_STATIC=1 at cmake configure. For BLAS/LAPACK/SCALAPACK +use <b>BLA_STATIC=1</b>. </p> </div> </div> </div> <div id="postamble" class="status"> -<p class="author">Author: HiePACS</p> -<p class="date">Created: 2018-07-26 jeu. 15:38</p> -<p class="creator"><a href="http://www.gnu.org/software/emacs/">Emacs</a> 25.2.2 (<a href="http://orgmode.org">Org</a> mode 8.2.10)</p> +<p class="author">Author: Florent Pruvost</p> +<p class="date">Created: 2020-12-11 ven. 10:34</p> <p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p> </div> </body> diff --git a/modules/find/morse_cmakefind_doc.org b/modules/find/morse_cmakefind_doc.org index 205e005eb53a6e90ec3309240cfececcd45e6197..c19042b7c5dbf6480179c7961d8be688cdb8f550 100644 --- a/modules/find/morse_cmakefind_doc.org +++ b/modules/find/morse_cmakefind_doc.org @@ -1,5 +1,5 @@ #+TITLE: MORSE CMake "Find modules" documentation -#+AUTHOR: HiePACS +#+AUTHOR: Florent Pruvost #+LANGUAGE: en #+OPTIONS: H:3 num:t toc:t \n:nil @:t ::t |:t _:nil ^:nil -:t f:t *:t <:t #+OPTIONS: TeX:t LaTeX:t skip:nil d:nil pri:nil tags:not-in-toc html-style:nil @@ -19,121 +19,162 @@ which allow to detect library dependencies on UNIX systems (mainly Linux and MAC OS X). These additional modules have been written because either, they are not distributed by the CMake community, or, they already exist but some are outdated or miss the requirements we -need. +need. The modules correspond to packages that do not fully rely on +CMake or which do not provide a "PACKAGE"Config.cmake file. Ideally +these modules should not exist and packages should be compliant with +CMake by providing the cmake config file installed in +~<prefix>/lib/cmake/<package>/...~. * CMake find modules: what is it, why is it useful? -The CMake modules being here can be used to "find" some installed -libraries on the system through the invocation of the ~find_package~ -CMake command ("MODULE" mode signature, cf. CMake documentation of -~find_package~ command) -#+BEGIN_EXAMPLE -find_package(BLAS) # look for BLAS libraries and compiler/linker flags -add_executable(foo ${FOO_SOURCES}) # define an executable from sources -target_link_libraries(foo ${BLAS_LIBRARIES}) # add BLAS libraries for the link -#+END_EXAMPLE - -It allows to find efficiently the libraries we depend on. -The modules are generally written by the library developers or very -active users so that they know very well how the library is built how -it is installed, etc. - + The CMake modules being here can be used to "find" some installed + libraries on the system through the invocation of the ~find_package~ + CMake command ("MODULE" mode signature, cf. CMake documentation of + ~find_package~ command) + #+BEGIN_EXAMPLE + find_package(STARPU) # look for STARPU libraries and compiler/linker flags + add_executable(foo ${FOO_SOURCES}) # define an executable from sources + target_link_libraries(foo PRIVATE MORSE::STARPU) # add STARPU libraries for the link + # target_link_libraries(foo ${STARPU_LIBRARIES}) old school cmake with variables and not target + #+END_EXAMPLE + + It allows to find efficiently the libraries we depend on. The modules + are generally written by the library developers or very active users + so that they know very well how the library is built how it is + installed, etc. + + The ~find_package(FOO)~ command looks for the library(ies), the header + directory(ies) and compiler/linker flags. If found the following + CMake variables are set: + - FOO_FOUND: set if package is found + - FOO_PREFIX: root of the package installation (usually one + directory above lib/ one) + - FOO_VERSION: version of the package if found with pkg-config + - FOO_INCLUDE_DIRS: path to headers + - FOO_LIBRARY_DIRS: library directories + - FOO_LIBRARIES: list of libraries necessary to link with the + package (absolute paths given) + - FOO_CFLAGS_OTHER: required compiler flags + - FOO_LDLAGS_OTHER: required linker flags + - FOO_STATIC: to force using static libraries when exist or is set + to 1 if the only library found is static + + In addition the /find_package/ command define an imported target + *MORSE::FOO* to be used in modern CMake fashion. The target defines + the following CMake properties: + - INTERFACE_INCLUDE_DIRECTORIES + - INTERFACE_LINK_DIRECTORIES + - INTERFACE_LINK_LIBRARIES + - INTERFACE_COMPILE_OPTIONS + - INTERFACE_LINK_OPTIONS * How CMake is aware of these specific modules? -To use MORSE modules you should call the *MorseInit* module as follows: -#+BEGIN_EXAMPLE -# For example if Morse CMake modules are located in ./cmake_modules/morse_cmake -# append this directory to the list of directories containing CMake modules -list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules/morse_cmake/modules" ) -# Include the init module -include(MorseInit) -#+END_EXAMPLE - + To use MORSE modules you should call the *MorseInit* module as follows: + #+BEGIN_EXAMPLE + # For example if Morse CMake modules are located in ./cmake_modules/morse_cmake + # append this directory to the list of directories containing CMake modules + list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules/morse_cmake/modules" ) + # Include the init module + include(MorseInit) + #+END_EXAMPLE * Internal mechanism: what a "find" mainly do, what are the paths scanned? -The general process consists in looking into some system paths known -from CMake to find headers and libraries and define in output some -CMake variables the user need to link with his dependency. Additionaly -to the system paths, some environment variable can also be scanned -like ~LIBRARY_PATH~ ~LD_LIBRARY_PATH~ and ~CPATH~. A custom CMake cache -variable ~LIBNAME_DIR~ is also introduced in our modules in order to let -users indicate directly during the "configure" step a specific -installation directory for the library (e.g. where are located the -include/, lib/, etc, sub-directories). The priority order is the -following: -1) The CMake variable ~LIBNAME_DIR~ is set or both ~LIBNAME_INCDIR~ and - ~LIBNAME_LIBDIR~ are set -2) The environment variable ~LIBNAME_DIR~ is set or both ~LIBNAME_INCDIR~ and - ~LIBNAME_LIBDIR~ -3) A pkg-config .pc file (hwloc.pc) of the library is available in the - environment (cf. PKG_CONFIG_PATH environment variable) and is used -4) Look into the following paths - a) for headers: - - scan the paths present in the following environment variables - ~INCLUDE~, ~C_INCLUDE_PATH~, ~CPATH~, ~INCLUDE_PATH~ - - scan the system paths for headers: look into path present in - the CMake variable ~CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES~ - b) for libraries: - - scan the paths present in the following environment variables - ~LIBRARY_PATH~, ~LIB~ (Windows), ~DYLD_LIBRARY_PATH~ (Mac OS X), - ~LD_LIBRARY_PATH~ (Linux) - - scan the system paths for headers: look into path present in - the CMake variable ~CMAKE_C_IMPLICIT_LINK_DIRECTORIES~ - -When it is possible, compiler flags are also given to users. This last -point suggest that the information can be found in the library -installation, e.g. through a pkg-config file. - -In some cases, the library can be searched for a specific -configuration, e.g "I want to find an installation of this library -coming with all these components enabled" such as: MUMPS linear solver -must be able to use SCOTCH graph partitioner. See the "COMPONENTS" -option of the ~find_package~ command and look for the header of the -module file to get more information about possible components. - -Once some header files and libraries have been found the module tries -to call a basic function of the library to test the link step. During -this process, the CMake ~check_function_exists~ is used. If the test -fails a message is given with the compiler and linker flags used -during the test. The precise error can also be found in the -~CMakeFiles/CMakeError.log~ file of the build directory. + We try to enforce using pkg-config file if provided (update your + PKG_CONFIG_PATH environment variable). + + List of packages relying only on pkg-config file: EZTRACE, FXT, GTG, + HWLOC, PAPI, SIMGRID, PARSEC, STARPU. + + For packages which do not provide any pkg-config file the general + process consists in looking into some system paths known from CMake to + find headers and libraries and define in output some CMake variables + the user need to link with his dependency. Additionaly to the system + paths, some environment variable can also be scanned like ~LIBRARY_PATH~ + ~LD_LIBRARY_PATH~ and ~CPATH~. A custom CMake cache variable ~LIBNAME_DIR~ + is also introduced in our modules in order to let users indicate + directly during the "configure" step a specific installation directory + for the library (e.g. where are located the include/, lib/, etc, + sub-directories). The priority order is the following: + 1) The CMake variable ~LIBNAME_DIR~ is set or both ~LIBNAME_INCDIR~ and + ~LIBNAME_LIBDIR~ are set + 2) The environment variable ~LIBNAME_DIR~ is set or both ~LIBNAME_INCDIR~ and + ~LIBNAME_LIBDIR~ + 3) A pkg-config .pc file (hwloc.pc) of the library is available in the + environment (cf. PKG_CONFIG_PATH environment variable) and is used + 4) Look into the following paths + a) for headers: + - scan the paths present in the following environment variables + ~INCLUDE~, ~C_INCLUDE_PATH~, ~CPATH~, ~INCLUDE_PATH~ + - scan the system paths for headers: look into path present in + the CMake variable ~CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES~ + b) for libraries: + - scan the paths present in the following environment variables + ~LIBRARY_PATH~, ~LIB~ (Windows), ~DYLD_LIBRARY_PATH~ (Mac OS X), + ~LD_LIBRARY_PATH~ (Linux) + - scan the system paths for headers: look into path present in + the CMake variable ~CMAKE_C_IMPLICIT_LINK_DIRECTORIES~ + + When it is possible, compiler flags are also given to users. This last + point suggest that the information can be found in the library + installation, e.g. through a pkg-config file. + + In some cases, the library can be searched for a specific + configuration, e.g "I want to find an installation of this library + coming with all these components enabled" such as: MUMPS linear solver + must be able to use SCOTCH graph partitioner. See the "COMPONENTS" + option of the ~find_package~ command and look for the header of the + module file to get more information about possible components. + + Once some header files and libraries have been found the module tries + to call a basic function of the library to test the link step. During + this process, the CMake ~check_function_exists~ is used. If the test + fails a message is given with the compiler and linker flags used + during the test. The precise error can also be found in the + ~CMakeFiles/CMakeError.log~ file of the build directory. ** How to act on the searching process? -If the user does not change the environment (do not modify environment -variables like ~LIBRARY_PATH~, ~LD_LIBRARY_PATH~), and gives no hint at all about the -location of the libraries, the module will match the situation 4.2 and -will look into system paths. - -To give an "exotic" locations, i.e. not in system paths, the user can -use scripts or a ~module~ like system to set the paths in environment -variables (~LD_LIBRARY_PATH~, ~INCLUDE~, ...), cf. situation 4.1 and 2. - -For some libraries it is possible to rely on ~pkg-config~ if the .pc -file path is in the ~PKG_CONFIG_PATH~ environment variable, -cf. situation 3. - -Finally, to directly give "by hand" the path, the user can set a CMake -variable ~LIBNAME_DIR~, or the pair ~LIBNAME_INCDIR~ and ~LIBNAME_LIBDIR~, -cf. situation 1. - + If the user does not change the environment (do not modify + environment variables like ~LIBRARY_PATH~, ~LD_LIBRARY_PATH~), and + gives no hint at all about the location of the libraries, the + module will match the situation 4.2 and will look into system + paths. + + To give an "exotic" locations, i.e. not in system paths, the user + can use scripts or a ~module~ like system to set the paths in + environment variables (~LD_LIBRARY_PATH~, ~INCLUDE~, ...), + cf. situation 4.1 and 2. + + For some libraries it is possible to rely on ~pkg-config~ if the .pc + file path is in the ~PKG_CONFIG_PATH~ environment variable, + cf. situation 3. + + Finally, to directly give "by hand" the path, the user can set a + CMake variable ~LIBNAME_DIR~, or the pair ~LIBNAME_INCDIR~ and + ~LIBNAME_LIBDIR~, cf. situation 1. ** A version of the library is found but I want another one, how to change? -If a first configuration has found a library somewhere but you are not -satisfied with this one and want to give some hints to look for it: -- update your environment or give the location "by hand" (~LIBNAME_DIR~) -- delete the CMake cache file to make it "forget" the libraries - already found: ~rm CMakeCache.txt~ -- configure again: ~cmake path/to/your/CMakeLists.txt ...~ - + If a first configuration has found a library somewhere but you are not + satisfied with this one and want to give some hints to look for it: + - update your environment or give the location "by hand" (~LIBNAME_DIR~) + - delete the CMake cache file to make it "forget" the libraries + already found: ~rm CMakeCache.txt~ + - configure again: ~cmake path/to/your/CMakeLists.txt ...~ * How to get more information about a specific module usage? -Specific information about a precise Find module are given directly at -the head of the module file. The usage, the optional parameters that -can be used and the output variables are explained here. + Specific information about a precise Find module are given directly + at the head of the module file. The usage, the optional parameters + that can be used and the output variables are explained here. +* Choose a specific BLAS/LAPACK + See ~cmake --help-module FindBLAS~ or ~cmake --help-module FindLAPACK~ + to get all available BLA_VENDOR. * Hint for Intel MKL -To look for the Intel MKL BLAS, LAPACK (or CBLAS, LAPACKE), one can -enforce Intel MKL search with the CMake variable *BLA_VENDOR* as it is -documented in BLAS and LAPACK officiel modules ~cmake --help-module FindLAPACK~ -#+BEGIN_EXAMPLE -# for sequential blas/lapack -cmake .. -DBLA_VENDOR=Intel10_64lp_seq -# for multithreaded blas/lapack -cmake .. -DBLA_VENDOR=Intel10_64lp -# play with MKL_NUM_THREADS env. var. to set number of threads used internally -#+END_EXAMPLE -or set BLA_VENDOR directly in your CMake files. + To look for the Intel MKL BLAS, LAPACK (or CBLAS, LAPACKE), one can + enforce Intel MKL search with the CMake variable *BLA_VENDOR* as it is + documented in BLAS and LAPACK officiel modules ~cmake --help-module + FindLAPACK~ + #+BEGIN_EXAMPLE + # for sequential blas/lapack + cmake .. -DBLA_VENDOR=Intel10_64lp_seq + # for multithreaded blas/lapack + cmake .. -DBLA_VENDOR=Intel10_64lp + # play with MKL_NUM_THREADS env. var. to set number of threads used internally + #+END_EXAMPLE + or set BLA_VENDOR directly in your CMake files. +* To prefer static libraries if both static and dynamic are available + Set "PACKAGE"_STATIC=1 at cmake configure. For BLAS/LAPACK/SCALAPACK + use *BLA_STATIC=1*. diff --git a/modules/find/tests/CMakeLists.txt b/modules/find/tests/CMakeLists.txt index 9d6b2f2bb91a55656154e3a2c938f9b212fa5776..73cc28367daacb5692c553dc5b17a1643f1b93d7 100644 --- a/modules/find/tests/CMakeLists.txt +++ b/modules/find/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.1) project(TEST_MORSE_CMAKE_MODULES_FIND Fortran C CXX) # location of Morse modules to get some specific macros @@ -12,25 +12,35 @@ set(PACKAGES "" CACHE STRING "List of packages to find, ex: BLAS;STARPU;PASTIX") # specific components to look for with packages set(LAPACKE_COMPONENTS "" CACHE STRING "List of specific dependencies to look for with LAPACKE, ex: TMG") set(QUARK_COMPONENTS "" CACHE STRING "List of specific dependencies to look for with QUARK, ex: HWLOC") -set(PASTIX_COMPONENTS "" CACHE STRING "List of specific dependencies to look for with PASTIX, ex: SPM;MPI;SEQ;STARPU;STARPU_CUDA;STARPU_FXT;SCOTCH;PTSCOTCH;METIS") set(PETSC_COMPONENTS "" CACHE STRING "List of specific dependencies to look for with PETSc, ex: CXX|C") set(FFTW_COMPONENTS "" CACHE STRING "List of specific dependencies to look for with FFTW, ex: MKL;ESSL;THREADS;OMP;SIMPLE;LONG;QUAD") set(MUMPS_COMPONENTS "" CACHE STRING "List of specific dependencies to look for with MUMPS, ex: MPI;SEQ;SCOTCH;PTSCOTCH;METIS;PARMETIS;OPENMP") -set(CHAMELEON_COMPONENTS "" CACHE STRING "List of specific dependencies to look for with CHAMELEON, ex: STARPU;QUARK;CUDA;MPI;FXT") -set(STARPU_COMPONENTS "" CACHE STRING "List of specific dependencies to look for with STARPU, ex: HWLOC;CUDA;MPI;BLAS;MAGMA;FXT;SIMGRID") -set(PARSEC_COMPONENTS "" CACHE STRING "List of specific dependencies to look for with PARSEC, ex: HWLOC;CUDA;MPI;AYUDAME") # to enable ctests option(ENABLE_CTEST "Enable Testing: will test all supported packages" OFF) foreach(_library ${PACKAGES}) + # in case _library is unset inside find_package + set (_library_cpy ${_library}) + if (${_library}_COMPONENTS) find_package(${_library} COMPONENTS ${${_library}_COMPONENTS}) else() find_package(${_library}) endif() + set (_library ${_library_cpy}) + if (${_library}_FOUND) + if (${_library}_PREFIX) + message(STATUS "${_library}_PREFIX ${${_library}_PREFIX}") + endif() + if (${_library}_VERSION) + message(STATUS "${_library}_VERSION ${${_library}_VERSION}") + endif() + if (${_library}_STATIC) + message(STATUS "${_library}_STATIC ${${_library}_STATIC}") + endif() if (${_library}_LIBRARIES) message(STATUS "${_library}_LIBRARIES found: ${${_library}_LIBRARIES}") else() @@ -39,31 +49,47 @@ foreach(_library ${PACKAGES}) if (${_library}_STATIC_LIBRARIES) message(STATUS "${_library}_STATIC_LIBRARIES found: ${${_library}_STATIC_LIBRARIES}") endif() - if (${_library}_LIBRARIES_DEP) - message(STATUS "${_library}_LIBRARIES_DEP found: ${${_library}_LIBRARIES_DEP}") - endif() if (${_library}_LIBRARY_DIRS) message(STATUS "${_library}_LIBRARY_DIRS found: ${${_library}_LIBRARY_DIRS}") else() message(WARNING "${_library}_LIBRARY_DIRS not found: ${${_library}_LIBRARY_DIRS}") endif() - if (${_library}_LIBRARY_DIRS_DEP) - message(STATUS "${_library}_LIBRARY_DIRS_DEP found: ${${_library}_LIBRARY_DIRS_DEP}") - endif() if (${_library}_INCLUDE_DIRS) message(STATUS "${_library}_INCLUDE_DIRS found: ${${_library}_INCLUDE_DIRS}") else() message(WARNING "${_library}_INCLUDE_DIRS not found: ${${_library}_INCLUDE_DIRS}") endif() - if (${_library}_INCLUDE_DIRS_DEP) - message(STATUS "${_library}_INCLUDE_DIRS_DEP found: ${${_library}_INCLUDE_DIRS_DEP}") - endif() if (${_library}_CFLAGS_OTHER) message(STATUS "${_library}_CFLAGS_OTHER found: ${${_library}_CFLAGS_OTHER}") endif() if (${_library}_LDFLAGS_OTHER) message(STATUS "${_library}_LDFLAGS_OTHER found: ${${_library}_LDFLAGS_OTHER}") endif() + if (TARGET MORSE::${_library}) + get_target_property(_INCLUDES MORSE::${_library} INTERFACE_INCLUDE_DIRECTORIES) + get_target_property(_DIRECTORIES MORSE::${_library} INTERFACE_LINK_DIRECTORIES) + get_target_property(_LIBRARIES MORSE::${_library} INTERFACE_LINK_LIBRARIES) + get_target_property(_CFLAGS MORSE::${_library} INTERFACE_COMPILE_OPTIONS) + get_target_property(_LDFLAGS MORSE::${_library} INTERFACE_LINK_OPTIONS) + message(STATUS "IMPORTED TARGET MORSE::${_library} INTERFACE_INCLUDE_DIRECTORIES ${_INCLUDES}") + message(STATUS "IMPORTED TARGET MORSE::${_library} INTERFACE_LINK_DIRECTORIES ${_DIRECTORIES}") + message(STATUS "IMPORTED TARGET MORSE::${_library} INTERFACE_LINK_LIBRARIES ${_LIBRARIES}") + message(STATUS "IMPORTED TARGET MORSE::${_library} INTERFACE_COMPILE_OPTIONS ${_CFLAGS}") + message(STATUS "IMPORTED TARGET MORSE::${_library} INTERFACE_LINK_OPTIONS ${_LDFLAGS}") + endif() + # for BLAS and LAPACK or other external/official Find that we check + if (TARGET ${_library}::${_library}) + get_target_property(_INCLUDES ${_library}::${_library} INTERFACE_INCLUDE_DIRECTORIES) + get_target_property(_DIRECTORIES ${_library}::${_library} INTERFACE_LINK_DIRECTORIES) + get_target_property(_LIBRARIES ${_library}::${_library} INTERFACE_LINK_LIBRARIES) + get_target_property(_CFLAGS ${_library}::${_library} INTERFACE_COMPILE_OPTIONS) + get_target_property(_LDFLAGS ${_library}::${_library} INTERFACE_LINK_OPTIONS) + message(STATUS "IMPORTED TARGET ${_library}::${_library} INTERFACE_INCLUDE_DIRECTORIES ${_INCLUDES}") + message(STATUS "IMPORTED TARGET ${_library}::${_library} INTERFACE_LINK_DIRECTORIES ${_DIRECTORIES}") + message(STATUS "IMPORTED TARGET ${_library}::${_library} INTERFACE_LINK_LIBRARIES ${_LIBRARIES}") + message(STATUS "IMPORTED TARGET ${_library}::${_library} INTERFACE_COMPILE_OPTIONS ${_CFLAGS}") + message(STATUS "IMPORTED TARGET ${_library}::${_library} INTERFACE_LINK_OPTIONS ${_LDFLAGS}") + endif() else() message(FATAL_ERROR "${_library} NOT FOUND !!") endif() @@ -79,21 +105,19 @@ if (ENABLE_CTEST) set(CTEST_PACKAGES_LIST # AL4SAN # not installed in the common image hpclib/hiepacs, see hpclib/al4san to get it BLAS - BLASEXT CBLAS - CHAMELEON + # CHAMELEON must give its Config.cmake CPPCHECK # EZTRACE # not installed yet, we should do it - FABULOUS + # FABULOUS must give its Config.cmake FFTW FXT GTG - HQR + # HQR must give its Config.cmake HWLOC HYPRE LAPACK LAPACKE - LAPACKEXT METIS MPIEXT MUMPS @@ -101,15 +125,16 @@ if (ENABLE_CTEST) PAPI PARMETIS PARSEC - PASTIX + # PASTIX must give its Config.cmake PETSC PTSCOTCH QUARK SCALAPACK SCOTCH SIMGRID - SPM + # SPM must give its Config.cmake SLEPC + # SCALFMM must give its Config.cmake STARPU SUITESPARSE TMG) diff --git a/modules/find/tests/run_ctest.sh b/modules/find/tests/run_ctest.sh index f338f1bb40e1cccf03c64fe27ffd300e050f9688..06e884f847a715747b4522365e187f11f9db9948 100755 --- a/modules/find/tests/run_ctest.sh +++ b/modules/find/tests/run_ctest.sh @@ -6,6 +6,6 @@ mkdir -p build cd build -cmake $CI_PROJECT_DIR/modules/find/tests -DENABLE_CTEST=ON -DLAPACKE_COMPONENTS="TMG" -DQUARK_COMPONENTS="HWLOC" -DCHAMELEON_COMPONENTS="MPI;FXT;STARPU" -DPASTIX_COMPONENTS="SPM" +cmake $CI_PROJECT_DIR/modules/find/tests -DENABLE_CTEST=ON -DLAPACKE_COMPONENTS="TMG" -DQUARK_COMPONENTS="HWLOC" -DCMAKE_PREFIX_PATH="$PARSEC_DIR" ctest -D Experimental