# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#[=======================================================================[.rst:
U s e P k g C o n f i g
- - - - - - - - - - - -
O b s o l e t e p k g - c o n f i g m o d u l e f o r C M a k e , u s e F i n d P k g C o n f i g i n s t e a d .
T h i s m o d u l e d e f i n e s t h e f o l l o w i n g m a c r o :
PKGCONFIG ( package includedir libdir linkflags cflags )
C a l l i n g P K G C O N F I G w i l l f i l l t h e d e s i r e d i n f o r m a t i o n i n t o t h e 4 g i v e n
a r g u m e n t s , e . g . PKGCONFIG ( libart-2.0 LIBART_INCLUDE_DIR
L I B A R T _ L I N K _ D I R L I B A R T _ L I N K _ F L A G S L I B A R T _ C F L A G S ) i f p k g - c o n f i g w a s N O T
f o u n d o r t h e s p e c i f i e d s o f t w a r e p a c k a g e d o e s n ' t e x i s t , t h e v a r i a b l e
w i l l b e e m p t y w h e n t h e f u n c t i o n r e t u r n s , o t h e r w i s e t h e y w i l l c o n t a i n
t h e r e s p e c t i v e i n f o r m a t i o n
#]=======================================================================]
find_program ( PKGCONFIG_EXECUTABLE NAMES pkg-config )
macro ( PKGCONFIG _package _include_DIR _link_DIR _link_FLAGS _cflags )
message ( STATUS
" 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 " )
# reset the variables at the beginning
set ( ${ _include_DIR } )
set ( ${ _link_DIR } )
set ( ${ _link_FLAGS } )
set ( ${ _cflags } )
# if pkg-config has been found
if ( PKGCONFIG_EXECUTABLE )
execute_process ( COMMAND ${ PKGCONFIG_EXECUTABLE } ${ _package } --exists RESULT_VARIABLE _return_VALUE OUTPUT_VARIABLE _pkgconfigDevNull )
# and if the package of interest also exists for pkg-config, then get the information
if ( NOT _return_VALUE )
execute_process ( COMMAND ${ PKGCONFIG_EXECUTABLE } ${ _package } --variable=includedir
O U T P U T _ V A R I A B L E $ { _ i n c l u d e _ D I R } O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
string ( REGEX REPLACE "[\r\n]" " " ${ _include_DIR } "${${_include_DIR}}" )
execute_process ( COMMAND ${ PKGCONFIG_EXECUTABLE } ${ _package } --variable=libdir
O U T P U T _ V A R I A B L E $ { _ l i n k _ D I R } O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
string ( REGEX REPLACE "[\r\n]" " " ${ _link_DIR } "${${_link_DIR}}" )
execute_process ( COMMAND ${ PKGCONFIG_EXECUTABLE } ${ _package } --libs
O U T P U T _ V A R I A B L E $ { _ l i n k _ F L A G S } O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
string ( REGEX REPLACE "[\r\n]" " " ${ _link_FLAGS } "${${_link_FLAGS}}" )
execute_process ( COMMAND ${ PKGCONFIG_EXECUTABLE } ${ _package } --cflags
O U T P U T _ V A R I A B L E $ { _ c f l a g s } O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
string ( REGEX REPLACE "[\r\n]" " " ${ _cflags } "${${_cflags}}" )
else ( )
message ( STATUS "PKGCONFIG() indicates that ${_package} is not installed (install the package which contains ${_package}.pc if you want to support this feature)" )
endif ( )
# if pkg-config has NOT been found, INFORM the user
else ( )
message ( STATUS "WARNING: PKGCONFIG() indicates that the tool pkg-config has not been found on your system. You should install it." )
endif ( )
endmacro ( )
mark_as_advanced ( PKGCONFIG_EXECUTABLE )