Where can a project install its CMake modules when using CPS

This is a follow-up question to Where can a project install its CMake modules

To briefly describe the issue again:

Main project provides CMake modules and configuration that extensions (built as separate projects) need to use. When using package config file(s) this works ok I think and projects then need to find the main package and adjust the CMAKE_MODULE_PATH to have access to main project’s CMake modules.

What about when a project installs CPS? Where and how could this be then resolved? Is it possible to specify some variable in CPS where CMake modules can be loaded from?

Thank you.

@Matthew_Woehlke might have opinions on this one.

Where can a project install its CMake modules when using CPS?

The same place; <datadir>/cmake/<project>. It’s still a CMake module, and presumably it isn’t arch-dependent. (If it is, use <libdir> instead of <datadir>. And, to be fair, you probably won’t get lynched if you just use <libdir> whether or not it’s arch-dependent. :slightly_smiling_face:)

Is it possible to specify some variable in CPS where CMake modules can be loaded from?

Not presently. It’s a known issue, but will require changes to CMake to solve.

1 Like