fix(cmakev2/component): sanitize PATHS argument before calling __get_relative_paths

Currently, when the cmakev1 properties for INCLUDE_DIRS and
PRIV_INCLUDE_DIRS are constructed in the
__set_component_cmakev1_properties function, the return values from the
get_target_property function for INCLUDE_DIRECTORIES and
INTERFACE_INCLUDE_DIRECTORIES properties are not checked. If a component
target does not set e.g. INCLUDE_DIRECTORIES property,
get_target_property will return a value such as `include_dirs-NOTFOUND`.
This value is subsequently passed to __get_relative_paths in the PATHS
argument, causing the file(RELATIVE_PATH) call in __get_relative_paths
to fail with an error.

```
CMake Error at /home/fhrbata/work/esp-idf/tools/cmakev2/utilities.cmake:235 (file):
  file RELATIVE_PATH must be passed a full path to the file:
  include_dirs-NOTFOUND
```

Fix this by explicitly set the PATHS to an empty list before passing it
to the __get_relative_paths function if the property is not set.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
Frantisek Hrbata
2025-11-04 07:48:15 +01:00
parent 514a27073d
commit c2e54b259c
+8
View File
@@ -716,9 +716,17 @@ function(__set_component_cmakev1_properties component_name)
# Set INCLUDE_DIRS and PRIV_INCLUDE_DIRS properties
get_target_property(include_dirs "${component_real_target}" INCLUDE_DIRECTORIES)
if(NOT include_dirs)
# get_target_property may return include_dirs-NOTFOUND
set(include_dirs "")
endif()
__remove_genex(include_dirs)
get_target_property(interface_include_dirs "${component_real_target}" INTERFACE_INCLUDE_DIRECTORIES)
if(NOT interface_include_dirs)
# get_target_property may return interface_include_dirs-NOTFOUND
set(interface_include_dirs "")
endif()
__remove_genex(interface_include_dirs)
__list_intersection(interface_include_dirs include_dirs public_include_dirs_abs)