title: How to force CMake to use linker instead of compiler during linking
body: <p>I'm using CMake with the TI compiler (<code>cl6x</code>). The goal is to create a shared object. The compiler is used correctly to create object files, but during linking, CMake defaults to using the compiler (<code>cl6x</code>) to combine all object files into one binary.</p>
  
  <pre><code>cl6x    -shared -Wl,-soname,libwhatever.so -o libwhatever.so CMakeFiles/whatever.dir/__/whatever.c.o
  </code></pre>
  
  <p>While this is fine with <code>gcc</code>, in this case, I require a call to <code>lnk6x</code> instead. </p>
  
  <p>I use <code>add_library(whatever SHARED ${whatever_srcs})</code> to generate the <code>*.so</code>. I also set:</p>
  
  <pre><code>set(CMAKE_LINKER "path/to/lnk6x")
  set(CMAKE_C_LINK_EXECUTABLE "&lt;CMAKE_LINKER&gt; &lt;FLAGS&gt; &lt;CMAKE_C_LINK_FLAGS&gt; &lt;LINK_FLAGS&gt; &lt;OBJECTS&gt; -o &lt;TARGET&gt; &lt;LINK_LIBRARIES&gt;")
  </code></pre>
  
  <p>And I issue:</p>
  
  <pre><code>cmake .. -DCMAKE_C_COMPILER=cl6x -DCMAKE_SYSTEM_NAME=Generic 
  </code></pre>
  
  <p>Short of issuing a custom command, is there a way around this?</p>