From c2e54b259cac93c1d6390b0f4c9ea17f024c039f Mon Sep 17 00:00:00 2001 From: Frantisek Hrbata Date: Fri, 3 Oct 2025 16:30:40 +0200 Subject: [PATCH] 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 --- tools/cmakev2/component.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/cmakev2/component.cmake b/tools/cmakev2/component.cmake index b99d0b968c7..bdbb6a7e030 100644 --- a/tools/cmakev2/component.cmake +++ b/tools/cmakev2/component.cmake @@ -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)