mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Added build flag to disable pedantic builds
This commit is contained in:
parent
3c0a7355d0
commit
9290ccb908
@ -35,6 +35,7 @@ endif()
|
||||
option(SOLC_LINK_STATIC "Link solc executable statically on supported platforms" OFF)
|
||||
option(SOLC_STATIC_STDLIBS "Link solc against static versions of libgcc and libstdc++ on supported platforms" OFF)
|
||||
option(STRICT_Z3_VERSION "Use the latest version of Z3" ON)
|
||||
option(PEDANTIC "Enable extra warnings and pedantic build flags. Treat all warnings as errors." ON)
|
||||
|
||||
# Setup cccache.
|
||||
include(EthCcache)
|
||||
@ -48,6 +49,9 @@ include_directories(SYSTEM ${JSONCPP_INCLUDE_DIR})
|
||||
|
||||
find_package(Threads)
|
||||
|
||||
if(NOT PEDANTIC)
|
||||
message(WARNING "-- Pedantic build flags turned off. Warnings will not make compilation fail. This is NOT recommended in development builds.")
|
||||
endif()
|
||||
# Figure out what compiler and system are we using
|
||||
include(EthCompilerSettings)
|
||||
|
||||
|
@ -23,7 +23,9 @@ if(NOT EMSCRIPTEN)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
eth_add_cxx_compiler_flag_if_supported(-Wimplicit-fallthrough)
|
||||
if(PEDANTIC)
|
||||
eth_add_cxx_compiler_flag_if_supported(-Wimplicit-fallthrough)
|
||||
endif()
|
||||
|
||||
# Prevent the path of the source directory from ending up in the binary via __FILE__ macros.
|
||||
eth_add_cxx_compiler_flag_if_supported("-fmacro-prefix-map=${CMAKE_SOURCE_DIR}=/solidity")
|
||||
@ -32,18 +34,23 @@ eth_add_cxx_compiler_flag_if_supported("-fmacro-prefix-map=${CMAKE_SOURCE_DIR}=/
|
||||
# if the argument was not wrapped in a call. This happens when moving a local
|
||||
# variable in a return statement when the variable is the same type as the
|
||||
# return type or using a move to create a new object from a temporary object.
|
||||
eth_add_cxx_compiler_flag_if_supported(-Wpessimizing-move)
|
||||
if(PEDANTIC)
|
||||
eth_add_cxx_compiler_flag_if_supported(-Wpessimizing-move)
|
||||
endif()
|
||||
|
||||
# -Wredundant-move warns when an implicit move would already be made, so the
|
||||
# std::move call is not needed, such as when moving a local variable in a return
|
||||
# that is different from the return type.
|
||||
eth_add_cxx_compiler_flag_if_supported(-Wredundant-move)
|
||||
if(PEDANTIC)
|
||||
eth_add_cxx_compiler_flag_if_supported(-Wredundant-move)
|
||||
endif()
|
||||
|
||||
if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang"))
|
||||
# Enables all the warnings about constructions that some users consider questionable,
|
||||
# and that are easy to avoid. Also enable some extra warning flags that are not
|
||||
# enabled by -Wall. Finally, treat at warnings-as-errors, which forces developers
|
||||
# to fix warnings as they arise, so they don't accumulate "to be fixed later".
|
||||
if(PEDANTIC)
|
||||
add_compile_options(-Wall)
|
||||
add_compile_options(-Wextra)
|
||||
add_compile_options(-Werror)
|
||||
@ -65,6 +72,7 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
|
||||
eth_add_cxx_compiler_flag_if_supported(-Wduplicate-enum)
|
||||
eth_add_cxx_compiler_flag_if_supported(-Wlogical-op)
|
||||
eth_add_cxx_compiler_flag_if_supported(-Wno-unknown-attributes)
|
||||
endif()
|
||||
|
||||
# Configuration-specific compiler settings.
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3 -DETH_DEBUG")
|
||||
@ -158,7 +166,9 @@ elseif (DEFINED MSVC)
|
||||
|
||||
add_compile_options(/MP) # enable parallel compilation
|
||||
add_compile_options(/EHsc) # specify Exception Handling Model in msvc
|
||||
if(PEDANTIC)
|
||||
add_compile_options(/WX) # enable warnings-as-errors
|
||||
endif()
|
||||
add_compile_options(/wd4068) # disable unknown pragma warning (4068)
|
||||
add_compile_options(/wd4996) # disable unsafe function warning (4996)
|
||||
add_compile_options(/wd4503) # disable decorated name length exceeded, name was truncated (4503)
|
||||
|
Loading…
Reference in New Issue
Block a user