diff options
author | Owen Anderson <owen.anderson@oculus.com> | 2019-01-28 20:51:52 -0800 |
---|---|---|
committer | Facebook Github Bot <facebook-github-bot@users.noreply.github.com> | 2019-01-28 20:57:18 -0800 |
commit | f204e3e624753e5cba8661ac64da1caf70db3ce7 (patch) | |
tree | cba941c3ba256467a5a28be1e2869b7e96b6dbe6 /cmake | |
parent | 99fab457337d3e060348de05694555f92776ebc8 (diff) | |
download | pytorch-f204e3e624753e5cba8661ac64da1caf70db3ce7.tar.gz pytorch-f204e3e624753e5cba8661ac64da1caf70db3ce7.tar.bz2 pytorch-f204e3e624753e5cba8661ac64da1caf70db3ce7.zip |
Pass WERROR to CMake as an explicit parameter rather than an env var.
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/16465
Differential Revision: D13853949
Pulled By: resistor
fbshipit-source-id: 71ccf90a2824ad21c9f26dd753b186f30435d82a
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/Utils.cmake | 56 | ||||
-rw-r--r-- | cmake/public/utils.cmake | 2 |
2 files changed, 1 insertions, 57 deletions
diff --git a/cmake/Utils.cmake b/cmake/Utils.cmake index e40d0db381..b0f931f11c 100644 --- a/cmake/Utils.cmake +++ b/cmake/Utils.cmake @@ -238,59 +238,3 @@ function(print_target_properties tgt) endif() endforeach(prop) endfunction(print_target_properties) - - -### -# Helper function to add style warning options to the given target -# Optionally pass in the second argument ($ARGV1) which will force -Werror if -# it evaluates to true. -function(target_enable_style_warnings TARGET) - if(MSVC) - # TODO Also add some warning options that MSVC can understand - set(WARNING_OPTIONS "") - else() - set(WARNING_OPTIONS - -Wall - -Wextra - -Wold-style-cast - -Wno-missing-braces - -Wcast-align - -Wcast-qual - -Wctor-dtor-privacy - -Wdisabled-optimization - -Wformat=2 - -Winit-self - -Wmissing-include-dirs - -Woverloaded-virtual - -Wredundant-decls - -Wno-shadow - -Wsign-promo - -Wno-strict-overflow - -fdiagnostics-show-option - -Wno-conversion - -Wpedantic - -Wundef - ) - # -Wno-gnu-zero-variadic-macro-arguments is not available in GCC-4.8.5. Set - # only when using clang. - # Compared against https://gcc.gnu.org/onlinedocs/gcc-4.8.5/gcc/Option-Summary.html - if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - list(APPEND WARNING_OPTIONS "-Wno-gnu-zero-variadic-macro-arguments") - endif() - set(WERROR $ENV{WERROR}) - if (${ARGC} GREATER 1) - # accessing ${ARGV1} is UB when ${ARGC} <= 1 - # CMake doesn't do smart AND, so we have to use a nested `if` - if (${ARGV1}) - set(WERROR TRUE) - endif() - endif() - if (WERROR) - list(APPEND WARNING_OPTIONS "-Werror") - endif() - endif() - if(APPLE) - set(WARNING_OPTIONS -Wno-gnu-zero-variadic-macro-arguments) - endif() - target_compile_options(${TARGET} PRIVATE ${WARNING_OPTIONS}) -endfunction() diff --git a/cmake/public/utils.cmake b/cmake/public/utils.cmake index 71783748c9..00c62a89b2 100644 --- a/cmake/public/utils.cmake +++ b/cmake/public/utils.cmake @@ -202,7 +202,7 @@ function(torch_compile_options libname) -Wno-unused-parameter -Wno-unknown-warning-option -Wno-unknown-pragmas) - if ($ENV{WERROR}) + if (WERROR) target_compile_options(${libname} PRIVATE -Werror) endif() endfunction() |