docopt.cpp icon indicating copy to clipboard operation
docopt.cpp copied to clipboard

Add pkgconfig support

Open mpoquet opened this issue 5 years ago • 3 comments

Hello,

This PR adds the generation of a pkg-config file for docopt when calling make/ninja/etc. install. Merging it should close #68.

In brief, pkg-config eases the utilization of software libraries by allowing the developers of a library to define how the library should be used — instead of letting end users struggling with it. It therefore allows docopt users to link/include it without having to know internal details such as include path or the library name.

Some build systems support the definition of dependencies via pkg-config (e.g., this is the main way to define dependencies in Meson, CMake can use pkg-config dependencies).

I added some fixes over 849e261 (#68) to make it work on non-Debian-based systems.

mpoquet avatar Dec 10 '18 15:12 mpoquet

Would be great to have!

tdegeus avatar Nov 12 '19 17:11 tdegeus

This branch has conflicts and would need rebased. Also, I'd like a couple people who know this technology in order to vouch for the patch (I don't know it personally)

jaredgrubb avatar Nov 27 '19 17:11 jaredgrubb

It seems that the only different w.r.t. the current master are the first two lines

libdir=@CMAKE_INSTALL_FULL_LIBDIR@
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@

I've tried on my system: They new implementation gives a final docopt.pc that reads

libdir=/Users/tdegeus/miniconda3/envs/test/lib
includedir=/Users/tdegeus/miniconda3/envs/test/include

Name: docopt.cpp
Description: C++11 port of docopt
Version: 0.6.2
Libs: -L${libdir} -ldocopt
Cflags: -I${includedir}

In contrast, the old implementation gives

libdir=/Users/tdegeus/miniconda3/envs/test/lib
includedir=/Users/tdegeus/miniconda3/envs/test/include/docopt

Name: docopt.cpp
Description: C++11 port of docopt
Version: 0.6.2
Requires:
Libs: -L${libdir} -ldocopt
Cflags: -I${includedir}

The difference being that with the new implementation one can

#include <docopt/docopt.h>

As one would also do when using CMake.

The old implementation would require

#include <docopt.h>

That being said, the readme is may not entirely clear on this point?

Update

I was wrong about the CMake behaviour. With CMake one should

#include <docopt.h>

@jaredgrubb Can you clarify?

I one in fact should use #include <docopt.h> with CMake, I guess the original pkgconfig behaviour is correct, and this PR should be closed. However, this point should be clarified in the readme.

tdegeus avatar Nov 28 '19 17:11 tdegeus