title: How to use a different compiler with CMake (IAR)?
body: <p>I've noticed that CMake is installed with numerous modules such as the IAR compiler: </p>
  
  <p><a href="https://github.com/Kitware/CMake/blob/master/Modules/Compiler/IAR.cmake" rel="nofollow noreferrer">https://github.com/Kitware/CMake/blob/master/Modules/Compiler/IAR.cmake</a></p>
  
  <p>In a previous question I asked how to load this particular module. The answer was just to add: </p>
  
  <pre><code>set(CMAKE_C_COMPILER iccarm.exe) 
  </code></pre>
  
  <p>on my <code>CMakeLists.txt</code>. </p>
  
  <p>Unfortunately I noticed, this is not enough because the <code>IAR.cmake</code> is never really used. With the following <code>CMakeLists.txt</code>: </p>
  
  <pre><code>cmake_minimum_required(VERSION 3.6)
  
  set(CMAKE_SYSTEM_NAME Generic)
  set(CMAKE_SYSTEM_PROCESSOR arm)
  
  set(CMAKE_C_COMPILER iccarm.exe)
  
  set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
  set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
  set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
  set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
  
  list(APPEND src src/main.c)
  
  project("foo" C)
  
  add_executable(foo ${src})
  
  message(STATUS "IARARM_CMAKE_LOADED=${_IARARM_CMAKE_LOADED}")
  message(STATUS "IAR CMAKE_C_COMPILE_OBJECT=${CMAKE_C_COMPILE_OBJECT}")
  </code></pre>
  
  <p>I get this output: </p>
  
  <pre><code>-- The C compiler identification is IAR
  -- Check for working C compiler: C:/Program Files (x86)/IAR Systems/Embedded Workbench 8.0/arm/bin/iccarm.exe
  -- Check for working C compiler: C:/Program Files (x86)/IAR Systems/Embedded Workbench 8.0/arm/bin/iccarm.exe -- works
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- IARARM_CMAKE_LOADED=
  -- IAR CMAKE_C_COMPILE_OBJECT=&lt;CMAKE_C_COMPILER&gt; &lt;SOURCE&gt; &lt;DEFINES&gt; &lt;INCLUDES&gt; &lt;FLAGS&gt; -o &lt;OBJECT&gt;
  -- Configuring done
  -- Generating done
  -- Build files have been written to: C:/Users/Ycr/Home/sandbox/cmake
  </code></pre>
  
  <p>Where <code>IARARM_CMAKE_LOADED</code> isn't defined and <code>CMAKE_C_COMPILE_OBJECT</code> doesn't have the <code>--silent</code> option defined <a href="https://github.com/Kitware/CMake/blob/master/Modules/Compiler/IAR.cmake" rel="nofollow noreferrer">here</a> </p>
  
  <p>How can I tell CMake to use the IAR Module?</p>