summaryrefslogtreecommitdiffstats
path: root/Modules/UsePkgConfig.cmake
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2006-12-09 20:02:19 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2006-12-09 20:02:19 (GMT)
commitff6146334cbfcc5599e97cc864115bb15e93db11 (patch)
tree20da1efb2344e9b53d082674fbef03556260deb6 /Modules/UsePkgConfig.cmake
parentb9787a965f8d414b0d505ba48d10c0d4a5082d69 (diff)
downloadCMake-ff6146334cbfcc5599e97cc864115bb15e93db11.zip
CMake-ff6146334cbfcc5599e97cc864115bb15e93db11.tar.gz
CMake-ff6146334cbfcc5599e97cc864115bb15e93db11.tar.bz2
ENH: better backwards compatibility, and deprecate PKGCONFIG
Diffstat (limited to 'Modules/UsePkgConfig.cmake')
-rw-r--r--Modules/UsePkgConfig.cmake44
1 files changed, 36 insertions, 8 deletions
diff --git a/Modules/UsePkgConfig.cmake b/Modules/UsePkgConfig.cmake
index 62cc1d5..ed47e2d 100644
--- a/Modules/UsePkgConfig.cmake
+++ b/Modules/UsePkgConfig.cmake
@@ -1,6 +1,6 @@
# - obsolete pkg-config module for CMake
#
-# Includes FindPkgConfig.cmake which defines
+# Defines the following macros:
#
# PKGCONFIG(package includedir libdir linkflags cflags)
#
@@ -10,11 +10,39 @@
# variable will be empty when the function returns, otherwise they will contain the respective information
#
-INCLUDE(FindPkgConfig)
-# Retain backwards compatibility with old PKGCONFIG_EXECUTABLE name.
-IF(PKG_CONFIG_EXECUTABLE)
- SET(PKGCONFIG_EXECUTABLE ${PKG_CONFIG_EXECUTABLE})
-ELSE(PKG_CONFIG_EXECUTABLE)
- SET(PKGCONFIG_EXECUTABLE PKGCONFIG_EXECUTABLE-NOTFOUND)
-ENDIF(PKG_CONFIG_EXECUTABLE)
+
+FIND_PROGRAM(PKGCONFIG_EXECUTABLE NAMES pkg-config PATHS /usr/local/bin )
+
+MACRO(PKGCONFIG _package _include_DIR _link_DIR _link_FLAGS _cflags)
+ message(STATUS
+ "WARNING: you are using the obsolete 'PKGCONFIG' macro use FindPkgConfig")
+# 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)
+
+ EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --exists RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _pkgconfigDevNull )
+
+ # and if the package of interest also exists for pkg-config, then get the information
+ IF(NOT _return_VALUE)
+
+ EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --variable=includedir OUTPUT_VARIABLE ${_include_DIR} )
+
+ EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --variable=libdir OUTPUT_VARIABLE ${_link_DIR} )
+
+ EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --libs OUTPUT_VARIABLE ${_link_FLAGS} )
+
+ EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --cflags OUTPUT_VARIABLE ${_cflags} )
+
+ ENDIF(NOT _return_VALUE)
+
+ ENDIF(PKGCONFIG_EXECUTABLE)
+
+ENDMACRO(PKGCONFIG _include_DIR _link_DIR _link_FLAGS _cflags)
+
+MARK_AS_ADVANCED(PKGCONFIG_EXECUTABLE)