# Pass argument directly to the compiler

**URL:** <https://discourse.cmake.org/t/pass-argument-directly-to-the-compiler/1181>\
**Category:** Code\
**Created:** [May 11, 2020, 4:48pm UTC](https://discourse.cmake.org/t/pass-argument-directly-to-the-compiler/1181 "2020-05-11T16:48:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![developer](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/bcef8e/32.png) [@developer](https://discourse.cmake.org/u/developer)\
**Post date:** [May 11, 2020, 4:48pm UTC](https://discourse.cmake.org/t/pass-argument-directly-to-the-compiler/1181/1 "2020-05-11T16:48:56Z")

</div>

Effectively, I want to pass the actual compiler as an argument to my stub compiler.  
Having the `CMAKE_CXX_COMPILER` variable set by a toolchain file previously, I would like to do

```auto
set(CMAKE_CXX_COMPILER "/usr/bin/imposter ${CMAKE_CXX_COMPILER}")

```

However, when I go to make the actual targets, I get errors like

```auto
/bin/sh: 1: $(/usr/bin/imposter /usr/bin/g++): not found

```

This is because the `CMAKE_CXX_COMPILER` is getting passed as an explicit string, meaning sh is thinking that `"/usr/bin/imposter /usr/bin/g++"` is the whole command, rather than `/usr/bin/imposter` with an argument of `/usr/bin/g++`, which is what I want. Any ideas?

---

<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:** [May 11, 2020, 5:15pm UTC](https://discourse.cmake.org/t/pass-argument-directly-to-the-compiler/1181/2 "2020-05-11T17:15:17Z")

</div>

I think you probably want `CMAKE_CXX_COMPILER_LAUNCHER` instead ([https://cmake.org/cmake/help/latest/variable/CMAKE\_LANG\_COMPILER\_LAUNCHER.html](https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_LAUNCHER.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:** [May 11, 2020, 5:15pm UTC](https://discourse.cmake.org/t/pass-argument-directly-to-the-compiler/1181/3 "2020-05-11T17:15:46Z")

</div>

Though using `;` instead of a space may also work.

---

<div class="post-metadata">

**Author:** ![developer](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/bcef8e/32.png) [@developer](https://discourse.cmake.org/u/developer)\
**Post date:** [May 11, 2020, 5:24pm UTC](https://discourse.cmake.org/t/pass-argument-directly-to-the-compiler/1181/4 "2020-05-11T17:24:58Z")

</div>

Using `;` didn’t work.  
But setting `set(CMAKE_CXX_COMPILER_LAUNCHER "/usr/bin/imposter")` did work!  
Thank you!
