unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
* Custom package, specifying cmake source directory?
@ 2020-12-14  2:55 Matthew Brooks
  2020-12-14 13:09 ` Ekaitz Zarraga
  0 siblings, 1 reply; 3+ messages in thread
From: Matthew Brooks @ 2020-12-14  2:55 UTC (permalink / raw)
  To: help-guix@gnu.org

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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Custom package, specifying cmake source directory?
  2020-12-14  2:55 Custom package, specifying cmake source directory? Matthew Brooks
@ 2020-12-14 13:09 ` Ekaitz Zarraga
  2020-12-14 13:34   ` Ekaitz Zarraga
  0 siblings, 1 reply; 3+ messages in thread
From: Ekaitz Zarraga @ 2020-12-14 13:09 UTC (permalink / raw)
  To: Matthew Brooks; +Cc: help-guix@gnu.org

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Custom package, specifying cmake source directory?
  2020-12-14 13:09 ` Ekaitz Zarraga
@ 2020-12-14 13:34   ` Ekaitz Zarraga
  0 siblings, 0 replies; 3+ messages in thread
From: Ekaitz Zarraga @ 2020-12-14 13:34 UTC (permalink / raw)
  To: Ekaitz Zarraga; +Cc: help-guix@gnu.org

Hi again,

Let me re-answer because I think I screwed in a couple of points.

So, you are not trying to use other build directory but a different source directory.

That's a little bit different. Instead of making a `chdir` you need to touch the `srcdir` variable.

In that case, you can change the current directory in a previous phase, adding a new phase before the `configure` step that just jumps to source code just like `hypre` does.
Run `guix edit hypre` to see it:

``` scheme
         (add-before 'configure 'chdir-src
           (lambda _ (chdir "src")))
```

Probably this last option is the best, I'm not sure if it works. It should.


Sorry for the misunderstanding!

Good luck,

Ekaitz


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-12-14 13:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-14  2:55 Custom package, specifying cmake source directory? Matthew Brooks
2020-12-14 13:09 ` Ekaitz Zarraga
2020-12-14 13:34   ` Ekaitz Zarraga

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).