help-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Custom package, specifying cmake source directory?


From: Ekaitz Zarraga
Subject: Re: Custom package, specifying cmake source directory?
Date: Mon, 14 Dec 2020 13:09:15 +0000

Hi Matthew,



‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Monday, December 14, 2020 3:55 AM, Matthew Brooks 
<matthewfbrooks@mailbox.org> wrote:

> I'm working on a custom package definition, but when it gets built the cmake 
> files are in "source/src" instead of "source", and so the build system errors 
> out when trying to run cmake. How do I specify the source directory for the 
> cmake build system?
> From grepping around in the definition for the cmake build system, it appears 
> that it expects the "source" variable to point to the appropriate location, 
> but I'm not at all familiar with scheme or guile, and I have no idea if 
> that's correct or how to change it.


I'll try to answer you. I'm never played with this, but I think we can find 
something together.

Cmake buildsystem has an interesting keyword argument called #:out-of-source? 
that chooses to compile the project inside sources or in a separate build 
directory. You need something similar, but not that.

I tracked down that variable and I finally got into Cmake's configure step: I'm 
reading the contents of the file `guix/build/cmake-build-system.scm`.

There you can find the definition of the `configure` step. You don't really 
need to do a lot in you package. You can replace the configure step with your 
own version of it, using the `sources/src` directory instead of what the 
default version uses.

In order to replace the configure phase you need to do add a `#:phases` 
`argument` to your package and use a `modify-phases` call to `replace 
'configure` with your own. (all the parts marked with backticks are literal 
code, grep them in the gnu/packages/ directory and you'll find examples).

Your version could have the exact same contents that the default but with 
different directory. You just need to make a `chdir` to the place you like, 
just like this block (line 46 in guix/build/cmake-build-system.scm) does:

``` scheme
    (when out-of-source?
      (mkdir "../build")
      (chdir "../build"))
    (format #t "build directory: ~s~%" (getcwd))

```

Remove all of it and change it with `(chdir "src")` or something like that and 
it should work.

That's most of it. I just gave you a high-level explanation but you can ask me 
more if you need. Just ask anything you need.


Best,
Ekaitz



reply via email to

[Prev in Thread] Current Thread [Next in Thread]