1##
2##   ______                              _
3##  / _____)             _              | |
4## ( (____  _____ ____ _| |_ _____  ____| |__
5##  \____ \| ___ |    (_   _) ___ |/ ___)  _ \
6##  _____) ) ____| | | || |_| ____( (___| | | |
7## (______/|_____)_|_|_| \__)_____)\____)_| |_|
8## (C)2013-2017 Semtech
9##  ___ _____ _   ___ _  _____ ___  ___  ___ ___
10## / __|_   _/_\ / __| |/ / __/ _ \| _ \/ __| __|
11## \__ \ | |/ _ \ (__| ' <| _| (_) |   / (__| _|
12## |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___|
13## embedded.connectivity.solutions.==============
14##
15## License:  Revised BSD License, see LICENSE.TXT file included in the project
16## Authors:  Johannes Bruder ( STACKFORCE ), Miguel Luis ( Semtech )
17##
18##
19## CMake arm-none-eabi toolchain file
20##
21
22# Append current directory to CMAKE_MODULE_PATH for making device specific cmake modules visible
23list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
24
25# Target definition
26set(CMAKE_SYSTEM_NAME  Generic)
27set(CMAKE_SYSTEM_PROCESSOR ARM)
28
29#---------------------------------------------------------------------------------------
30# Set toolchain paths
31#---------------------------------------------------------------------------------------
32set(TOOLCHAIN arm-none-eabi)
33if(NOT DEFINED TOOLCHAIN_PREFIX)
34    if(CMAKE_HOST_SYSTEM_NAME STREQUAL Linux)
35        set(TOOLCHAIN_PREFIX "/usr")
36    elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin)
37        set(TOOLCHAIN_PREFIX "/usr/local")
38    elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
39        message(STATUS "Please specify the TOOLCHAIN_PREFIX !\n For example: -DTOOLCHAIN_PREFIX=\"C:/Program Files/GNU Tools ARM Embedded\" ")
40    else()
41        set(TOOLCHAIN_PREFIX "/usr")
42        message(STATUS "No TOOLCHAIN_PREFIX specified, using default: " ${TOOLCHAIN_PREFIX})
43    endif()
44endif()
45set(TOOLCHAIN_BIN_DIR ${TOOLCHAIN_PREFIX}/bin)
46set(TOOLCHAIN_INC_DIR ${TOOLCHAIN_PREFIX}/${TOOLCHAIN}/include)
47set(TOOLCHAIN_LIB_DIR ${TOOLCHAIN_PREFIX}/${TOOLCHAIN}/lib)
48
49# Set system depended extensions
50if(WIN32)
51    set(TOOLCHAIN_EXT ".exe" )
52else()
53    set(TOOLCHAIN_EXT "" )
54endif()
55
56# Perform compiler test with static library
57set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
58
59#---------------------------------------------------------------------------------------
60# Preset some general GCC Options
61#---------------------------------------------------------------------------------------
62
63# Options for DEBUG build
64# -Og enables optimizations that do not interfere with debugging
65# -g produce debugging information in the operating system’s native format
66set(CMAKE_C_FLAGS_DEBUG "-Og -g -DDEBUG" CACHE INTERNAL "C Compiler options for debug build type")
67set(CMAKE_CXX_FLAGS_DEBUG "-Og -g -DDEBUG" CACHE INTERNAL "C++ Compiler options for debug build type")
68set(CMAKE_ASM_FLAGS_DEBUG "-g" CACHE INTERNAL "ASM Compiler options for debug build type")
69set(CMAKE_EXE_LINKER_FLAGS_DEBUG "" CACHE INTERNAL "Linker options for debug build type")
70
71# Options for RELEASE build
72# -Os Optimize for size. -Os enables all -O2 optimizations
73set(CMAKE_C_FLAGS_RELEASE "-Os" CACHE INTERNAL "C Compiler options for release build type")
74set(CMAKE_CXX_FLAGS_RELEASE "-Os" CACHE INTERNAL "C++ Compiler options for release build type")
75set(CMAKE_ASM_FLAGS_RELEASE "" CACHE INTERNAL "ASM Compiler options for release build type")
76set(CMAKE_EXE_LINKER_FLAGS_RELEASE "" CACHE INTERNAL "Linker options for release build type")
77
78#---------------------------------------------------------------------------------------
79# Set compilers
80#---------------------------------------------------------------------------------------
81set(CMAKE_C_COMPILER ${TOOLCHAIN_BIN_DIR}/${TOOLCHAIN}-gcc${TOOLCHAIN_EXT} CACHE INTERNAL "C Compiler")
82set(CMAKE_CXX_COMPILER ${TOOLCHAIN_BIN_DIR}/${TOOLCHAIN}-g++${TOOLCHAIN_EXT} CACHE INTERNAL "C++ Compiler")
83set(CMAKE_ASM_COMPILER ${TOOLCHAIN_BIN_DIR}/${TOOLCHAIN}-gcc${TOOLCHAIN_EXT} CACHE INTERNAL "ASM Compiler")
84
85set(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN_PREFIX}/${${TOOLCHAIN}} ${CMAKE_PREFIX_PATH})
86set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
87set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
88set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
89set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
90
91