1# 2# CMake Toolchain file for crosscompiling on Mediatek Linkit 7967 3# 4# This can be used like this (with Linkit sdk unpacked to /projects/linkit/sdk) 5# 6# cd build/ 7# cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/projects/linkit/cross-root \ 8# -DCMAKE_TOOLCHAIN_FILE=../contrib/cross-linkit.cmake \ 9# -DLWS_PLAT_FREERTOS=1 \ 10# -DLWS_WITH_ZLIB=0 \ 11# -DLWS_WITHOUT_EXTENSIONS=1 \ 12# -DLWS_WITH_ZIP_FOPS=0 \ 13# -DLWS_WITH_HTTP_STREAM_COMPRESSION=0 \ 14# -DLWS_WITH_MBEDTLS=1 \ 15# -DLWS_WITH_FILE_OPS=0 16# 17 18# if your sdk lives somewhere else, this is the only place that should need changing 19set(CROSS_BASE /projects/linkit/sdk) 20set(CROSS_PATH ${CROSS_BASE}/tools/gcc/gcc-arm-none-eabi) 21 22# 23# Target operating system name. 24set(CMAKE_SYSTEM_NAME Generic) 25 26# Name of C compiler. 27set(CMAKE_C_COMPILER "${CROSS_PATH}/bin/arm-none-eabi-gcc") 28set(CMAKE_CXX_COMPILER "${CROSS_PATH}/bin/arm-none-eabi-g++") 29 30# 31# cmake believes we should link a NOP test program OK, but since we're 32# baremetal, that's not true in our case. It tries to build this test 33# with the cross compiler, but with no args on it, and it fails. 34# So disable this test for this toolchain (we'll find out soon enough 35# if we actually can't compile anything) 36 37set(CMAKE_C_COMPILER_WORKS 1) 38set(CMAKE_CXX_COMPILER_WORKS 1) 39 40# 41# Different build system distros set release optimization level to different 42# things according to their local policy, eg, Fedora is -O2 and Ubuntu is -O3 43# here. Actually the build system's local policy is completely unrelated to 44# our desire for cross-build release optimization policy for code built to run 45# on a completely different target than the build system itself. 46# 47# Since this goes last on the compiler commandline we have to override it to a 48# sane value for cross-build here. Notice some gcc versions enable broken 49# optimizations with -O3. 50# 51if (CMAKE_BUILD_TYPE MATCHES RELEASE OR CMAKE_BUILD_TYPE MATCHES Release OR CMAKE_BUILD_TYPE MATCHES release) 52 set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2") 53 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2") 54endif() 55 56set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -nostartfiles -I${CROSS_BASE}/middleware/third_party/lwip/src/include/lwip -I${CROSS_BASE}/middleware/third_party/lwip/src/include -I${CROSS_BASE}/project/mt7687_hdk/apps/httpd/inc/ -I${CROSS_BASE}/kernel/service/inc/ -I${CROSS_BASE}/driver/chip/inc -I${CROSS_BASE}/driver/chip/mt7687/inc/ -I${CROSS_BASE}/driver/CMSIS/Device/MTK/mt7687/Include/ -I${CROSS_BASE}/driver/CMSIS/Include -I${CROSS_BASE}/middleware/third_party/lwip/ports/include/ -I${CROSS_BASE}/middleware/third_party/lwip/src/include/posix/ -I${CROSS_BASE}/kernel/rtos/FreeRTOS/Source/include/ -I${CROSS_BASE}/middleware/third_party/mbedtls/include/ -I${CROSS_BASE}/kernel/rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F/ -I${CROSS_BASE}/middleware/third_party/sntp/inc/ -DLWS_AMAZON_RTOS=1" 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