[Reverse chronological order]
UPDATE 2:
Okay, I fixed the Two environments
problem by moving the entire esp_loader
to a new top-level directory name external', and updating the top-level
CMakeLists.txt` thusly:
I suspect the Two environments
issue is because the CMakeLists.txt
in src
performs a recursive file glob, and some of the same files are also added by the CMakeLists.txt
in esp_loader
.
cmake_minimum_required(VERSION 3.16.0)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
list(APPEND EXTRA_COMPONENT_DIRS external/esp_loader)
project(firmware)
UPDATE 1:
I fixed this by adding
list( APPENDEXTRA_COMPONENT_DIRS src/updater/esp_loader)
to the top level CMakelists.txt
, but now I get:
*** Two environments with different actions were specified for the same target: <REDACTED>/firmware/.pio/build/esp32dev/src/updater/esp_loader/src/esp_loader.o
Original problem below
I have some code in a sub directory that has a simple CMakeLists.txt file:
cmake_minimum_required(VERSION 3.5)
set(srcs
src/esp_targets.c
src/md5_hash.c
src/esp_loader.c
src/protocol_common.c
)
idf_component_register(SRCS ${srcs}
INCLUDE_DIRS include port
PRIV_INCLUDE_DIRS private_include
PRIV_REQUIRES driver esp_timer)
How can I have PIO honor this CMakeLists.txt file
?
The build fails because the include paths are wrong; I could just change the code, but it’s external code, and I’d rather keep the structure as-is.
I suspect, but I’m not sure that it’s okay to have a sub-directory CMakeLists.txt
like this within the IDF, but that implies it would be explicitly included by a higher-level CMakeLists.txt
, but with PIO, the CMakeLists.txt
is generated …
Also, I added a FATAL_ERROR
to the CMakeLists.txt
, and it does not abort, so I know it’s not reading it.
Errors specifically like this:
Compiling .pio/build/esp32dev/src/updater/esp_loader/src/protocol_common.o
src/updater/esp_loader/src/esp_targets.c:16:10: fatal error: esp_targets.h: No such file or directory
16 | #include "esp_targets.h"
| ^~~~~~~~~~~~~~~
compilation terminated.
Directory structure:
.
├── CMakeLists.txt
├── include
│ ├── esp_loader.h
│ ├── esp_loader_io.h
│ └── serial_io.h
├── private_include
│ ├── esp_targets.h
│ ├── md5_hash.h
│ ├── protocol.h
│ ├── protocol_prv.h
│ └── slip.h
└── src
├── esp32_port.c
├── esp32_port.h
├── esp_loader.c
├── esp_targets.c
├── md5_hash.c
├── protocol_common.c
├── protocol_spi.c
├── protocol_uart.c
└── slip.c