mirror of
https://github.com/intel/llvm.git
synced 2026-01-17 14:48:27 +08:00
[CMake][llvm] avoid changing global flags (may be used outside of llvm)
Changing global flags can break builds of projects that include/build llvm as a sub-project, as the effect is global. Ideally we would disable this warning at the directory level instead, but the obvious way (disabling warning D9025) isn't supported. At least we can limit the effect to only MSVC. Patch by Jim Radford. Differential Revision: https://reviews.llvm.org/D100900
This commit is contained in:
committed by
Francis Visoiu Mistrih
parent
91f7a4fff7
commit
16a0d80912
@@ -62,18 +62,19 @@ if( LLVM_ENABLE_ASSERTIONS )
|
||||
# NOTE: use `add_compile_options` rather than `add_definitions` since
|
||||
# `add_definitions` does not support generator expressions.
|
||||
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-UNDEBUG>)
|
||||
|
||||
# Also remove /D NDEBUG to avoid MSVC warnings about conflicting defines.
|
||||
foreach (flags_var_to_scrub
|
||||
CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL
|
||||
CMAKE_C_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_C_FLAGS_MINSIZEREL)
|
||||
string (REGEX REPLACE "(^| )[/-]D *NDEBUG($| )" " "
|
||||
"${flags_var_to_scrub}" "${${flags_var_to_scrub}}")
|
||||
endforeach()
|
||||
if (MSVC)
|
||||
# Also remove /D NDEBUG to avoid MSVC warnings about conflicting defines.
|
||||
foreach (flags_var_to_scrub
|
||||
CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL
|
||||
CMAKE_C_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_C_FLAGS_MINSIZEREL)
|
||||
string (REGEX REPLACE "(^| )[/-]D *NDEBUG($| )" " "
|
||||
"${flags_var_to_scrub}" "${${flags_var_to_scrub}}")
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user