• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# CMake Toolchain file for crosscompiling on ARM.
3#
4# This can be used when running cmake in the following way:
5#  cd build/
6#  cmake .. -DCMAKE_TOOLCHAIN_FILE=../cross-arm-linux-gnueabihf.cmake
7#
8
9# Target operating system name.
10set(CMAKE_SYSTEM_NAME Linux)
11
12# assumed these are set up on the $PATH
13set(TC xtensa-esp32-elf)
14
15set(CMAKE_C_COMPILER	"${TC}-gcc${EXECUTABLE_EXT}")
16set(CMAKE_AR		"${TC}-ar${EXECUTABLE_EXT}")
17set(CMAKE_RANLIB	"${TC}-ranlib${EXECUTABLE_EXT}")
18set(CMAKE_LINKER	"${TC}-ld${EXECUTABLE_EXT}")
19
20#
21# Different build system distros set release optimization level to different
22# things according to their local policy, eg, Fedora is -O2 and Ubuntu is -O3
23# here.  Actually the build system's local policy is completely unrelated to
24# our desire for cross-build release optimization policy for code built to run
25# on a completely different target than the build system itself.
26#
27# Since this goes last on the compiler commandline we have to override it to a
28# sane value for cross-build here.  Notice some gcc versions enable broken
29# optimizations with -O3.
30#
31if (CMAKE_BUILD_TYPE MATCHES RELEASE OR CMAKE_BUILD_TYPE MATCHES Release OR CMAKE_BUILD_TYPE MATCHES release)
32	set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2")
33	set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
34endif()
35
36SET(CMAKE_C_FLAGS "-nostdlib -Wall -Werror \
37	-I${BUILD_DIR_BASE}/include \
38	-I${IDF_PATH}/components/newlib/platform_include \
39	-I${IDF_PATH}/components/mdns/include \
40	-I${IDF_PATH}/components/heap/include \
41	-I${IDF_PATH}/components/driver/include \
42	-I${IDF_PATH}/components/spi_flash/include \
43	-I${IDF_PATH}/components/nvs_flash/include \
44	-I${IDF_PATH}/components/tcpip_adapter/include \
45	-I${IDF_PATH}/components/lwip/include/lwip/posix \
46	-I${IDF_PATH}/components/lwip/include/lwip \
47	-I${IDF_PATH}/components/lwip/include/lwip/port \
48	-I${IDF_PATH}/components/esp32/include/ \
49	-I${IDF_PATH}/components/bootloader_support/include/ \
50	-I${IDF_PATH}/components/app_update/include/ \
51	-I$(IDF_PATH)/components/soc/esp32/include/ \
52	-I$(IDF_PATH)/components/soc/include/ \
53	-I$(IDF_PATH)/components/vfs/include/ \
54	${LWS_C_FLAGS} -Os \
55	-I${IDF_PATH}/components/nvs_flash/test_nvs_host \
56	-I${IDF_PATH}/components/freertos/include" CACHE STRING "" FORCE)
57
58# Where to look for the target environment. (More paths can be added here)
59set(CMAKE_FIND_ROOT_PATH "${CROSS_PATH}")
60
61# Adjust the default behavior of the FIND_XXX() commands:
62# search programs in the host environment only.
63set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
64
65# Search headers and libraries in the target environment only.
66set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
67set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
68
69