diff mbox series

[1/2] support/misc/toolchainfile.cmake.in: set PKG_CONFIG/CMAKE prefix paths

Message ID 20220728014402.142320-1-james.hilliard1@gmail.com
State Changes Requested
Headers show
Series [1/2] support/misc/toolchainfile.cmake.in: set PKG_CONFIG/CMAKE prefix paths | expand

Commit Message

James Hilliard July 28, 2022, 1:44 a.m. UTC
These appear to not be getting set correctly and are needed when using
meson's relocatable pkgconfig format.

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
 support/misc/toolchainfile.cmake.in | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Romain Naour Jan. 11, 2023, 3:19 p.m. UTC | #1
Hello James,

Le 28/07/2022 à 03:44, James Hilliard a écrit :
> These appear to not be getting set correctly and are needed when using
> meson's relocatable pkgconfig format.

How this cmake file (toolchainfile.cmake.in) is used by a meson package ?

Best regards,
Romain

> 
> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
> ---
>  support/misc/toolchainfile.cmake.in | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/support/misc/toolchainfile.cmake.in b/support/misc/toolchainfile.cmake.in
> index 5d2b8695b4..2c6adfd02d 100644
> --- a/support/misc/toolchainfile.cmake.in
> +++ b/support/misc/toolchainfile.cmake.in
> @@ -91,6 +91,12 @@ endif()
>  if(NOT DEFINED CMAKE_FIND_ROOT_PATH_MODE_INCLUDE)
>    set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
>  endif()
> +if(NOT DEFINED PKG_CONFIG_USE_CMAKE_PREFIX_PATH)
> +  set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON)
> +endif()
> +if(NOT DEFINED CMAKE_PREFIX_PATH)
> +  set(CMAKE_PREFIX_PATH "${RELOCATED_HOST_DIR}/@@STAGING_SUBDIR@@/usr")
> +endif()
>  set(ENV{PKG_CONFIG_SYSROOT_DIR} "${RELOCATED_HOST_DIR}/@@STAGING_SUBDIR@@")
>  
>  # This toolchain file can be used both inside and outside Buildroot.
Nicolas Cavallari Jan. 11, 2023, 4:01 p.m. UTC | #2
On 11/01/2023 16:19, Romain Naour wrote:
> Hello James,
> 
> Le 28/07/2022 à 03:44, James Hilliard a écrit :
>> These appear to not be getting set correctly and are needed when using
>> meson's relocatable pkgconfig format.
> 
> How this cmake file (toolchainfile.cmake.in) is used by a meson package ?

I understand it as "a cmake package needs this to use a pkgconfig file 
generated by a meson package when meson is configured to generate 
relocatable pkgconfig files".
Romain Naour Jan. 11, 2023, 4:12 p.m. UTC | #3
Hi Nicolas,

Le 11/01/2023 à 17:01, Nicolas Cavallari a écrit :
> On 11/01/2023 16:19, Romain Naour wrote:
>> Hello James,
>>
>> Le 28/07/2022 à 03:44, James Hilliard a écrit :
>>> These appear to not be getting set correctly and are needed when using
>>> meson's relocatable pkgconfig format.
>>
>> How this cmake file (toolchainfile.cmake.in) is used by a meson package ?
> 
> I understand it as "a cmake package needs this to use a pkgconfig file generated
> by a meson package when meson is configured to generate relocatable pkgconfig
> files".

Ok thanks, I misunderstood what James wrote... my bad.

Best regards,
Romain
Yann E. MORIN Jan. 11, 2023, 4:44 p.m. UTC | #4
Nicolas, James, All,

On 2023-01-11 17:01 +0100, Nicolas Cavallari spake thusly:
> On 11/01/2023 16:19, Romain Naour wrote:
> >Le 28/07/2022 à 03:44, James Hilliard a écrit :
> >>These appear to not be getting set correctly and are needed when using
> >>meson's relocatable pkgconfig format.
> >How this cmake file (toolchainfile.cmake.in) is used by a meson package ?
> I understand it as "a cmake package needs this to use a pkgconfig file
> generated by a meson package when meson is configured to generate
> relocatable pkgconfig files".

OK, but then I have a few questions:

  - what are "relocatable pkgconfig files", and how do they fit in the
    pkgconfig spec?

  - how do they differ from standard pkgconfig files? By "standard", I
    mean all the pkgconfig files we currently install and use from the
    hundreds, if not thousands, of packages that provided them.

  - why is meson generating those pkgconfig files, rather than standard
    ones?

  - and finally, if the "relocatable pkgconfig files" generated by meson
    are incorrect wrt the pkgconfig spec, can we tell meson not to do
    that?

This should be answered with explanations in the commit log, rather than
providing reviewers with an elusive and confusing "appear to not be
getting set correctly" without research and explanations...

Regards,
Yann E. MORIN.
Nicolas Cavallari Jan. 11, 2023, 5:35 p.m. UTC | #5
On 11/01/2023 17:44, Yann E. MORIN wrote:
> Nicolas, James, All,
> 
> On 2023-01-11 17:01 +0100, Nicolas Cavallari spake thusly:
>> On 11/01/2023 16:19, Romain Naour wrote:
>>> Le 28/07/2022 à 03:44, James Hilliard a écrit :
>>>> These appear to not be getting set correctly and are needed when using
>>>> meson's relocatable pkgconfig format.
>>> How this cmake file (toolchainfile.cmake.in) is used by a meson package ?
>> I understand it as "a cmake package needs this to use a pkgconfig file
>> generated by a meson package when meson is configured to generate
>> relocatable pkgconfig files".
> 
> OK, but then I have a few questions:
> 
>    - what are "relocatable pkgconfig files", and how do they fit in the
>      pkgconfig spec? >
>    - how do they differ from standard pkgconfig files? By "standard", I
>      mean all the pkgconfig files we currently install and use from the
>      hundreds, if not thousands, of packages that provided them.

Reading the meson's source, they are merely standard pkgconfig files 
that use the ${pcfiledir} variable to define paths instead of hardcoding 
a prefix. These are not specific to meson and are supported by 
pkg-config. (It happen that some of our private packages uses that trick 
too, and they are not meson packages)

>    - why is meson generating those pkgconfig files, rather than standard
>      ones?

Because patch 2/2 tells it to.

>    - and finally, if the "relocatable pkgconfig files" generated by meson
>      are incorrect wrt the pkgconfig spec, can we tell meson not to do
>      that?

They are not incorrect.  From experience, autotools and meson packages 
handles them fine. cmake however, according to the commit message, does 
not and needs some extra variables.
Yann E. MORIN Jan. 11, 2023, 6:36 p.m. UTC | #6
Nicolas, James, All,

On 2023-01-11 18:35 +0100, Nicolas Cavallari spake thusly:
> On 11/01/2023 17:44, Yann E. MORIN wrote:
> >On 2023-01-11 17:01 +0100, Nicolas Cavallari spake thusly:
> >>On 11/01/2023 16:19, Romain Naour wrote:
> >>>Le 28/07/2022 à 03:44, James Hilliard a écrit :
> >>>>These appear to not be getting set correctly and are needed when using
> >>>>meson's relocatable pkgconfig format.
> >>>How this cmake file (toolchainfile.cmake.in) is used by a meson package ?
> >>I understand it as "a cmake package needs this to use a pkgconfig file
> >>generated by a meson package when meson is configured to generate
> >>relocatable pkgconfig files".
> >
> >OK, but then I have a few questions:
> >
> >   - what are "relocatable pkgconfig files", and how do they fit in the
> >     pkgconfig spec? >
> >   - how do they differ from standard pkgconfig files? By "standard", I
> >     mean all the pkgconfig files we currently install and use from the
> >     hundreds, if not thousands, of packages that provided them.
> 
> Reading the meson's source, they are merely standard pkgconfig files that
> use the ${pcfiledir} variable to define paths instead of hardcoding a
> prefix. These are not specific to meson and are supported by pkg-config. (It
> happen that some of our private packages uses that trick too, and they are
> not meson packages)

That. It has nothing meson specific, in fact. It just happens that meson
is the only tool that generates .pc files with pcfiledir, and pcfiledir
is not widely used either (we've never had a related issue so far, have
we?) (and no, private tools and packages do not count! ;-] )

> >   - why is meson generating those pkgconfig files, rather than standard
> >     ones?
> Because patch 2/2 tells it to.

Ah, yes, I just replied to that second patch too, now. If a change is
needed in preparation of another one, then it should be mentioned (with
an abridged explanation of the problem that will be fixed in that later
change, if possible). And a cover letter that explains the whole picture
is more than welcome, too.

> >   - and finally, if the "relocatable pkgconfig files" generated by meson
> >     are incorrect wrt the pkgconfig spec, can we tell meson not to do
> >     that?
> They are not incorrect.  From experience, autotools and meson packages
> handles them fine. cmake however, according to the commit message, does not
> and needs some extra variables.

Yes, this makes so much more sense now: it is a cmake issue first and
foremost, that is exposed by .pc files generated by meson. Thanks for
the explanations!

James, can you respin this one patch with all this discussion nicely
aggregated and reformatted as a proper commit log, please?

Regards,
Yann E. MORIN.
diff mbox series

Patch

diff --git a/support/misc/toolchainfile.cmake.in b/support/misc/toolchainfile.cmake.in
index 5d2b8695b4..2c6adfd02d 100644
--- a/support/misc/toolchainfile.cmake.in
+++ b/support/misc/toolchainfile.cmake.in
@@ -91,6 +91,12 @@  endif()
 if(NOT DEFINED CMAKE_FIND_ROOT_PATH_MODE_INCLUDE)
   set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
 endif()
+if(NOT DEFINED PKG_CONFIG_USE_CMAKE_PREFIX_PATH)
+  set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON)
+endif()
+if(NOT DEFINED CMAKE_PREFIX_PATH)
+  set(CMAKE_PREFIX_PATH "${RELOCATED_HOST_DIR}/@@STAGING_SUBDIR@@/usr")
+endif()
 set(ENV{PKG_CONFIG_SYSROOT_DIR} "${RELOCATED_HOST_DIR}/@@STAGING_SUBDIR@@")
 
 # This toolchain file can be used both inside and outside Buildroot.