Skip to content

Commit

Permalink
CMake: Pass NDEBUG through LDC_CXXFLAGS rather than EXTRA_CXXFLAGS (l…
Browse files Browse the repository at this point in the history
…dc-developers#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
ldc-developers#4574

Fixes ldc-developers#4573.
  • Loading branch information
kalev authored Feb 5, 2024
1 parent def7bba commit 9ce6063
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

#
Expand Down

0 comments on commit 9ce6063

Please sign in to comment.