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

Support for pkg-config #140

Open
Uberoverlord opened this issue May 11, 2023 · 4 comments
Open

Support for pkg-config #140

Uberoverlord opened this issue May 11, 2023 · 4 comments

Comments

@Uberoverlord
Copy link

On Linux, there is not really a standard location for libraries and headers to be. Due to this and gprbuild's apparent inability to dynamically locate these resources, properly packaging software to be compiled with gprbuild often requires hard coding paths (which may be incorrect on many systems, damaging portability) or using a secondary build tool to template in this information before gprbuild (which complicates the build process, hinting at a flaw in gprbuild)

The more or less standard solution to this issue, at least on Linux, is to use pkg-config which can find where these resources for any given library are. I've been unable to find any way that gprbuild is able to use this vital tool however, and it seems much of the ecosystem built atop of gprbuild has been unable to use pkg-config as well (some example packages showing this is an issue within alire would be: tash, gtkada, adasdl). This has lead to the aforementioned problems of damaged portability and over-complicated build processes being common whenever third party libraries are required.

If using pkg-config to dynamically locate these resources is an existing capability, it needs to be documented better so that developers may be able to use it. If it is not, then I would like to have a discussion about how it could be brought into gprbuild because it would greatly improve the quality and experience of using of gprbuild.

@briot
Copy link

briot commented May 12, 2023 via email

@Uberoverlord
Copy link
Author

I think I would personally go with generating your project file on the fly.
So before you run gprbuild, you actually generate the .gpr file from
various pieces of
information, including the output of pkg-config.

This is a solution I am meaning to avoid as then any projects wanting to import the library as a dependency would need to complicate their build process as well to handle the 2 step processes of their dependencies and the complexity only ever bubbles up in this way.
Ideally, libraries should be more "plug and play" than this and one should be able to "with" a library as a dependency to their project and use gprbuild without also writing a makefile or what-have-you because why would they not then just use make or some other alternative given it would reduce dependencies and overall simplify the build process.

@Fabien-Chouteau
Copy link
Member

@Uberoverlord there are plans for pkg-config support in Alire itself, as part of the "external dependency" system.

@carloxff
Copy link

carloxff commented Jun 7, 2024

I had to takle this very same problem, reaching to the following solution. Before calling to gprbuild, I source a bash script that exports an env variable APPINCLUDES containing all necessary include switches extracted from pkg-config. That way, I just had to retrieve and use that information in the compiler section of the gpr file, using external_as_list(APPINCLUDES, " "). That worked fine for me, but I still look forward to getting a native solution from gnat team.

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

No branches or pull requests

4 participants