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

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

<div class="highlight highlight-source-shell"><pre>edd@max:<span class="pl-k">~</span>$ pkg-config nlopt --cflags       <span class="pl-c"># on Ubuntu, and headers in /usr/include</span>

edd@max:<span class="pl-k">~</span>$ pkg-config nlopt --libs         <span class="pl-c"># ditto, no -L needed</span>
-lnlopt -lm
edd@max:<span class="pl-k">~</span>$ pkg-config nlopt --version      <span class="pl-c"># useful for 'minimal version x.y.z ?' comp.</span>
0.29.1
edd@max:<span class="pl-k">~</span>$ </pre></div>

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

<p>Here, <a href="http://ab-initio.mit.edu/wiki/index.php/NLopt">nlopt</a> has <a href="https://github.com/stevengj/nlopt/blob/master/nlopt.pc.in">this file</a> in its GitHub repo:</p>

<div class="highlight highlight-source-makefile"><pre><span class="pl-smi">prefix</span>=@CMAKE_INSTALL_PREFIX@
<span class="pl-smi">exec_prefix</span>=${prefix}
<span class="pl-smi">libdir</span>=${exec_prefix}/lib
<span class="pl-smi">includedir</span>=${prefix}/include

<span class="pl-en">Name</span>: NLopt
<span class="pl-en">Description</span>: nonlinear optimization libary
<span class="pl-en">Version</span>: @NLOPT_VERSION_STRING@
<span class="pl-en">Libs</span>: -L${libdir} -lnlopt@NLOPT_SUFFIX@ -lm
<span class="pl-en">Cflags</span>: -I${includedir}</pre></div>

<p>and this paragraph in its <a href="https://github.com/stevengj/nlopt/blob/master/CMakeLists.txt"><code>CMakeLists.txt</code></a>:</p>

<div class="highlight highlight-source-cmake"><pre><span class="pl-c"># pkgconfig file</span>
<span class="pl-k">if</span> (<span class="pl-k">UNIX</span> <span class="pl-k">OR</span> MINGW)
  <span class="pl-c1">configure_file</span> (<span class="pl-smi">${CMAKE_CURRENT_SOURCE_DIR}</span>/nlopt.pc.in <span class="pl-smi">${CMAKE_CURRENT_BINARY_DIR}</span>/nlopt.pc @<span class="pl-k">ONLY</span>)
  <span class="pl-c1">install</span> (<span class="pl-k">FILES</span> <span class="pl-smi">${CMAKE_CURRENT_BINARY_DIR}</span>/nlopt.pc <span class="pl-k">DESTINATION</span> <span class="pl-smi">${RELATIVE_INSTALL_LIB_DIR}</span>/pkgconfig)
<span class="pl-k">endif</span> ()</pre></div>

<p>I haven't <code>pkg-config</code>-ified a library myself, but would try to work up a pull request if you like the idea.<br><br>
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?</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/mlpack/mlpack/issues/777">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AJ4bFKbAq-QQI07TWYlknBaK0Hk6cU_pks5qmsBggaJpZM4J0h6y">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFDjrwt6acv2vbwxXaK-eZVS_Ams9ks5qmsBggaJpZM4J0h6y.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/mlpack/mlpack/issues/777"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>

<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/mlpack/mlpack","title":"mlpack/mlpack","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/mlpack/mlpack"}},"updates":{"snippets":[{"icon":"DESCRIPTION","message":"pkg-config support? (#777)"}],"action":{"name":"View Issue","url":"https://github.com/mlpack/mlpack/issues/777"}}}</script>