From f67955cd47aedc8ef813142d27f20f8858c5eca7 Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Tue, 25 Feb 2025 16:51:51 -0500
Subject: [PATCH] Remove C++ 17 workarounds for esp32.

These fail to compile currently with an error like:

```
CMake Error at CMakeLists.txt:83 (get_target_property):
  get_target_property() called with non-existent target
  "pw_build.cpp17._public_config".

CMake Error at CMakeLists.txt:86 (set_target_properties):
  set_target_properties Can not find target to add properties to:
  pw_build.cpp17._public_config
```

The target of `_public_config` seems private so we should not
mess with it. Tested that RPC compiles locally.
---
 config/ameba/chip.cmake                                   | 1 -
 examples/energy-management-app/esp32/CMakeLists.txt       | 4 ----
 examples/lighting-app/esp32/CMakeLists.txt                | 4 ----
 examples/lock-app/esp32/CMakeLists.txt                    | 4 ----
 examples/ota-requestor-app/esp32/CMakeLists.txt           | 4 ----
 examples/pigweed-app/esp32/CMakeLists.txt                 | 5 -----
 examples/temperature-measurement-app/esp32/CMakeLists.txt | 4 ----
 7 files changed, 26 deletions(-)

diff --git a/config/ameba/chip.cmake b/config/ameba/chip.cmake
index 9cd2ab5511b3fb..0a8f3c52b39a80 100644
--- a/config/ameba/chip.cmake
+++ b/config/ameba/chip.cmake
@@ -117,7 +117,6 @@ endif (matter_enable_persistentstorage_audit)
 
 # Build RPC
 if (matter_enable_rpc)
-#string(APPEND CHIP_GN_ARGS "remove_default_configs = [\"//third_party/connectedhomeip/third_party/pigweed/repo/pw_build:cpp17\"]\n")
 string(APPEND CHIP_GN_ARGS "chip_build_pw_rpc_lib = true\n")
 string(APPEND CHIP_GN_ARGS "pw_log_BACKEND = \"//third_party/connectedhomeip/third_party/pigweed/repo/pw_log_basic\"\n")
 string(APPEND CHIP_GN_ARGS "pw_assert_BACKEND = \"//third_party/connectedhomeip/third_party/pigweed/repo/pw_assert_log:check_backend\"\n")
diff --git a/examples/energy-management-app/esp32/CMakeLists.txt b/examples/energy-management-app/esp32/CMakeLists.txt
index c9944ab9a39e46..003d4c28f35343 100644
--- a/examples/energy-management-app/esp32/CMakeLists.txt
+++ b/examples/energy-management-app/esp32/CMakeLists.txt
@@ -80,8 +80,4 @@ add_subdirectory(third_party/connectedhomeip/third_party/pigweed/repo)
 add_subdirectory(third_party/connectedhomeip/third_party/nanopb/repo)
 add_subdirectory(third_party/connectedhomeip/examples/platform/esp32/pw_sys_io)
 
-get_target_property(_target_cxx_flags pw_build.cpp17._public_config INTERFACE_COMPILE_OPTIONS)
-list(REMOVE_ITEM _target_cxx_flags $<$<COMPILE_LANGUAGE:CXX>:-std=c++17>)
-list(APPEND _target_cxx_flags $<$<COMPILE_LANGUAGE:CXX>:-std=gnu++17>)
-set_target_properties(pw_build.cpp17._public_config PROPERTIES INTERFACE_COMPILE_OPTIONS "${_target_cxx_flags}")
 endif(CONFIG_ENABLE_PW_RPC)
diff --git a/examples/lighting-app/esp32/CMakeLists.txt b/examples/lighting-app/esp32/CMakeLists.txt
index ab349bb2ec4d86..1ff842ddaa169a 100644
--- a/examples/lighting-app/esp32/CMakeLists.txt
+++ b/examples/lighting-app/esp32/CMakeLists.txt
@@ -80,8 +80,4 @@ add_subdirectory(third_party/connectedhomeip/third_party/pigweed/repo)
 add_subdirectory(third_party/connectedhomeip/third_party/nanopb/repo)
 add_subdirectory(third_party/connectedhomeip/examples/platform/esp32/pw_sys_io)
 
-get_target_property(_target_cxx_flags pw_build.cpp17._public_config INTERFACE_COMPILE_OPTIONS)
-list(REMOVE_ITEM _target_cxx_flags $<$<COMPILE_LANGUAGE:CXX>:-std=c++17>)
-list(APPEND _target_cxx_flags $<$<COMPILE_LANGUAGE:CXX>:-std=gnu++17>)
-set_target_properties(pw_build.cpp17._public_config PROPERTIES INTERFACE_COMPILE_OPTIONS "${_target_cxx_flags}")
 endif(CONFIG_ENABLE_PW_RPC)
diff --git a/examples/lock-app/esp32/CMakeLists.txt b/examples/lock-app/esp32/CMakeLists.txt
index 24110deb8352c2..dc60efc678c4c9 100644
--- a/examples/lock-app/esp32/CMakeLists.txt
+++ b/examples/lock-app/esp32/CMakeLists.txt
@@ -61,10 +61,6 @@ add_subdirectory(third_party/connectedhomeip/third_party/pigweed/repo)
 add_subdirectory(third_party/connectedhomeip/third_party/nanopb/repo)
 add_subdirectory(third_party/connectedhomeip/examples/platform/esp32/pw_sys_io)
 
-get_target_property(_target_cxx_flags pw_build.cpp17._public_config INTERFACE_COMPILE_OPTIONS)
-list(REMOVE_ITEM _target_cxx_flags $<$<COMPILE_LANGUAGE:CXX>:-std=c++17>)
-list(APPEND _target_cxx_flags $<$<COMPILE_LANGUAGE:CXX>:-std=gnu++17>)
-set_target_properties(pw_build.cpp17._public_config PROPERTIES INTERFACE_COMPILE_OPTIONS "${_target_cxx_flags}")
 endif(CONFIG_ENABLE_PW_RPC)
 
 flashing_script()
diff --git a/examples/ota-requestor-app/esp32/CMakeLists.txt b/examples/ota-requestor-app/esp32/CMakeLists.txt
index 567bd30267ff78..1a151debdd8901 100644
--- a/examples/ota-requestor-app/esp32/CMakeLists.txt
+++ b/examples/ota-requestor-app/esp32/CMakeLists.txt
@@ -61,10 +61,6 @@ add_subdirectory(third_party/connectedhomeip/third_party/pigweed/repo)
 add_subdirectory(third_party/connectedhomeip/third_party/nanopb/repo)
 add_subdirectory(third_party/connectedhomeip/examples/platform/esp32/pw_sys_io)
 
-get_target_property(_target_cxx_flags pw_build.cpp17._public_config INTERFACE_COMPILE_OPTIONS)
-list(REMOVE_ITEM _target_cxx_flags $<$<COMPILE_LANGUAGE:CXX>:-std=c++17>)
-list(APPEND _target_cxx_flags $<$<COMPILE_LANGUAGE:CXX>:-std=gnu++17>)
-set_target_properties(pw_build.cpp17._public_config PROPERTIES INTERFACE_COMPILE_OPTIONS "${_target_cxx_flags}")
 endif(CONFIG_ENABLE_PW_RPC)
 
 
diff --git a/examples/pigweed-app/esp32/CMakeLists.txt b/examples/pigweed-app/esp32/CMakeLists.txt
index 08d38727e94e1b..262376d5ea9562 100644
--- a/examples/pigweed-app/esp32/CMakeLists.txt
+++ b/examples/pigweed-app/esp32/CMakeLists.txt
@@ -62,9 +62,4 @@ add_subdirectory(third_party/connectedhomeip/third_party/pigweed/repo)
 add_subdirectory(third_party/connectedhomeip/third_party/nanopb/repo)
 add_subdirectory(third_party/connectedhomeip/examples/platform/esp32/pw_sys_io)
 
-get_target_property(_target_cxx_flags pw_build.cpp17._public_config INTERFACE_COMPILE_OPTIONS)
-list(REMOVE_ITEM _target_cxx_flags $<$<COMPILE_LANGUAGE:CXX>:-std=c++17>)
-list(APPEND _target_cxx_flags $<$<COMPILE_LANGUAGE:CXX>:-std=gnu++17>)
-set_target_properties(pw_build.cpp17._public_config PROPERTIES INTERFACE_COMPILE_OPTIONS "${_target_cxx_flags}")
-
 flashing_script(DEPENDS "${CMAKE_CURRENT_LIST_DIR}/echo_test_config.yml" "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/pigweed-app/mobly_tests/echo_test.py")
diff --git a/examples/temperature-measurement-app/esp32/CMakeLists.txt b/examples/temperature-measurement-app/esp32/CMakeLists.txt
index c1c8251bfdbba4..cba8c066ed419d 100644
--- a/examples/temperature-measurement-app/esp32/CMakeLists.txt
+++ b/examples/temperature-measurement-app/esp32/CMakeLists.txt
@@ -63,8 +63,4 @@ add_subdirectory(third_party/connectedhomeip/third_party/pigweed/repo)
 add_subdirectory(third_party/connectedhomeip/third_party/nanopb/repo)
 add_subdirectory(third_party/connectedhomeip/examples/platform/esp32/pw_sys_io)
 
-get_target_property(_target_cxx_flags pw_build.cpp17._public_config INTERFACE_COMPILE_OPTIONS)
-list(REMOVE_ITEM _target_cxx_flags $<$<COMPILE_LANGUAGE:CXX>:-std=c++17>)
-list(APPEND _target_cxx_flags $<$<COMPILE_LANGUAGE:CXX>:-std=gnu++17>)
-set_target_properties(pw_build.cpp17._public_config PROPERTIES INTERFACE_COMPILE_OPTIONS "${_target_cxx_flags}")
 endif(CONFIG_ENABLE_PW_RPC)