From 0798691bf07a0fd746a0ade95de35a7e8ccb5a15 Mon Sep 17 00:00:00 2001 From: Harshit Malpani Date: Wed, 20 Sep 2023 14:05:10 +0530 Subject: [PATCH] fix: Fix protocols example to build without setting target Protocol examples used to raise an error if the target was not set and `idf.py build` command was used. This commit fix this error and when IDF_TARGET is not set, ESP32 is selected as default target --- examples/protocols/esp_http_client/CMakeLists.txt | 2 +- examples/protocols/esp_http_client/main/CMakeLists.txt | 4 +++- examples/protocols/http_server/simple/CMakeLists.txt | 2 +- examples/protocols/http_server/simple/main/CMakeLists.txt | 4 +++- examples/protocols/sockets/tcp_client/main/CMakeLists.txt | 4 +++- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/examples/protocols/esp_http_client/CMakeLists.txt b/examples/protocols/esp_http_client/CMakeLists.txt index e012d1a3fd..0715448e56 100644 --- a/examples/protocols/esp_http_client/CMakeLists.txt +++ b/examples/protocols/esp_http_client/CMakeLists.txt @@ -2,7 +2,7 @@ # CMakeLists in this exact order for cmake to work correctly cmake_minimum_required(VERSION 3.16) -if(${IDF_TARGET} STREQUAL "linux") +if("${IDF_TARGET}" STREQUAL "linux") set(COMPONENTS main) endif() diff --git a/examples/protocols/esp_http_client/main/CMakeLists.txt b/examples/protocols/esp_http_client/main/CMakeLists.txt index 23ba7fa726..bfee9f9c9e 100644 --- a/examples/protocols/esp_http_client/main/CMakeLists.txt +++ b/examples/protocols/esp_http_client/main/CMakeLists.txt @@ -2,7 +2,9 @@ # # (If this was a component, we would set COMPONENT_EMBED_TXTFILES here.) set(requires "") -if(${IDF_TARGET} STREQUAL "linux") +idf_build_get_property(target IDF_TARGET) + +if(${target} STREQUAL "linux") list(APPEND requires esp_stubs esp_event esp-tls esp_http_client protocol_examples_common nvs_flash) endif() idf_component_register(SRCS "esp_http_client_example.c" diff --git a/examples/protocols/http_server/simple/CMakeLists.txt b/examples/protocols/http_server/simple/CMakeLists.txt index 42acdd7cc7..9bed06a079 100644 --- a/examples/protocols/http_server/simple/CMakeLists.txt +++ b/examples/protocols/http_server/simple/CMakeLists.txt @@ -2,7 +2,7 @@ # in this exact order for cmake to work correctly cmake_minimum_required(VERSION 3.16) -if(${IDF_TARGET} STREQUAL "linux") +if("${IDF_TARGET}" STREQUAL "linux") set(COMPONENTS main) endif() diff --git a/examples/protocols/http_server/simple/main/CMakeLists.txt b/examples/protocols/http_server/simple/main/CMakeLists.txt index 28894fd56e..564c3f54f6 100644 --- a/examples/protocols/http_server/simple/main/CMakeLists.txt +++ b/examples/protocols/http_server/simple/main/CMakeLists.txt @@ -1,5 +1,7 @@ set(requires "") -if(${IDF_TARGET} STREQUAL "linux") +idf_build_get_property(target IDF_TARGET) + +if(${target} STREQUAL "linux") list(APPEND requires esp_stubs esp-tls esp_http_server protocol_examples_common nvs_flash) endif() idf_component_register(SRCS "main.c" diff --git a/examples/protocols/sockets/tcp_client/main/CMakeLists.txt b/examples/protocols/sockets/tcp_client/main/CMakeLists.txt index 0ac00ed402..5862a63d4a 100644 --- a/examples/protocols/sockets/tcp_client/main/CMakeLists.txt +++ b/examples/protocols/sockets/tcp_client/main/CMakeLists.txt @@ -1,4 +1,6 @@ -if(${IDF_TARGET} STREQUAL "linux") +idf_build_get_property(target IDF_TARGET) + +if(${target} STREQUAL "linux") set(requires esp_event esp_stubs protocol_examples_common nvs_flash) endif()