diff options
author | Alexander Neundorf <neundorf@kde.org> | 2006-01-16 18:09:26 +0000 |
---|---|---|
committer | Alexander Neundorf <neundorf@kde.org> | 2006-01-16 18:09:26 +0000 |
commit | 49b236c6856b3b7c22a798320c0bd4c1f9ab6df5 (patch) | |
tree | abdab436cbe06bf4de7a7bccf5b1430691b483aa | |
parent | 9fef46b7d2fdd70de66fa64668f3d03f1c6f792a (diff) | |
download | extra-cmake-modules-49b236c6856b3b7c22a798320c0bd4c1f9ab6df5.tar.gz extra-cmake-modules-49b236c6856b3b7c22a798320c0bd4c1f9ab6df5.tar.bz2 |
cmake module for using pkg-config
usage:
pkgconfig(alsa ALSA_INCLUDE_DIR ALSA_LINK_DIR ALSA_LINK_FLAGS ALSA_CFLAGS)
This will fill in the respective values in these four variables. If pkg-config or the software package is not found they will be empty.
This command is not intended to be used directly, but in FindFOO.cmake modules.
CCMAIL: kde-buildsystem@kde.org
Alex
svn path=/trunk/KDE/kdesdk/cmake/; revision=498955
-rw-r--r-- | modules/UsePkgConfig.cmake | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/modules/UsePkgConfig.cmake b/modules/UsePkgConfig.cmake new file mode 100644 index 00000000..7dc74777 --- /dev/null +++ b/modules/UsePkgConfig.cmake @@ -0,0 +1,39 @@ +# - 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 ) + +# 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-only-other OUTPUT_VARIABLE ${_link_FLAGS} ) + + EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --cflags-only-other OUTPUT_VARIABLE ${_cflags} ) + + ENDIF(NOT _return_VALUE) + + ENDIF(PKGCONFIG_EXECUTABLE) + +ENDMACRO(PKGCONFIG _include_DIR _link_DIR _link_FLAGS _cflags) + |