diff --git a/tools/cmake/build.cmake b/tools/cmake/build.cmake index 208bc54c16..928dc128c8 100644 --- a/tools/cmake/build.cmake +++ b/tools/cmake/build.cmake @@ -198,6 +198,8 @@ function(__build_init idf_path) # Create the build target, to which the ESP-IDF build properties, dependencies are attached to. # Must be global so as to be accessible from any subdirectory in custom projects. add_library(__idf_build_target STATIC IMPORTED GLOBAL) + # Set the IMPORTED_LOCATION property to avoid errors on IDE codemodel queries with CMake >=4.2 + set_property(TARGET __idf_build_target PROPERTY IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/dummy.a") # Set the Python path (which may be passed in via -DPYTHON=) and store in a build property set_default(PYTHON "python") diff --git a/tools/cmake/component.cmake b/tools/cmake/component.cmake index f261da213c..3f9faf96b1 100644 --- a/tools/cmake/component.cmake +++ b/tools/cmake/component.cmake @@ -166,6 +166,8 @@ function(__component_add component_dir prefix component_source) if(NOT component_target IN_LIST component_targets) if(NOT TARGET ${component_target}) add_library(${component_target} STATIC IMPORTED) + # Set the IMPORTED_LOCATION property to avoid errors on IDE codemodel queries with CMake >=4.2 + set_property(TARGET ${component_target} PROPERTY IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/dummy.a") endif() idf_build_set_property(__COMPONENT_TARGETS ${component_target} APPEND) else()