# CMAKE\_CXX\_COMPILER\_LAUNCHER=ccache usage question

**URL:** https://discourse.cmake.org/t/cmake-cxx-compiler-launcher-ccache-usage-question/9036
**Category:** Usage
**Created:** [September 21, 2023, 2:41pm UTC](https://discourse.cmake.org/t/cmake-cxx-compiler-launcher-ccache-usage-question/9036 "2023-09-21T14:41:53Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![buildSystemPerson](https://discourse.cmake.org/user_avatar/discourse.cmake.org/buildsystemperson/32/2851_2.png) [@buildSystemPerson](https://discourse.cmake.org/u/buildSystemPerson)
#### Post date: [September 21, 2023, 2:41pm UTC](https://discourse.cmake.org/t/cmake-cxx-compiler-launcher-ccache-usage-question/9036/1 "2023-09-21T14:41:53Z")

</div>

What happens if I set `CMAKE_CXX_COMPILER_LAUNCHER=ccache` and ccache doesn’t exist?

Will CMake error out? Or will CMake just ignore `CMAKE_CXX_COMPILER_LAUNCHER`?

---

<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: [September 24, 2023, 12:42am UTC](https://discourse.cmake.org/t/cmake-cxx-compiler-launcher-ccache-usage-question/9036/2 "2023-09-24T00:42:12Z")

</div>

Configure and generate will succeed, but the build tool will fail with “no such file or directory” when it tries to run `ccache` itself. I’ve run into this multiple times when running CI scripts that set up `sccache` but I don’t inside of containers (as the cache isn’t going to do much once the container disappears).

---

<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: [September 24, 2023, 2:52am UTC](https://discourse.cmake.org/t/cmake-cxx-compiler-launcher-ccache-usage-question/9036/3 "2023-09-24T02:52:57Z")

</div>

I generally protect `set(CMAKE_CXX_COMPILER_LAUNCHER ccache)` with a `find_program(CCACHE_EXECUTABLE ccache)` before it. Depending on the strategy you want to employ, if the `find_program()` call fails, you’d either issue a fatal error or you’d skip setting `CMAKE_CXX_COMPILER_LAUNCHER`.
