[cmake-developers] FindPkgConfig, find_program and stuff

Rolf Eike Beer eike at sf-mail.de
Sun Aug 19 05:39:58 EDT 2012


I scanned through the patches Gentoo applies to CMake to find out which ones 
should be dropped in 2.8.9. I found this one:

diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake
index c47f583..5783d37 100644
--- a/Modules/FindPkgConfig.cmake
+++ b/Modules/FindPkgConfig.cmake
@@ -87,7 +87,12 @@
 set(PKG_CONFIG_VERSION 1)
 set(PKG_CONFIG_FOUND   0)
 
-find_program(PKG_CONFIG_EXECUTABLE NAMES pkg-config DOC "pkg-config executable")
+if(NOT PKG_CONFIG_EXECUTABLE)
+       set(PKG_CONFIG_EXECUTABLE $ENV{PKG_CONFIG})
+       if(NOT PKG_CONFIG_EXECUTABLE)
+               find_program(PKG_CONFIG_EXECUTABLE NAMES pkg-config DOC "pkg-
config executable")
+       endif(NOT PKG_CONFIG_EXECUTABLE)
+endif(NOT PKG_CONFIG_EXECUTABLE)
 mark_as_advanced(PKG_CONFIG_EXECUTABLE)
 
 if(PKG_CONFIG_EXECUTABLE)

While thinking if we could do that better I found 2 things:

-Not related to this patch: autoconf searches for prefixed pkg-config first, i.e. 
prefixed with the compiler prefix. We should probably do the same when cross-
compiling.

-We have a way to give hints about the paths via an environment variable for 
find_program, but I think it would make sense to also allow environment 
variables specifying the absolute path to the executable itself as part of the 
find_program API.

Any thoughts?

Eike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20120819/3d23fe66/attachment.sig>


More information about the cmake-developers mailing list