diff --git a/tools/cmake/project.cmake b/tools/cmake/project.cmake index 04459a1e8..f90847b84 100644 --- a/tools/cmake/project.cmake +++ b/tools/cmake/project.cmake @@ -18,25 +18,31 @@ endfunction() macro(project name) - # Bridge existing documented variable names with library namespaced variables in order for old projects to work. + # Bridge existing documented variable names with library namespaced + # variables in order for old projects to work. + if(COMPONENT_DIRS) spaces2list(COMPONENT_DIRS) foreach(component_dir ${COMPONENT_DIRS}) - get_filename_component(full_path ${component_dir} ABSOLUTE) - get_filename_component(idf_path "${IDF_PATH}/components" ABSOLUTE) - - if(NOT full_path STREQUAL idf_path) - set(IDF_EXTRA_COMPONENT_DIRS "${IDF_EXTRA_COMPONENT_DIRS} ${component_dir}") - endif() + get_filename_component(component_dir ${component_dir} ABSOLUTE BASE_DIR ${CMAKE_SOURCE_DIR}) + list(APPEND IDF_COMPONENT_DIRS "${component_dir}") endforeach() - else() - if(MAIN_SRCS) - set(IDF_EXTRA_COMPONENT_DIRS "${EXTRA_COMPONENT_DIRS} ${CMAKE_SOURCE_DIR}/components") - else() - set(IDF_EXTRA_COMPONENT_DIRS "${EXTRA_COMPONENT_DIRS} \ - ${CMAKE_SOURCE_DIR}/components ${CMAKE_SOURCE_DIR}/main") - endif() + endif() + + if(EXTRA_COMPONENT_DIRS) + spaces2list(EXTRA_COMPONENT_DIRS) + + foreach(component_dir ${EXTRA_COMPONENT_DIRS}) + get_filename_component(component_dir ${component_dir} ABSOLUTE BASE_DIR ${CMAKE_SOURCE_DIR}) + list(APPEND IDF_EXTRA_COMPONENT_DIRS "${component_dir}") + endforeach() + endif() + + list(APPEND IDF_EXTRA_COMPONENT_DIRS "${CMAKE_SOURCE_DIR}/components") + + if(NOT MAIN_SRCS) + list(APPEND IDF_EXTRA_COMPONENT_DIRS "${CMAKE_SOURCE_DIR}/main") endif() if(COMPONENTS)