Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(cmake): improve pkg-config generation #3252

Merged
merged 1 commit into from
Sep 20, 2022

Conversation

Tachi107
Copy link
Contributor

@Tachi107 Tachi107 commented Aug 28, 2022

With this patch the pkg-config generation when using the CMake build
system is improved in the following ways:

  • Libs.private is now filled when needed
  • The JoinPaths module is now used to join paths, leading to simpler code
  • The .pc file is always generated, regardless of the platform, as it can also be consumed on Windows

Here's how the .pc file is affected by these changes, in comparison to the one generated with the official Makefiles:

$ diff -s lib/libzstd.pc build/cmake/build-old/lib/libzstd.pc
15c15
< Libs.private: -pthread
---
> Libs.private:

$ diff -s lib/libzstd.pc build/cmake/build-new/lib/libzstd.pc
Files lib/libzstd.pc and build/cmake/build-new/lib/libzstd.pc are
identical

With this patch the pkg-config generation when using the CMake build
system is improved in the following ways:

- Libs.private is now filled when needed
- The JoinPaths module is now used to join paths, leading to simpler
  code
- The .pc file is always generated, regardless of the platform, as it
  can also be consumed on Windows

Here's how the .pc file is affected by these changes, in comparison to
the one generated with the official Makefiles:

    $ diff -s lib/libzstd.pc build/cmake/build-old/lib/libzstd.pc
    15c15
    < Libs.private: -pthread
    ---
    > Libs.private:

    $ diff -s lib/libzstd.pc build/cmake/build-new/lib/libzstd.pc
    Files lib/libzstd.pc and build/cmake/build-new/lib/libzstd.pc are
    identical
@Cyan4973
Copy link
Contributor

This looks good to me.

It reminds me, it's a bit regrettable that we don't seem to have good CI tests for pkg-config generation, that would avoid potential future regressions from future contributions. Though that's a concern legitimately outside of the scope of this PR.

@Tachi107
Copy link
Contributor Author

Tachi107 commented Sep 20, 2022

Maybe something like simdjson/simdjson#1767 (comment) ?

@Cyan4973
Copy link
Contributor

Maybe something like simdjson/simdjson#1767 (comment) ?

Yes, something like that

@Cyan4973 Cyan4973 merged commit 1c04514 into facebook:dev Sep 20, 2022
@Tachi107 Tachi107 deleted the build-cmake-pkg-config-always branch September 20, 2022 19:21
Tachi107 added a commit to Tachi107/zstd that referenced this pull request Sep 20, 2022
As mentioned in
facebook#3252 (comment) ,
this patch adds a CI job that builds and installs libzstd on the job
runner, and then compiles a sample binary linking against the installed
library; the needed build flags are passed by invoking pkg-config.
Tachi107 added a commit to Tachi107/zstd that referenced this pull request Sep 20, 2022
As mentioned in
facebook#3252 (comment) ,
this patch adds a CI job that builds and installs libzstd on the job
runner, and then compiles a sample binary linking against the installed
library; the needed build flags are passed by invoking pkg-config.
Tachi107 added a commit to Tachi107/zstd that referenced this pull request Sep 20, 2022
As mentioned in
facebook#3252 (comment) ,
this patch adds a CI job that builds and installs libzstd on the job
runner, and then compiles a sample binary linking against the installed
library; the needed build flags are passed by invoking pkg-config.
@Cyan4973 Cyan4973 mentioned this pull request Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants