Difference between platforms in global ${CMAKE_CXX_FLAGS} defintion.

CvR_XX
Posts: 3
Joined: Thu Oct 21, 2021 9:39 am

Difference between platforms in global ${CMAKE_CXX_FLAGS} defintion.

Postby CvR_XX » Thu Oct 21, 2021 9:48 am

I'm trying to set some C++ flags for all the components I'm using.

I've succeeded by adding set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSOMEFLAG") to the CMakeLists.txt in the main folder. This compiles perfectly and all components see the define SOMEFLAG. Idf.py --version outputs: ESP-IDF v4.3.1.

Now it gets interesting. When I compile the exact same code in the esp-idf docker container the build fails because the defines are not found in the other components. If I run Idf.py --version here it outputs: ESP-IDF v4.3.1-dirty.

What could cause this? How can I add defines so that they would also be found by the components in the docker container?

Thanks in advance!

Carlos

ESP_Dazz
Posts: 308
Joined: Fri Jun 02, 2017 6:50 am

Re: Difference between platforms in global ${CMAKE_CXX_FLAGS} defintion.

Postby ESP_Dazz » Sat Oct 23, 2021 6:42 am

  • Use idf_build_set_property() at the project level to set properties at the project level (e.g., apply compiler flags across the entire project).
  • To target the compiler options of a particular component, try target_compile_options() inside the component's CMakeLists.txt

Who is online

Users browsing this forum: Baidu [Spider] and 119 guests