File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,9 @@ option(VAL_USE_LIBBACKTRACE_BACKTRACE "enable libbacktrace validation backtrace
4747set (UR_DPCXX "" CACHE FILEPATH "Path of the DPC++ compiler executable" )
4848set (UR_SYCL_LIBRARY_DIR "" CACHE PATH
4949 "Path of the SYCL runtime library directory" )
50+ option (UR_ENABLE_ASSERTIONS "Enable assertions for all build types" OFF )
51+
52+ include (Assertions)
5053
5154set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} /lib)
5255set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} /lib)
Original file line number Diff line number Diff line change 1+ # From the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2+ # See https://llvm.org/LICENSE.txt for license information.
3+ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
5+ # This is lifted from llvm's LLVM_ENABLE_ASSERTIONS implementation
6+ # https://github.com/llvm/llvm-project/blob/6be0e979896f7dd610abf263f845c532f1be3762/llvm/cmake/modules/HandleLLVMOptions.cmake#L89
7+ if (UR_ENABLE_ASSERTIONS)
8+ # MSVC doesn't like _DEBUG on release builds
9+ if ( NOT MSVC )
10+ add_compile_definitions (_DEBUG)
11+ endif ()
12+ # On non-Debug builds cmake automatically defines NDEBUG, so we
13+ # explicitly undefine it:
14+ if ( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
15+ add_compile_options ($<$<OR :$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-UNDEBUG>)
16+ if (MSVC )
17+ # Also remove /D NDEBUG to avoid MSVC warnings about conflicting defines.
18+ foreach (flags_var_to_scrub
19+ CMAKE_CXX_FLAGS_RELEASE
20+ CMAKE_CXX_FLAGS_RELWITHDEBINFO
21+ CMAKE_CXX_FLAGS_MINSIZEREL
22+ CMAKE_C_FLAGS_RELEASE
23+ CMAKE_C_FLAGS_RELWITHDEBINFO
24+ CMAKE_C_FLAGS_MINSIZEREL)
25+ string (REGEX REPLACE "(^| )[/-]D *NDEBUG($| )" " "
26+ "${flags_var_to_scrub} " "${${flags_var_to_scrub} }" )
27+ endforeach ()
28+ endif ()
29+ endif ()
30+ endif ()
You can’t perform that action at this time.
0 commit comments