unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
From: Ekaitz Zarraga <ekaitz@elenq.tech>
To: Matthew Brooks <matthewfbrooks@mailbox.org>
Cc: "help-guix@gnu.org" <help-guix@gnu.org>
Subject: Re: Custom package, specifying cmake source directory?
Date: Mon, 14 Dec 2020 13:09:15 +0000	[thread overview]
Message-ID: <w50M2pFLeHQ_GEbqnYKNMnRnehUYqGY14Jwmek-pW9kEReOXXN0S64HFEjnJRetTbmkjR_a0wvWdYIZAqPQc2T-kgiR2wkvsQE6th8_BlVo=@elenq.tech> (raw)
In-Reply-To: <20201213205530.25cc3612@mailbox.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


  reply	other threads:[~2020-12-14 13:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-14  2:55 Custom package, specifying cmake source directory? Matthew Brooks
2020-12-14 13:09 ` Ekaitz Zarraga [this message]
2020-12-14 13:34   ` Ekaitz Zarraga

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='w50M2pFLeHQ_GEbqnYKNMnRnehUYqGY14Jwmek-pW9kEReOXXN0S64HFEjnJRetTbmkjR_a0wvWdYIZAqPQc2T-kgiR2wkvsQE6th8_BlVo=@elenq.tech' \
    --to=ekaitz@elenq.tech \
    --cc=help-guix@gnu.org \
    --cc=matthewfbrooks@mailbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).