<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>
<div>Hello,</div>

<div> </div>

<div>Here is some more information to the question before.</div>

<div>I use the https://launchpad.net/gcc-arm-embedded toolchain for cortex m4 development.</div>

<div> </div>

<div>I am on windows7 machine and I have installed more than one version of a GNU ARM toolchain.</div>

<div>c:\Program Files (x86)\GNU Tools ARM Embedded\</div>

<div>4.7 2013q2</div>

<div>4.8 2013q4</div>

<div>4.9 2014q4</div>

<div>4.9 2015q1</div>

<div> </div>

<div>I use the latest cmake version.</div>

<div> </div>

<div>So how can I force a special toolchain as an example 4.9 2014q4 ???</div>

<div> </div>

<div>I read a lot of stuff in the web; I also search for some toolchain files used for ARM.</div>

<div> </div>

<div>So the file is a bunch of all the information I found on the web and or github... but it doesn´t work as I expected</div>

<div> </div>

<div>Here ist the File.</div>

<div> </div>

<div>### start file</div>

<div> </div>

<div>include(CMakeForceCompiler)<br/>
set(CMAKE_SYSTEM_NAME Generic)<br/>
set(CMAKE_SYSTEM_PROCESSOR cortex-m4)</div>

<div># cmake calls this file twice<br/>
#if( NOT cross_configure )<br/>
#set(cross_configure 1) </div>

<div>## standard way<br/>
#CMAKE_FORCE_C_COMPILER(arm-none-eabi-gcc GNU)<br/>
#CMAKE_FORCE_CXX_COMPILER(arm-none-eabi-g++ GNU)</div>

<div># search for the toolchain<br/>
if(NOT TOOLCHAIN_DIR)<br/>
    set(TOOLCHAIN_DIR "c:/Program Files (x86)/GNU Tools ARM Embedded/4.9 2014q4")<br/>
else()<br/>
    message(STATUS ${TOOLCHAIN_DIR} )<br/>
endif()</div>

<div>find_program(GNU_ARM_C arm-none-eabi-gcc ${TOOLCHAIN_DIR})<br/>
find_program(GNU_ARM_CXX arm-none-eabi-g++ ${TOOLCHAIN_DIR})<br/>
find_program(GNU_ARM_OBJCOPY arm-none-eabi-objcopy ${TOOLCHAIN_DIR})<br/>
find_program(GNU_ARM_SIZE_TOOL arm-none-eabi-size ${TOOLCHAIN_DIR})</div>

<div>CMAKE_FORCE_C_COMPILER(${GNU_ARM_C} GNU)<br/>
CMAKE_FORCE_CXX_COMPILER(${GNU_ARM_CXX} GNU)</div>

<div># works without<br/>
#set(CMAKE_ASM_COMPILER ${GNU_ARM_C})</div>

<div># Find the target environment prefix..<br/>
# First see where gcc is keeping libc.a<br/>
execute_process(<br/>
  COMMAND ${CMAKE_C_COMPILER} -print-file-name=libc.a<br/>
  OUTPUT_VARIABLE CMAKE_INSTALL_PREFIX<br/>
  OUTPUT_STRIP_TRAILING_WHITESPACE<br/>
)</div>

<div># Strip the filename off<br/>
get_filename_component(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" PATH)<br/>
# Then find the canonical path to the directory one up from there<br/>
get_filename_component(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/.." REALPATH)</div>

<div>set(CMAKE_INSTALL_PREFIX  ${CMAKE_INSTALL_PREFIX} CACHE FILEPATH "Install path prefix, prepended onto install directories.")</div>

<div>message(STATUS "cross compiling with gnu tools ...")<br/>
message(STATUS "toolchain prefix: ${CMAKE_INSTALL_PREFIX}")</div>

<div>set(CMAKE_FIND_ROOT_PATH  ${CMAKE_INSTALL_PREFIX})<br/>
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)<br/>
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)<br/>
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)</div>

<div> </div>

<div>### end file</div>

<div> </div>

<div>First try:</div>

<div>cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain-gnu-tools-arm-embedded-cortex-m4.cmake -G"MinGW Makefiles" ../</div>

<div>So I tried it => it works it uses the compiler on the path variable.. The latest version is on the sytem path (4.9 2015q1)</div>

<div> </div>

<div>Second try:<br/>
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain-gnu-tools-arm-embedded-cortex-m4.cmake -DTOOLCHAIN_DIR="c:\Program Files (x86)\GNU Tools ARM Embedded\4.9 2014q4" -G"MinGW Makefiles" ../</div>

<div>=> i use out of source build I delete the whole build dir and and rerun..</div>

<div>=> So it doesn´t work that way cmake uses the compiler on the path.</div>

<div> </div>

<div>Third try:</div>

<div>I remove the compiler from the path => now it works. </div>

<div> </div>

<div>I would like to write a toolchain which selects the compiler on a special version/path ... and this should also work if there is any version on the system path</div>

<div> </div>

<div>Is this possible with cmake I searched a lot and i found no solution.</div>

<div> </div>

<div>thanks for the help</div>

<div> </div>

<div> </div>

<div> </div>

<div> </div>
</div></div></body></html>