Hello,
Here is some more information to the question before.
I use the https://launchpad.net/gcc-arm-embedded toolchain for cortex m4 development.
I am on windows7 machine and I have installed more than one version of a GNU ARM toolchain.
c:\Program Files (x86)\GNU Tools ARM Embedded\
4.7 2013q2
4.8 2013q4
4.9 2014q4
4.9 2015q1
I use the latest cmake version.
So how can I force a special toolchain as an example 4.9 2014q4 ???
I read a lot of stuff in the web; I also search for some toolchain files used for ARM.
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
Here ist the File.
### start file
include(CMakeForceCompiler)
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR cortex-m4)
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR cortex-m4)
# cmake calls this file twice
#if( NOT cross_configure )
#set(cross_configure 1)
#if( NOT cross_configure )
#set(cross_configure 1)
## standard way
#CMAKE_FORCE_C_COMPILER(arm-none-eabi-gcc GNU)
#CMAKE_FORCE_CXX_COMPILER(arm-none-eabi-g++ GNU)
#CMAKE_FORCE_C_COMPILER(arm-none-eabi-gcc GNU)
#CMAKE_FORCE_CXX_COMPILER(arm-none-eabi-g++ GNU)
# search for the toolchain
if(NOT TOOLCHAIN_DIR)
set(TOOLCHAIN_DIR "c:/Program Files (x86)/GNU Tools ARM Embedded/4.9 2014q4")
else()
message(STATUS ${TOOLCHAIN_DIR} )
endif()
if(NOT TOOLCHAIN_DIR)
set(TOOLCHAIN_DIR "c:/Program Files (x86)/GNU Tools ARM Embedded/4.9 2014q4")
else()
message(STATUS ${TOOLCHAIN_DIR} )
endif()
find_program(GNU_ARM_C arm-none-eabi-gcc ${TOOLCHAIN_DIR})
find_program(GNU_ARM_CXX arm-none-eabi-g++ ${TOOLCHAIN_DIR})
find_program(GNU_ARM_OBJCOPY arm-none-eabi-objcopy ${TOOLCHAIN_DIR})
find_program(GNU_ARM_SIZE_TOOL arm-none-eabi-size ${TOOLCHAIN_DIR})
find_program(GNU_ARM_CXX arm-none-eabi-g++ ${TOOLCHAIN_DIR})
find_program(GNU_ARM_OBJCOPY arm-none-eabi-objcopy ${TOOLCHAIN_DIR})
find_program(GNU_ARM_SIZE_TOOL arm-none-eabi-size ${TOOLCHAIN_DIR})
CMAKE_FORCE_C_COMPILER(${GNU_ARM_C} GNU)
CMAKE_FORCE_CXX_COMPILER(${GNU_ARM_CXX} GNU)
CMAKE_FORCE_CXX_COMPILER(${GNU_ARM_CXX} GNU)
# works without
#set(CMAKE_ASM_COMPILER ${GNU_ARM_C})
#set(CMAKE_ASM_COMPILER ${GNU_ARM_C})
# Find the target environment prefix..
# First see where gcc is keeping libc.a
execute_process(
COMMAND ${CMAKE_C_COMPILER} -print-file-name=libc.a
OUTPUT_VARIABLE CMAKE_INSTALL_PREFIX
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# First see where gcc is keeping libc.a
execute_process(
COMMAND ${CMAKE_C_COMPILER} -print-file-name=libc.a
OUTPUT_VARIABLE CMAKE_INSTALL_PREFIX
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Strip the filename off
get_filename_component(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" PATH)
# Then find the canonical path to the directory one up from there
get_filename_component(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/.." REALPATH)
get_filename_component(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" PATH)
# Then find the canonical path to the directory one up from there
get_filename_component(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/.." REALPATH)
set(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE FILEPATH "Install path prefix, prepended onto install directories.")
message(STATUS "cross compiling with gnu tools ...")
message(STATUS "toolchain prefix: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "toolchain prefix: ${CMAKE_INSTALL_PREFIX}")
set(CMAKE_FIND_ROOT_PATH ${CMAKE_INSTALL_PREFIX})
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_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
### end file
First try:
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain-gnu-tools-arm-embedded-cortex-m4.cmake -G"MinGW Makefiles" ../
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)
Second try:
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" ../
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" ../
=> i use out of source build I delete the whole build dir and and rerun..
=> So it doesn´t work that way cmake uses the compiler on the path.
Third try:
I remove the compiler from the path => now it works.
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
Is this possible with cmake I searched a lot and i found no solution.
thanks for the help
-- Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake