]> granicus.if.org Git - esp-idf/commitdiff
cmake: fix error in converting project variables to namespaced ones
authorRenz Christian Bagaporo <renz@espressif.com>
Tue, 4 Dec 2018 14:04:00 +0000 (22:04 +0800)
committerRenz Christian Bagaporo <renz@espressif.com>
Wed, 5 Dec 2018 02:51:10 +0000 (10:51 +0800)
Closes https://github.com/espressif/esp-idf/issues/2764

tools/cmake/project.cmake

index 04459a1e83bab5a039efb9cc4635cda0d0d11b99..f90847b84ed9a9d373ce3aa04af75faa8943c7ff 100644 (file)
@@ -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)
+            get_filename_component(component_dir ${component_dir} ABSOLUTE BASE_DIR ${CMAKE_SOURCE_DIR})
+            list(APPEND IDF_COMPONENT_DIRS "${component_dir}")
+        endforeach()
+    endif()
 
-            if(NOT full_path STREQUAL idf_path)
-                set(IDF_EXTRA_COMPONENT_DIRS "${IDF_EXTRA_COMPONENT_DIRS} ${component_dir}")
-            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()
-    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()
+
+    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)