Index: UsePkgConfig.cmake
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/UsePkgConfig.cmake,v
retrieving revision 1.7
diff -b -u -p -r1.7 UsePkgConfig.cmake
--- UsePkgConfig.cmake	16 Aug 2008 11:01:49 -0000	1.7
+++ UsePkgConfig.cmake	3 Nov 2008 22:03:23 -0000
@@ -14,9 +14,25 @@
 
 FIND_PROGRAM(PKGCONFIG_EXECUTABLE NAMES pkg-config )
 
+# When crosscompiling, pkg_config should not search for packages of the host system,
+# but for the target system. To do this, there is the environment variable 
+# PKG_CONFIG_LIBDIR, which was added to pkg_config explicitely for crosscompiling.
+# So set this here to point inside the CMAKE_FIND_ROOT_PATH so it can find
+# only packages for the target system when crosscompiling. Alex
+SET(pkgconfigLibDir)
+IF(CMAKE_CROSSCOMPILING  AND  CMAKE_FIND_ROOT_PATH)
+   FOREACH(currentFindRoot ${CMAKE_FIND_ROOT_PATH})
+      LIST(APPEND pkgconfigLibDir ${currentFindRoot}/usr/lib/pkgconfig )
+      LIST(APPEND pkgconfigLibDir ${currentFindRoot}/usr/local/lib/pkgconfig )
+   ENDFOREACH(currentFindRoot)
+   FILE(TO_NATIVE_PATH "${pkgconfigLibDir}" pkgconfigLibDir)
+   SET(ENV{PKG_CONFIG_LIBDIR} "${pkgconfigLibDir}" )
+ENDIF(CMAKE_CROSSCOMPILING  AND  CMAKE_FIND_ROOT_PATH)
+
+
 MACRO(PKGCONFIG _package _include_DIR _link_DIR _link_FLAGS _cflags)
   MESSAGE(STATUS
-    "WARNING: you are using the obsolete 'PKGCONFIG' macro use FindPkgConfig")
+    "WARNING: you are using the obsolete 'PKGCONFIG' macro, use FindPkgConfig instead")
 # reset the variables at the beginning
   SET(${_include_DIR})
   SET(${_link_DIR})
Index: FindPkgConfig.cmake
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/FindPkgConfig.cmake,v
retrieving revision 1.7
diff -b -u -p -r1.7 FindPkgConfig.cmake
--- FindPkgConfig.cmake	7 Feb 2008 18:19:38 -0000	1.7
+++ FindPkgConfig.cmake	3 Nov 2008 22:03:23 -0000
@@ -103,6 +103,20 @@ if(PKG_CONFIG_EXECUTABLE)
   set(PKG_CONFIG_FOUND 1)
 endif(PKG_CONFIG_EXECUTABLE)
 
+# When crosscompiling, pkg_config should not search for packages of the host system,
+# but for the target system. To do this, there is the environment variable 
+# PKG_CONFIG_LIBDIR, which was added to pkg_config explicitely for crosscompiling.
+# So set this here to point inside the CMAKE_FIND_ROOT_PATH so it can find
+# only packages for the target system when crosscompiling. Alex
+if(CMAKE_CROSSCOMPILING  AND  CMAKE_FIND_ROOT_PATH)
+   set(pkgconfigLibDir)
+   foreach(currentFindRoot ${CMAKE_FIND_ROOT_PATH})
+      list(APPEND pkgconfigLibDir ${currentFindRoot}/usr/lib/pkgconfig )
+      list(APPEND pkgconfigLibDir ${currentFindRoot}/usr/local/lib/pkgconfig )
+   endforeach(currentFindRoot)
+   file(TO_NATIVE_PATH "${pkgconfigLibDir}" pkgconfigLibDir)
+   set(ENV{PKG_CONFIG_LIBDIR} "${pkgconfigLibDir}" )
+endif(CMAKE_CROSSCOMPILING  AND  CMAKE_FIND_ROOT_PATH)
 
 # Unsets the given variables
 macro(_pkgconfig_unset var)
