1 # - obsolete pkg-config module for CMake
3 # Defines the following macros:
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 the respective information
15 FIND_PROGRAM(PKGCONFIG_EXECUTABLE NAMES pkg-config )
17 MACRO(PKGCONFIG _package _include_DIR _link_DIR _link_FLAGS _cflags)
19 "WARNING: you are using the obsolete 'PKGCONFIG' macro use FindPkgConfig")
20 # reset the variables at the beginning
26 # if pkg-config has been found
27 IF(PKGCONFIG_EXECUTABLE)
29 EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --exists RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _pkgconfigDevNull )
31 # and if the package of interest also exists for pkg-config, then get the information
34 EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --variable=includedir
35 OUTPUT_VARIABLE ${_include_DIR} )
36 STRING(REGEX REPLACE "[\r\n]" " " ${_include_DIR} "${${_include_DIR}}")
39 EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --variable=libdir
40 OUTPUT_VARIABLE ${_link_DIR} )
41 STRING(REGEX REPLACE "[\r\n]" " " ${_link_DIR} "${${_link_DIR}}")
43 EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --libs
44 OUTPUT_VARIABLE ${_link_FLAGS} )
45 STRING(REGEX REPLACE "[\r\n]" " " ${_link_FLAGS} "${${_link_FLAGS}}")
47 EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --cflags
48 OUTPUT_VARIABLE ${_cflags} )
49 STRING(REGEX REPLACE "[\r\n]" " " ${_cflags} "${${_cflags}}")
51 ELSE( NOT _return_VALUE)
53 MESSAGE(STATUS "PKGCONFIG() indicates that ${_package} is not installed (install the package which contains ${_package}.pc if you want to support this feature)")
55 ENDIF(NOT _return_VALUE)
57 ENDIF(PKGCONFIG_EXECUTABLE)
59 ENDMACRO(PKGCONFIG _include_DIR _link_DIR _link_FLAGS _cflags)
61 MARK_AS_ADVANCED(PKGCONFIG_EXECUTABLE)