From 2de70c79c2193b598046e8debf1e738ff3879961 Mon Sep 17 00:00:00 2001 From: "Peter S. Hollander" Date: Fri, 21 Jun 2024 19:37:33 +0000 Subject: [PATCH] Fix PICO_DEOPTIMIZED_DEBUG not updating compiler flags (#1620) * Fix PICO_DEOPTIMIZED_DEBUG not updating compiler flags Setting CMAKE_${LANG}_FLAGS_DEBUG_INIT specifically only sets the flags for the Debug config the first time it is configured by CMake, pulling the initially-configured flags from CMakeCache.txt on subsequent configurations. This causes PICO_DEOPTIMIZED_DEBUG to not have any effect after the initial configuration, causing breakpoint issues when debugging certain functions. Clearing the cache of the debug flags allows the flags to be updated every configuration, and appended to appropriately (such as with "-g"). See Issue #1618 and the comments of Pull Request #1620 for further details. Fixes #1618 --- cmake/preload/toolchains/set_flags.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/preload/toolchains/set_flags.cmake b/cmake/preload/toolchains/set_flags.cmake index bd6e24070..7f208db3b 100644 --- a/cmake/preload/toolchains/set_flags.cmake +++ b/cmake/preload/toolchains/set_flags.cmake @@ -2,6 +2,7 @@ get_property(IS_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE) foreach(LANG IN ITEMS C CXX ASM) set(CMAKE_${LANG}_FLAGS_INIT "${ARM_TOOLCHAIN_COMMON_FLAGS}") + unset(CMAKE_${LANG}_FLAGS_DEBUG CACHE) if (PICO_DEOPTIMIZED_DEBUG) set(CMAKE_${LANG}_FLAGS_DEBUG_INIT "-O0") else()