diff --git a/CMakeLists.txt b/CMakeLists.txt index c98d3d8c5..a65cb36fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,7 +110,7 @@ foreach(component_target ${build_component_targets}) set(COMPONENT_NAME ${_name}) set(COMPONENT_DIR ${dir}) set(COMPONENT_ALIAS ${alias}) - set(COMPONENT_PATH ${dir}) # same deprecation situation here + set(COMPONENT_PATH ${dir}) # also deprecated, see comment in previous loop idf_build_get_property(build_prefix __PREFIX) set(__idf_component_context 1) if(NOT prefix STREQUAL build_prefix) diff --git a/tools/cmake/component.cmake b/tools/cmake/component.cmake index ccb7bc02a..2f65dca2e 100644 --- a/tools/cmake/component.cmake +++ b/tools/cmake/component.cmake @@ -112,6 +112,18 @@ function(__component_add component_dir prefix) get_filename_component(abs_dir ${component_dir} ABSOLUTE) get_filename_component(base_dir ${abs_dir} NAME) + # Check this is really a directory and that a CMakeLists.txt file for this component exists + # - warn and skip anything which isn't valid looking (probably cruft) + if(NOT IS_DIRECTORY "${abs_dir}") + message(WARNING "Unexpected file in components directory: ${abs_dir}") + return() + endif() + if(NOT EXISTS "${abs_dir}/CMakeLists.txt") + message(WARNING "Component directory ${abs_dir} does not contain a CMakeLists.txt file. " + "No component will be added") + return() + endif() + set(component_name ${base_dir}) # The component target has three underscores as a prefix. The corresponding component library # only has two.