MASTER OF CODE
MASTER OF CODE

Reputation: 302

CMake Error: include could not find load file: targets

I'm trying to run AmazonFreeRTOS on my ESP32 (at Windows). After creating build folder in my amazon-freertos main folder I've tried to build it from main folder with

cmake --build .\build

The Error I've got is

include could not find load file: targets

However, there is a idf_functions.cmake file that contains include(targets) command, and the targets.cmake file is in the same folder so I don't know why the error occured.

Upvotes: 3

Views: 6672

Answers (2)

danieljovan
danieljovan

Reputation: 259

If you pay close attention to the error, you'd notice the full error says something like:

CMake Error at your-amazon-freertos-directory/vendors/espressif/esp-idf/tools/cmake/idf_functions.cmake: 26 (include)

include could not find load file:

targets

This is because idf_functions.cmake sets the variable IDF_PATH to $ENV{IDF_PATH} which was configured in ~/.profile when the line export IDF_PATH=~/esp/esp-idf was added, as seen here.

If you navigate to ~/esp/esp-idf/tools/cmake/ you'd notice that files like target.cmake and ldgen.cmake, which are being included <your-amazon-freertos-directory>/vendors/espressif/esp-idf/tools/cmake/idf_functions.cmake, do not exist.

Solution 1 (somewhat hacky):
Copy the contents of <your-amazon-freertos-directory>/vendors/espressif/esp-idf/tools/cmake/ to ~/esp/esp-idf/tools/cmake/

Solution 2:
Modify the ~/.profile file to add the following lines instead of that suggested in the guide:
export IDF_PATH=~/<your-amazon-freertos-directory>/vendors/espressif/esp-idf/
export PATH="$PATH:$IDF_PATH/tools"

This should circumvent any CMake include errors during generation of build files and during build.

Upvotes: 4

rose
rose

Reputation: 347

Since Amazon FreeRTOS supports many different platforms in addition to ESP32, you might need to supply additional commands to tell CMake that ESP32 is the target you want to build.

Try using

cmake -DVENDOR=espressif -DBOARD=esp32_wrover_kit -DCOMPILER=xtensa-esp32 -S . -B your-build-directory

from your top level folder to generate your makefiles into the build folder, and then switching to your build folder and calling

make all

(From the "Build, Flash, and Run the Amazon FreeRTOS Demo Project" section of https://docs.aws.amazon.com/freertos/latest/userguide/getting_started_espressif.html)

Upvotes: 0

Related Questions