diff --git a/components/app_trace/CMakeLists.txt b/components/app_trace/CMakeLists.txt index 78513c5c295..56a53429a4e 100644 --- a/components/app_trace/CMakeLists.txt +++ b/components/app_trace/CMakeLists.txt @@ -4,8 +4,9 @@ if(${target} STREQUAL "linux") return() # This component is not supported by the POSIX/Linux simulator endif() +set(srcs) if(CONFIG_ESP_TRACE_TRANSPORT_APPTRACE) - set(srcs + list(APPEND srcs "app_trace.c" "app_trace_util.c" "host_file_io.c" diff --git a/components/bootloader_support/CMakeLists.txt b/components/bootloader_support/CMakeLists.txt index 4f4f71702d8..9a91d1c10e9 100644 --- a/components/bootloader_support/CMakeLists.txt +++ b/components/bootloader_support/CMakeLists.txt @@ -105,9 +105,13 @@ else() esp_hal_clock esp_hal_security) endif() +# src/flash_encrypt.c includes esp_security/esp_key_mgr.h on +# SOC_KEY_MANAGER_SUPPORTED targets. flash_encrypt.c is in the unconditional +# srcs list, so declare the dep unconditionally for all build variants. +list(APPEND priv_requires esp_security) + if(BOOTLOADER_BUILD) list(APPEND srcs "src/bootloader_panic.c") - list(APPEND priv_requires esp_security) if(CONFIG_SECURE_FLASH_ENC_ENABLED) list(APPEND srcs "src/flash_encryption/flash_encrypt.c" diff --git a/components/bt/CMakeLists.txt b/components/bt/CMakeLists.txt index 190b388c73d..25919fd36dd 100644 --- a/components/bt/CMakeLists.txt +++ b/components/bt/CMakeLists.txt @@ -91,6 +91,7 @@ set(bt_priv_requires esp_ringbuf esp_gdbstub esp_security + esp_event ) idf_component_register(SRCS "${srcs}" diff --git a/components/console/linenoise/linenoise.c b/components/console/linenoise/linenoise.c index 64fcf23a12d..e0c0bc21657 100644 --- a/components/console/linenoise/linenoise.c +++ b/components/console/linenoise/linenoise.c @@ -124,9 +124,11 @@ #include #include #include "linenoise.h" +#if !CONFIG_IDF_TARGET_LINUX #if CONFIG_LIBC_PICOLIBC #include #endif +#endif // !CONFIG_IDF_TARGET_LINUX #if CONFIG_LIBC_PICOLIBC && !CONFIG_LIBC_PICOLIBC_NEWLIB_COMPATIBILITY __thread FILE *linenoise_stdin; diff --git a/components/esp_event/test_apps/main/CMakeLists.txt b/components/esp_event/test_apps/main/CMakeLists.txt index f5f1624eda0..025a652260b 100644 --- a/components/esp_event/test_apps/main/CMakeLists.txt +++ b/components/esp_event/test_apps/main/CMakeLists.txt @@ -1,7 +1,7 @@ idf_build_get_property(target IDF_TARGET) set(srcs "test_event_main.c" "test_event_common.cpp") -set(priv_requires "esp_event unity") +set(priv_requires esp_event unity) if(NOT ${target} STREQUAL "linux") list(APPEND srcs diff --git a/components/esp_hal_gpspi/spi_hal_iram.c b/components/esp_hal_gpspi/spi_hal_iram.c index f03bffcc91c..10386c34cb6 100644 --- a/components/esp_hal_gpspi/spi_hal_iram.c +++ b/components/esp_hal_gpspi/spi_hal_iram.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -50,10 +50,12 @@ esp_err_t spi_hal_cal_clock_conf(const spi_hal_timing_param_t *timing_param, spi spi_hal_cal_timing(timing_param->clk_src_hz, eff_clk_n, timing_param->use_gpio, timing_param->input_delay_ns, &dummy, &miso_delay); #if SPI_LL_SUPPORT_TIME_TUNING - const int freq_limit = spi_hal_get_freq_limit(timing_param->use_gpio, timing_param->input_delay_ns); - if (!(timing_param->half_duplex || dummy == 0 || timing_param->no_compensate)) { - // This only a short log used as a "key" of the idf hint system, see `hints.yml` + // Short log used as a "key" by the idf hint system (see `hints.yml`). + // freq_limit is consumed only by HAL_EARLY_LOGE; mark unused so + // -Wunused-variable stays quiet when the macro expands to empty. + const int freq_limit __attribute__((unused)) = + spi_hal_get_freq_limit(timing_param->use_gpio, timing_param->input_delay_ns); HAL_EARLY_LOGE(SPI_HAL_TAG, "The clock_speed_hz should less than %d", freq_limit); return ESP_ERR_NOT_SUPPORTED; } diff --git a/components/esp_hal_sd/sdio_slave_hal.c b/components/esp_hal_sd/sdio_slave_hal.c index 25829f397e1..dd36936bd71 100644 --- a/components/esp_hal_sd/sdio_slave_hal.c +++ b/components/esp_hal_sd/sdio_slave_hal.c @@ -7,6 +7,7 @@ // The HAL layer for SDIO slave (common part) #include +#include #include #include "soc/sdio_slc_struct.h" #include "soc/sdio_hinf_struct.h" diff --git a/components/esp_hw_support/include/spinlock.h b/components/esp_hw_support/include/spinlock.h index 66f825efce4..e34f7564879 100644 --- a/components/esp_hw_support/include/spinlock.h +++ b/components/esp_hw_support/include/spinlock.h @@ -13,7 +13,7 @@ #if __XTENSA__ #include "xtensa/xtruntime.h" #include "xt_utils.h" -#else +#elif __riscv #include "riscv/rv_utils.h" #endif diff --git a/components/esp_libc/Kconfig b/components/esp_libc/Kconfig index 6c7447c9d60..f49eee7c104 100644 --- a/components/esp_libc/Kconfig +++ b/components/esp_libc/Kconfig @@ -1,4 +1,5 @@ menu "LibC" + depends on !IDF_TARGET_LINUX choice LIBC prompt "LibC to build application with" diff --git a/components/esp_partition/host_test/partition_api_test/CMakeLists.txt b/components/esp_partition/host_test/partition_api_test/CMakeLists.txt index e2f75e47709..ead8ac860c6 100644 --- a/components/esp_partition/host_test/partition_api_test/CMakeLists.txt +++ b/components/esp_partition/host_test/partition_api_test/CMakeLists.txt @@ -41,4 +41,4 @@ add_custom_target(partition-table-8M ${partition_table_display} VERBATIM) -add_dependencies(partition_api_test.elf partition-table partition-table-8M) +add_dependencies(${project_elf} partition-table partition-table-8M) diff --git a/components/esp_stdio/CMakeLists.txt b/components/esp_stdio/CMakeLists.txt index b929cc4e4a7..f4253624659 100644 --- a/components/esp_stdio/CMakeLists.txt +++ b/components/esp_stdio/CMakeLists.txt @@ -27,7 +27,7 @@ endif() idf_component_register(SRCS ${srcs} INCLUDE_DIRS ${includes}) -if(CONFIG_VFS_SUPPORT_IO) +if(CONFIG_VFS_SUPPORT_IO AND NOT ${target} STREQUAL "linux") if(IDF_BUILD_V2) idf_component_include(vfs) @@ -63,6 +63,9 @@ if(CONFIG_VFS_SUPPORT_IO) endif() target_link_libraries(${COMPONENT_LIB} PRIVATE idf::vfs) - # Make sure esp_stdio_register gets called at startup stage + # Make sure esp_stdio_register gets called at startup stage. + # The referenced symbol is defined in stdio_vfs.c, which is only added to + # the source list above on non-Linux targets; the force-undef is gated on + # the same condition for the link line to remain resolvable. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u esp_vfs_include_console_register") endif() diff --git a/components/esp_tee/CMakeLists.txt b/components/esp_tee/CMakeLists.txt index f75bb4b970b..dcba631e4d3 100644 --- a/components/esp_tee/CMakeLists.txt +++ b/components/esp_tee/CMakeLists.txt @@ -19,6 +19,7 @@ elseif(esp_tee_build) # TEE build currently only uses the shared headers. idf_component_register(INCLUDE_DIRS include) else() + set(srcs) if(CONFIG_SECURE_ENABLE_TEE) if(NOT CMAKE_BUILD_EARLY_EXPANSION) # Add custom flash target for TEE binary diff --git a/components/esp_trace/CMakeLists.txt b/components/esp_trace/CMakeLists.txt index 876cdf00e77..937b664d110 100644 --- a/components/esp_trace/CMakeLists.txt +++ b/components/esp_trace/CMakeLists.txt @@ -4,8 +4,9 @@ if(${target} STREQUAL "linux") return() endif() +set(srcs) if(CONFIG_ESP_TRACE_ENABLE) - set(srcs + list(APPEND srcs "src/core/esp_trace_core.c" "src/core/esp_trace_registry.c" "src/ports/port_utils.c" diff --git a/components/esp_wifi/CMakeLists.txt b/components/esp_wifi/CMakeLists.txt index ddda9ebb331..a0c6f614167 100644 --- a/components/esp_wifi/CMakeLists.txt +++ b/components/esp_wifi/CMakeLists.txt @@ -15,25 +15,18 @@ if( NOT CONFIG_ESP_WIFI_ENABLED "src/wifi_netif.c" "src/wifi_default_ap.c") - # In build system v2, idf_component_optional_requires() includes the target - # component into the build immediately, so these stub sources are compiled - # even on targets where Wi-Fi is not supported. The stubs need esp_event and - # esp_netif headers, so those dependencies must be declared here for v2. - # - # In build system v1, idf_component_optional_requires() only links a - # component that is already part of the build. On non-Wi-Fi targets, this - # component is never pulled in, so the stubs are never compiled and the - # dependencies are not needed. Additionally, the CMAKE_BUILD_EARLY_EXPANSION - # guard ensures that the stubs are not compiled for v1. - set(priv_reqs "") - if(IDF_BUILD_V2) - set(priv_reqs "esp_event" "esp_netif") - endif() + # Public headers (notably esp_wifi_default.h) include esp_event.h, + # esp_netif.h and esp_phy.h. Declare these in REQUIRES so the headers + # are visible to consumers — same interface as the WiFi-enabled + # registration at the bottom of this file. + set(reqs "esp_event" "esp_netif" "esp_phy") + set(priv_reqs "wpa_supplicant") # This component provides "esp_wifi" "wifi_apps/nan_app" headers if WiFi not enabled # (implementation supported optionally in a managed component esp_wifi_remote) idf_component_register(SRCS "${srcs}" INCLUDE_DIRS "include" "wifi_apps/nan_app/include" + REQUIRES ${reqs} PRIV_REQUIRES ${priv_reqs}) add_subdirectory(remote) # wifi-remote on esp32p4/h2 (no wifi) return() diff --git a/components/hal/CMakeLists.txt b/components/hal/CMakeLists.txt index 31fc5d88bc7..f9ab4e27f0c 100644 --- a/components/hal/CMakeLists.txt +++ b/components/hal/CMakeLists.txt @@ -3,6 +3,7 @@ idf_build_get_property(esp_tee_build ESP_TEE_BUILD) set(srcs "hal_utils.c") set(includes "platform_port/include") +set(priv_include) set(requires) # target specific include must be added before the generic one diff --git a/components/nvs_flash/host_test/nvs_page_test/main/CMakeLists.txt b/components/nvs_flash/host_test/nvs_page_test/main/CMakeLists.txt index ef19b495893..37dd200b799 100644 --- a/components/nvs_flash/host_test/nvs_page_test/main/CMakeLists.txt +++ b/components/nvs_flash/host_test/nvs_page_test/main/CMakeLists.txt @@ -8,7 +8,7 @@ idf_component_register(SRCS "nvs_page_test.cpp" PRIV_REQUIRES spi_flash) target_compile_options(${COMPONENT_LIB} PUBLIC --coverage) -target_link_libraries(${COMPONENT_LIB} --coverage) +target_link_libraries(${COMPONENT_LIB} PUBLIC --coverage) if(CMAKE_C_COMPILER_ID MATCHES "Clang") target_compile_options(${COMPONENT_LIB} PRIVATE -std=gnu++20) endif() diff --git a/components/spiffs/CMakeLists.txt b/components/spiffs/CMakeLists.txt index e53ea7166dd..27ae6405740 100644 --- a/components/spiffs/CMakeLists.txt +++ b/components/spiffs/CMakeLists.txt @@ -6,6 +6,8 @@ set(original_srcs "spiffs/src/spiffs_cache.c" "spiffs/src/spiffs_hydrogen.c" "spiffs/src/spiffs_nucleus.c") +set(srcs) +set(pr) list(APPEND srcs "spiffs_api.c" ${original_srcs}) if(NOT ${target} STREQUAL "linux") diff --git a/components/spiffs/host_test/CMakeLists.txt b/components/spiffs/host_test/CMakeLists.txt index ad58d6cb410..5d962307296 100644 --- a/components/spiffs/host_test/CMakeLists.txt +++ b/components/spiffs/host_test/CMakeLists.txt @@ -23,4 +23,4 @@ set_property( APPEND PROPERTY ADDITIONAL_CLEAN_FILES "${build_dir}/image.bin") -add_dependencies(host_test_spiffs.elf image.bin) +add_dependencies(${project_elf} image.bin) diff --git a/components/ulp/project_include.cmake b/components/ulp/project_include.cmake index 891bbaecc43..bc9712fa26e 100644 --- a/components/ulp/project_include.cmake +++ b/components/ulp/project_include.cmake @@ -5,6 +5,7 @@ function(__setup_ulp_project app_name project_path prefix type s_sources exp_dep_srcs) if(NOT CMAKE_BUILD_EARLY_EXPANSION) + set(sources "") spaces2list(s_sources) foreach(source ${s_sources}) get_filename_component(source ${source} ABSOLUTE BASE_DIR ${CMAKE_CURRENT_LIST_DIR}) diff --git a/examples/common_components/protocol_examples_common/CMakeLists.txt b/examples/common_components/protocol_examples_common/CMakeLists.txt index 56b6b035669..a57438922ad 100644 --- a/examples/common_components/protocol_examples_common/CMakeLists.txt +++ b/examples/common_components/protocol_examples_common/CMakeLists.txt @@ -33,7 +33,8 @@ endif() idf_component_register(SRCS "${srcs}" INCLUDE_DIRS "include" - PRIV_REQUIRES esp_netif esp_driver_gpio esp_driver_uart esp_wifi vfs console openthread) + REQUIRES esp_netif + PRIV_REQUIRES esp_driver_gpio esp_driver_uart esp_wifi vfs console openthread) if(CONFIG_EXAMPLE_PROVIDE_WIFI_CONSOLE_CMD) idf_component_optional_requires(PRIVATE console) diff --git a/examples/protocols/dns_over_https/components/dns_over_https/CMakeLists.txt b/examples/protocols/dns_over_https/components/dns_over_https/CMakeLists.txt index 38bfd7d6e1b..8e7b57083f3 100644 --- a/examples/protocols/dns_over_https/components/dns_over_https/CMakeLists.txt +++ b/examples/protocols/dns_over_https/components/dns_over_https/CMakeLists.txt @@ -3,5 +3,5 @@ idf_component_register(SRCS "dns_over_https.c" "dns_utils.c" PRIV_REQUIRES nvs_flash lwip esp_event esp-tls esp_http_client) if(CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_CUSTOM) - target_link_libraries(${COMPONENT_LIB} "-u lwip_hook_netconn_external_resolve") + target_link_libraries(${COMPONENT_LIB} PRIVATE "-u lwip_hook_netconn_external_resolve") endif() diff --git a/examples/protocols/dns_over_https/main/CMakeLists.txt b/examples/protocols/dns_over_https/main/CMakeLists.txt index 90701fa2804..30048ac7121 100644 --- a/examples/protocols/dns_over_https/main/CMakeLists.txt +++ b/examples/protocols/dns_over_https/main/CMakeLists.txt @@ -7,4 +7,5 @@ endif() idf_component_register(SRCS "example_dns_over_https.c" INCLUDE_DIRS "." + PRIV_REQUIRES time_sync nvs_flash esp_event esp_timer mbedtls EMBED_TXTFILES ${cert_file}) diff --git a/tools/test_apps/system/gdb/main/CMakeLists.txt b/tools/test_apps/system/gdb/main/CMakeLists.txt index 69def7bc1d8..6d3124864f7 100644 --- a/tools/test_apps/system/gdb/main/CMakeLists.txt +++ b/tools/test_apps/system/gdb/main/CMakeLists.txt @@ -1,3 +1,4 @@ idf_component_register(SRCS "hello_world_main.c" - INCLUDE_DIRS "") + INCLUDE_DIRS "" + PRIV_REQUIRES spi_flash) target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/tools/test_apps/system/memprot/main/CMakeLists.txt b/tools/test_apps/system/memprot/main/CMakeLists.txt index 7a4baca5a7e..102448ae89d 100644 --- a/tools/test_apps/system/memprot/main/CMakeLists.txt +++ b/tools/test_apps/system/memprot/main/CMakeLists.txt @@ -1,10 +1,13 @@ if( IDF_TARGET STREQUAL "esp32s2" ) idf_component_register(SRCS "esp32s2/test_memprot_main.c" "esp32s2/test_panic.c" - INCLUDE_DIRS "") + INCLUDE_DIRS "" + PRIV_REQUIRES esp_hal_wdt) elseif( IDF_TARGET STREQUAL "esp32c3" ) idf_component_register(SRCS "esp32c3/test_memprot_main.c" "esp32c3/test_panic.c" "esp32c3/return_from_panic.S" - INCLUDE_DIRS "") + INCLUDE_DIRS "" + PRIV_REQUIRES esp_hal_wdt) elseif( IDF_TARGET STREQUAL "esp32s3" ) idf_component_register(SRCS "esp32s3/test_memprot_main.c" "esp32s3/test_panic.c" - INCLUDE_DIRS "") + INCLUDE_DIRS "" + PRIV_REQUIRES esp_hal_wdt) endif()