Commit 82fc6489 authored by PRUVOST Florent's avatar PRUVOST Florent
Browse files

Merge branch 'improve-pkg-config' into 'master'

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

See merge request !16
parents 289efa0a 6ee95304
...@@ -34,10 +34,19 @@ macro(FIND_PKGCONFIG_LIBRARIES_ABSOLUTE_PATH _prefix) ...@@ -34,10 +34,19 @@ macro(FIND_PKGCONFIG_LIBRARIES_ABSOLUTE_PATH _prefix)
endif() endif()
list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}")
list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}")
# non static case
set(${_prefix}_LIBRARIES_COPY "${${_prefix}_LIBRARIES}") set(${_prefix}_LIBRARIES_COPY "${${_prefix}_LIBRARIES}")
set(${_prefix}_LIBRARIES "") set(${_prefix}_LIBRARIES "")
foreach(_library ${${_prefix}_LIBRARIES_COPY}) 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) get_filename_component(_library "${_library}" NAME_WE)
endif()
find_library(_library_path NAMES ${_library} find_library(_library_path NAMES ${_library}
HINTS ${${_prefix}_LIBDIR} ${${_prefix}_LIBRARY_DIRS} ${_lib_env}) HINTS ${${_prefix}_LIBDIR} ${${_prefix}_LIBRARY_DIRS} ${_lib_env})
if (_library_path) if (_library_path)
...@@ -46,12 +55,22 @@ macro(FIND_PKGCONFIG_LIBRARIES_ABSOLUTE_PATH _prefix) ...@@ -46,12 +55,22 @@ macro(FIND_PKGCONFIG_LIBRARIES_ABSOLUTE_PATH _prefix)
message(FATAL_ERROR "Dependency of ${_prefix} '${_library}' NOT FOUND") message(FATAL_ERROR "Dependency of ${_prefix} '${_library}' NOT FOUND")
endif() endif()
unset(_library_path CACHE) unset(_library_path CACHE)
set (${_prefix}_LIBRARIES "${${_prefix}_LIBRARIES}" CACHE INTERNAL "" FORCE) endif()
endforeach() endforeach()
set (${_prefix}_LIBRARIES "${${_prefix}_LIBRARIES}" CACHE INTERNAL "" FORCE)
# static case
set(${_prefix}_STATIC_LIBRARIES_COPY "${${_prefix}_STATIC_LIBRARIES}") set(${_prefix}_STATIC_LIBRARIES_COPY "${${_prefix}_STATIC_LIBRARIES}")
set(${_prefix}_STATIC_LIBRARIES "") set(${_prefix}_STATIC_LIBRARIES "")
foreach(_library ${${_prefix}_STATIC_LIBRARIES_COPY}) 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) get_filename_component(_library "${_library}" NAME_WE)
endif()
find_library(_library_path NAMES ${_library} find_library(_library_path NAMES ${_library}
HINTS ${${_prefix}_STATIC_LIBDIR} ${${_prefix}_STATIC_LIBRARY_DIRS} ${_lib_env}) HINTS ${${_prefix}_STATIC_LIBDIR} ${${_prefix}_STATIC_LIBRARY_DIRS} ${_lib_env})
if (_library_path) if (_library_path)
...@@ -60,8 +79,9 @@ macro(FIND_PKGCONFIG_LIBRARIES_ABSOLUTE_PATH _prefix) ...@@ -60,8 +79,9 @@ macro(FIND_PKGCONFIG_LIBRARIES_ABSOLUTE_PATH _prefix)
message(FATAL_ERROR "Dependency of ${_prefix} '${_library}' NOT FOUND") message(FATAL_ERROR "Dependency of ${_prefix} '${_library}' NOT FOUND")
endif() endif()
unset(_library_path CACHE) unset(_library_path CACHE)
set (${_prefix}_STATIC_LIBRARIES "${${_prefix}_STATIC_LIBRARIES}" CACHE INTERNAL "" FORCE) endif()
endforeach() endforeach()
set (${_prefix}_STATIC_LIBRARIES "${${_prefix}_STATIC_LIBRARIES}" CACHE INTERNAL "" FORCE)
endmacro() endmacro()
## ##
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
# is found # is found
# BLAS_LINKER_FLAGS - uncached list of required linker flags (excluding -l # BLAS_LINKER_FLAGS - uncached list of required linker flags (excluding -l
# and -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 # BLAS_LIBRARIES - uncached list of libraries (using full path name) to
# link against to use BLAS # link against to use BLAS
# BLAS95_LIBRARIES - uncached list of libraries (using full path name) # BLAS95_LIBRARIES - uncached list of libraries (using full path name)
...@@ -32,6 +32,21 @@ ...@@ -32,6 +32,21 @@
# all the possibilities # all the possibilities
# BLAS_VENDOR_FOUND stores the BLAS vendor found # BLAS_VENDOR_FOUND stores the BLAS vendor found
# BLA_F95 if set on tries to find the f95 interfaces for BLAS/LAPACK # 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 # 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): # options at configure (ex: cmake path/to/project -DBLAS_DIR=path/to/blas):
# BLAS_DIR - Where to find the base directory of blas # BLAS_DIR - Where to find the base directory of blas
...@@ -342,7 +357,6 @@ find_package(PkgConfig QUIET) ...@@ -342,7 +357,6 @@ find_package(PkgConfig QUIET)
if( PKG_CONFIG_EXECUTABLE AND NOT BLAS_GIVEN_BY_USER AND BLA_VENDOR STREQUAL "All") if( PKG_CONFIG_EXECUTABLE AND NOT BLAS_GIVEN_BY_USER AND BLA_VENDOR STREQUAL "All")
pkg_search_module(BLAS blas) pkg_search_module(BLAS blas)
find_pkgconfig_libraries_absolute_path(BLAS)
if (NOT BLAS_FIND_QUIETLY) if (NOT BLAS_FIND_QUIETLY)
if (BLAS_FOUND AND BLAS_LIBRARIES) 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 ...@@ -354,17 +368,17 @@ if( PKG_CONFIG_EXECUTABLE AND NOT BLAS_GIVEN_BY_USER AND BLA_VENDOR STREQUAL "Al
endif() endif()
endif() endif()
if (BLAS_FOUND AND BLAS_LIBRARIES)
set(BLAS_FOUND_WITH_PKGCONFIG "TRUE")
find_pkgconfig_libraries_absolute_path(BLAS)
if (BLA_STATIC) if (BLA_STATIC)
set(BLAS_LINKER_FLAGS "${BLAS_STATIC_LDFLAGS}") set(BLAS_LINKER_FLAGS "${BLAS_STATIC_LDFLAGS_OTHER}")
set(BLAS_COMPILER_FLAGS "${BLAS_STATIC_CFLAGS}") set(BLAS_COMPILER_FLAGS "${BLAS_STATIC_CFLAGS_OTHER}")
set(BLAS_LIBRARIES "${BLAS_STATIC_LIBRARIES}") set(BLAS_LIBRARIES "${BLAS_STATIC_LIBRARIES}")
else() else()
set(BLAS_LINKER_FLAGS "${BLAS_LDFLAGS}") set(BLAS_LINKER_FLAGS "${BLAS_LDFLAGS_OTHER}")
set(BLAS_COMPILER_FLAGS "${BLAS_CFLAGS}") set(BLAS_COMPILER_FLAGS "${BLAS_CFLAGS_OTHER}")
endif() endif()
if (BLAS_FOUND AND BLAS_LIBRARIES)
set(BLAS_FOUND_WITH_PKGCONFIG "TRUE")
else() else()
set(BLAS_FOUND_WITH_PKGCONFIG "FALSE") set(BLAS_FOUND_WITH_PKGCONFIG "FALSE")
endif() endif()
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# @copyright (c) 2009-2014 The University of Tennessee and The University # @copyright (c) 2009-2014 The University of Tennessee and The University
# of Tennessee Research Foundation. # of Tennessee Research Foundation.
# All rights reserved. # 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. # @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved.
# #
### ###
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
# This module finds headers and cblas library. # This module finds headers and cblas library.
# Results are reported in variables: # Results are reported in variables:
# CBLAS_FOUND - True if headers and requested libraries were found # 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_INCLUDE_DIRS - cblas include directories
# CBLAS_LIBRARY_DIRS - Link directories for cblas libraries # CBLAS_LIBRARY_DIRS - Link directories for cblas libraries
# CBLAS_LIBRARIES - cblas component libraries to be linked # CBLAS_LIBRARIES - cblas component libraries to be linked
...@@ -30,6 +29,20 @@ ...@@ -30,6 +29,20 @@
# CBLAS_LIBRARIES_DEP - cblas libraries + dependencies # CBLAS_LIBRARIES_DEP - cblas libraries + dependencies
# CBLAS_HAS_ZGEMM3M - True if cblas contains zgemm3m fast complex mat-mat product # 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 # 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): # options at configure (ex: cmake path/to/project -DCBLAS_DIR=path/to/cblas):
# CBLAS_DIR - Where to find the base directory of cblas # CBLAS_DIR - Where to find the base directory of cblas
...@@ -59,11 +72,11 @@ ...@@ -59,11 +72,11 @@
# #
#============================================================================= #=============================================================================
# Copyright 2012-2013 Inria # Copyright 2012-2018 Inria
# Copyright 2012-2013 Emmanuel Agullo # Copyright 2012-2013 Emmanuel Agullo
# Copyright 2012-2013 Mathieu Faverge # Copyright 2012-2013 Mathieu Faverge
# Copyright 2012 Cedric Castagnede # Copyright 2012 Cedric Castagnede
# Copyright 2013-2016 Florent Pruvost # Copyright 2013-2018 Florent Pruvost
# #
# Distributed under the OSI-approved BSD License (the "License"); # Distributed under the OSI-approved BSD License (the "License");
# see accompanying file MORSE-Copyright.txt for details. # see accompanying file MORSE-Copyright.txt for details.
...@@ -130,19 +143,51 @@ if (BLAS_FOUND) ...@@ -130,19 +143,51 @@ if (BLAS_FOUND)
set(CBLAS_INCLUDE_DIRS "${BLAS_INCLUDE_DIRS}") set(CBLAS_INCLUDE_DIRS "${BLAS_INCLUDE_DIRS}")
set(CBLAS_INCLUDE_DIRS_DEP "${BLAS_INCLUDE_DIRS_DEP}") set(CBLAS_INCLUDE_DIRS_DEP "${BLAS_INCLUDE_DIRS_DEP}")
endif() endif()
if (BLAS_LINKER_FLAGS)
set(CBLAS_LINKER_FLAGS "${BLAS_LINKER_FLAGS}")
endif()
endif() endif()
endif (NOT CBLAS_STANDALONE) endif (NOT CBLAS_STANDALONE)
# test fails with blas: try to find CBLAS lib exterior to BLAS
if (CBLAS_STANDALONE OR NOT CBLAS_WORKS) if (CBLAS_STANDALONE OR NOT CBLAS_WORKS)
if(NOT CBLAS_WORKS AND NOT CBLAS_FIND_QUIETLY) 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")
endif() 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 # Try to find CBLAS lib
####################### #######################
...@@ -283,6 +328,9 @@ if (BLAS_FOUND) ...@@ -283,6 +328,9 @@ if (BLAS_FOUND)
message(STATUS "Looking for cblas -- lib cblas not found") message(STATUS "Looking for cblas -- lib cblas not found")
endif() endif()
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 # check a function to validate the find
if(CBLAS_LIBRARIES) if(CBLAS_LIBRARIES)
...@@ -296,6 +344,12 @@ if (BLAS_FOUND) ...@@ -296,6 +344,12 @@ if (BLAS_FOUND)
if (CBLAS_INCLUDE_DIRS) if (CBLAS_INCLUDE_DIRS)
set(REQUIRED_INCDIRS "${CBLAS_INCLUDE_DIRS}") set(REQUIRED_INCDIRS "${CBLAS_INCLUDE_DIRS}")
endif() 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) if (CBLAS_LIBRARY_DIRS)
set(REQUIRED_LIBDIRS "${CBLAS_LIBRARY_DIRS}") set(REQUIRED_LIBDIRS "${CBLAS_LIBRARY_DIRS}")
endif() endif()
...@@ -304,16 +358,20 @@ if (BLAS_FOUND) ...@@ -304,16 +358,20 @@ if (BLAS_FOUND)
if (BLAS_INCLUDE_DIRS) if (BLAS_INCLUDE_DIRS)
list(APPEND REQUIRED_INCDIRS "${BLAS_INCLUDE_DIRS}") list(APPEND REQUIRED_INCDIRS "${BLAS_INCLUDE_DIRS}")
endif() endif()
if (BLAS_LIBRARY_DIRS) if (BLAS_COMPILER_FLAGS)
list(APPEND REQUIRED_LIBDIRS "${BLAS_LIBRARY_DIRS}") list(APPEND REQUIRED_FLAGS "${BLAS_COMPILER_FLAGS}")
endif() endif()
list(APPEND REQUIRED_LIBS "${BLAS_LIBRARIES}")
if (BLAS_LINKER_FLAGS) if (BLAS_LINKER_FLAGS)
list(APPEND REQUIRED_LDFLAGS "${BLAS_LINKER_FLAGS}") list(APPEND REQUIRED_LDFLAGS "${BLAS_LINKER_FLAGS}")
endif() 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 required libraries for link
set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
set(CMAKE_REQUIRED_LIBRARIES) set(CMAKE_REQUIRED_LIBRARIES)
list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}") list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
foreach(lib_dir ${REQUIRED_LIBDIRS}) foreach(lib_dir ${REQUIRED_LIBDIRS})
...@@ -341,10 +399,8 @@ if (BLAS_FOUND) ...@@ -341,10 +399,8 @@ if (BLAS_FOUND)
set(CBLAS_LIBRARIES_DEP "${REQUIRED_LIBS}") set(CBLAS_LIBRARIES_DEP "${REQUIRED_LIBS}")
set(CBLAS_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}") set(CBLAS_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}")
set(CBLAS_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") set(CBLAS_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}")
set(CBLAS_LINKER_FLAGS "${REQUIRED_LDFLAGS}")
list(REMOVE_DUPLICATES CBLAS_LIBRARY_DIRS_DEP) list(REMOVE_DUPLICATES CBLAS_LIBRARY_DIRS_DEP)
list(REMOVE_DUPLICATES CBLAS_INCLUDE_DIRS_DEP) list(REMOVE_DUPLICATES CBLAS_INCLUDE_DIRS_DEP)
list(REMOVE_DUPLICATES CBLAS_LINKER_FLAGS)
else() else()
if(NOT CBLAS_FIND_QUIETLY) if(NOT CBLAS_FIND_QUIETLY)
message(STATUS "Looking for cblas : test of cblas_dscal with cblas and blas libraries fails") message(STATUS "Looking for cblas : test of cblas_dscal with cblas and blas libraries fails")
...@@ -358,8 +414,6 @@ if (BLAS_FOUND) ...@@ -358,8 +414,6 @@ if (BLAS_FOUND)
set(CMAKE_REQUIRED_LIBRARIES) set(CMAKE_REQUIRED_LIBRARIES)
endif(CBLAS_LIBRARIES) endif(CBLAS_LIBRARIES)
endif (CBLAS_STANDALONE OR NOT CBLAS_WORKS)
else(BLAS_FOUND) else(BLAS_FOUND)
if (NOT CBLAS_FIND_QUIETLY) if (NOT CBLAS_FIND_QUIETLY)
......
...@@ -37,14 +37,27 @@ ...@@ -37,14 +37,27 @@
# This module finds headers and chameleon library. # This module finds headers and chameleon library.
# Results are reported in variables: # Results are reported in variables:
# CHAMELEON_FOUND - True if headers and requested libraries were found # 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_LINKER_FLAGS - list of required linker flags (excluding -l and -L)
# CHAMELEON_INCLUDE_DIRS - chameleon include directories # CHAMELEON_INCLUDE_DIRS - chameleon include directories
# CHAMELEON_LIBRARY_DIRS - Link directories for chameleon libraries # CHAMELEON_LIBRARY_DIRS - Link directories for chameleon libraries
# CHAMELEON_INCLUDE_DIRS_DEP - chameleon + dependencies include directories # CHAMELEON_INCLUDE_DIRS_DEP - chameleon + dependencies include directories
# CHAMELEON_LIBRARY_DIRS_DEP - chameleon + dependencies link directories # CHAMELEON_LIBRARY_DIRS_DEP - chameleon + dependencies link directories
# CHAMELEON_LIBRARIES_DEP - chameleon libraries + dependencies # CHAMELEON_LIBRARIES_DEP - chameleon libraries + dependencies
#
# CHAMELEON_FOUND_WITH_PKGCONFIG - True if found with pkg-config # 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 # 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): # options at configure (ex: cmake path/to/project -DCHAMELEON_DIR=path/to/chameleon):
# CHAMELEON_DIR - Where to find the base directory of chameleon # CHAMELEON_DIR - Where to find the base directory of chameleon
...@@ -132,6 +145,7 @@ find_package(PkgConfig QUIET) ...@@ -132,6 +145,7 @@ find_package(PkgConfig QUIET)
if(PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_GIVEN_BY_USER) if(PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_GIVEN_BY_USER)
pkg_search_module(CHAMELEON chameleon) pkg_search_module(CHAMELEON chameleon)
if (NOT CHAMELEON_FIND_QUIETLY) if (NOT CHAMELEON_FIND_QUIETLY)
if (CHAMELEON_FOUND AND CHAMELEON_LIBRARIES) if (CHAMELEON_FOUND AND CHAMELEON_LIBRARIES)
message(STATUS "Looking for CHAMELEON - found using PkgConfig") message(STATUS "Looking for CHAMELEON - found using PkgConfig")
...@@ -163,13 +177,9 @@ if(PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_GIVEN_BY_USER) ...@@ -163,13 +177,9 @@ if(PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_GIVEN_BY_USER)
endif() endif()
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) if (CHAMELEON_FOUND AND CHAMELEON_LIBRARIES)
set(CHAMELEON_FOUND_WITH_PKGCONFIG "TRUE") set(CHAMELEON_FOUND_WITH_PKGCONFIG "TRUE")
find_pkgconfig_libraries_absolute_path(CHAMELEON)
else() else()
set(CHAMELEON_FOUND_WITH_PKGCONFIG "FALSE") set(CHAMELEON_FOUND_WITH_PKGCONFIG "FALSE")
endif() endif()
...@@ -534,8 +544,10 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUN ...@@ -534,8 +544,10 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUN
endforeach(chameleon_lib ${CHAMELEON_libs_to_find}) endforeach(chameleon_lib ${CHAMELEON_libs_to_find})
# check a function to validate the find endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR (CHAMELEON_GIVEN_BY_USER) )
if(CHAMELEON_LIBRARIES)
# check a function to validate the find
if(CHAMELEON_LIBRARIES)
set(REQUIRED_LDFLAGS) set(REQUIRED_LDFLAGS)
set(REQUIRED_INCDIRS) set(REQUIRED_INCDIRS)
...@@ -546,6 +558,12 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUN ...@@ -546,6 +558,12 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUN
if (CHAMELEON_INCLUDE_DIRS) if (CHAMELEON_INCLUDE_DIRS)
set(REQUIRED_INCDIRS "${CHAMELEON_INCLUDE_DIRS}") set(REQUIRED_INCDIRS "${CHAMELEON_INCLUDE_DIRS}")
endif() 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}) foreach(libdir ${CHAMELEON_LIBRARY_DIRS})
if (libdir) if (libdir)
list(APPEND REQUIRED_LIBDIRS "${libdir}") list(APPEND REQUIRED_LIBDIRS "${libdir}")
...@@ -729,6 +747,7 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUN ...@@ -729,6 +747,7 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUN
# set required libraries for link # set required libraries for link
set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
set(CMAKE_REQUIRED_LIBRARIES) set(CMAKE_REQUIRED_LIBRARIES)
list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}") list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
foreach(lib_dir ${REQUIRED_LIBDIRS}) foreach(lib_dir ${REQUIRED_LIBDIRS})
...@@ -766,9 +785,7 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUN ...@@ -766,9 +785,7 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUN
set(CMAKE_REQUIRED_INCLUDES) set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_FLAGS) set(CMAKE_REQUIRED_FLAGS)
set(CMAKE_REQUIRED_LIBRARIES) set(CMAKE_REQUIRED_LIBRARIES)
endif(CHAMELEON_LIBRARIES) endif(CHAMELEON_LIBRARIES)
endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR (CHAMELEON_GIVEN_BY_USER) )
if (CHAMELEON_LIBRARIES) if (CHAMELEON_LIBRARIES)
if (CHAMELEON_LIBRARY_DIRS) if (CHAMELEON_LIBRARY_DIRS)
...@@ -795,11 +812,6 @@ mark_as_advanced(CHAMELEON_DIR_FOUND) ...@@ -795,11 +812,6 @@ mark_as_advanced(CHAMELEON_DIR_FOUND)
# check that CHAMELEON has been found # check that CHAMELEON has been found
# --------------------------------- # ---------------------------------
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
if (PKG_CONFIG_EXECUTABLE AND CHAMELEON_FOUND) find_package_handle_standard_args(CHAMELEON DEFAULT_MSG
find_package_handle_standard_args(CHAMELEON DEFAULT_MSG
CHAMELEON_LIBRARIES)
else()
find_package_handle_standard_args(CHAMELEON DEFAULT_MSG
CHAMELEON_LIBRARIES CHAMELEON_LIBRARIES
CHAMELEON_WORKS) CHAMELEON_WORKS)
endif()
...@@ -20,11 +20,23 @@ ...@@ -20,11 +20,23 @@
# This module finds headers and eztrace library. # This module finds headers and eztrace library.
# Results are reported in variables: # Results are reported in variables:
# EZTRACE_FOUND - True if headers and requested libraries were found # 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_INCLUDE_DIRS - eztrace include directories
# EZTRACE_LIBRARY_DIRS - Link directories for eztrace libraries # EZTRACE_LIBRARY_DIRS - Link directories for eztrace libraries
# EZTRACE_LIBRARIES - eztrace component libraries to be linked # EZTRACE_LIBRARIES - eztrace component libraries to be linked
#
# EZTRACE_FOUND_WITH_PKGCONFIG - True if found with pkg-config # 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 # 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): # options at configure (ex: cmake path/to/project -DEZTRACE_DIR=path/to/eztrace):
...@@ -73,14 +85,10 @@ find_package(PkgConfig QUIET) ...@@ -73,14 +85,10 @@ find_package(PkgConfig QUIET)
if( PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_GIVEN_BY_USER ) if( PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_GIVEN_BY_USER )
pkg_search_module(EZTRACE eztrace) pkg_search_module(EZTRACE eztrace)
if (NOT EZTRACE_FIND_QUIETLY) if (NOT EZTRACE_FIND_QUIETLY)
if (EZTRACE_FOUND AND EZTRACE_LIBRARIES) if (EZTRACE_FOUND AND EZTRACE_LIBRARIES)
message(STATUS "Looking for EZTRACE - found using PkgConfig") 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() else()
message(STATUS "${Magenta}Looking for EZTRACE - not found using PkgConfig." message(STATUS "${Magenta}Looking for EZTRACE - not found using PkgConfig."
"\n Perhaps you should add the directory containing eztrace.pc to" "\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 ) ...@@ -88,13 +96,12 @@ if( PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_GIVEN_BY_USER )
endif() endif()
if (EZTRACE_FOUND AND EZTRACE_LIBRARIES) if (EZTRACE_FOUND AND EZTRACE_LIBRARIES)
set(EZTRACE_FOUND_WITH_PKGCONFIG "TRUE") set(EZTRACE_FOUND_WITH_PKGCONFIG "TRUE")
find_pkgconfig_libraries_absolute_path(EZTRACE)
else() else()
set(EZTRACE_FOUND_WITH_PKGCONFIG "FALSE") set(EZTRACE_FOUND_WITH_PKGCONFIG "FALSE")
endif() endif()