cmake: set IDF_VERSION_* variables at requirement expansion stage

Currently IDF_VERSION_* variables are not available to the component
CMakeLists.txt files at the requirements expansion stage. This makes
it harder to write component CMakeLists files compatible with
different IDF versions.

Include version.cmake from the requirements expansion script, add a
build system test.
This commit is contained in:
Ivan Grokhotkov 2020-12-15 20:53:19 +01:00
parent f5fc806588
commit b82577168a
2 changed files with 8 additions and 0 deletions

View File

@ -130,6 +130,13 @@ function run_tests()
git checkout -- main/CMakeLists.txt
rm main/main2.c
print_status "Use IDF version variables in component CMakeLists.txt file"
clean_build_dir
(echo -e "if (NOT IDF_VERSION_MAJOR)\n message(FATAL_ERROR \"IDF version not set\")\n endif()" \
&& cat main/CMakeLists.txt) > main/CMakeLists.new && mv main/CMakeLists.new main/CMakeLists.txt
idf.py reconfigure || failure "Failed to use IDF_VERSION_MAJOR in component CMakeLists.txt"
git checkout -- main/CMakeLists.txt
print_status "Moving BUILD_DIR_BASE out of tree"
clean_build_dir
OUTOFTREE_BUILD=${TESTDIR}/alt_build

View File

@ -32,6 +32,7 @@
cmake_minimum_required(VERSION 3.5)
include("${IDF_PATH}/tools/cmake/utilities.cmake")
include("${IDF_PATH}/tools/cmake/component_utils.cmake")
include("${IDF_PATH}/tools/cmake/version.cmake")
set(ESP_PLATFORM 1)