[CMake] Determine the directory to install package config and version files (like /usr/lib/cmake)

Craig Scott craig.scott at crascit.com
Sun Jun 17 00:52:39 EDT 2018


On Sun, Jun 17, 2018 at 11:15 AM, Daniel Wyatt <daniel.wyatt at gmail.com>
wrote:

> Is there a way to determine this directory?
>
> Right now I have something like:
> ${CMAKE_INSTALL_LIBDIR}/cmake/<project-name>/something-version.cmake
>
> On CentOS 7 w/cmake3, however, this should be /usr/lib/cmake3/...
>
> Obviously I can just check to see if this directory exists and then fall
> back,
> but I'm wondering if there is a bultin variable to retrieve this (I've
> looked, but no luck so far).
>

CMake does not require one specific location, it searches quite a few
locations. It is up to the project where it installs to, but I'd normally
recommend the place you are already using (${CMAKE_INSTALL_LIBDIR}/cmake/
<project-name>/). Have a look here for the full list (scroll down to the
list of directories starting with <prefix>/...):

https://cmake.org/cmake/help/latest/command/find_package.html

The only thing I could find that referred to a .../cmake3/ location was the
cmake3 package from epel, which I assume they do to avoid clashing with the
default cmake package. Personally, I'd consider that to be wrong behavior
though since CMake won't be searching that location by default (unless they
patched their cmake3 executable to search there as well, but still it's not
ideal).


-- 
Craig Scott
Melbourne, Australia
https://crascit.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180617/1f47333d/attachment.html>


More information about the CMake mailing list