Hi,

when crosscompiling, pkg_config shouldn't find packages for the host system, 
but for the target system. 
Attached is a patch against current cmake cvs which tries to do that by 
setting the env var PKG_CONFIG_LIBDIR to /usr/lib/pkgconfig 
and /usr/local/lib/pkgconfig inside the directories of CMAKE_FIND_ROOT_PATH.

So, can somebody please test the attached patch ?

Thanks
Alex
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	18 Jul 2008 21:44:26 -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)
Index: UsePkgConfig.cmake
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/UsePkgConfig.cmake,v
retrieving revision 1.6
diff -b -u -p -r1.6 UsePkgConfig.cmake
--- UsePkgConfig.cmake	7 Mar 2007 20:36:09 -0000	1.6
+++ UsePkgConfig.cmake	18 Jul 2008 21:44:26 -0000
@@ -12,7 +12,23 @@
 
 
 
-FIND_PROGRAM(PKGCONFIG_EXECUTABLE NAMES pkg-config PATHS /usr/local/bin )
+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
+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)
+
 
 MACRO(PKGCONFIG _package _include_DIR _link_DIR _link_FLAGS _cflags)
   message(STATUS
_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to