Skip to content

Commit 1927f3f

Browse files
committed
CMake: Add LDC_ENABLE_ASSERTIONS option
As accidentally enabling them, combined with an LLVM 11 with disabled assertions, seems to work fine for the macOS/arm64 job. So allow the user to override the inherited LLVM assertions mode.
1 parent aafa48c commit 1927f3f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

CMakeLists.txt

+7-5
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ set(LIB_SUFFIX "" CACHE STRING "Appended to the library installation directory.
140140

141141
set(COMPILE_D_MODULES_SEPARATELY OFF CACHE BOOL "Compile each D module separately (instead of all at once). Useful for many CPU cores and/or iterative development; generated executables will be somewhat slower.")
142142

143+
set(LDC_ENABLE_ASSERTIONS "${LLVM_ENABLE_ASSERTIONS}" CACHE BOOL "Enable LDC assertions. Defaults to the LLVM assertions mode.")
144+
143145
if(D_VERSION EQUAL 1)
144146
message(FATAL_ERROR "D version 1 is no longer supported.
145147
Please consider using D version 2 or checkout the 'd1' git branch for the last version supporting D version 1.")
@@ -172,7 +174,7 @@ if(NOT MSVC_IDE)
172174
append("-O -inline -release" DFLAGS_BUILD_TYPE)
173175
endif()
174176

175-
if(LLVM_ENABLE_ASSERTIONS)
177+
if(LDC_ENABLE_ASSERTIONS)
176178
string(REPLACE " -release" "" DFLAGS_BUILD_TYPE "${DFLAGS_BUILD_TYPE}")
177179
endif()
178180
endif()
@@ -495,15 +497,15 @@ if(LDC_WITH_LLD)
495497
endif()
496498
message(STATUS "-- Building LDC with integrated LLD linker (LDC_WITH_LLD): ${LDC_WITH_LLD}")
497499

498-
# if llvm was built with assertions we have to do the same
499-
# as there are some headers with differing behavior based on NDEBUG
500-
if(LLVM_ENABLE_ASSERTIONS)
501-
message(STATUS "-- Building LDC with enabled assertions (inherited from LLVM build)")
500+
message(STATUS "-- Building LDC with enabled assertions (LDC_ENABLE_ASSERTIONS): ${LDC_ENABLE_ASSERTIONS}")
501+
if(LDC_ENABLE_ASSERTIONS)
502502
append("-UNDEBUG" EXTRA_CXXFLAGS)
503503
# avoid MSVC warning D9025 about "-DNDEBUG ... -UNDEBUG"
504504
string(REGEX REPLACE "(^| )[/-]D *NDEBUG( |$)" "\\1-UNDEBUG\\2" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
505505
string(REGEX REPLACE "(^| )[/-]D *NDEBUG( |$)" "\\1-UNDEBUG\\2" CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}")
506506
string(REGEX REPLACE "(^| )[/-]D *NDEBUG( |$)" "\\1-UNDEBUG\\2" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
507+
else()
508+
append("-DNDEBUG" EXTRA_CXXFLAGS)
507509
endif()
508510

509511
#

0 commit comments

Comments
 (0)