opm-simulators/cmake/Modules/UseWarnings.cmake
Atgeirr Flø Rasmussen d3ec9f63ff Fix option name to match name in use in conditional.
Also add a useful doc string.
2014-04-22 13:35:24 +02:00

32 lines
1.2 KiB
CMake

# - Turn on warnings when compiling
include (AddOptions)
include (UseCompVer)
is_compiler_gcc_compatible ()
if (CXX_COMPAT_GCC)
# default warnings flags, if not set by user
set_default_option (CXX _warn_flag "-Wall" "(^|\ )-W")
if (_warn_flag)
message (STATUS "All warnings enabled: ${_warn_flag}")
add_options (ALL_LANGUAGES ALL_BUILDS "${_warn_flag}")
endif (_warn_flag)
endif ()
option(SILENCE_EXTERNAL_WARNINGS "Disable some warnings from external packages (requires GCC 4.6 or newer)" OFF)
if(SILENCE_EXTERNAL_WARNINGS AND CXX_COMPAT_GCC)
file(WRITE ${CMAKE_BINARY_DIR}/disable_warning_pragmas.h "
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored \"-Wdeprecated-declarations\"
#pragma GCC diagnostic ignored \"-Wdeprecated-register\"
#pragma GCC diagnostic ignored \"-Wignored-qualifiers\"
#pragma GCC diagnostic ignored \"-Wmismatched-tags\"
#pragma GCC diagnostic ignored \"-Wshadow\"
#pragma GCC diagnostic ignored \"-Wsign-compare\"
#pragma GCC diagnostic ignored \"-Wunused-parameter\"")
file(WRITE ${CMAKE_BINARY_DIR}/reenable_warning_pragmas.h "#pragma GCC diagnostic pop")
else()
file(WRITE ${CMAKE_BINARY_DIR}/disable_warning_pragmas.h "")
file(WRITE ${CMAKE_BINARY_DIR}/reenable_warning_pragmas.h "")
endif()