all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Add path to a guix package into CMakeLists.txt
@ 2024-09-30 15:44 Aristide Doussot
  2024-10-03 13:18 ` Andreas Enge
  0 siblings, 1 reply; 4+ messages in thread
From: Aristide Doussot @ 2024-09-30 15:44 UTC (permalink / raw)
  To: help-guix

Hello,

     I am new with Guix and currently Guixifying an astronomical library 
(called Wsclean) which directly includes some code from another library 
(namely aocommon) that is already on guix astronomy.scm. In the 
CMakeLists.txt of the library I am trying to install, I want to change 
the line:

"include_directories(${CMAKE_SOURCE_DIR}/external/aocommon/include/)"

into the already installed guix version of aocommon, in my case it would 
be :

"include_directories(/gnu/store/1wiw8m5yjcr26pcqhzbh7bw5ghvbaw90-aocommon-0.0.0-1.7329a07/include/)"

However I don't think other users installing the package would 
mandatorily have 
"/gnu/store/1wiw8m5yjcr26pcqhzbh7bw5ghvbaw90-aocommon-0.0.0-1.7329a07" 
as their path to their installed guix version of aocommon. My question 
is therefore : is there a way to ask guix to find this path based on the 
name of the dependency and use it in my substitute* command on the 
CMakeLists file ?

Thanks,
Aristide Doussot


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

* Re: Add path to a guix package into CMakeLists.txt
  2024-09-30 15:44 Add path to a guix package into CMakeLists.txt Aristide Doussot
@ 2024-10-03 13:18 ` Andreas Enge
  2024-10-04  1:12   ` James Smith
  2024-10-04 14:18   ` Felix Lechner via
  0 siblings, 2 replies; 4+ messages in thread
From: Andreas Enge @ 2024-10-03 13:18 UTC (permalink / raw)
  To: Aristide Doussot; +Cc: help-guix

Hello Aristide,

Am Mon, Sep 30, 2024 at 05:44:26PM +0200 schrieb Aristide Doussot:
> into the already installed guix version of aocommon, in my case it would be
> "include_directories(/gnu/store/1wiw8m5yjcr26pcqhzbh7bw5ghvbaw90-aocommon-0.0.0-1.7329a07/include/)"
> However I don't think other users installing the package would mandatorily
> have "/gnu/store/1wiw8m5yjcr26pcqhzbh7bw5ghvbaw90-aocommon-0.0.0-1.7329a07"
> as their path to their installed guix version of aocommon. My question is
> therefore : is there a way to ask guix to find this path based on the name
> of the dependency and use it in my substitute* command on the CMakeLists
> file ?

this is indeed quite a common action. For instance, I do something like this
in the package vinci in gnu/packages/maths.scm:

       (modify-phases %standard-phases
         (replace 'configure
           ;; register the lrs location in the config file
           (lambda* (#:key inputs #:allow-other-keys)
             (let* ((lrs (assoc-ref inputs "lrslib"))
                    (lrsexec (string-append lrs "/bin/lrs")))
               (substitute* "vinci.h"
                 (("#define LRS_EXEC      \"lrs\"")
                  (string-append "#define LRS_EXEC \"" lrsexec "\""))))
             #t))

So the function defining the phase needs to take the keyword parameter
"inputs", and this is set to the inputs of the package.
Then (assoc-ref inputs "lrslib") resolves to /gnu/store/...-lrslib-...,
the store path corresponding to the input package.

However, this is an "old style" package; for instance, phases do not end
with #t anymore. I do not know whether one would do differently with the
modern gexp style approach.

In any case, I hope you can already continue in this direction.

Andreas



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

* Re: Add path to a guix package into CMakeLists.txt
  2024-10-03 13:18 ` Andreas Enge
@ 2024-10-04  1:12   ` James Smith
  2024-10-04 14:18   ` Felix Lechner via
  1 sibling, 0 replies; 4+ messages in thread
From: James Smith @ 2024-10-04  1:12 UTC (permalink / raw)
  To: Andreas Enge; +Cc: Aristide Doussot, help-guix

Andreas Enge <andreas@enge.fr> writes:

> this is indeed quite a common action. For instance, I do something like this
> in the package vinci in gnu/packages/maths.scm:
>
>        (modify-phases %standard-phases
>          (replace 'configure
>            ;; register the lrs location in the config file
>            (lambda* (#:key inputs #:allow-other-keys)
>              (let* ((lrs (assoc-ref inputs "lrslib"))
>                     (lrsexec (string-append lrs "/bin/lrs")))
>                (substitute* "vinci.h"
>                  (("#define LRS_EXEC      \"lrs\"")
>                   (string-append "#define LRS_EXEC \"" lrsexec "\""))))
>              #t))
>
> So the function defining the phase needs to take the keyword parameter
> "inputs", and this is set to the inputs of the package.
> Then (assoc-ref inputs "lrslib") resolves to /gnu/store/...-lrslib-...,
> the store path corresponding to the input package.
>
> However, this is an "old style" package; for instance, phases do not end
> with #t anymore. I do not know whether one would do differently with the
> modern gexp style approach.

In case you're wondering, the example above when rewritten in the
current style would look something like this:

  #~(modify-phases %standard-phases
      (replace 'configure
        ;; Register the lrs location in the config file.
        (lambda* (#:key inputs #:allow-other-keys)
          (substitute* "vinci.h"
            (("#define LRS_EXEC      \"lrs\"")
             (string-append "#define LRS_EXEC \""
                            (search-input-file inputs "/bin/lrs") "\""))))))

Hope that helps,

James


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

* Re: Add path to a guix package into CMakeLists.txt
  2024-10-03 13:18 ` Andreas Enge
  2024-10-04  1:12   ` James Smith
@ 2024-10-04 14:18   ` Felix Lechner via
  1 sibling, 0 replies; 4+ messages in thread
From: Felix Lechner via @ 2024-10-04 14:18 UTC (permalink / raw)
  To: Aristide Doussot, Andreas Enge; +Cc: help-guix, Liliana Marie Prikler

Hi Aristide,

On Thu, Oct 03 2024, Andreas Enge wrote:

> (let* ((lrs (assoc-ref inputs "lrslib"))

Andreas practically co-founded Guix and I'm a noobie, but I think Lily
might have told me once that 'search-input-file' is now preferred.

Kind regards
Felix


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

end of thread, other threads:[~2024-10-04 21:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-30 15:44 Add path to a guix package into CMakeLists.txt Aristide Doussot
2024-10-03 13:18 ` Andreas Enge
2024-10-04  1:12   ` James Smith
2024-10-04 14:18   ` Felix Lechner via

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.