technyon / Arduino-CMake-Toolchain

CMake toolchain for all Arduino compatible boards
MIT License
20 stars 7 forks source link

ESP8266: xtensa-lx106-elf-g++: error: ..... /core/build.opt: No such file or directory #13

Open TobyChaloner opened 3 months ago

TobyChaloner commented 3 months ago

With esp8266 version 3.1.2

-- Check for working CXX compiler: /home/.../.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.1.0-gcc10.3-e5f9fec/bin/xtensa-lx106-elf-g++ - broken
CMake Error at /usr/share/cmake-3.22/Modules/CMakeTestCXXCompiler.cmake:62 (message):
  The C++ compiler
    "/home/.../.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.1.0-gcc10.3-e5f9fec/bin/xtensa-lx106-elf-g++"
  is not able to compile a simple test program.
    Building CXX object CMakeFiles/cmTC_c666f.dir/testCXXCompiler.cxx.o
xtensa-lx106-elf-gcc/3.1.0-gcc10.3-e5f9fec/bin/xtensa-lx106-elf-g++      ...     -DESP8266    @/home/  ...  /esp8266/core/build.opt 
    xtensa-lx106-elf-g++: error: /home/   ...   /esp8266/core/build.opt: No such file or directory

The compilation is looking for a file ${CMAKE_BINARY_DIR}/core/build.opt

The file platform.txt at

$HOME/.arduino15/packages/esp8266/hardware/esp8266/3.1.2/platform.txt

has the line

build.opt.fqfn={build.path}/core/build.opt

I'm tempted to suggest changing Arduino-toolchain.cmake from

# Workaround for CMAKE_TRY_COMPILE_TARGET_TYPE. For later ESP32 cores this file is missing
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/build_opt.h" "")

to

# Workaround for CMAKE_TRY_COMPILE_TARGET_TYPE. For later ESP32 cores this file is missing
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/build_opt.h" "")

file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/core)
file(TOUCH ${CMAKE_BINARY_DIR}/core/build.opt)

However this seems simplistic. Is there a way at this level of interrogating whether there is a property or whatever called build.opt.fqfn, so making the creation of the empty file conditional on the board requiring it?