【问题标题】:CMake Error: include could not find load file: targetsCMake 错误:包含找不到加载文件:目标
【发布时间】:2019-12-03 23:42:13
【问题描述】:
我正在尝试在我的 ESP32(在 Windows 上)上运行 AmazonFreeRTOS。在我的 amazon-freertos 主文件夹中创建构建文件夹后,我尝试使用
从主文件夹构建它
cmake --build .\build
我遇到的错误是
include 找不到加载文件:目标
但是,有一个 idf_functions.cmake 文件包含include(targets) 命令,并且targets.cmake 文件在同一个文件夹中,所以我不知道为什么会出现错误。
【问题讨论】:
标签:
cmake
configuration
freertos
esp32
【解决方案1】:
如果您密切注意该错误,您会注意到完整的错误如下所示:
CMake 错误
your-amazon-freertos-directory/vendors/espressif/esp-idf/tools/cmake/idf_functions.cmake:26(包括)
include 找不到加载文件:
目标
这是因为idf_functions.cmake 将变量IDF_PATH 设置为$ENV{IDF_PATH},这是在添加export IDF_PATH=~/esp/esp-idf 行时在~/.profile 中配置的,如here 所示。
如果您导航到~/esp/esp-idf/tools/cmake/,您会注意到<your-amazon-freertos-directory>/vendors/espressif/esp-idf/tools/cmake/idf_functions.cmake 中包含的target.cmake 和ldgen.cmake 等文件不存在。
解决方案 1(有点老套):
将<your-amazon-freertos-directory>/vendors/espressif/esp-idf/tools/cmake/的内容复制到~/esp/esp-idf/tools/cmake/
解决方案 2:
修改 ~/.profile 文件以添加以下行而不是 the guide 中建议的行:
export IDF_PATH=~/<your-amazon-freertos-directory>/vendors/espressif/esp-idf/
export PATH="$PATH:$IDF_PATH/tools"
这应该在生成构建文件和构建过程中避免任何 CMake 包含错误。