cmake: Corrected setting of C++ language standard

* reverted old faulty mechanism to set different
  standard according to the toolchain
* Using -std=gnu++2b now for both gcc and clang
* Added a build test app to check the C++ standard in IDF
* Updated english docs to reflect the change to C++23
This commit is contained in:
Jakob Hasse
2023-05-09 10:09:19 +08:00
parent 75d00928f5
commit 0244c24c8d
6 changed files with 40 additions and 13 deletions
@@ -3,8 +3,13 @@
# C++ build test
This build-only app can be used to check if certain headers, macros or features can be successfully compiled in a C++ source file.
This build-only app can be used to check if certain headers, macros or features can be successfully compiled in a C++ source file. It furthermore checks the current C++ language standard set in IDF is the expected one.
To add a new test, create a new file `main/test_<name>.cpp` and add it to main/CMakeLists.txt.
## This App Broke My Build :(
If you need to check specific compiler flags, use `set_source_files_properties` CMake function to adjust the compilation flags for the given source file.
It is likely that one of the following situations occurred:
1. The language standard for IDF has been changed without changing the test in this application.
2. Code incompatible to C++ has been added to one of the public header files in IDF. Check the C++ documentation section [Combining C and C++ code](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/cplusplus.html#combining-c-and-c-code) for more details.
## Adding New Test
Create a new file `main/test_<name>.cpp` and add it to main/CMakeLists.txt. If you need to check specific compiler flags, use `set_source_files_properties` CMake function to adjust the compilation flags for the given source file.
@@ -1,6 +1,7 @@
idf_component_register(SRCS cxx_build_test_main.cpp
test_soc_reg_macros.cpp
test_esp_hw_support.cpp
test_cxx_standard.cpp
INCLUDE_DIRS "."
PRIV_REQUIRES driver
REQUIRES soc)
@@ -0,0 +1,10 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
/*
* Current (2023-05-04) value for -std=gnu++23 and -std=gnu++2b.
* If you change the C++ standard for IDF, you also need to change this.
*/
static_assert(__cplusplus == 202100L);