Hi,
I still have an uncommitted patch lying around here, you can find it attached.
It deals with pkgconfig when cross compiling.
What it does it sets the environment variable PKG_CONFIG_LIBDIR to the
pkgconfig subdirs of each of the directories in CMAKE_FIND_ROOT_PATH.
E.g. if you have /opt/eldk-4.1/ppc_4xxFP/ppc_4xxFP in CMAKE_FIND_ROOT_PATH,
then PKG_CONFIG_LIBDIR will contain
/opt/eldk-4.1/ppc_4xxFP/ppc_4xxFP/usr/lib/pkgconfig .
This has the effect that pkgconfig will now first (?) look in the
pkgconfig-directories for the target architecture and return the results from
there.
But there are some issues:
-after checking the dirs from PKG_CONFIG_LIBDIR, it checks the dirs from
PKG_CONFIG_PATH. E.g. on my system, PKG_CONFIG_PATH is set
to /usr/lib/pkgconfig and /usr/local/lib/pkgconfig. This means that if
somethign wasn't found in CMAKE_FIND_ROOT_PATH, it will still be found for my
host system. This is wrong. But always setting PKG_CONFIG_PATH empty also
doesn't sound good, since it may have been set on purpose. What to do here ?
-Once it found the correct pc-file, it returns the result. Problem: the
results don't contain the target architecture prefix, e.g. here incdir
gives "/usr/include" while it should be
/opt/eldk-4.1/ppc_4xxFP/ppc_4xxFP/usr/include .
So what to do ? Try to automatically adjust it by adding some appropriate path
in the beginning ? Ignore it and use the wrong include dir ? Sounds even
worse.
So, with it still giving wrong results, I guess adding support for
PKG_CONFIG_LIBDIR doesn't make sense, since it will still be wrong. Or is it
just the eldk pc files which are not correct ?
Alex
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)
_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake