]> granicus.if.org Git - esp-idf/commitdiff
cmake: Warn if something which looks like a component directory isn't
authorAngus Gratton <angus@espressif.com>
Mon, 15 Apr 2019 01:15:58 +0000 (11:15 +1000)
committerRenz Christian Bagaporo <renz@espressif.com>
Mon, 13 May 2019 11:57:39 +0000 (19:57 +0800)
Otherwise, fails build at the add_subdirectory stage

CMakeLists.txt
tools/cmake/component.cmake

index c98d3d8c5e74e6f2317f3aceff8a20b4596d8e2c..a65cb36fa0736a44510e73d6e633e8ec7a9f1e86 100644 (file)
@@ -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)
index ccb7bc02a14c0343c11f7f30221f2b9ff348c948..2f65dca2ec2072e2e2eac5de7abd420295bfc43f 100644 (file)
@@ -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.