title: Why does CMake ignore exported CXX and CC environment variables?
body: <p>I am running a CMake (3.4.3) like this as explained in the <a href="https://cmake.org/Wiki/CMake_FAQ#How_do_I_use_a_different_compiler.3F" rel="noreferrer">CMake FAQ's</a>:</p>
  
  <pre><code>export CC="cc_args.py $PWD/../bin/gcc"
  export CXX="cc_args.py $PWD/../bin/g++"
  cmake -DCMAKE_BUILD_TYPE=Debug ..
  </code></pre>
  
  <p>However when I print <code>CMAKE_CXX_COMPILER</code> and <code>CMAKE_C_COMPILER</code> it still points to the system's default compilers in <code>/usr/bin</code>. It only works when I explicitly read-in the environment variables like this:</p>
  
  <pre><code>IF (NOT $ENV{CC} STREQUAL "")
    SET(CMAKE_C_COMPILER $ENV{CC})
  ENDIF ()
  IF (NOT $ENV{CXX} STREQUAL "")
    SET(CMAKE_CXX_COMPILER $ENV{CXX})
  ENDIF ()
  </code></pre>
  
  <p>But even then the building fails with this message:</p>
  
  <pre><code>/bin/sh: 1: /home/peterg/bin/cc_args.py /home/peterg/Code/build/../bin/g++: not found
  </code></pre>
  
  <p>However I am certain that all paths are correct since executing just the path between the two colons outputs this as expected:</p>
  
  <pre><code>g++: fatal error: no input files
  compilation terminated.
  </code></pre>
  
  <h3>Update:</h3>
  
  <p>It seems the compiling process does not like spaces in the compiler paths. I've now created two scripts (one for GCC and one for CC) which wrap the commands and propagate the arguments and that seems to work. But it still seems I am doing something fundamentally wrong because CMake would also not accept the exported <code>CC=proxy_script_cc.sh</code> and <code>GCC=proxy_script_gcc.sh</code> variables without spaces by itself.</p>