aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Montel <montel@kde.org>2007-07-09 21:33:47 +0000
committerLaurent Montel <montel@kde.org>2007-07-09 21:33:47 +0000
commitd7afe91db8b90db6b6aab69430270895ea3546d4 (patch)
treeb891b834d9a74babdaff54e49b7add4704ad15b6
parent70dc85a661b066111d0aa63b64618e35b8d1e7fc (diff)
downloadextra-cmake-modules-d7afe91db8b90db6b6aab69430270895ea3546d4.tar.gz
extra-cmake-modules-d7afe91db8b90db6b6aab69430270895ea3546d4.tar.bz2
Duplicate from cmake module which inform when module is not install. I will send an email to cmake dev but not today, it's very difficult to have an adsl connection in my hostel
svn path=/trunk/KDE/kdelibs/; revision=685861
-rw-r--r--modules/UsePkgConfig.cmake50
1 files changed, 50 insertions, 0 deletions
diff --git a/modules/UsePkgConfig.cmake b/modules/UsePkgConfig.cmake
new file mode 100644
index 00000000..a3f831e5
--- /dev/null
+++ b/modules/UsePkgConfig.cmake
@@ -0,0 +1,50 @@
+# - 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} )
+
+ ELSE( NOT _return_VALUE)
+
+ MESSAGE(STATUS "PKGCONFIG macro signal that ${_package} is not installed on your computer.")
+ MESSAGE(STATUS "Install package which contains ${_package}.pc if you want to support this feature.")
+
+ ENDIF(NOT _return_VALUE)
+
+ ENDIF(PKGCONFIG_EXECUTABLE)
+
+ENDMACRO(PKGCONFIG _include_DIR _link_DIR _link_FLAGS _cflags)
+
+MARK_AS_ADVANCED(PKGCONFIG_EXECUTABLE)