diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 13fc4a248a..121f711ce0 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -121,6 +121,20 @@ before_script:
- export PYTHONPATH="$IDF_PATH/tools:$IDF_PATH/tools/ci/python_packages:$PYTHONPATH"
- fetch_submodules
+# this is a workaround since CI on 4.3 is using python 3.4 and the real support version is 3.6
+# Can't find package versions that match both of them at the same time.
+# install the idf-component-manager here instead of in the dockerfile with a fixed version
+.before_script_build_cmake:
+ before_script:
+ - source tools/ci/utils.sh
+ - source tools/ci/setup_python.sh
+ - apply_bot_filter
+ - add_gitlab_ssh_keys
+ - source tools/ci/configure_ci_environment.sh
+ - *setup_tools_unless_target_test
+ - fetch_submodules
+ - pip install "idf-component-manager~=1.1"
+
default:
retry:
max: 2
diff --git a/docs/en/api-guides/build-system.rst b/docs/en/api-guides/build-system.rst
index 3f3d53d9d4..b1c20b7ea2 100644
--- a/docs/en/api-guides/build-system.rst
+++ b/docs/en/api-guides/build-system.rst
@@ -1241,6 +1241,7 @@ These are properties that describe the build. Values of build properties can be
- EXECUTABLE - project executable; set by call to ``idf_build_executable``
- EXECUTABLE_NAME - name of project executable without extension; set by call to ``idf_build_executable``
- EXECUTABLE_DIR - path containing the output executable
+- IDF_COMPONENT_MANAGER - the component manager is enabled by default, but if this property is set to ``0`` it was disabled by the IDF_COMPONENT_MANAGER environment variable
- IDF_PATH - ESP-IDF path; set from IDF_PATH environment variable, if not, inferred from the location of ``idf.cmake``
- IDF_TARGET - target chip for the build; set from the required target argument for ``idf_build_process``
- IDF_VER - ESP-IDF version; set from either a version file or the Git revision of the IDF_PATH repository
diff --git a/docs/en/api-guides/tools/idf-component-manager.rst b/docs/en/api-guides/tools/idf-component-manager.rst
index 3700256194..fcd268c380 100644
--- a/docs/en/api-guides/tools/idf-component-manager.rst
+++ b/docs/en/api-guides/tools/idf-component-manager.rst
@@ -6,13 +6,6 @@ The IDF Component manager is a tool that downloads dependencies for any ESP-IDF
A list of components can be found on ``_
-Activating the Component Manager
-================================
-
-If CMake is started using ``idf.py`` or `ESP-IDF VSCode Extension `_ then the component manager will be activated by default.
-
-If CMake is used directly or with some CMake-based IDE like CLion, it's necessary to set the ``IDF_COMPONENT_MANAGER`` environment variable to ``1`` to enable the component manager integration with the build system.
-
Using with a project
====================
@@ -70,3 +63,8 @@ Defining dependencies in the manifest
# # with relative or absolute path
# some_local_component:
# path: ../../projects/component
+
+Disabling the Component Manager
+===============================
+
+The component manager can be explicitly disabled by setting ``IDF_COMPONENT_MANAGER`` environment variable to ``0``.
diff --git a/tools/ci/config/build.yml b/tools/ci/config/build.yml
index 542b2fc33d..c43d00d9a9 100644
--- a/tools/ci/config/build.yml
+++ b/tools/ci/config/build.yml
@@ -191,7 +191,9 @@ build_examples_make:
# same as above, but for CMake
.build_examples_cmake:
- extends: .build_examples_template
+ extends:
+ - .build_examples_template
+ - .before_script_build_cmake
artifacts:
paths:
- build_${TEST_PREFIX}/list.json
diff --git a/tools/cmake/build.cmake b/tools/cmake/build.cmake
index 12875b46d8..2e53a6dd50 100644
--- a/tools/cmake/build.cmake
+++ b/tools/cmake/build.cmake
@@ -414,6 +414,35 @@ macro(idf_build_process target)
idf_build_set_property(__COMPONENT_REQUIRES_COMMON "")
endif()
+ idf_build_get_property(idf_component_manager IDF_COMPONENT_MANAGER)
+ if(idf_component_manager EQUAL "1")
+ set(managed_components_list_file ${CMAKE_BINARY_DIR}/managed_components_list.temp.cmake)
+
+ # Call for package manager to prepare remote dependencies
+ execute_process(COMMAND ${PYTHON}
+ "-m"
+ "idf_component_manager.prepare_components"
+ "--project_dir=${CMAKE_CURRENT_LIST_DIR}"
+ "prepare_dependencies"
+ "--managed_components_list_file=${managed_components_list_file}"
+ RESULT_VARIABLE result
+ ERROR_VARIABLE error)
+
+ if(NOT result EQUAL 0)
+ message(FATAL_ERROR "${error}")
+ endif()
+
+ # Include managed components
+ include(${managed_components_list_file})
+ file(REMOVE ${managed_components_list_file})
+ else()
+ message(VERBOSE "IDF Component manager was explicitly disabled by setting IDF_COMPONENT_MANAGER=0")
+ if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/idf_project.yml")
+ message(WARNING "\"idf_project.yml\" file is found in project directory, "
+ "but component manager is not enabled. Please set IDF_COMPONENT_MANAGER environment variable.")
+ endif()
+ endif()
+
# Perform early expansion of component CMakeLists.txt in CMake scripting mode.
# It is here we retrieve the public and private requirements of each component.
# It is also here we add the common component requirements to each component's
diff --git a/tools/cmake/component.cmake b/tools/cmake/component.cmake
index ae9dcec154..028238ce6e 100644
--- a/tools/cmake/component.cmake
+++ b/tools/cmake/component.cmake
@@ -225,7 +225,7 @@ function(__component_get_requirements)
endif()
idf_build_get_property(idf_component_manager IDF_COMPONENT_MANAGER)
- if(idf_component_manager AND idf_component_manager EQUAL "1")
+ if(idf_component_manager EQUAL 1)
# Call for component manager once again to inject dependencies
idf_build_get_property(python PYTHON)
execute_process(COMMAND ${python}
diff --git a/tools/cmake/project.cmake b/tools/cmake/project.cmake
index 096d292482..a875f8efa9 100644
--- a/tools/cmake/project.cmake
+++ b/tools/cmake/project.cmake
@@ -37,6 +37,13 @@ endif()
# value passed externally.
__target_init()
+# Enable the component manager for regular projects if not explicitly disabled.
+if(NOT "$ENV{IDF_COMPONENT_MANAGER}" EQUAL "0")
+ idf_build_set_property(IDF_COMPONENT_MANAGER 1)
+endif()
+# Set component manager interface version
+idf_build_set_property(__COMPONENT_MANAGER_INTERFACE_VERSION 0)
+
#
# Get the project version from either a version file or the Git revision. This is passed
# to the idf_build_process call. Dependencies are also set here for when the version file
@@ -172,8 +179,6 @@ function(__project_init components_var test_components_var)
endif()
endfunction()
- idf_build_set_property(IDF_COMPONENT_MANAGER "$ENV{IDF_COMPONENT_MANAGER}")
-
# Add component directories to the build, given the component filters, exclusions
# extra directories, etc. passed from the root CMakeLists.txt.
if(COMPONENT_DIRS)
@@ -188,39 +193,6 @@ function(__project_init components_var test_components_var)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_CURRENT_LIST_DIR}/idf_project.yml")
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_CURRENT_LIST_DIR}/dependencies.lock")
- idf_build_get_property(idf_component_manager IDF_COMPONENT_MANAGER)
- if(idf_component_manager)
- if(idf_component_manager EQUAL "0")
- message(VERBOSE "IDF Component manager was explicitly disabled by setting IDF_COMPONENT_MANAGER=0")
- elseif(idf_component_manager EQUAL "1")
- set(managed_components_list_file ${CMAKE_BINARY_DIR}/managed_components_list.temp.cmake)
-
- # Call for package manager to prepare remote dependencies
- execute_process(COMMAND ${PYTHON}
- "-m"
- "idf_component_manager.prepare_components"
- "--project_dir=${CMAKE_CURRENT_LIST_DIR}"
- "prepare_dependencies"
- "--managed_components_list_file=${managed_components_list_file}"
- RESULT_VARIABLE result
- ERROR_VARIABLE error)
-
- if(NOT result EQUAL 0)
- message(FATAL_ERROR "${error}")
- endif()
-
- # Include managed components
- include(${managed_components_list_file})
- file(REMOVE ${managed_components_list_file})
- else()
- message(WARNING "IDF_COMPONENT_MANAGER environment variable is set to unknown value "
- "\"${idf_component_manager}\". If you want to use component manager set it to 1.")
- endif()
- elseif(EXISTS "${CMAKE_CURRENT_LIST_DIR}/idf_project.yml")
- message(WARNING "\"idf_project.yml\" file is found in project directory, "
- "but component manager is not enabled. Please set IDF_COMPONENT_MANAGER environment variable.")
- endif()
-
spaces2list(EXTRA_COMPONENT_DIRS)
foreach(component_dir ${EXTRA_COMPONENT_DIRS})
__project_component_dir("${component_dir}")