circuitpython/ports
Brian 'redbeard' Harrington 5fe2a3f14f esp32/CMake: Change PROJECT_DIR to CMAKE_CURRENT_LIST_DIR.
This migrates the CMake variable `MICROPY_PORT_DIR` from the ESP-IDF
defined project to the component. Previously used instances of the variable
within the project definition have been migrated to
`CMAKE_CURRENT_LIST_DIR`. Within the component (the `main` subdirectory in
the ESP32 port) we define `MICROPY_PORT_DIR` using `CMAKE_CURRENT_LIST_DIR`
and subsequently use the `MICROPY_PORT_DIR` value in all locations where
`PROJECT` had previously been used.

Context:

In commit 9b90882146, initial support was added for building with the newly
introduced CMake support provided by the ESP-IDF.

Specifically, the commit message states:

> This commit adds support for building the esp32 port with CMake, and in
particular, it builds MicroPython as a component within the ESP-IDF. Using
CMake and the ESP-IDF build infrastructure makes it much easier to maintain
the port, especially with the various new ESP32 MCUs and their required
toolchains.

`PROJECT_DIR` is a variable populated by the ESP-IDF specifically and is
not stable when used with "[Pure CMake components][1]" as documented in the
ESP-IDF. It is intended to be used in the scope of the parent of the
current file (the "project") as opposed to the current file ("the
component"). Crossing into the parent scope like this works solely when the
"project" is MicroPython, but not when used as a component by other ESP-IDF
projects.

Analyzing this file, the intention is to reference the "Project" which in
the example is the parent directory. Within the [CMake variables][2]
documentation, there is one specifically defined for referencing the
directory for the CMake listfile currently being processed:
[`CMAKE_CURRENT_LIST_DIR`][3].

After making the change from `PROJECT_DIR` to `CMAKE_CURRENT_LIST_DIR`, the
reach into the parent scope defined by the ESP-IDF and the resulting CMake
interface violation is removed.

Similar to the component definition, the project `CMakeLists.txt` uses the
variable `CMAKE_SOURCE_DIR` which CMake defines as "The path to the top
level of the source tree."  This commit changes the variable to
`CMAKE_CURRENT_LIST_DIR` for the reasons cited above.

[1]: https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/api-guides/build-system.html#writing-pure-cmake-components
[2]: https://cmake.org/cmake/help/latest/manual/cmake-variables.7.html
[3]: https://cmake.org/cmake/help/latest/variable/CMAKE_CURRENT_LIST_DIR.html

Signed-off-by: Brian 'redbeard' Harrington <redbeard@dead-city.org>
2023-06-13 00:11:05 -07:00
..
bare-arm bare-arm/mpconfigport.h: Disable remaining optional features. 2021-11-01 14:23:06 +11:00
cc3200 all: Use MP_REGISTER_EXTENSIBLE_MODULE for overrideable built-ins. 2023-06-08 17:54:21 +10:00
embed all: Rename *umodule*.c to remove the "u" prefix. 2023-06-08 17:54:17 +10:00
esp32 esp32/CMake: Change PROJECT_DIR to CMAKE_CURRENT_LIST_DIR. 2023-06-13 00:11:05 -07:00
esp8266 py/mkrules.mk: Automatically configure frozen options when manifest set. 2023-06-08 23:12:56 +10:00
mimxrt py/mkrules.mk: Automatically configure frozen options when manifest set. 2023-06-08 23:12:56 +10:00
minimal all: Fix spelling mistakes based on codespell check. 2023-04-27 18:03:06 +10:00
nrf py/mkrules.mk: Automatically configure frozen options when manifest set. 2023-06-08 23:12:56 +10:00
pic16bit ports: Implement simple write polling for stdout. 2023-03-23 13:51:17 +11:00
powerpc all: Fix spelling mistakes based on codespell check. 2023-04-27 18:03:06 +10:00
qemu-arm py/mkrules.mk: Automatically configure frozen options when manifest set. 2023-06-08 23:12:56 +10:00
renesas-ra py/mkrules.mk: Automatically configure frozen options when manifest set. 2023-06-08 23:12:56 +10:00
rp2 all: Replace all uses of umodule in Python code. 2023-06-08 17:54:24 +10:00
samd py/mkrules.mk: Automatically configure frozen options when manifest set. 2023-06-08 23:12:56 +10:00
stm32 py/mkrules.mk: Automatically configure frozen options when manifest set. 2023-06-08 23:12:56 +10:00
teensy ports: Standardise docs link in help text. 2023-06-02 11:48:46 +10:00
unix py/mkrules.mk: Automatically configure frozen options when manifest set. 2023-06-08 23:12:56 +10:00
webassembly webassembly/modutime: Use extmod version of time module. 2023-04-27 15:11:52 +10:00
windows py/mkrules.mk: Automatically configure frozen options when manifest set. 2023-06-08 23:12:56 +10:00
zephyr py/mkrules.mk: Automatically configure frozen options when manifest set. 2023-06-08 23:12:56 +10:00