I created a collection of CMake functions and macros that will be rolled out on our development machines. Our projects should just need to include the collection’s main .cmake file to make use of it.
I had in mind to somehow propagate the collection’s location on the development machines and let the projects call
include() to import this functionality, as its documentation says
Load and run CMake code from a file or module.
But it seems like I cannot make
include() search specific locations other than the current directory, CMake’s module directory and what
CMAKE_MODULE_PATH points to (not in this order). The latter seems like the one to use but it is not available as environment variable (like
find_package()), so the user would need to specify it on the command line for the CMake call. But the user/developer should not need to care about this path.
Is it possible to make CMake aware of such external modules on a machine?
Is this anyways a use case for the
include() call or should I consider to treat my collection as a package? My understanding is that packages provide build dependencies and CMake code should be included.
Or should I consider to deploy my scripts into the CMake installation’s module directory? This doesn’t seem right to me as it makes them look like a part of the CMake distribution.
Atm the closest solution I have would be to retrieve the path from a dedicated environment variable right before the
include() call. But I’m wondering if I could even reach my idea.