2

I have a custom (complex) Find-cmake module. Everything works just fine.

My problem is that i need this find-module in many projects to detect my libraray (like the QT cmake stuff).

Is it possible to install my module in a central directory where i can "find" it?

I know that i have to set the CMAKE_MODULE_PATH to the directory, but for a central install location this approach seems to be strange.

So what is the preferred way to use a find module in multiple projects?

Michael Aigner
  • 4,820
  • 4
  • 21
  • 33
  • As far as I know, there is no "central directory" for `Find` modules. If some project needs a module which is absent in cmake installation, the project itself should be shipped with this module. As a workaround on concrete machine, you may add your `Find` module to directory with modules installed with CMake itself. On Linux this directory is `/usr/share/cmake/Modules`. – Tsyvarev Mar 24 '16 at 07:41
  • See [Making cmake library accessible by other cmake packages automatically](http://stackoverflow.com/questions/33462209/making-cmake-library-accessible-by-other-cmake-packages-automatically) – Florian Mar 24 '16 at 15:17

1 Answers1

2

Actually there is a registry for CMake packages:

https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#user-package-registry

Note that I never used it, because where I work we do both compilation and cross-compilation on the same box, thus we have to have different cmake files

Dimitri Merejkowsky
  • 1,001
  • 10
  • 12
  • it seems that only config.cmake files works with that. Can you tell me how to map my Find...cmake into the config file!? – Michael Aigner Mar 24 '16 at 15:32
  • 1
    @tonka: Main difference between `Find` and `Config` scripts is that the last one needn't to use `find_library` and other `find_*` commands: it just sets corresponded variables to concrete values. At the end `Config` script should set `_FOUND` variable manually. BTW, the [page](https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html) referred in the answer also describes creation aspects of packaging. – Tsyvarev Mar 24 '16 at 19:33