[mlpack-git] [mlpack/mlpack] pkg-config support? (#777)

Dirk Eddelbuettel notifications at github.com
Sun Sep 4 08:58:08 EDT 2016


I am currently building a small project against MLPACK and its library.  I use standard tools to 'find' where `libmlpack.so` may be installed.  

One solution that has emerged over the years is support for [pkg-config](https://en.wikipedia.org/wiki/Pkg-config).  This seems to have originated from the desktop world but is clearly used in other places.  Take for example [nlopt](http://ab-initio.mit.edu/wiki/index.php/NLopt) which has support:

```bash
edd at max:~$ pkg-config nlopt --cflags       # on Ubuntu, and headers in /usr/include

edd at max:~$ pkg-config nlopt --libs         # ditto, no -L needed
-lnlopt -lm
edd at max:~$ pkg-config nlopt --version      # useful for 'minimal version x.y.z ?' comp.
0.29.1
edd at max:~$ 
```

Getting these results back is way faster and easier than fiddling with `auto*` or `cmake`.  (There are older, one-off variants other projects have, i.e. `gsl-config` is very similar.  I will not name another big project starting with B and ending in oost for its awful alternative ;-) .) 

Here, [nlopt](http://ab-initio.mit.edu/wiki/index.php/NLopt) has [this file](https://github.com/stevengj/nlopt/blob/master/nlopt.pc.in) in its GitHub repo:

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

Name: NLopt
Description: nonlinear optimization libary
Version: @NLOPT_VERSION_STRING@
Libs: -L${libdir} -lnlopt at NLOPT_SUFFIX@ -lm
Cflags: -I${includedir}
```

and this paragraph in its [`CMakeLists.txt`](https://github.com/stevengj/nlopt/blob/master/CMakeLists.txt):

```cmake
# pkgconfig file
if (UNIX OR MINGW)
  configure_file (${CMAKE_CURRENT_SOURCE_DIR}/nlopt.pc.in ${CMAKE_CURRENT_BINARY_DIR}/nlopt.pc @ONLY)
  install (FILES ${CMAKE_CURRENT_BINARY_DIR}/nlopt.pc DESTINATION ${RELATIVE_INSTALL_LIB_DIR}/pkgconfig)
endif ()
```

I haven't `pkg-config`-ified a library myself, but would try to work up a pull request if you like the idea.  
Of course, you being fluent at CMake when I am not it would also be very nice if you just carried this over :)  It looks simple enough, and would be really useful.   Thoughts?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/mlpack/mlpack/issues/777
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20160904/a0b358b8/attachment-0001.html>


More information about the mlpack-git mailing list