Skip to content

Commit 8e273c3

Browse files
alandefreitassdkrystian
authored andcommitted
build: reset LLVM warning flags
LLVM unfortunately defines global compile flags that are inherited by all other targets in the project, including fetched dependencies. Warning flags, with are functionally unnecessary, can cause conflicts with other targets. fix cppalliance#251
1 parent 8a0bb97 commit 8e273c3

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

CMakeLists.txt

+24-2
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,25 @@ endif()
7777

7878
set(CMAKE_FOLDER Dependencies)
7979

80+
macro(add_variable_override var_name var_val)
81+
macro(handle_${var_name}_access var)
82+
set(${var} ${var_val})
83+
endmacro()
84+
variable_watch(${var_name} handle_${var_name}_access)
85+
endmacro()
86+
87+
macro(remove_variable_override var_name)
88+
macro(handle_${var_name}_access)
89+
endmacro()
90+
endmacro()
91+
8092
# LLVM
8193
find_package(LLVM REQUIRED CONFIG)
8294
find_package(Clang REQUIRED CONFIG)
8395
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
96+
add_variable_override(msvc_warning_flags "")
8497
include(HandleLLVMOptions)
98+
remove_variable_override(msvc_warning_flags)
8599
add_definitions(${LLVM_DEFINITIONS})
86100
llvm_map_components_to_libnames(llvm_libs all)
87101

@@ -181,16 +195,24 @@ if (WIN32)
181195
get_target_property(LLVM_CONFIGURATION_TYPE LLVMCore IMPORTED_CONFIGURATIONS)
182196
if (LLVM_CONFIGURATION_TYPE STREQUAL RELWITHDEBINFO)
183197
target_compile_definitions(mrdox PUBLIC -D_ITERATOR_DEBUG_LEVEL=0)
184-
target_compile_options(mrdox PUBLIC /MD)
198+
# target_compile_options(mrdox PUBLIC /MD)
185199
endif()
186200
if(MSVC)
187201
target_compile_options(
188202
mrdox
189203
PUBLIC
190204
/permissive- # strict C++
191-
/W4 # enable all warnings
192205
/MP # multi-processor compilation
193206
/EHsc # C++ Exception handling
207+
/W4 # enable all warnings
208+
/wd4100 # unreferenced formal parameter
209+
/wd4702 # unreachable code
210+
/wd4706 # assignment within conditional expression
211+
/wd4244 # narrowing integral conversion
212+
/wd4267 # narrowing std::size_t conversion
213+
/wd4456 # declaration hides local declaration
214+
/wd4457 # declaration hides function parameter declaration
215+
/wd4459 # declaration hides global declaration
194216
)
195217
endif()
196218
endif ()

0 commit comments

Comments
 (0)