Bug 12191

Summary: cmake BUILDDIR
Product: buildroot Reporter: Harsh Bokil <harshavardhan.bokil>
Component: OtherAssignee: unassigned
Status: RESOLVED WONTFIX    
Severity: normal CC: buildroot, harshavardhan.bokil
Priority: P5    
Version: 2019.02.5   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:
Attachments: Allow custom _BUILDDIR for cmake packages

Description Harsh Bokil 2019-09-05 17:31:46 UTC
I am building a cmake package that strictly does not allow in source build, output/build/$(PKG_NAME)-$(PKG_VERSION)/buildroot-build is rejected. Suggest this change which solves the problem

--- a/package/pkg-cmake.mk
+++ b/package/pkg-cmake.mk
@@ -66,9 +66,9 @@
 
 
 ifeq ($$($(3)_SUPPORTS_IN_SOURCE_BUILD),YES)
-$(2)_BUILDDIR			= $$($(2)_SRCDIR)
-else
-$(2)_BUILDDIR			= $$($(2)_SRCDIR)/buildroot-build
+$(2)_BUILDDIR			?= $$($(2)_SRCDIR)
+else
+$(2)_BUILDDIR			?= $$($(2)_SRCDIR)/buildroot-build
 endif
 
 #
Comment 1 Thomas Petazzoni 2019-09-05 18:48:05 UTC
Could you submit this as a proper patch to the mailing list, with an update to the Buildroot manual ? Thanks!
Comment 2 Harsh Bokil 2019-09-05 20:40:42 UTC
Created attachment 8241 [details]
Allow custom _BUILDDIR for cmake packages
Comment 3 Harsh Bokil 2019-09-06 01:21:33 UTC
(In reply to Thomas Petazzoni from comment #1)
Attached here.
Comment 4 Arnout Vandecappelle 2019-09-08 15:45:56 UTC
> --- a/package/pkg-cmake.mk
> +++ b/package/pkg-cmake.mk
> @@ -66,9 +66,9 @@
>  
>  
>  ifeq ($$($(3)_SUPPORTS_IN_SOURCE_BUILD),YES)
> -$(2)_BUILDDIR			= $$($(2)_SRCDIR)
> -else
> -$(2)_BUILDDIR			= $$($(2)_SRCDIR)/buildroot-build
> +$(2)_BUILDDIR			?= $$($(2)_SRCDIR)
> +else
> +$(2)_BUILDDIR			?= $$($(2)_SRCDIR)/buildroot-build
>  endif

I am not at all happy with this approach.

First of all, it becomes unnecessary if/when the separate-source-and-build-dir series finally gets merged.

Second, the approach taken by pkg-cmake is already kind of awkward IMO; allowing individual packages to override BUILDDIR makes it worse.

Third, it breaks a couple of things, e.g. <pkg>-dirclean.

Finally, the problem is really with the package itself, there should be no reason at all to reject output/build/$(PKG_NAME)-$(PKG_VERSION)/buildroot-build as the build directory. So just patch the package and whatever check it does, replace it with a check that CMAKE_SOURCE_DIR != CMAKE_BINARY_DIR.

Failing that, I would be more in favour in advancing the separate-source-and-build-dir approach.
Comment 5 Thomas Petazzoni 2019-09-08 16:39:40 UTC
I agree that fixing the package seems like a much better option.