2011-09-27 11:54:38 +04:00
# - Obsolete pkg-config module for CMake, use FindPkgConfig instead.
2006-03-15 21:20:03 +03:00
#
2011-09-22 16:47:18 +04:00
# This module defines the following macro:
2006-03-15 21:20:03 +03:00
#
# PKGCONFIG(package includedir libdir linkflags cflags)
#
# Calling PKGCONFIG will fill the desired information into the 4 given arguments,
# e.g. PKGCONFIG(libart-2.0 LIBART_INCLUDE_DIR LIBART_LINK_DIR LIBART_LINK_FLAGS LIBART_CFLAGS)
# if pkg-config was NOT found or the specified software package doesn't exist, the
2011-09-22 16:47:18 +04:00
# variable will be empty when the function returns, otherwise they will contain
# the respective information
2006-03-15 21:20:03 +03:00
#
2009-09-28 19:46:51 +04:00
#=============================================================================
# Copyright 2006-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
2010-08-07 04:48:47 +04:00
# (To distribute this file outside of CMake, substitute the full
2009-09-28 19:46:51 +04:00
# License text for the above reference.)
2006-12-09 23:02:19 +03:00
2012-08-13 21:47:32 +04:00
find_program ( PKGCONFIG_EXECUTABLE NAMES pkg-config )
2006-12-09 23:02:19 +03:00
2012-08-13 21:47:32 +04:00
macro ( PKGCONFIG _package _include_DIR _link_DIR _link_FLAGS _cflags )
message ( STATUS
2011-09-22 16:47:18 +04:00
" W A R N I N G : y o u a r e u s i n g t h e o b s o l e t e ' P K G C O N F I G ' m a c r o , u s e F i n d P k g C o n f i g " )
2006-12-09 23:02:19 +03:00
# reset the variables at the beginning
2012-08-13 21:47:32 +04:00
set ( ${ _include_DIR } )
set ( ${ _link_DIR } )
set ( ${ _link_FLAGS } )
set ( ${ _cflags } )
2006-12-09 23:02:19 +03:00
# if pkg-config has been found
2012-08-13 21:47:32 +04:00
if ( PKGCONFIG_EXECUTABLE )
2006-12-09 23:02:19 +03:00
2012-08-13 21:47:32 +04:00
exec_program ( ${ PKGCONFIG_EXECUTABLE } ARGS ${ _package } --exists RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _pkgconfigDevNull )
2006-12-09 23:02:19 +03:00
# and if the package of interest also exists for pkg-config, then get the information
2012-08-13 21:47:32 +04:00
if ( NOT _return_VALUE )
2006-12-09 23:02:19 +03:00
2012-08-13 21:47:32 +04:00
exec_program ( ${ PKGCONFIG_EXECUTABLE } ARGS ${ _package } --variable=includedir
2007-03-07 23:36:09 +03:00
O U T P U T _ V A R I A B L E $ { _ i n c l u d e _ D I R } )
2012-08-13 21:47:32 +04:00
string ( REGEX REPLACE "[\r\n]" " " ${ _include_DIR } "${${_include_DIR}}" )
2007-03-07 23:36:09 +03:00
2011-09-22 16:39:19 +04:00
2012-08-13 21:47:32 +04:00
exec_program ( ${ PKGCONFIG_EXECUTABLE } ARGS ${ _package } --variable=libdir
2007-03-07 23:36:09 +03:00
O U T P U T _ V A R I A B L E $ { _ l i n k _ D I R } )
2012-08-13 21:47:32 +04:00
string ( REGEX REPLACE "[\r\n]" " " ${ _link_DIR } "${${_link_DIR}}" )
2007-03-07 23:36:09 +03:00
2012-08-13 21:47:32 +04:00
exec_program ( ${ PKGCONFIG_EXECUTABLE } ARGS ${ _package } --libs
2007-03-07 23:36:09 +03:00
O U T P U T _ V A R I A B L E $ { _ l i n k _ F L A G S } )
2012-08-13 21:47:32 +04:00
string ( REGEX REPLACE "[\r\n]" " " ${ _link_FLAGS } "${${_link_FLAGS}}" )
2007-03-07 23:36:09 +03:00
2012-08-13 21:47:32 +04:00
exec_program ( ${ PKGCONFIG_EXECUTABLE } ARGS ${ _package } --cflags
2007-03-07 23:36:09 +03:00
O U T P U T _ V A R I A B L E $ { _ c f l a g s } )
2012-08-13 21:47:32 +04:00
string ( REGEX REPLACE "[\r\n]" " " ${ _cflags } "${${_cflags}}" )
2008-08-16 15:01:49 +04:00
2012-08-13 21:50:14 +04:00
else ( )
2008-08-16 15:01:49 +04:00
2012-08-13 21:47:32 +04:00
message ( STATUS "PKGCONFIG() indicates that ${_package} is not installed (install the package which contains ${_package}.pc if you want to support this feature)" )
2006-12-09 23:02:19 +03:00
2012-08-13 21:50:14 +04:00
endif ( )
2011-09-22 16:39:19 +04:00
2009-09-16 20:40:37 +04:00
# if pkg-config has NOT been found, INFORM the user
2012-08-13 21:50:14 +04:00
else ( )
2011-09-22 16:39:19 +04:00
2012-08-13 21:47:32 +04:00
message ( STATUS "WARNING: PKGCONFIG() indicates that the tool pkg-config has not been found on your system. You should install it." )
2006-12-09 23:02:19 +03:00
2012-08-13 21:50:14 +04:00
endif ( )
2006-12-09 23:02:19 +03:00
2012-08-13 21:50:14 +04:00
endmacro ( )
2006-12-09 23:02:19 +03:00
2012-08-13 21:47:32 +04:00
mark_as_advanced ( PKGCONFIG_EXECUTABLE )