# Adhere to the rules stipulated in 'cmake-developer' or those in 'find\_package' for Find modules?

**URL:** <https://discourse.cmake.org/t/adhere-to-the-rules-stipulated-in-cmake-developer-or-those-in-find-package-for-find-modules/10053>\
**Category:** Code\
**Created:** [February 11, 2024, 10:00am UTC](https://discourse.cmake.org/t/adhere-to-the-rules-stipulated-in-cmake-developer-or-those-in-find-package-for-find-modules/10053 "2024-02-11T10:00:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hwhsu1231](https://discourse.cmake.org/user_avatar/discourse.cmake.org/hwhsu1231/32/5358_2.png) [@hwhsu1231](https://discourse.cmake.org/u/hwhsu1231)\
**Post date:** [February 11, 2024, 10:00am UTC](https://discourse.cmake.org/t/adhere-to-the-rules-stipulated-in-cmake-developer-or-those-in-find-package-for-find-modules/10053/1 "2024-02-11T10:00:34Z")

</div>

Hello, CMake Team.

Recently, while writing my own Find module, I encountered a point of confusion:

> _Should I adhere to the rules stipulated in cmake-developer or those in find\_package for Find modules?_

In the cmake-developer manual ([Standard Variable Names](https://cmake.org/cmake/help/v3.28/manual/cmake-developer.7.html#standard-variable-names)), it is specified that we should provide certain variables in Find modules. For example:

- `Xxx_INCLUDE_DIRS`
- `Xxx_LIBRARIES`
- `Xxx_EXECUTABLE`
- …etc

However, at the same time, I saw in the find\_package manual ([Package File Interface Variables](https://cmake.org/cmake/help/v3.28/command/find_package.html#package-file-interface-variables)) that we are required to provide another format of variables. For example:

- `CMAKE_FIND_PACKAGE_NAME`
- `<PackageName>_FIND_REQUIRED`
- `<PackageName>_FIND_QUIETLY`
- …etc

Or is it that our Find modules should provide variables in both formats?

---

<div class="post-metadata">

**Author:** ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Post date:** [February 11, 2024, 6:26pm UTC](https://discourse.cmake.org/t/adhere-to-the-rules-stipulated-in-cmake-developer-or-those-in-find-package-for-find-modules/10053/2 "2024-02-11T18:26:41Z")

</div>

> [@hwhsu1231](#):
>
> However, at the same time, I saw in the find\_package manual ([Package File Interface Variables](https://cmake.org/cmake/help/v3.28/command/find_package.html#package-file-interface-variables)) that we are required to provide another format of variables.

This Variables are set from `find_package` and are used in `exported cmake config packages`.

---

<div class="post-metadata">

**Author:** ![hwhsu1231](https://discourse.cmake.org/user_avatar/discourse.cmake.org/hwhsu1231/32/5358_2.png) [@hwhsu1231](https://discourse.cmake.org/u/hwhsu1231)\
**Post date:** [February 12, 2024, 10:21am UTC](https://discourse.cmake.org/t/adhere-to-the-rules-stipulated-in-cmake-developer-or-those-in-find-package-for-find-modules/10053/3 "2024-02-12T10:21:08Z")

</div>

@ClausKlein

> This Variables are set from `find_package`

So these interface variables mentioned in find\_package manual ([Package File Interface Variables](https://cmake.org/cmake/help/v3.28/command/find_package.html#package-file-interface-variables)) are set “automatically” when calling `find_package` in config mode.

> and are used in `exported cmake config packages` .

And after `find_package` sets these interface variables, those config files (`<PackageName>Config.cmake`, `<PackageName>ConfigVersion.cmake`…etc) will do something based these interface variables.

Is that what you mean?

Then, what about module mode? If we call `find_package` in module mode, which means using Find modules, will these interface variables work in Find modules as well?

---

<div class="post-metadata">

**Author:** ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Post date:** [February 12, 2024, 11:14am UTC](https://discourse.cmake.org/t/adhere-to-the-rules-stipulated-in-cmake-developer-or-those-in-find-package-for-find-modules/10053/4 "2024-02-12T11:14:54Z")

</div>

It may help to inspect a simple example like [FindZLIB.cmke](https://cmake.org/cmake/help/v3.28/module/FindZLIB.html)

---

<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:** [February 17, 2024, 6:12am UTC](https://discourse.cmake.org/t/adhere-to-the-rules-stipulated-in-cmake-developer-or-those-in-find-package-for-find-modules/10053/5 "2024-02-17T06:12:09Z")

</div>

> [@hwhsu1231](#):
>
> - `CMAKE_FIND_PACKAGE_NAME`
> - `<PackageName>_FIND_REQUIRED`
> - `<PackageName>_FIND_QUIETLY`
> - …etc

These are _inputs_ to your Find module code to know what variables were passed by the calling `find_package`.

> [@hwhsu1231](#):
>
> - `Xxx_INCLUDE_DIRS`
> - `Xxx_LIBRARIES`
> - `Xxx_EXECUTABLE`
> - …etc

These are variables your Find module sets to communicate what was found.
