# Namespace concept for CMakeLists.txt

**URL:** <https://discourse.cmake.org/t/namespace-concept-for-cmakelists-txt/9491>\
**Category:** Code\
**Created:** [November 23, 2023, 10:24am UTC](https://discourse.cmake.org/t/namespace-concept-for-cmakelists-txt/9491 "2023-11-23T10:24:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oodini](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/o/db5fbb/32.png) [@Oodini](https://discourse.cmake.org/u/Oodini)\
**Post date:** [November 23, 2023, 10:24am UTC](https://discourse.cmake.org/t/namespace-concept-for-cmakelists-txt/9491/1 "2023-11-23T10:24:48Z")

</div>

Hello,

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 ?

Thanks.

---

<div class="post-metadata">

**Author:** ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)\
**Post date:** [November 23, 2023, 9:26pm UTC](https://discourse.cmake.org/t/namespace-concept-for-cmakelists-txt/9491/2 "2023-11-23T21:26:17Z")

</div>

Functions have global scope in CMake. There’s [this proposal](https://gitlab.kitware.com/cmake/cmake/-/issues/22687) for project-level namespaces, but currently namespace-level functions are not part of that proposal.

---

<div class="post-metadata">

**Author:** ![Oodini](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/o/db5fbb/32.png) [@Oodini](https://discourse.cmake.org/u/Oodini)\
**Post date:** [November 23, 2023, 9:46pm UTC](https://discourse.cmake.org/t/namespace-concept-for-cmakelists-txt/9491/3 "2023-11-23T21:46:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)\
**Post date:** [November 23, 2023, 10:07pm UTC](https://discourse.cmake.org/t/namespace-concept-for-cmakelists-txt/9491/4 "2023-11-23T22:07:25Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [November 23, 2023, 10:40pm UTC](https://discourse.cmake.org/t/namespace-concept-for-cmakelists-txt/9491/5 "2023-11-23T22:40:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![starball](https://discourse.cmake.org/user_avatar/discourse.cmake.org/starball/32/3437_2.png) [@starball](https://discourse.cmake.org/u/starball)\
**Post date:** [November 30, 2023, 2:57am UTC](https://discourse.cmake.org/t/namespace-concept-for-cmakelists-txt/9491/6 "2023-11-30T02:57:22Z")

</div>

[How can I find the definition of a user-defined CMake function using CMake?](https://stackoverflow.com/q/76476028/11107541)
