Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

CMake: Use basic compiler settings from Cable #5407

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ endif()
include(cmake/cable/bootstrap.cmake)
include(CableBuildInfo)
include(CableBuildType)
include(CableCompilerSettings)
include(CableToolchains)
include(GNUInstallDirs)

Expand Down Expand Up @@ -51,6 +52,8 @@ cable_set_build_type(DEFAULT RelWithDebInfo CONFIGURATION_TYPES Debug;Release;Re

cable_add_buildinfo_library(PROJECT_NAME aleth)

cable_configure_compiler(NO_CONVERSION_WARNINGS NO_PEDANTIC)

set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY On)

include(EthCcache)
Expand Down
67 changes: 17 additions & 50 deletions cmake/EthCompilerSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,7 @@
#
# These settings then end up spanning all POSIX platforms (Linux, OS X, BSD, etc)

include(EthCheckCXXCompilerFlag)

eth_add_cxx_compiler_flag_if_supported(-fstack-protector-strong have_stack_protector_strong_support)
if(NOT have_stack_protector_strong_support)
eth_add_cxx_compiler_flag_if_supported(-fstack-protector)
endif()

eth_add_cxx_compiler_flag_if_supported(-Wimplicit-fallthrough)

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".
add_compile_options(-Wall)
add_compile_options(-Wextra)
add_compile_options(-Werror)

# Disable warnings about unknown pragmas (which is enabled by -Wall).
add_compile_options(-Wno-unknown-pragmas)

if (CABLE_COMPILER_GNULIKE)
# Configuration-specific compiler settings.
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g -DETH_DEBUG")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
Expand Down Expand Up @@ -73,21 +53,22 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
# The major alternative compiler to GCC/Clang is Microsoft's Visual C++ compiler, only available on Windows.
elseif (MSVC)

add_compile_options(/MP) # enable parallel compilation
add_compile_options(/EHsc) # specify Exception Handling Model in msvc
add_compile_options(/WX) # enable warnings-as-errors
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)
add_compile_options(/wd4267) # disable conversion from 'size_t' to 'type', possible loss of data (4267)
add_compile_options(/wd4180) # disable qualifier applied to function type has no meaning; ignored (4180)
add_compile_options(/wd4290) # disable C++ exception specification ignored except to indicate a function is not __declspec(nothrow) (4290)
add_compile_options(/wd4297) # disable <vector>'s function assumed not to throw an exception but does (4297)
add_compile_options(/wd4244) # disable conversion from 'type1' to 'type2', possible loss of data (4244)
add_compile_options(/wd4800) # disable forcing value to bool 'true' or 'false' (performance warning) (4800)
add_compile_options(-D_WIN32_WINNT=0x0600) # declare Windows Vista API requirement
add_compile_options(-DNOMINMAX) # undefine windows.h MAX && MIN macros cause it cause conflicts with std::min && std::max functions
add_compile_options(-DMINIUPNP_STATICLIB) # define miniupnp static library
add_compile_options(/MP) # enable parallel compilation
add_compile_options(/EHsc) # specify Exception Handling Model in msvc
add_compile_options(/WX) # enable warnings-as-errors
add_compile_options(/wd4068) # disable unknown pragma warning (4068)
add_compile_options(/wd4180) # disable qualifier applied to function type has no meaning; ignored (4180)
add_compile_options(/wd4244) # disable conversion from 'type1' to 'type2', possible loss of data (4244)
add_compile_options(/wd4267) # disable conversion from 'size_t' to 'type', possible loss of data (4267)
add_compile_options(/wd4290) # disable C++ exception specification ignored except to indicate a function is not __declspec(nothrow) (4290)
add_compile_options(/wd4297) # disable <vector>'s function assumed not to throw an exception but does (4297)
add_compile_options(/wd4503) # disable decorated name length exceeded, name was truncated (4503)
add_compile_options(/wd4714) # disable function marked as __forceinline not inlined
add_compile_options(/wd4800) # disable forcing value to bool 'true' or 'false' (performance warning) (4800)
add_compile_options(/wd4996) # disable unsafe function warning (4996)
add_compile_options(-D_WIN32_WINNT=0x0600) # declare Windows Vista API requirement
add_compile_options(-DNOMINMAX) # undefine windows.h MAX && MIN macros cause it cause conflicts with std::min && std::max functions
add_compile_options(-DMINIUPNP_STATICLIB) # define miniupnp static library

# Always use Release variant of C++ runtime.
# We don't want to provide Debug variants of all dependencies. Some default
Expand All @@ -112,20 +93,6 @@ else ()
message(WARNING "Your compiler is not tested, if you run into any issues, we'd welcome any patches.")
endif ()

if (SANITIZE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=${SANITIZE}")
if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize-blacklist=${CMAKE_SOURCE_DIR}/sanitizer-blacklist.txt")
endif()
endif()

option(COVERAGE "Build with code coverage support" OFF)
if(COVERAGE)
add_compile_options(-g --coverage)
set(CMAKE_SHARED_LINKER_FLAGS "--coverage ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "--coverage ${CMAKE_EXE_LINKER_FLAGS}")
endif()

if(UNIX AND NOT APPLE)
option(STATIC_LIBSTDCPP "Link libstdc++ staticly")
if(STATIC_LIBSTDCPP)
Expand Down
3 changes: 2 additions & 1 deletion libethcore/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class RLPStream;

namespace eth
{
using namespace boost::multiprecision::literals;

/// Current protocol version.
extern const unsigned c_protocolVersion;
Expand Down Expand Up @@ -88,7 +89,7 @@ static const h256 LatestBlockHash = h256(2);
static const h256 EarliestBlockHash = h256(1);
static const h256 PendingBlockHash = h256(0);

static const u256 DefaultBlockGasLimit = 4712388;
constexpr u256 DefaultBlockGasLimit = 0x47e7c4_cppui256; // 4712388

enum class RelativeBlock: BlockNumber
{
Expand Down