-
-
Notifications
You must be signed in to change notification settings - Fork 177
/
toolchain.xtensa-esp32s2-elf.cmake
61 lines (47 loc) · 1.73 KB
/
toolchain.xtensa-esp32s2-elf.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#
# Copyright (c) .NET Foundation and Contributors
# See LICENSE file in the project root for full license information.
#
include(CMakeForceCompiler)
# the name of the operating system for which CMake is to build
set(CMAKE_SYSTEM_NAME Generic)
# macro to setup compilers
macro(nf_set_compiler_var var name)
find_program(
CMAKE_${var}
xtensa-esp32s2-elf-${name}
CMAKE_FIND_ROOT_PATH_BOTH
REQUIRED)
endmacro()
# safer to have these here as a check if the toolchain are accessible in the PATH
# setup C compiler
nf_set_compiler_var(C_COMPILER gcc)
# setup C++ compiler
nf_set_compiler_var(CXX_COMPILER g++)
# setup Assembler compiler
nf_set_compiler_var(ASM_COMPILER gcc)
# other toolchain configurations
find_program(
CMAKE_OBJCOPY
xtensa-esp32s2-elf-objcopy
CMAKE_FIND_ROOT_PATH_BOTH)
find_program(
CMAKE_OBJDUMP
xtensa-esp32s2-elf-objdump
CMAKE_FIND_ROOT_PATH_BOTH)
find_program(
CMAKE_SIZE
xtensa-esp32s2-elf-size
CMAKE_FIND_ROOT_PATH_BOTH)
set(CMAKE_C_FLAGS "-mlongcalls -Wno-frame-address" CACHE STRING "C Compiler Base Flags")
set(CMAKE_CXX_FLAGS "-mlongcalls -Wno-frame-address -Wno-literal-suffix" CACHE STRING "C++ Compiler Base Flags")
# root paths to search on the filesystem for cross-compiling
get_filename_component(CMAKE_FIND_ROOT_PATH ${CMAKE_C_COMPILER} DIRECTORY CACHE)
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 required C and C++ standard for ALL targets
set(CMAKE_C_STANDARD 11 CACHE INTERNAL "C standard for all targets")
set(CMAKE_CXX_STANDARD 11 CACHE INTERNAL "C++ standard for all targets")
# Perform compiler test with static library
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)