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

pkg-config file #926

Open
amirouche opened this issue Apr 16, 2019 · 8 comments
Open

pkg-config file #926

amirouche opened this issue Apr 16, 2019 · 8 comments

Comments

@amirouche
Copy link

NNG & Platform details.

GNU Linux

Expected Behavior

The build system install a pkg-config .pc file somewhere

Actual Behavior

No .pc is installed

Steps to Reproduce

  $ mkdir build
  $ cd build
  $ cmake -G Ninja ..
  $ ninja
  $ ninja test
  $ ninja install
@gdamore
Copy link
Contributor

gdamore commented Apr 16, 2019

I switched to CMake a while ago. I haven't had a chance to reinvestigate pkg-config, which needs to be populated with the specifics of where the package is installed.

@amirouche amirouche changed the title pkg-config config pkg-config file Apr 16, 2019
@xfbs
Copy link

xfbs commented Aug 1, 2019

A pkg-config file would be pretty useful for me too. Do you want me to pop one in and send you a pull request?

@xueruini
Copy link

xueruini commented Aug 2, 2019

We created a pc file internally for easy development.

@gdamore
Copy link
Contributor

gdamore commented Dec 28, 2020

Its funny that grousing around I couldn't find any standard way to set this up from cmake. How disappointing.

It's not sufficient to just record the location of the nng library and header tree -- you also need to record dependencies if the installation was static.

Of course, if you're using a static library, you probably should just download the library yourself in your own project tree, rather than relying upon a system installation -- I'm assuming that a system installation is more useful with shared libraries.

@tlsa
Copy link

tlsa commented Jan 9, 2024

I was going to request this, but found this existing issue already here. Can anything be done about it?

I just found this:
https://discourse.cmake.org/t/how-to-generate-pc-pkg-config-file-supporting-prefix-of-the-cmake-install/4109/9

@gdamore
Copy link
Contributor

gdamore commented Dec 27, 2024

I found this :

# this template is filled-in by CMake `configure_file(... @ONLY)`
# the `@....@` are filled in by CMake configure_file(), 
# from variables set in your CMakeLists.txt or by CMake itself
#
# Good tutoral for understanding .pc files: 
# https://people.freedesktop.org/~dbn/pkg-config-guide.html

prefix="@CMAKE_INSTALL_PREFIX@"
exec_prefix="${prefix}"
libdir="${prefix}/lib"
includedir="${prefix}/include"

Name: @PROJECT_NAME@
Description: @CMAKE_PROJECT_DESCRIPTION@
URL: @CMAKE_PROJECT_HOMEPAGE_URL@
Version: @PROJECT_VERSION@
Requires: @pc_req_public@
Requires.private: @pc_req_private@
Cflags: -I"${includedir}"
Libs: -L"${libdir}" -l@target1@ -l@target2@
Libs.private: -L"${libdir}" -l@target1@ -l@target2@ @pc_libs_private@

Some thinking that the libdir needs tweaking as well:

libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@

Anyway there might be hope here.

@gdamore
Copy link
Contributor

gdamore commented Dec 27, 2024

Well, after a couple of hours, I've discovered that cmake doesn't have good support for this at all. Essentially we cannot automatically generate the transitive dependencies using "modern" cmake, because it doesn't understand how to expand targets like Thread::threads or whatever, when doing configure_file().

With a variety of optional dependencies, its sufficiently problematic that I don't want to do it.

Meson does have a pkg-config generator.

I'm leaning more and more towards meson.

@gdamore
Copy link
Contributor

gdamore commented Jan 2, 2025

I'm going to leave this open for now, but with a help-wanted label. If someone has some brilliant solution to this problem, I'd love to hear it.

The reality is that pkg-config is not very portable and has a bunch of problems. Cmake also has problems, but it has fewer of them then pkg-config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants