diff --git a/tools/cmake/build.cmake b/tools/cmake/build.cmake index d0abf84386..fe1942e38b 100644 --- a/tools/cmake/build.cmake +++ b/tools/cmake/build.cmake @@ -150,10 +150,12 @@ function(__build_init idf_path) file(GLOB component_dirs ${idf_path}/components/*) list(SORT component_dirs) foreach(component_dir ${component_dirs}) - get_filename_component(component_dir ${component_dir} ABSOLUTE) - __component_dir_quick_check(is_component ${component_dir}) - if(is_component) - __component_add(${component_dir} ${prefix}) + # A potential component must be a directory + if(IS_DIRECTORY ${component_dir}) + __component_dir_quick_check(is_component ${component_dir}) + if(is_component) + __component_add(${component_dir} ${prefix}) + endif() endif() endforeach() diff --git a/tools/cmake/component.cmake b/tools/cmake/component.cmake index 12cf324586..d017699f39 100644 --- a/tools/cmake/component.cmake +++ b/tools/cmake/component.cmake @@ -97,16 +97,11 @@ function(__component_dir_quick_check var component_dir) set(res 1) get_filename_component(abs_dir ${component_dir} ABSOLUTE) - # 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(STATUS "Unexpected file in components directory: ${abs_dir}") - set(res 0) - endif() - get_filename_component(base_dir ${abs_dir} NAME) string(SUBSTRING "${base_dir}" 0 1 first_char) + # Check the component directory contains a CMakeLists.txt file + # - warn and skip anything which isn't valid looking (probably cruft) if(NOT first_char STREQUAL ".") if(NOT EXISTS "${abs_dir}/CMakeLists.txt") message(STATUS "Component directory ${abs_dir} does not contain a CMakeLists.txt file. " diff --git a/tools/cmake/project.cmake b/tools/cmake/project.cmake index 099d07c27e..0057e6d4d8 100644 --- a/tools/cmake/project.cmake +++ b/tools/cmake/project.cmake @@ -157,13 +157,14 @@ function(__project_init components_var test_components_var) function(__project_component_dir component_dir) get_filename_component(component_dir "${component_dir}" ABSOLUTE) + # The directory itself is a valid idf component if(EXISTS ${component_dir}/CMakeLists.txt) idf_build_component(${component_dir}) else() + # otherwise, check whether the subfolders are potential idf components file(GLOB component_dirs ${component_dir}/*) foreach(component_dir ${component_dirs}) - if(EXISTS ${component_dir}/CMakeLists.txt) - get_filename_component(base_dir ${component_dir} NAME) + if(IS_DIRECTORY ${component_dir}) __component_dir_quick_check(is_component ${component_dir}) if(is_component) idf_build_component(${component_dir}) @@ -205,9 +206,11 @@ function(__project_init components_var test_components_var) file(GLOB bootloader_component_dirs "${CMAKE_CURRENT_LIST_DIR}/bootloader_components/*") list(SORT bootloader_component_dirs) foreach(bootloader_component_dir ${bootloader_component_dirs}) - __component_dir_quick_check(is_component ${bootloader_component_dir}) - if(is_component) - __kconfig_bootloader_component_add("${bootloader_component_dir}") + if(IS_DIRECTORY ${bootloader_component_dir}) + __component_dir_quick_check(is_component ${bootloader_component_dir}) + if(is_component) + __kconfig_bootloader_component_add("${bootloader_component_dir}") + endif() endif() endforeach()