Skip to content

Commit 8aa3000

Browse files
committedMar 19, 2015
[CMake] Don't pass in MSVC warning flags as definitions.
NFC currently but required as a prerequisite for using the Microsoft resource compiler in conjunction with CMake's ninja generator, which knows how to filter flags appropriately, but not definitions. Differential Revision: http://reviews.llvm.org/D8188 llvm-svn: 232727
1 parent 845e32c commit 8aa3000

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed
 

‎llvm/cmake/modules/HandleLLVMOptions.cmake

+9-2
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,9 @@ if( MSVC )
253253
-D_CRT_NONSTDC_NO_WARNINGS
254254
-D_SCL_SECURE_NO_DEPRECATE
255255
-D_SCL_SECURE_NO_WARNINGS
256+
)
256257

258+
set(msvc_warning_flags
257259
# Disabled warnings.
258260
-wd4146 # Suppress 'unary minus operator applied to unsigned type, result still unsigned'
259261
-wd4180 # Suppress 'qualifier applied to function type has no meaning; ignored'
@@ -282,14 +284,19 @@ if( MSVC )
282284

283285
# Enable warnings
284286
if (LLVM_ENABLE_WARNINGS)
285-
add_llvm_definitions( /W4 )
287+
append("/W4" msvc_warning_flags)
286288
if (LLVM_ENABLE_PEDANTIC)
287289
# No MSVC equivalent available
288290
endif (LLVM_ENABLE_PEDANTIC)
289291
endif (LLVM_ENABLE_WARNINGS)
290292
if (LLVM_ENABLE_WERROR)
291-
add_llvm_definitions( /WX )
293+
append("/WX" msvc_warning_flags)
292294
endif (LLVM_ENABLE_WERROR)
295+
296+
foreach(flag ${msvc_warning_flags})
297+
append("${flag}" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
298+
endforeach(flag)
299+
293300
elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE )
294301
if (LLVM_ENABLE_WARNINGS)
295302
append("-Wall -W -Wno-unused-parameter -Wwrite-strings" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)

0 commit comments

Comments
 (0)
Please sign in to comment.