X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=blobdiff_plain;f=CMake%2FFollyCompiler.cmake;h=70dfe378674771683bfc3af03fac6a476f13bafb;hp=31184ec983b5e50fa024f61f0f35d0230f2dfa4d;hb=37335efb4659f1389db145a485f8d663d343261f;hpb=5d24ef4474ee6177d8f3e8a8dc24035fded6f65c diff --git a/CMake/FollyCompiler.cmake b/CMake/FollyCompiler.cmake index 31184ec9..70dfe378 100755 --- a/CMake/FollyCompiler.cmake +++ b/CMake/FollyCompiler.cmake @@ -43,6 +43,20 @@ if (MSVC_USE_STATIC_RUNTIME) endforeach() endif() +# The Ninja generator doesn't de-dup the exception mode flag, so remove the +# default flag so that MSVC doesn't warn about it on every single file. +if ("${CMAKE_GENERATOR}" STREQUAL "Ninja") + foreach(flag_var + CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE + CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO + CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE + CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) + if (${flag_var} MATCHES "/EHsc") + string(REGEX REPLACE "/EHsc" "" ${flag_var} "${${flag_var}}") + endif() + endforeach() +endif() + # In order for /Zc:inline, which speeds up the build significantly, to work # we need to remove the /Ob0 parameter that CMake adds by default, because that # would normally disable all inlining. @@ -58,6 +72,7 @@ function(apply_folly_compile_options_to_target THETARGET) target_compile_options(${THETARGET} PUBLIC /EHa # Enable both SEH and C++ Exceptions. + /GF # There are bugs with constexpr StringPiece when string pooling is disabled. /Zc:referenceBinding # Disallow temporaries from binding to non-const lvalue references. /Zc:rvalueCast # Enforce the standard rules for explicit type conversion. /Zc:implicitNoexcept # Enable implicit noexcept specifications where required, such as destructors. @@ -81,14 +96,12 @@ function(apply_folly_compile_options_to_target THETARGET) # Debug builds $<$: /Gy- # Disable function level linking. - /GF- # Disable string pooling. $<$:/Ob2> # Add /Ob2 if allowing inlining in debug mode. > # Non-debug builds $<$>: - /GF # Enable string pooling. (this is enabled by default by the optimization level, but we enable it here for clarity) /Gw # Optimize global data. (-fdata-sections) /Gy # Enable function level linking. (-ffunction-sections) /Qpar # Enable parallel code generation. @@ -235,15 +248,14 @@ function(apply_folly_compile_options_to_target THETARGET) # And the extra defines: target_compile_definitions(${THETARGET} PUBLIC - NOMINMAX # This is needed because, for some absurd reason, one of the windows headers tries to define "min" and "max" as macros, which messes up most uses of std::numeric_limits. _CRT_NONSTDC_NO_WARNINGS # Don't deprecate posix names of functions. _CRT_SECURE_NO_WARNINGS # Don't deprecate the non _s versions of various standard library functions, because safety is for chumps. _SCL_SECURE_NO_WARNINGS # Don't deprecate the non _s versions of various standard library functions, because safety is for chumps. _STL_EXTRA_DISABLED_WARNINGS=4774\ 4987 - $<$:"_HAS_AUTO_PTR_ETC=1"> # We're building in C++ 17 or greater mode, but certain dependencies (Boost) still have dependencies on unary_function and binary_function, so we have to make sure not to remove them. - $<$:"WIN32_LEAN_AND_MEAN"> # Don't include most of Windows.h + $<$:_HAS_AUTO_PTR_ETC=1> # We're building in C++ 17 or greater mode, but certain dependencies (Boost) still have dependencies on unary_function and binary_function, so we have to make sure not to remove them. + $<$:WIN32_LEAN_AND_MEAN> # Don't include most of Windows.h ) # Ignore a warning about an object file not defining any symbols,