# Passing \`option\`s through to \`find\_package\`

**URL:** <https://discourse.cmake.org/t/passing-option-s-through-to-find-package/4255>\
**Category:** Code\
**Created:** [October 12, 2021, 4:27pm UTC](https://discourse.cmake.org/t/passing-option-s-through-to-find-package/4255 "2021-10-12T16:27:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Barry\_Revzin](https://discourse.cmake.org/user_avatar/discourse.cmake.org/barry_revzin/32/1283_2.png) [@Barry\_Revzin](https://discourse.cmake.org/u/Barry_Revzin)\
**Post date:** [October 12, 2021, 4:27pm UTC](https://discourse.cmake.org/t/passing-option-s-through-to-find-package/4255/1 "2021-10-12T16:27:35Z")

</div>

Let’s say I have a project which wants to use [spdlog](https://github.com/gabime/spdlog), which depends on fmtlib.

The main spdlog CMakeLists.txt has a bunch of `option`s for how to configure it, including `SPDLOG_FMT_EXTERNAL`. Let’s say I:

- want to clone spdlog from source, and
- want to provide my own `fmt` version and then I want to tell spdlog to use that.

What is the right way to write `Findspdlog.cmake` to clone the repo and to set `SPDLOG_FMT_EXTERNAL` so that it does the right thing?

* * *

Or, for a different example of the same idea, we could look at [date](https://github.com/HowardHinnant/date) and the desire to set `BUILD_TZ_LIB` and `USE_SYSTEM_TZ_DB`. How do I write `Finddate.cmake` to do this?

---

<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:** [October 13, 2021, 11:42am UTC](https://discourse.cmake.org/t/passing-option-s-through-to-find-package/4255/2 "2021-10-13T11:42:33Z")

</div>

Since you want to build spdlog from source, I’d personally use [FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html) rather than trying to create a `Findspdlog.cmake`. I don’t know how spdlog expects to find its fmt dependency though. Are you going to have a pre-built fmt available somewhere, or are you building fmt from source as well?

FWIW, if you take the `FetchContent` route, then set the `SPDLOG_FMT_EXTERNAL` variable just before you call `FetchContent_MakeAvailable(spdlog)`. Without looking through the spdlog sources, I think that should probably do what you’re trying to set up.
