You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apply warning and error compile flags only to 1P code (#7241)
Move all the configuration of error and warning flags to after we have
added the third_party subdirectory and declared all of the 3P targets.
This ensures that only the basic configuration that e.g. affects ABI is
applied to the 3P code. This will make it easier to add 3P code that
does not compile cleanly with all the warnings and errors we enable for
our own code.
# Add output directory to include path so config.h can be found
184
179
include_directories(${CMAKE_CURRENT_BINARY_DIR})
185
180
181
+
# Configure output locations.
182
+
186
183
# Force output to bin/ and lib/. This is to suppress CMake multigenerator output paths and avoid bin/Debug, bin/Release/ and so on, which is CMake default.
message(FATAL_ERROR"ThinLTO is only supported by clang")
@@ -210,19 +218,10 @@ if(MSVC)
210
218
add_compile_flag("/arch:sse2")
211
219
endif()
212
220
endif()
213
-
add_compile_flag("/wd4146") # Ignore warning "warning C4146: unary minus operator applied to unsigned type, result still unsigned", this pattern is used somewhat commonly in the code.
214
-
# 4267 and 4244 are conversion/truncation warnings. We might want to fix these but they are currently pervasive.
215
-
add_compile_flag("/wd4267")
216
-
add_compile_flag("/wd4244")
217
-
# 4722 warns that destructors never return, even with [[noreturn]].
218
-
add_compile_flag("/wd4722")
219
-
# "destructor was implicitly defined as deleted" caused by LLVM headers.
220
-
add_compile_flag("/wd4624")
221
-
add_compile_flag("/WX-")
221
+
222
222
add_debug_compile_flag("/Od")
223
223
add_nondebug_compile_flag("/O2")
224
-
add_compile_flag("/D_CRT_SECURE_NO_WARNINGS")
225
-
add_compile_flag("/D_SCL_SECURE_NO_WARNINGS")
224
+
226
225
# workaround for https://github.com/WebAssembly/binaryen/issues/3661
# Visual Studio 2018 15.8 implemented conformant support for std::aligned_storage, but the conformant support is only enabled when the following flag is passed, to avoid
@@ -400,6 +358,69 @@ if(UNIX AND CMAKE_GENERATOR STREQUAL "Ninja")
400
358
endif()
401
359
endif()
402
360
361
+
# Add targets and sources for 3P code.
362
+
363
+
add_subdirectory(third_party)
364
+
365
+
# Additionally configure compiler for 1P code.
366
+
367
+
if(BUILD_LLVM_DWARF)
368
+
if(MSVC)
369
+
add_compile_flag("/DBUILD_LLVM_DWARF")
370
+
else()
371
+
add_compile_flag("-DBUILD_LLVM_DWARF")
372
+
endif()
373
+
endif()
374
+
375
+
# Configure warnings and errors
376
+
377
+
if(MSVC)
378
+
add_compile_flag("/wd4146") # Ignore warning "warning C4146: unary minus operator applied to unsigned type, result still unsigned", this pattern is used somewhat commonly in the code.
379
+
# 4267 and 4244 are conversion/truncation warnings. We might want to fix these but they are currently pervasive.
380
+
add_compile_flag("/wd4267")
381
+
add_compile_flag("/wd4244")
382
+
# 4722 warns that destructors never return, even with [[noreturn]].
383
+
add_compile_flag("/wd4722")
384
+
# "destructor was implicitly defined as deleted" caused by LLVM headers.
385
+
add_compile_flag("/wd4624")
386
+
add_compile_flag("/WX-")
387
+
add_compile_flag("/D_CRT_SECURE_NO_WARNINGS")
388
+
add_compile_flag("/D_SCL_SECURE_NO_WARNINGS")
389
+
390
+
if(RUN_STATIC_ANALYZER)
391
+
add_definitions(/analyze)
392
+
endif()
393
+
394
+
else() # MSVC
395
+
396
+
add_compile_flag("-Wall")
397
+
if(ENABLE_WERROR)
398
+
add_compile_flag("-Werror")
399
+
endif()
400
+
add_compile_flag("-Wextra")
401
+
add_compile_flag("-Wno-unused-parameter")
402
+
add_compile_flag("-Wno-dangling-pointer") # false positive in gcc
403
+
# TODO(https://github.com/WebAssembly/binaryen/pull/2314): Remove these two
0 commit comments