How to set "ESP_PLATFORM" to 1 in Custom CMake Projects

Serdar
Posts: 18
Joined: Fri Sep 02, 2022 7:33 pm

How to set "ESP_PLATFORM" to 1 in Custom CMake Projects

Postby Serdar » Wed Feb 22, 2023 2:56 am

Hi, i have a similar project to this. I used tinyUSB inside this project.
https://github.com/espressif/esp-idf/tr ... idf_as_lib

After get this warning I realized that ESP_PLATFORM is 0

Code: Select all

warning: implicit declaration of function 'traceISR_EXIT_TO_SCHEDULER' [-Wimplicit-function-declaration]

Code: Select all

void app_main(void)
{

    #if defined(ESP_PLATFORM)
    ESP_LOGI(TAG, "ESP_PLATFORM_Definded");
    #else
    ESP_LOGE(TAG, "ESP_PLATFORM_NOT_Definded");//code goes here
    #endif /*ESP_PLATFORM*/
    ....
    ....
I tried these to make ESP PLATFORM 1

/build-esp32s3.sh

Code: Select all

#!/usr/bin/env bash
set -euo pipefail
PARAM=""

# Retrive the target from the current filename, if no target specified,
# the variable will be empty

TARGET=$(echo $0 | cut -s -f2 -d- | cut -s -f1 -d.)

if [[ -n $TARGET ]]
then
    # Target is not null, specify the build parameters
    PARAM="-DESP_PLATFORM=1 -DCMAKE_TOOLCHAIN_FILE=$IDF_PATH/tools/cmake/toolchain-${TARGET}.cmake -DTARGET=${TARGET} -GNinja"
fi
rm -rf build && mkdir build && cd build
cmake .. $PARAM
cmake --build .
But that didn't work.

/CMakeLists.txt

Code: Select all

....
set(ESP_PLATFORM  ON)
....
But that didn't work too

How can I make ESP_PLATFORM set to 1 ?

Have a nice day!
-Serdar

ESP_Bob
Posts: 80
Joined: Fri Nov 27, 2020 12:52 pm

Re: How to set "ESP_PLATFORM" to 1 in Custom CMake Projects

Postby ESP_Bob » Tue Feb 20, 2024 3:55 am

IDF provide a simple cmake function `idf_build_set_property`, Please refer https://github.com/espressif/esp-idf/bl ... #L620-L621

Who is online

Users browsing this forum: Baidu [Spider], ccrause and 194 guests