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: fix pkg-config file generation #9953

Closed
wants to merge 2 commits into from

Conversation

Tachi107
Copy link
Contributor

@Tachi107 Tachi107 commented May 5, 2022

  • Instead of hardcoding "lib" and "include" in libdir and includedir, use the values from GNUInstallDirs.

  • Use PROJECT_DESCRIPTION and PROJECT_HOMEPAGE_URL instead of their
    CMAKE_ conterparts to fix pkg-config generation when rocksdb is not the top-level project (see project()).

  • Drop explicit CMAKE_CURRENT_SOURCE_DIR and CMAKE_CURRENT_BINARY_DIR in configure_file() as that's implied by default (and quite intuitive).

See #9945
CC: @trynity

@facebook-github-bot
Copy link
Contributor

Hi @Tachi107!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@trynity
Copy link
Contributor

trynity commented May 5, 2022

Ah, thanks for the cleanup! First time trying to generate PC files from CMake, so was bound to get a few things not the cleanest.

@Tachi107 Tachi107 marked this pull request as draft May 5, 2022 17:15
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@Tachi107
Copy link
Contributor Author

Tachi107 commented May 5, 2022

Converted to draft as a few things don't work as expected

Edit: forgot the CMAKE_INSTALL_ prefix for the GNUInstallDirs variables, fixed!

- Instead of hardcoding "lib" and "include" in libdir and includedir,
  use the values from GNUInstallDirs.

- Use PROJECT_DESCRIPTION and PROJECT_HOMEPAGE_URL instead of their
CMAKE_ conterparts to fix pkg-config generation when rocksdb is not the
  top-level project.

- Drop explicit CMAKE_CURRENT_SOURCE_DIR and CMAKE_CURRENT_BINARY_DIR in
  configure_file() as that's implied by default (and quite intuitive).
@Tachi107 Tachi107 marked this pull request as ready for review May 5, 2022 17:17
@tristan957
Copy link

Some of us recently put in the effort to add pkg-config support to HdrHistogram_c which is also CMake-based. From the looks of it, your pkg-config file has a pitfall which was corrected in the HdrHistogram_c repo in this commit: HdrHistogram/HdrHistogram_c@b083efd. You may want to do a similar fix.

@Tachi107
Copy link
Contributor Author

From the looks of it, your pkg-config file has a pitfall which was corrected in the HdrHistogram_c repo in this commit: HdrHistogram/HdrHistogram_c@b083efd.

Hi, thanks for the feedback :)

@jtojnar's JoinPaths.cmake says that Windows is not supported (even though by looking at the code I don't understand why). Fixing generation of pkg-config files when absolute directories are specified at the cost of breaking Windows support doesn't look like a good trade off to me

@tristan957
Copy link

tristan957 commented May 13, 2022

you can just special case Windows to do what you are currently doing.

# invalid since I don't write cmake

if (IS_WINDOWS)
  SET(include_dir_for_pc_file, ${CMAKE_INSTALL_INCLUDEDIR}) 
  SET(libdir_dir_for_pc_file, ${CMAKE_INSTALL_LIBDIR}) 
else
  join_paths(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
  join_paths(libdir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_LIBDIR}")
endif

Are pkg-config files even used on Windows with Windows paths?

@jtojnar
Copy link

jtojnar commented May 13, 2022

@jtojnar's JoinPaths.cmake says that Windows is not supported (even though by looking at the code I don't understand why).

I wrote a bit about it here: jtojnar/cmake-snips#4

TLDR: Windows has two more path types (absolute paths without drive letter and relative paths with drive letter) and I have no idea how it behaves there. Then there is using / as directory separator but that might not actually be an issue.

If you are able to raise minimum CMake version to 3.20, you can replace the custom module with cmake_path(APPEND …), see https://github.com/jtojnar/cmake-snips#concatenating-paths-when-building-pkg-config-files.

@facebook-github-bot
Copy link
Contributor

@jay-zhuang has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@tristan957
Copy link

tristan957 commented May 26, 2022

Shame this got pulled in even though it is broken, imo. Unless imported means something other than merged. Don't really know how this process works.

@Tachi107
Copy link
Contributor Author

Shame this got pulled in even though it is broken, imo.

Still less broken than before :)

It can always be refined afterwards

Copy link
Contributor

@ajkr ajkr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@facebook-github-bot
Copy link
Contributor

@Tachi107 has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@jay-zhuang has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@Tachi107 Tachi107 deleted the cmake-pkg-config-fix branch May 30, 2022 19:48
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

7 participants