1 # - Obsolete pkg-config module for CMake, use FindPkgConfig instead.
3 # This module defines the following macro:
5 # PKGCONFIG(package includedir libdir linkflags cflags)
7 # Calling PKGCONFIG will fill the desired information into the 4 given arguments,
8 # e.g. PKGCONFIG(libart-2.0 LIBART_INCLUDE_DIR LIBART_LINK_DIR LIBART_LINK_FLAGS LIBART_CFLAGS)
9 # if pkg-config was NOT found or the specified software package doesn't exist, the
10 # variable will be empty when the function returns, otherwise they will contain
11 # the respective information
14 #=============================================================================
15 # Copyright 2006-2009 Kitware, Inc.
17 # Distributed under the OSI-approved BSD License (the "License");
18 # see accompanying file Copyright.txt for details.
20 # This software is distributed WITHOUT ANY WARRANTY; without even the
21 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22 # See the License for more information.
23 #=============================================================================
24 # (To distribute this file outside of CMake, substitute the full
25 # License text for the above reference.)
27 find_program(PKGCONFIG_EXECUTABLE NAMES pkg-config )
29 macro(PKGCONFIG _package _include_DIR _link_DIR _link_FLAGS _cflags)
31 "WARNING: you are using the obsolete 'PKGCONFIG' macro, use FindPkgConfig")
32 # reset the variables at the beginning
38 # if pkg-config has been found
39 if(PKGCONFIG_EXECUTABLE)
41 exec_program(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --exists RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _pkgconfigDevNull )
43 # and if the package of interest also exists for pkg-config, then get the information
46 exec_program(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --variable=includedir
47 OUTPUT_VARIABLE ${_include_DIR} )
48 string(REGEX REPLACE "[\r\n]" " " ${_include_DIR} "${${_include_DIR}}")
51 exec_program(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --variable=libdir
52 OUTPUT_VARIABLE ${_link_DIR} )
53 string(REGEX REPLACE "[\r\n]" " " ${_link_DIR} "${${_link_DIR}}")
55 exec_program(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --libs
56 OUTPUT_VARIABLE ${_link_FLAGS} )
57 string(REGEX REPLACE "[\r\n]" " " ${_link_FLAGS} "${${_link_FLAGS}}")
59 exec_program(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --cflags
60 OUTPUT_VARIABLE ${_cflags} )
61 string(REGEX REPLACE "[\r\n]" " " ${_cflags} "${${_cflags}}")
65 message(STATUS "PKGCONFIG() indicates that ${_package} is not installed (install the package which contains ${_package}.pc if you want to support this feature)")
69 # if pkg-config has NOT been found, INFORM the user
72 message(STATUS "WARNING: PKGCONFIG() indicates that the tool pkg-config has not been found on your system. You should install it.")
78 mark_as_advanced(PKGCONFIG_EXECUTABLE)