summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2006-03-08 22:11:01 (GMT)
committerAlexander Neundorf <neundorf@kde.org>2006-03-08 22:11:01 (GMT)
commit6dd39ceaa083f97809247eb2127fbaf967b6c04f (patch)
tree7c474edd502bbdda64617c92a3eb4df208c639a8 /Modules
parente8affe5cc23ca560f4241362ec0f5d0ad5a6a455 (diff)
downloadCMake-6dd39ceaa083f97809247eb2127fbaf967b6c04f.zip
CMake-6dd39ceaa083f97809247eb2127fbaf967b6c04f.tar.gz
CMake-6dd39ceaa083f97809247eb2127fbaf967b6c04f.tar.bz2
ENH: add a cmake module for using pkg-config, tested in kdelibs, ok by Bill Hoffman
Alex
Diffstat (limited to 'Modules')
-rw-r--r--Modules/UsePkgConfig.cmake40
1 files changed, 40 insertions, 0 deletions
diff --git a/Modules/UsePkgConfig.cmake b/Modules/UsePkgConfig.cmake
new file mode 100644
index 0000000..4490d2c
--- /dev/null
+++ b/Modules/UsePkgConfig.cmake
@@ -0,0 +1,40 @@
+# - pkg-config module for CMake
+# Defines the following macros:
+# 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
+# variable will be empty when the function returns, otherwise they will contain the respective information
+
+FIND_PROGRAM(PKGCONFIG_EXECUTABLE NAMES pkg-config PATHS /usr/local/bin )
+
+MACRO(PKGCONFIG _package _include_DIR _link_DIR _link_FLAGS _cflags)
+# 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)