Pass argument directly to the compiler

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

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

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

/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?

I think you probably want CMAKE_CXX_COMPILER_LAUNCHER instead (https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_LAUNCHER.html).

Though using ; instead of a space may also work.

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