Commit 6ee95304 authored by PRUVOST Florent's avatar PRUVOST Florent

transform relative path from pkg-config into absolute path and check function...

transform relative path from pkg-config into absolute path and check function exist also when found with pkg-config
parent 289efa0a
......@@ -34,10 +34,19 @@ macro(FIND_PKGCONFIG_LIBRARIES_ABSOLUTE_PATH _prefix)
endif()
list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}")
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)
......@@ -46,12 +55,22 @@ macro(FIND_PKGCONFIG_LIBRARIES_ABSOLUTE_PATH _prefix)
message(FATAL_ERROR "Dependency of ${_prefix} '${_library}' NOT FOUND")
endif()
unset(_library_path CACHE)
set (${_prefix}_LIBRARIES "${${_prefix}_LIBRARIES}" CACHE INTERNAL "" FORCE)
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()
find_library(_library_path NAMES ${_library}
HINTS ${${_prefix}_STATIC_LIBDIR} ${${_prefix}_STATIC_LIBRARY_DIRS} ${_lib_env})
if (_library_path)
......@@ -60,8 +79,9 @@ macro(FIND_PKGCONFIG_LIBRARIES_ABSOLUTE_PATH _prefix)
message(FATAL_ERROR "Dependency of ${_prefix} '${_library}' NOT FOUND")
endif()
unset(_library_path CACHE)
set (${_prefix}_STATIC_LIBRARIES "${${_prefix}_STATIC_LIBRARIES}" CACHE INTERNAL "" FORCE)
endif()
endforeach()
set (${_prefix}_STATIC_LIBRARIES "${${_prefix}_STATIC_LIBRARIES}" CACHE INTERNAL "" FORCE)
endmacro()
##
......
......@@ -20,7 +20,7 @@
# is found
# BLAS_LINKER_FLAGS - uncached list of required linker flags (excluding -l
# and -L).
# BLAS_COMPILER_FLAGS - uncached list of required compiler flags (including -I for mkl headers).
# BLAS_COMPILER_FLAGS - uncached list of required compiler flags (including -I).
# BLAS_LIBRARIES - uncached list of libraries (using full path name) to
# link against to use BLAS
# BLAS95_LIBRARIES - uncached list of libraries (using full path name)
......@@ -32,6 +32,21 @@
# 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
#
# 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
......@@ -342,7 +357,6 @@ find_package(PkgConfig QUIET)
if( PKG_CONFIG_EXECUTABLE AND NOT BLAS_GIVEN_BY_USER AND BLA_VENDOR STREQUAL "All")
pkg_search_module(BLAS blas)
find_pkgconfig_libraries_absolute_path(BLAS)
if (NOT BLAS_FIND_QUIETLY)
if (BLAS_FOUND AND BLAS_LIBRARIES)
......@@ -354,17 +368,17 @@ if( PKG_CONFIG_EXECUTABLE AND NOT BLAS_GIVEN_BY_USER AND BLA_VENDOR STREQUAL "Al
endif()
endif()
if (BLAS_FOUND AND BLAS_LIBRARIES)
set(BLAS_FOUND_WITH_PKGCONFIG "TRUE")
find_pkgconfig_libraries_absolute_path(BLAS)
if (BLA_STATIC)
set(BLAS_LINKER_FLAGS "${BLAS_STATIC_LDFLAGS}")
set(BLAS_COMPILER_FLAGS "${BLAS_STATIC_CFLAGS}")
set(BLAS_LINKER_FLAGS "${BLAS_STATIC_LDFLAGS_OTHER}")
set(BLAS_COMPILER_FLAGS "${BLAS_STATIC_CFLAGS_OTHER}")
set(BLAS_LIBRARIES "${BLAS_STATIC_LIBRARIES}")
else()
set(BLAS_LINKER_FLAGS "${BLAS_LDFLAGS}")
set(BLAS_COMPILER_FLAGS "${BLAS_CFLAGS}")
set(BLAS_LINKER_FLAGS "${BLAS_LDFLAGS_OTHER}")
set(BLAS_COMPILER_FLAGS "${BLAS_CFLAGS_OTHER}")
endif()
if (BLAS_FOUND AND BLAS_LIBRARIES)
set(BLAS_FOUND_WITH_PKGCONFIG "TRUE")
else()
set(BLAS_FOUND_WITH_PKGCONFIG "FALSE")
endif()
......
......@@ -3,7 +3,7 @@
# @copyright (c) 2009-2014 The University of Tennessee and The University
# of Tennessee Research Foundation.
# All rights reserved.
# @copyright (c) 2012-2016 Inria. All rights reserved.
# @copyright (c) 2012-2018 Inria. All rights reserved.
# @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved.
#
###
......@@ -21,7 +21,6 @@
# This module finds headers and cblas library.
# Results are reported in variables:
# CBLAS_FOUND - True if headers and requested libraries were found
# CBLAS_LINKER_FLAGS - list of required linker flags (excluding -l and -L)
# CBLAS_INCLUDE_DIRS - cblas include directories
# CBLAS_LIBRARY_DIRS - Link directories for cblas libraries
# CBLAS_LIBRARIES - cblas component libraries to be linked
......@@ -30,6 +29,20 @@
# CBLAS_LIBRARIES_DEP - cblas libraries + dependencies
# 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
# <PREFIX> = CBLAS
# <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 -DCBLAS_DIR=path/to/cblas):
# CBLAS_DIR - Where to find the base directory of cblas
......@@ -59,11 +72,11 @@
#
#=============================================================================
# Copyright 2012-2013 Inria
# Copyright 2012-2018 Inria
# Copyright 2012-2013 Emmanuel Agullo
# Copyright 2012-2013 Mathieu Faverge
# Copyright 2012 Cedric Castagnede
# Copyright 2013-2016 Florent Pruvost
# Copyright 2013-2018 Florent Pruvost
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file MORSE-Copyright.txt for details.
......@@ -130,19 +143,51 @@ if (BLAS_FOUND)
set(CBLAS_INCLUDE_DIRS "${BLAS_INCLUDE_DIRS}")
set(CBLAS_INCLUDE_DIRS_DEP "${BLAS_INCLUDE_DIRS_DEP}")
endif()
if (BLAS_LINKER_FLAGS)
set(CBLAS_LINKER_FLAGS "${BLAS_LINKER_FLAGS}")
endif()
endif()
endif (NOT CBLAS_STANDALONE)
# test fails with blas: try to find CBLAS lib exterior to BLAS
if (CBLAS_STANDALONE OR NOT CBLAS_WORKS)
if(NOT CBLAS_WORKS AND NOT CBLAS_FIND_QUIETLY)
message(STATUS "Looking for cblas : test with blas fails")
endif()
# test fails: try to find CBLAS lib exterior to BLAS
# try with pkg-config
set(ENV_CBLAS_DIR "$ENV{CBLAS_DIR}")
set(ENV_CBLAS_INCDIR "$ENV{CBLAS_INCDIR}")
set(ENV_CBLAS_LIBDIR "$ENV{CBLAS_LIBDIR}")
set(CBLAS_GIVEN_BY_USER "FALSE")
if ( CBLAS_DIR OR ( CBLAS_INCDIR AND CBLAS_LIBDIR) OR ENV_CBLAS_DIR OR (ENV_CBLAS_INCDIR AND ENV_CBLAS_LIBDIR) )
set(CBLAS_GIVEN_BY_USER "TRUE")
endif()
include(FindPkgConfig)
find_package(PkgConfig QUIET)
if( PKG_CONFIG_EXECUTABLE AND NOT CBLAS_GIVEN_BY_USER)
pkg_search_module(CBLAS cblas)
if (NOT CBLAS_FIND_QUIETLY)
if (CBLAS_FOUND AND CBLAS_LIBRARIES)
message(STATUS "Looking for CBLAS - found using PkgConfig")
else()
message(STATUS "${Magenta}Looking for CBLAS - not found using PkgConfig."
"\n Perhaps you should add the directory containing cblas.pc to"
"\n the PKG_CONFIG_PATH environment variable.${ColourReset}")
endif()
endif()
if (CBLAS_FOUND AND CBLAS_LIBRARIES)
set(CBLAS_FOUND_WITH_PKGCONFIG "TRUE")
find_pkgconfig_libraries_absolute_path(CBLAS)
else()
set(CBLAS_FOUND_WITH_PKGCONFIG "FALSE")
endif()
endif()
if (NOT CBLAS_FOUND_WITH_PKGCONFIG OR CBLAS_GIVEN_BY_USER)
# Try to find CBLAS lib
#######################
......@@ -283,6 +328,9 @@ if (BLAS_FOUND)
message(STATUS "Looking for cblas -- lib cblas not found")
endif()
endif ()
endif (NOT CBLAS_FOUND_WITH_PKGCONFIG OR CBLAS_GIVEN_BY_USER)
endif (CBLAS_STANDALONE OR NOT CBLAS_WORKS)
# check a function to validate the find
if(CBLAS_LIBRARIES)
......@@ -296,6 +344,12 @@ if (BLAS_FOUND)
if (CBLAS_INCLUDE_DIRS)
set(REQUIRED_INCDIRS "${CBLAS_INCLUDE_DIRS}")
endif()
if (CBLAS_CFLAGS_OTHER)
list(APPEND REQUIRED_FLAGS "${CBLAS_CFLAGS_OTHER}")
endif()
if (CBLAS_LDFLAGS_OTHER)
list(APPEND REQUIRED_LDFLAGS "${CBLAS_LDFLAGS_OTHER}")
endif()
if (CBLAS_LIBRARY_DIRS)
set(REQUIRED_LIBDIRS "${CBLAS_LIBRARY_DIRS}")
endif()
......@@ -304,16 +358,20 @@ if (BLAS_FOUND)
if (BLAS_INCLUDE_DIRS)
list(APPEND REQUIRED_INCDIRS "${BLAS_INCLUDE_DIRS}")
endif()
if (BLAS_LIBRARY_DIRS)
list(APPEND REQUIRED_LIBDIRS "${BLAS_LIBRARY_DIRS}")
if (BLAS_COMPILER_FLAGS)
list(APPEND REQUIRED_FLAGS "${BLAS_COMPILER_FLAGS}")
endif()
list(APPEND REQUIRED_LIBS "${BLAS_LIBRARIES}")
if (BLAS_LINKER_FLAGS)
list(APPEND REQUIRED_LDFLAGS "${BLAS_LINKER_FLAGS}")
endif()
if (BLAS_LIBRARY_DIRS)
list(APPEND REQUIRED_LIBDIRS "${BLAS_LIBRARY_DIRS}")
endif()
list(APPEND REQUIRED_LIBS "${BLAS_LIBRARIES}")
# set required libraries for link
set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
set(CMAKE_REQUIRED_LIBRARIES)
list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
foreach(lib_dir ${REQUIRED_LIBDIRS})
......@@ -341,10 +399,8 @@ if (BLAS_FOUND)
set(CBLAS_LIBRARIES_DEP "${REQUIRED_LIBS}")
set(CBLAS_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}")
set(CBLAS_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}")
set(CBLAS_LINKER_FLAGS "${REQUIRED_LDFLAGS}")
list(REMOVE_DUPLICATES CBLAS_LIBRARY_DIRS_DEP)
list(REMOVE_DUPLICATES CBLAS_INCLUDE_DIRS_DEP)
list(REMOVE_DUPLICATES CBLAS_LINKER_FLAGS)
else()
if(NOT CBLAS_FIND_QUIETLY)
message(STATUS "Looking for cblas : test of cblas_dscal with cblas and blas libraries fails")
......@@ -358,8 +414,6 @@ if (BLAS_FOUND)
set(CMAKE_REQUIRED_LIBRARIES)
endif(CBLAS_LIBRARIES)
endif (CBLAS_STANDALONE OR NOT CBLAS_WORKS)
else(BLAS_FOUND)
if (NOT CBLAS_FIND_QUIETLY)
......
......@@ -37,14 +37,27 @@
# This module finds headers and chameleon library.
# Results are reported in variables:
# CHAMELEON_FOUND - True if headers and requested libraries were found
# CHAMELEON_C_FLAGS - list of required compilation flags (excluding -I)
# CHAMELEON_LINKER_FLAGS - list of required linker flags (excluding -l and -L)
# CHAMELEON_INCLUDE_DIRS - chameleon include directories
# CHAMELEON_LIBRARY_DIRS - Link directories for chameleon libraries
# CHAMELEON_INCLUDE_DIRS_DEP - chameleon + dependencies include directories
# CHAMELEON_LIBRARY_DIRS_DEP - chameleon + dependencies link directories
# CHAMELEON_LIBRARIES_DEP - chameleon libraries + dependencies
#
# 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
......@@ -132,6 +145,7 @@ 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")
......@@ -163,13 +177,9 @@ if(PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_GIVEN_BY_USER)
endif()
endif()
set(CHAMELEON_C_FLAGS "${CHAMELEON_CFLAGS_OTHER}")
set(CHAMELEON_INCLUDE_DIRS_DEP "${CHAMELEON_STATIC_INCLUDE_DIRS}")
set(CHAMELEON_LIBRARY_DIRS_DEP "${CHAMELEON_STATIC_LIBRARY_DIRS}")
set(CHAMELEON_LIBRARIES_DEP "${CHAMELEON_STATIC_LIBRARIES}")
if (CHAMELEON_FOUND AND CHAMELEON_LIBRARIES)
set(CHAMELEON_FOUND_WITH_PKGCONFIG "TRUE")
find_pkgconfig_libraries_absolute_path(CHAMELEON)
else()
set(CHAMELEON_FOUND_WITH_PKGCONFIG "FALSE")
endif()
......@@ -534,8 +544,10 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUN
endforeach(chameleon_lib ${CHAMELEON_libs_to_find})
# check a function to validate the find
if(CHAMELEON_LIBRARIES)
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_LDFLAGS)
set(REQUIRED_INCDIRS)
......@@ -546,6 +558,12 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUN
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}")
......@@ -729,6 +747,7 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUN
# set required libraries for link
set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
set(CMAKE_REQUIRED_LIBRARIES)
list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
foreach(lib_dir ${REQUIRED_LIBDIRS})
......@@ -766,9 +785,7 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUN
set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_FLAGS)
set(CMAKE_REQUIRED_LIBRARIES)
endif(CHAMELEON_LIBRARIES)
endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR (CHAMELEON_GIVEN_BY_USER) )
endif(CHAMELEON_LIBRARIES)
if (CHAMELEON_LIBRARIES)
if (CHAMELEON_LIBRARY_DIRS)
......@@ -795,11 +812,6 @@ mark_as_advanced(CHAMELEON_DIR_FOUND)
# check that CHAMELEON has been found
# ---------------------------------
include(FindPackageHandleStandardArgs)
if (PKG_CONFIG_EXECUTABLE AND CHAMELEON_FOUND)
find_package_handle_standard_args(CHAMELEON DEFAULT_MSG
CHAMELEON_LIBRARIES)
else()
find_package_handle_standard_args(CHAMELEON DEFAULT_MSG
find_package_handle_standard_args(CHAMELEON DEFAULT_MSG
CHAMELEON_LIBRARIES
CHAMELEON_WORKS)
endif()
......@@ -20,11 +20,23 @@
# This module finds headers and eztrace library.
# Results are reported in variables:
# EZTRACE_FOUND - True if headers and requested libraries were found
# EZTRACE_C_FLAGS - list of required compilation flags (excluding -I)
# EZTRACE_INCLUDE_DIRS - eztrace include directories
# EZTRACE_LIBRARY_DIRS - Link directories for eztrace libraries
# EZTRACE_LIBRARIES - eztrace component libraries to be linked
#
# EZTRACE_FOUND_WITH_PKGCONFIG - True if found with pkg-config
# if found with pkg-config the following variables are set
# <PREFIX> = EZTRACE
# <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 -DEZTRACE_DIR=path/to/eztrace):
......@@ -73,14 +85,10 @@ find_package(PkgConfig QUIET)
if( PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_GIVEN_BY_USER )
pkg_search_module(EZTRACE eztrace)
if (NOT EZTRACE_FIND_QUIETLY)
if (EZTRACE_FOUND AND EZTRACE_LIBRARIES)
message(STATUS "Looking for EZTRACE - found using PkgConfig")
#if(NOT EZTRACE_INCLUDE_DIRS)
# message("${Magenta}EZTRACE_INCLUDE_DIRS is empty using PkgConfig."
# "Perhaps the path to eztrace headers is already present in your"
# "C(PLUS)_INCLUDE_PATH environment variable.${ColourReset}")
#endif()
else()
message(STATUS "${Magenta}Looking for EZTRACE - not found using PkgConfig."
"\n Perhaps you should add the directory containing eztrace.pc to"
......@@ -88,13 +96,12 @@ if( PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_GIVEN_BY_USER )
endif()
if (EZTRACE_FOUND AND EZTRACE_LIBRARIES)
set(EZTRACE_FOUND_WITH_PKGCONFIG "TRUE")
find_pkgconfig_libraries_absolute_path(EZTRACE)
else()
set(EZTRACE_FOUND_WITH_PKGCONFIG "FALSE")
endif()
endif()
set(EZTRACE_C_FLAGS "${EZTRACE_CFLAGS_OTHER}")
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) )
......@@ -288,8 +295,10 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_FOUND)
list(REMOVE_DUPLICATES EZTRACE_LIBRARY_DIRS)
endif ()
# check a function to validate the find
if(EZTRACE_LIBRARIES)
endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_FOUND) OR (EZTRACE_GIVEN_BY_USER) )
# check a function to validate the find
if(EZTRACE_LIBRARIES)
set(REQUIRED_INCDIRS)
set(REQUIRED_LIBDIRS)
......@@ -299,6 +308,12 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_FOUND)
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}")
endif()
......@@ -306,7 +321,9 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_FOUND)
# set required libraries for link
set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
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()
......@@ -330,9 +347,7 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_FOUND)
set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_FLAGS)
set(CMAKE_REQUIRED_LIBRARIES)
endif(EZTRACE_LIBRARIES)
endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_FOUND) OR (EZTRACE_GIVEN_BY_USER) )
endif(EZTRACE_LIBRARIES)
if (EZTRACE_LIBRARIES)
if (EZTRACE_LIBRARY_DIRS)
......@@ -355,11 +370,6 @@ mark_as_advanced(EZTRACE_DIR_FOUND)
# check that EZTRACE has been found
# -------------------------------
include(FindPackageHandleStandardArgs)
if (PKG_CONFIG_EXECUTABLE AND EZTRACE_FOUND)
find_package_handle_standard_args(EZTRACE DEFAULT_MSG
EZTRACE_LIBRARIES)
else()
find_package_handle_standard_args(EZTRACE DEFAULT_MSG
find_package_handle_standard_args(EZTRACE DEFAULT_MSG
EZTRACE_LIBRARIES
EZTRACE_WORKS)
endif()
......@@ -28,7 +28,6 @@
# This module finds headers and fftw library.
# Results are reported in variables:
# FFTW_FOUND - True if headers and requested libraries were found
# FFTW_C_FLAGS - list of required compilation flags (excluding -I)
# FFTW_LINKER_FLAGS - list of required linker flags (excluding -l and -L)
# FFTW_INCLUDE_DIRS - fftw include directories
# FFTW_LIBRARY_DIRS - Link directories for fftw libraries
......@@ -36,7 +35,20 @@
# FFTW_INCLUDE_DIRS_DEP - fftw + dependencies include directories
# FFTW_LIBRARY_DIRS_DEP - fftw + dependencies link directories
# FFTW_LIBRARIES_DEP - fftw libraries + dependencies
#
# FFTW_FOUND_WITH_PKGCONFIG - True if found with pkg-config
# if found with pkg-config the following variables are set
# <PREFIX> = FFTW3F or FFTW3 or FFTW3L or FFTW3Q
# <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 -DFFTW_DIR=path/to/fftw):
......@@ -231,11 +243,11 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL)
pkg_search_module(FFTW3F fftw3f)
pkg_search_module(FFTW3 fftw3)
if (FFTW3F_FOUND)
set(FFTW_C_FLAGS "${FFTW3F_CFLAGS_OTHER}")
if (NOT FFTW_FIND_QUIETLY)
message(STATUS "Looking for FFTW3F - found using PkgConfig")
endif()
if (FFTW3F_LIBRARIES)
find_pkgconfig_libraries_absolute_path(FFTW3F)
list(APPEND FFTW_LIBRARIES "${FFTW3F_LIBRARIES}")
endif()
if(FFTW3F_INCLUDE_DIRS)
......@@ -261,11 +273,11 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL)
pkg_search_module(FFTW3L fftw3l)
pkg_search_module(FFTW3 fftw3)
if (FFTW3L_FOUND)
set(FFTW_C_FLAGS "${FFTW3L_CFLAGS_OTHER}")
if (NOT FFTW_FIND_QUIETLY)
message(STATUS "Looking for FFTW3L - found using PkgConfig")
endif()
if (FFTW3L_LIBRARIES)
find_pkgconfig_libraries_absolute_path(FFTW3L)
list(APPEND FFTW_LIBRARIES "${FFTW3L_LIBRARIES}")
endif()
if(FFTW3L_INCLUDE_DIRS)
......@@ -291,11 +303,11 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL)
pkg_search_module(FFTW3Q fftw3q)
pkg_search_module(FFTW3 fftw3)
if (FFTW3Q_FOUND)
set(FFTW_C_FLAGS "${FFTW3Q_CFLAGS_OTHER}")
if (NOT FFTW_FIND_QUIETLY)
message(STATUS "Looking for FFTW3Q - found using PkgConfig")
endif()
if (FFTW3Q_LIBRARIES)
find_pkgconfig_libraries_absolute_path(FFTW3Q)
list(APPEND FFTW_LIBRARIES "${FFTW3Q_LIBRARIES}")
endif()
if(FFTW3Q_INCLUDE_DIRS)
......@@ -319,13 +331,16 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL)
endif(FFTW3Q_FOUND)
else()
pkg_search_module(FFTW3 fftw3)
if (FFTW3_FOUND AND FFTW3_LIBRARIES)
find_pkgconfig_libraries_absolute_path(FFTW3)
endif()
endif()
if (FFTW3_FOUND)
set(FFTW_C_FLAGS "${FFTW3_CFLAGS_OTHER}")
if (NOT FFTW_FIND_QUIETLY)
message(STATUS "Looking for FFTW3 - found using PkgConfig")
endif()
if (FFTW3_LIBRARIES)
find_pkgconfig_libraries_absolute_path(FFTW3)
list(APPEND FFTW_LIBRARIES "${FFTW3_LIBRARIES}")
endif()
if(FFTW3_INCLUDE_DIRS)
......@@ -348,14 +363,6 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL)
endif()
endif(FFTW3_FOUND)
set(FFTW_INCLUDE_DIRS_DEP "${FFTW_STATIC_INCLUDE_DIRS}")
set(FFTW_LIBRARY_DIRS_DEP "${FFTW_STATIC_LIBRARY_DIRS}")
set(FFTW_LIBRARIES_DEP "${FFTW_STATIC_LIBRARIES}" )
if (FFTW_LIBRARIES)
set(FFTW_WORKS TRUE)
endif()
if (FFTW_FOUND AND FFTW_LIBRARIES)
set(FFTW_FOUND_WITH_PKGCONFIG "TRUE")
else()
......@@ -688,8 +695,15 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR
endif()
endforeach()
# check a function to validate the find
if(FFTW_LIBRARIES)
endif( (NOT PKG_CONFIG_EXECUTABLE) OR
(PKG_CONFIG_EXECUTABLE AND NOT FFTW_FOUND) OR
FFTW_GIVEN_BY_USER OR
FFTW_LOOK_FOR_MKL OR
FFTW_LOOK_FOR_ESSL
)
# check a function to validate the find
if(FFTW_LIBRARIES)
set(REQUIRED_FLAGS)
set(REQUIRED_LDFLAGS)
......@@ -701,6 +715,12 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR
if (FFTW_INCLUDE_DIRS)
set(REQUIRED_INCDIRS "${FFTW_INCLUDE_DIRS}")
endif()