From f9f318d66699a18bbc70fe8ab8bf2e737f8ae28e Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Tue, 15 Dec 2020 20:53:19 +0100 Subject: [PATCH] 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. --- tools/ci/test_build_system_cmake.sh | 7 +++++++ tools/cmake/scripts/component_get_requirements.cmake | 1 + 2 files changed, 8 insertions(+) diff --git a/tools/ci/test_build_system_cmake.sh b/tools/ci/test_build_system_cmake.sh index 02e7c528bc..14e9170937 100755 --- a/tools/ci/test_build_system_cmake.sh +++ b/tools/ci/test_build_system_cmake.sh @@ -124,6 +124,13 @@ function run_tests() version+=$(git describe --always --tags --dirty) grep "${version}" log.log || failure "Project version should have a hash commit" + 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 diff --git a/tools/cmake/scripts/component_get_requirements.cmake b/tools/cmake/scripts/component_get_requirements.cmake index f7a8002b06..57050b0d02 100644 --- a/tools/cmake/scripts/component_get_requirements.cmake +++ b/tools/cmake/scripts/component_get_requirements.cmake @@ -12,6 +12,7 @@ endfunction() idf_build_get_property(idf_path IDF_PATH) include(${idf_path}/tools/cmake/utilities.cmake) +include(${idf_path}/tools/cmake/version.cmake) function(__component_get_property var component_target property) set(_property __component_${component_target}_${property})