From 9ce6063c4d750e0b86c956a734d1a1e12d4e1ac8 Mon Sep 17 00:00:00 2001 From: Kalev Lember Date: Mon, 5 Feb 2024 22:02:43 +0100 Subject: [PATCH] CMake: Pass NDEBUG through LDC_CXXFLAGS rather than EXTRA_CXXFLAGS (#4575) NDEBUG needs to be correctly set depending on how LLVM is built. This commit moves -{D,U}NDEBUG from EXTRA_CXXFLAGS to LDC_CXXFLAGS as LDC_CXXFLAGS is already used for everything that links with LLVM and should be a better place to pass this. Suggested by Martin Kinkelin in https://github.com/ldc-developers/ldc/pull/4574 Fixes #4573. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f3c388a9938..3db2c0d8ec6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -505,13 +505,13 @@ message(STATUS "-- Building LDC with integrated LLD linker (LDC_WITH_LLD): ${LDC message(STATUS "-- Building LDC with enabled assertions (LDC_ENABLE_ASSERTIONS): ${LDC_ENABLE_ASSERTIONS}") if(LDC_ENABLE_ASSERTIONS) - append("-UNDEBUG" EXTRA_CXXFLAGS) + append("-UNDEBUG" LDC_CXXFLAGS) # avoid MSVC warning D9025 about "-DNDEBUG ... -UNDEBUG" string(REGEX REPLACE "(^| )[/-]D *NDEBUG( |$)" "\\1-UNDEBUG\\2" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") string(REGEX REPLACE "(^| )[/-]D *NDEBUG( |$)" "\\1-UNDEBUG\\2" CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}") string(REGEX REPLACE "(^| )[/-]D *NDEBUG( |$)" "\\1-UNDEBUG\\2" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") else() - append("-DNDEBUG" EXTRA_CXXFLAGS) + append("-DNDEBUG" LDC_CXXFLAGS) endif() #