diff --git a/tools/cmakev2/test/CMakeLists.txt b/tools/cmakev2/test/CMakeLists.txt index de855c5db1c..134c0beb85d 100644 --- a/tools/cmakev2/test/CMakeLists.txt +++ b/tools/cmakev2/test/CMakeLists.txt @@ -180,6 +180,26 @@ function(test_project_properties) endif() endfunction() +# Test that the targets for component1 and component2 are created when +# component2 is included. +function(test_include_component) + idf_build_library(INTERFACE idflibtest3 COMPONENTS component2) + idf_component_get_property(component_real_target + component2 + COMPONENT_REAL_TARGET) + if(NOT TARGET ${component_real_target}) + idf_die("Missing component2 target") + endif() + + # Test that component1 is included as a dependency of component2. + idf_component_get_property(component_real_target + component1 + COMPONENT_REAL_TARGET) + if(NOT TARGET ${component_real_target}) + idf_die("Missing component1 target") + endif() +endfunction() + # Run tests test_component_priority() test_idf_version() @@ -188,6 +208,7 @@ test_toolchain() test_idf_build_library() test_kconfig() test_project_properties() +test_include_component() __dump_all_properties() message("ALL TESTS PASSED") diff --git a/tools/cmakev2/test/components/component1/CMakeLists.txt b/tools/cmakev2/test/components/component1/CMakeLists.txt new file mode 100644 index 00000000000..7f126c75dc6 --- /dev/null +++ b/tools/cmakev2/test/components/component1/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(${COMPONENT_TARGET} component1.c) +target_include_directories(${COMPONENT_TARGET} PUBLIC ${CMAKE_CURRENT_LIST_DIR}) diff --git a/tools/cmakev2/test/components/component1/component1.c b/tools/cmakev2/test/components/component1/component1.c new file mode 100644 index 00000000000..682fc662cdf --- /dev/null +++ b/tools/cmakev2/test/components/component1/component1.c @@ -0,0 +1,11 @@ +/* + * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#include + +void component1_func(void) +{ + printf("component1\n"); +} diff --git a/tools/cmakev2/test/components/component1/component1.h b/tools/cmakev2/test/components/component1/component1.h new file mode 100644 index 00000000000..3157eb52d3b --- /dev/null +++ b/tools/cmakev2/test/components/component1/component1.h @@ -0,0 +1,9 @@ +/* + * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef _COMPONENT1_H_ +#define _COMPONENT1_H_ +void component1_func(void); +#endif diff --git a/tools/cmakev2/test/components/component2/CMakeLists.txt b/tools/cmakev2/test/components/component2/CMakeLists.txt new file mode 100644 index 00000000000..2471d235114 --- /dev/null +++ b/tools/cmakev2/test/components/component2/CMakeLists.txt @@ -0,0 +1,5 @@ +idf_component_include(component1 INTERFACE component1) + +add_library(${COMPONENT_TARGET} component2.c) +target_include_directories(${COMPONENT_TARGET} PUBLIC ${CMAKE_CURRENT_LIST_DIR}) +target_link_libraries(${COMPONENT_TARGET} PRIVATE ${component1}) diff --git a/tools/cmakev2/test/components/component2/component2.c b/tools/cmakev2/test/components/component2/component2.c new file mode 100644 index 00000000000..6bcd9f3526d --- /dev/null +++ b/tools/cmakev2/test/components/component2/component2.c @@ -0,0 +1,13 @@ +/* + * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#include +#include "component1.h" + +void component2_func(void) +{ + component1_func(); + printf("component2\n"); +} diff --git a/tools/cmakev2/test/components/component2/component2.h b/tools/cmakev2/test/components/component2/component2.h new file mode 100644 index 00000000000..0eb7756fcd9 --- /dev/null +++ b/tools/cmakev2/test/components/component2/component2.h @@ -0,0 +1,10 @@ +/* + * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef _COMPONENT2_H_ +#define _COMPONENT2_H_ + +void component2_func(void); +#endif