esp-idf/tools/cmake/toolchain-clang-esp32.cmake
Omar Chebib 0baf2c43cc Build: CMake compiler flags will be set, regardless of the cache status
Defining CMake variables from the command-line or from another CMake project,
such as `-DCMAKE_C_FLAGS= -DCMAKE_CXX_FLAGS=`, caused a link failure as ESP
CMake was unable to set its proper compilation flags.
Additional CMake compiler flags can now be provided by another project.

* Closes https://github.com/espressif/esp-idf/issues/7507
2021-11-29 09:48:13 +00:00

19 lines
754 B
CMake

include($ENV{IDF_PATH}/tools/cmake/utilities.cmake)
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)
set(CMAKE_ASM_COMPILER clang)
set(CMAKE_AR xtensa-esp32-elf-ar)
set(CMAKE_RANLIB xtensa-esp32-elf-gcc-ranlib)
set(CMAKE_OBJDUMP xtensa-esp32-elf-objdump)
# -freestanding is a hack to force Clang to use its own stdatomic.h,
# without falling back to the (incompatible) GCC stdatomic.h
# https://github.com/espressif/llvm-project/blob/d9341b81/clang/lib/Headers/stdatomic.h#L13-L18
list(APPEND c_compile_options "--target=xtensa" "-mcpu=esp32" "-ffreestanding")
list(APPEND cxx_compile_options "--target=xtensa" "-mcpu=esp32" "-ffreestanding")
list(APPEND asm_compile_options "--target=xtensa" "-mcpu=esp32")