Bug 6632

Summary: CMake use host pkg-config
Product: buildroot Reporter: Damien <damien>
Component: OtherAssignee: unassigned
Status: RESOLVED FIXED    
Severity: minor CC: buildroot
Priority: P5    
Version: 2013.02   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Host: Target:
Build:
Attachments: cairo-dock.mk

Description Damien 2013-10-30 09:46:47 UTC
Dear All,

I try to add cairo-dock in buildroot but I have a problem with CMAKE based package.

When I try to compile a CMAKE based package, cmake use the /usr/bin/pkg-config instead of the one compiled by buildroot.
So pkg-config look for package on host and not in buildroot directory.

Is there any solution to force cmake to use the correct pkg-config and find dependencies ?

Best regards
Comment 1 Thomas Petazzoni 2013-10-30 10:03:33 UTC
1/ Make sure your package depends on 'host-pkgconf', by doing something like <pkg>_DEPENDENCIES = host-pkgconf

2/ Make sure your package uses the cmake-package infrastructure, as described at http://buildroot.org/downloads/manual/manual.html#_infrastructure_for_cmake_based_packages. This will ensure that the directory where our cross pkg-config is installed is in the PATH, and before /usr/bin where the native pkg-config is.

Let us know if that fixes the problem for you.
Comment 2 Damien 2013-10-30 10:11:43 UTC
Created attachment 5108 [details]
cairo-dock.mk
Comment 3 Thomas Petazzoni 2013-10-30 10:29:15 UTC
What about something like:

diff --git a/package/pkg-cmake.mk b/package/pkg-cmake.mk
index 0e08722..70014b5 100644
--- a/package/pkg-cmake.mk
+++ b/package/pkg-cmake.mk
@@ -62,7 +62,7 @@ ifeq ($(5),target)
 define $(2)_CONFIGURE_CMDS
        (cd $$($$(PKG)_BUILDDIR) && \
        rm -f CMakeCache.txt && \
-       $$($$(PKG)_CONF_ENV) $(HOST_DIR)/usr/bin/cmake $$($$(PKG)_SRCDIR) \
+       $(TARGET_MAKE_ENV) $$($$(PKG)_CONF_ENV) $(HOST_DIR)/usr/bin/cmake $$($$(PKG)_SRCDIR) \
                -DCMAKE_TOOLCHAIN_FILE="$$(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake" \
                -DCMAKE_INSTALL_PREFIX="/usr" \
                $$($$(PKG)_CONF_OPT) \
@@ -74,7 +74,7 @@ else
 define $(2)_CONFIGURE_CMDS
        (cd $$($$(PKG)_BUILDDIR) && \
        rm -f CMakeCache.txt && \
-       $(HOST_DIR)/usr/bin/cmake $$($$(PKG)_SRCDIR) \
+       $(HOST_MAKE_ENV) $(HOST_DIR)/usr/bin/cmake $$($$(PKG)_SRCDIR) \
                -DCMAKE_INSTALL_SO_NO_EXE=0 \
                -DCMAKE_FIND_ROOT_PATH="$$(HOST_DIR)" \
                -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM="BOTH" \
Comment 4 Damien 2013-10-30 10:58:28 UTC
thanks a lot, it's work with your patch.