Namespace concept for CMakeLists.txt


I am trying to understand some CMakeLists.txt made in the company where I work, and there are some calls to non-standard functions. They’re actually defined somewhere, in a Git submodule, trough very indirect ways. And so it was difficult to find their definition.

Is there in CMake a way to mimic to C++ namespaces, by prefixing the functions calls, so that it would be easier to localize their definition ?


Functions have global scope in CMake. There’s this proposal for project-level namespaces, but currently namespace-level functions are not part of that proposal.

Would you have a method to suggest to avoid to have to search a function definition for some hours ?..
Are there good practices ?

Frankly, use a modern IDE and simply Ctrl+click the function name, which should take you to its definition. Otherwise, grep for a regular expression like function *\(someName or similar.

If there are shenanigans going on configuring with --trace-expand will allow for grep reliably.

1 Like

How can I find the definition of a user-defined CMake function using CMake?

1 Like