[CMake] lib/cmake vs share/cmake/Modules

44ghnqv8rg at snkmail.com 44ghnqv8rg at snkmail.com
Tue Feb 10 05:43:33 EST 2015


Alexander Neundorf wrote at 21:34 +0100 on Feb  9, 2015:
 > On Monday, February 09, 2015 18:23:41 44ghnqv8rg at snkmail.com wrote:
 > > How does one who is making a package which installs .cmake files
 > > decide whether to put them in .../share/cmake/Modules or
 > > .../lib/cmake?  Where are the docs about that?  I've seen
 > > examples of 3rd party packages doing both (e.g., pulseaudio in
 > > lib/cmake/Foo & opencollada - in share/cmake/Modules).
 >
 > architecture-independent files, i.e. which could sit on a shared
 > NFS drive and which could be mounted from hosts with any type of
 > CPU architecture, go into share/, i.e. basically data or text
 > files.  Files which are architecture dependend, e.g. Config.cmake
 > files for installed libraries, go into lib/.  (in doubt, lib/ is
 > the safe choice).

I'm looking for official cmake docs that explain the difference
between the two locations from cmake's perspective (rather than
just guidelines reiterated from hier(7)).

Clearly .cmake files are architecture independent - there's no
arch-dependent compiled binary version of a .cmake file (at least not
yet).  Based on the generic hints of hier(7), they should all be in
share/cmake.  But cmake supports (and encourages in cmake-packages(7))
package config files in lib/cmake.

The docs for find_package in cmake-commands(7) describe the search
hierarchy - it searches lib/cmake and share/cmake (at least on the
unix-ish platforms) - but doesn't say why package files might be in
either location.

Note there exist now some config .cmake files in share/cmake and some
in lib/cmake (as in the example cases I pointed out in the original
post).

The cmake project itself surely must have some policy written
somewhere that describes what goes in each location.  I just haven't
found it yet.

Or perhaps a lack of guidance has led to packagers picking either
place without clear consensus and thus has led to some fragmentation.
I'd also like to hear those opinions if people think that's the case.


More information about the CMake mailing list