CMake: Where to install FooBarConfig.cmake and Foo

2019-06-12 01:25发布

问题:

Let be a library A that I compile with CMake. I also want to distribute it via a package (e.g. RPM).

Where should my package install the files AConfig.cmake and AConfigVersion.cmake ?

In /usr/share/cmake/Modules on Linux ?

回答1:

You should find what you need here:

http://www.cmake.org/Wiki/CMake/Tutorials/Packaging

With the relevant portion of the text:

Consider a project "Foo" that installs the following files:

  • <prefix>/include/foo-1.2/foo.h
  • <prefix>/lib/foo-1.2/libfoo.a

It may also provide a CMake package configuration file

  • <prefix>/lib/foo-1.2/foo-config.cmake

The config files need the be in your install tree. Only the FindXXX.cmake file should go in the modules directory.