Mentions légales du service

Skip to content
Snippets Groups Projects
Commit d7ab2907 authored by PRUVOST Florent's avatar PRUVOST Florent
Browse files

Update Finds modules to provide "imported targets" __MORSE::FOO__ when a...

Update Finds modules to provide "imported targets" __MORSE::FOO__ when a package FOO is found see the documentation in file morse_cmakefind_doc.org.

Remove Find related to libraries that rely on CMake and which must provide its own FOOConfig.cmake at installation.
Relying on the old FindFOO.cmake is a really bad practice, FindFOO.cmake are reserved for package that are not compliant with CMake.
parent 15906197
Branches
No related tags found
No related merge requests found
Showing
with 688 additions and 7352 deletions
###
#
# @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.
#
###
#
......
......@@ -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")
......
###
#
# @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}")
......
This diff is collapsed.
###
#
# @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()
###
#
# @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()
This diff is collapsed.
###
#
# @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
##
###
#
# @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
###
#
# @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)
###
#
# @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
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -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()
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment