title: How to specify a compiler in CMake?
body: <p>I would like to use the IAR compiler. I noticed CMake has already have a bunch of files about this compiler:</p>
  
  <p><a href="https://github.com/jevinskie/cmake/blob/master/Modules/Compiler/IAR.cmake" rel="noreferrer">https://github.com/jevinskie/cmake/blob/master/Modules/Compiler/IAR.cmake</a></p>
  
  <p>From what I read the common solution is to specify manually ALL the toolchain in my <code>CMakeLists.txt</code>:</p>
  
  <pre><code>set(CMAKE_C_COMPILER iccarm)
  set(CMAKE_CPP_COMPILER iccarm)
  </code></pre>
  
  <p>How CMake can link these definitions with `Modules/Compiler/IAR.cmake"?</p>
  
  <p>I thought I would just have to do</p>
  
  <pre><code>include("Modules/Compiler/IAR.cmake")
  </code></pre>
  
  <p>What is the correct way to specify my IAR compiler?</p>
  
  <p>When I do </p>
  
  <pre><code>cmake .
  </code></pre>
  
  <p>It still tries to use <code>gcc</code> instead of my IAR compiler. Why?</p>