title: CMAKE separate Linker and Compiler Flags
body: <p>Right now my <code>toolchain.cmake</code> looks loke this:</p>
  
  <pre><code>CMAKE_FORCE_C_COMPILER(arm-none-eabi-gcc GNU)
  CMAKE_FORCE_CXX_COMPILER(arm-none-eabi-gcc GNU)
  SET(CMAKE_ASM_COMPILER arm-none-eabi-as)
  SET(CMAKE_OBJCOPY arm-none-eabi-objcopy CACHE INTERNAL "objcopy" FORCE)
  SET(CMAKE_OBJDUMP arm-none-eabi-objdump CACHE INTERNAL "objdump" FORCE)
  
  # Compiler Flags 
  SET(MCU_FLAGS "-mcpu=cortex-m3 -mthumb")
  SET(CMAKE_BUILD_FLAGS "-O2 -g -mfpu=vfp -mfloat-abi=soft -Wa,-meabi=5 -ffunction-sections -fno-common -pedantic -Wall -Wextra -Wno-missing-field-initializers")
  SET(CMAKE_C_FLAGS "${MCU_FLAGS} ${CMAKE_BUILD_FLAGS}"  CACHE INTERNAL "c compiler flags")
  SET(CMAKE_CXX_FLAGS ${CMAKE_C_FLAGS} CACHE INTERNAL "cxx compiler flags")
  SET(CMAKE_ASM_FLAGS "-g -mcpu=cortex-m3 -mthumb -mfpu=vfp -mfloat-abi=soft -meabi=5 -warn" CACHE INTERNAL "asm compiler flags")
  
  SET(CMAKE_EXE_LINKER_FLAGS "-mcpu=cortex-m3 -mthumb -Wall -Wextra -Wno-missing-field-initializers -g -nostartfiles -Wl,-T1.ld,-M=1.map,--gc-sections" CACHE INTERNAL "exe link flags")
  </code></pre>
  
  <p>The problem is that CMake passes to the Linker additionally the Compiler-flags! Is there any way to separate these two?</p>
  
  <p>Another thing is if I use another compiler-tool-chain (Like Fujitsu Softtune) how can I tell CMake explicitly to take a Linker and not the compiler to Link objects?</p>
  
  <p>Thanks</p>
  
  <hr>
  
  <p>So i finally solved it. for evryone else with the same problem, i changed CMakelists as follow:</p>
  
  <pre><code>add_executable(${PROJECT_NAME} ${PROJECT_SOURCES})
  SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE C CXX ASM)
  SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES  LINK_FLAGS "${LD_FLAGS_STR} -m ${PROJECT_NAME}.map")
  set(CMAKE_C_LINK_EXECUTABLE "FLNK907S.EXE  -o &lt;TARGET&gt; &lt;LINK_FLAGS&gt; &lt;OBJECTS&gt;")
  </code></pre>
  
  <p>and it works fine...</p>
  
  <p>where <code>${LD_FLAGS_STR}</code> is just the list of my linker flags (own variable). and <code>LNK907S.EXE</code> is the name of Linker i 'm using (Fujitsu).</p>