pkg-cmake: allow to build package in a subdirectory
authorGwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
Fri, 13 Mar 2015 08:24:08 +0000 (09:24 +0100)
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Fri, 13 Mar 2015 21:34:43 +0000 (22:34 +0100)
For some cmake based packages, like GNURadio, it's forbidden to do the
compilation directly in the sources directory. This patch add a new
variable to specify, if needed, the name of a sub-directory used to compile.

[Thomas: put the documentation at the right place in the manual, not
in the middle of the <pkg>_CONF_OPTS description.]

Signed-off-by: Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Tested-by: Angelo Compagnucci <angelo.compagnucci@gmail.com>
Reviewed-by: Samuel Martin <s.martin49@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
docs/manual/adding-packages-cmake.txt
package/pkg-cmake.mk

index d92b2090f879d94454bd3a3f2998291771f4b3d8..6ccf3902f8ccd7644f420688ff92d489e5897512 100644 (file)
@@ -107,6 +107,10 @@ typical packages will therefore only use a few of them.
 ** +BUILD_EXAMPLE+, +BUILD_EXAMPLES+ are disabled;
 ** +BUILD_TEST+, +BUILD_TESTS+, +BUILD_TESTING+ are disabled.
 
+* +LIBFOO_SUPPORTS_IN_SOURCE_BUILD = NO+ should be set when the package
+  cannot be built inside the source tree but needs a separate build
+  directory.
+
 * +LIBFOO_MAKE+, to specify an alternate +make+ command. This is
   typically useful when parallel make is enabled in the configuration
   (using +BR2_JLEVEL+) but that this feature should be disabled for
index 2404c40122a1085bff95d8b2f010411a5e4ad5a1..2262012483918b66d3ae77a9a51d955de1723523 100644 (file)
@@ -61,7 +61,15 @@ $(2)_INSTALL_STAGING_OPTS    ?= DESTDIR=$$(STAGING_DIR) install
 $(2)_INSTALL_TARGET_OPTS               ?= DESTDIR=$$(TARGET_DIR) install
 
 $(2)_SRCDIR                    = $$($(2)_DIR)/$$($(2)_SUBDIR)
+
+$(3)_SUPPORTS_IN_SOURCE_BUILD ?= YES
+
+
+ifeq ($$($(3)_SUPPORTS_IN_SOURCE_BUILD),YES)
 $(2)_BUILDDIR                  = $$($(2)_SRCDIR)
+else
+$(2)_BUILDDIR                  = $$($(2)_SRCDIR)/buildroot-build
+endif
 
 #
 # Configure step. Only define it if not already defined by the package
@@ -73,7 +81,8 @@ ifeq ($(4),target)
 
 # Configure package for target
 define $(2)_CONFIGURE_CMDS
-       (cd $$($$(PKG)_BUILDDIR) && \
+       (mkdir -p $$($$(PKG)_BUILDDIR) && \
+       cd $$($$(PKG)_BUILDDIR) && \
        rm -f CMakeCache.txt && \
        PATH=$$(BR_PATH) \
        $$($$(PKG)_CONF_ENV) $$(HOST_DIR)/usr/bin/cmake $$($$(PKG)_SRCDIR) \
@@ -98,7 +107,8 @@ else
 
 # Configure package for host
 define $(2)_CONFIGURE_CMDS
-       (cd $$($$(PKG)_BUILDDIR) && \
+       (mkdir -p $$($$(PKG)_BUILDDIR) && \
+       cd $$($$(PKG)_BUILDDIR) && \
        rm -f CMakeCache.txt && \
        PATH=$$(BR_PATH) \
        $$(HOST_DIR)/usr/bin/cmake $$($$(PKG)_SRCDIR) \