Skip to content

Commit c9e2bf4

Browse files
authored
Merge pull request #2093 from bitshares/release
Merge release branch to master branch for 4.0 release
2 parents 8b7542e + d8981f2 commit c9e2bf4

File tree

254 files changed

+36605
-6882
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

254 files changed

+36605
-6882
lines changed

.mailmap

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
3+
Christopher Sanborn <[email protected]>
4+
5+
6+
7+
8+
9+
Eric Frias <[email protected]>
10+
11+
12+
John M. Jones <[email protected]>
13+
14+
Matias Romeo <[email protected]>
15+
16+
17+
18+
19+
20+
21+
22+
23+
24+
25+
26+
Valentine Zavgorodnev <[email protected]>
27+
28+
29+
30+
31+
32+
33+
34+
35+
36+
37+
38+
39+
40+
41+
42+

.travis.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ env:
3030
jobs:
3131
include:
3232
- stage: build for cache
33-
script: ./programs/build_helpers/build_protocol
33+
script: ./programs/build_helpers/build_for_cache
3434
- stage: build and test
3535
script: ./programs/build_helpers/build_and_test
36+
- stage: scan with sonar, step 1
37+
script: ./programs/build_helpers/scan_with_sonar_step_1
38+
- stage: scan with sonar, step 2
39+
script: ./programs/build_helpers/scan_with_sonar_step_2
40+
- stage: scan with sonar, step 3
41+
script: ./programs/build_helpers/scan_with_sonar_step_3

CMakeLists.txt

+90-51
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
2828
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.3)
2929
message(FATAL_ERROR "Clang version must be at least 3.3!")
3030
endif()
31+
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
32+
if ("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "19.0")
33+
message(FATAL_ERROR "MSVC version must be at least 19.0 (Visual Studio 2015 Update 1)!")
34+
endif()
35+
36+
# allow MSVC VS2015 with Update 1, other 2015 versions are not supported
37+
if ("${CMAKE_CXX_COMPILER_VERSION}" VERSION_EQUAL "19.0")
38+
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL "19.0.23506.0")
39+
message(FATAL_ERROR "Your version ${CMAKE_CXX_COMPILER_VERSION} of MSVC is not supported, use version 19.0.23506.0 (Visual Studio 2015 Update 1)!")
40+
endif()
41+
endif()
3142
endif()
3243

3344
list( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules" )
@@ -38,53 +49,71 @@ include(Utils)
3849
# function to help with cUrl
3950
macro(FIND_CURL)
4051
if (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB)
52+
find_package(OpenSSL REQUIRED)
4153
set (OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
4254
set (CMAKE_FIND_LIBRARY_SUFFIXES .a)
4355
find_package(CURL REQUIRED)
44-
list(APPEND CURL_LIBRARIES ssl crypto)
56+
list(APPEND CURL_LIBRARIES ${OPENSSL_LIBRARIES} ${BOOST_THREAD_LIBRARY} ${CMAKE_DL_LIBS})
4557
set (CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_SUFFIXES})
4658
else (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB)
4759
find_package(CURL REQUIRED)
4860
endif (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB)
61+
62+
if( WIN32 )
63+
if ( MSVC )
64+
list( APPEND CURL_LIBRARIES Wldap32 )
65+
endif( MSVC )
66+
67+
if( MINGW )
68+
# MinGW requires a specific order of included libraries ( CURL before ZLib )
69+
find_package( ZLIB REQUIRED )
70+
list( APPEND CURL_LIBRARIES ${ZLIB_LIBRARY} pthread )
71+
endif( MINGW )
72+
73+
list( APPEND CURL_LIBRARIES ${PLATFORM_SPECIFIC_LIBS} )
74+
endif( WIN32 )
4975
endmacro()
5076

77+
# Save the old value of CMAKE_REQUIRED_FLAGS
78+
set( TEMP_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} )
79+
5180
# Fortify source
5281
if (CMAKE_COMPILER_IS_GNUCXX)
5382
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
54-
message ("-- Setting optimizations for clang++")
83+
message (STATUS "Setting optimizations for clang++")
5584
set(CMAKE_CXX_FLAGS_RELEASE "-D_FORTIFY_SOURCE=2 -O3 -DNDEBUG=1")
5685
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-D_FORTIFY_SOURCE=2 -O3 -DNDEBUG=1 -g")
5786

5887
# check and add data execution prevention
59-
message ("-- Enabling data execution prevention")
88+
message (STATUS "Enabling data execution prevention")
6089
add_linker_flag("-fsanitize=safe-stack")
6190

6291
# check and add Stack-based buffer overrun detection
6392
set(CMAKE_REQUIRED_FLAGS "-fstack-protector")
6493
check_c_compiler_flag("" HAVE_STACKPROTECTOR)
6594
if(HAVE_STACKPROTECTOR)
66-
message ("-- Enabling stack-based buffer overrun detection")
95+
message (STATUS "Enabling stack-based buffer overrun detection")
6796
add_flag_append(CMAKE_C_FLAGS "-fstack-protector")
6897
add_flag_append(CMAKE_CXX_FLAGS "-fstack-protector")
6998
endif()
7099
else ()
71-
message ("-- Setting optimizations for g++")
100+
message (STATUS "Setting optimizations for g++")
72101
set(CMAKE_CXX_FLAGS_RELEASE "-D_FORTIFY_SOURCE=2 -O3 -DNDEBUG=1")
73102
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-D_FORTIFY_SOURCE=2 -O3 -DNDEBUG=1 -g")
74103

75104
# check and add data execution prevention
76105
set(CMAKE_REQUIRED_FLAGS "-Wl,-znoexecstack")
77106
check_c_compiler_flag("" HAVE_NOEXECSTACK)
78107
if(HAVE_NOEXECSTACK)
79-
message ("-- Enabling data execution prevention")
108+
message (STATUS "Enabling data execution prevention")
80109
add_linker_flag("-znoexecstack")
81110
endif()
82111

83112
# check and add Stack-based buffer overrun detection
84113
set(CMAKE_REQUIRED_FLAGS "-fstack-protector-strong")
85114
check_c_compiler_flag("" HAVE_STACKPROTECTOR)
86115
if(HAVE_STACKPROTECTOR)
87-
message ("-- Enabling stack-based buffer overrun detection")
116+
message (STATUS "Enabling stack-based buffer overrun detection")
88117
add_flag_append(CMAKE_C_FLAGS "-fstack-protector-strong")
89118
add_flag_append(CMAKE_CXX_FLAGS "-fstack-protector-strong")
90119
endif()
@@ -96,22 +125,26 @@ endif ()
96125
set(CMAKE_REQUIRED_FLAGS "-Wl,-zrelro,-znow")
97126
check_c_compiler_flag("" HAVE_RELROFULL)
98127
if(HAVE_RELROFULL)
99-
message ("-- Enabling full data relocation and protection")
128+
message (STATUS "Enabling full data relocation and protection")
100129
add_linker_flag("-zrelro")
101130
add_linker_flag("-znow")
102131
else()
103132
#if full relro is not available, try partial relro
104133
set(CMAKE_REQUIRED_FLAGS "-Wl,-zrelro")
105134
check_c_compiler_flag("" HAVE_RELROPARTIAL)
106135
if(HAVE_RELROPARTIAL)
107-
message ("-- Enabling partial data relocation and protection")
136+
message (STATUS "Enabling partial data relocation and protection")
108137
add_linker_flag("-zrelro")
109138
endif()
110139
endif()
111140

141+
set(CMAKE_REQUIRED_FLAGS ${TEMP_REQUIRED_FLAGS} )
142+
112143
# position independent executetable (PIE)
113144
# position independent code (PIC)
114-
add_definitions (-fPIC)
145+
if (NOT MSVC)
146+
add_definitions (-fPIC)
147+
endif(NOT MSVC)
115148

116149
set(CMAKE_EXPORT_COMPILE_COMMANDS "ON")
117150
set( GRAPHENE_EGENESIS_JSON "${CMAKE_CURRENT_SOURCE_DIR}/libraries/egenesis/genesis.json"
@@ -123,9 +156,9 @@ endif(USE_PCH)
123156

124157
option(USE_PROFILER "Build with GPROF support(Linux)." OFF)
125158

126-
IF( NOT WIN32 )
127-
list( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/libraries/fc/CMakeModules" )
128-
ENDIF( NOT WIN32 )
159+
# Use Boost config file from fc
160+
set(Boost_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libraries/fc/CMakeModules/Boost")
161+
129162
list( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/libraries/fc/GitVersionGen" )
130163
include( GetGitRevisionDescription )
131164
get_git_head_revision( GIT_REFSPEC GIT_SHA2 )
@@ -139,14 +172,20 @@ LIST(APPEND BOOST_COMPONENTS thread
139172
program_options
140173
chrono
141174
unit_test_framework
142-
context)
175+
context
176+
coroutine
177+
regex)
143178
# boost::endian is also required, but FindBoost can't handle header-only libs
144179
SET( Boost_USE_STATIC_LIBS ON CACHE STRING "ON or OFF" )
145180

146-
IF( WIN32 )
147-
SET(BOOST_ROOT $ENV{BOOST_ROOT})
181+
IF(WIN32)
182+
if($ENV{BOOST_ROOT})
183+
SET(BOOST_ROOT $ENV{BOOST_ROOT})
184+
endif($ENV{BOOST_ROOT})
148185
set(Boost_USE_MULTITHREADED ON)
149186
set(BOOST_ALL_DYN_LINK OFF) # force dynamic linking for all libraries
187+
add_definitions("-DCURL_STATICLIB")
188+
list(APPEND PLATFORM_SPECIFIC_LIBS ws2_32 crypt32 mswsock userenv )
150189
ELSE( WIN32 )
151190
IF( APPLE )
152191
set( CMAKE_THREAD_LIBS_INIT "-lpthread" )
@@ -157,28 +196,36 @@ ELSE( WIN32 )
157196
ENDIF( APPLE )
158197
ENDIF(WIN32)
159198

160-
FIND_PACKAGE(Boost 1.57 REQUIRED COMPONENTS ${BOOST_COMPONENTS})
161-
# For Boost 1.53 on windows, coroutine was not in BOOST_LIBRARYDIR and do not need it to build, but if boost versin >= 1.54, find coroutine otherwise will cause link errors
162-
IF(NOT "${Boost_VERSION}" MATCHES "1.53(.*)")
163-
SET(BOOST_LIBRARIES_TEMP ${Boost_LIBRARIES})
164-
FIND_PACKAGE(Boost 1.54 REQUIRED COMPONENTS coroutine)
165-
LIST(APPEND BOOST_COMPONENTS coroutine)
166-
SET(Boost_LIBRARIES ${BOOST_LIBRARIES_TEMP} ${Boost_LIBRARIES})
167-
ENDIF()
199+
FIND_PACKAGE(Boost CONFIG REQUIRED COMPONENTS ${BOOST_COMPONENTS})
200+
201+
# enforce more strict compiler warnings and errors
202+
add_compiler_flag_if_available("-Wall")
203+
add_compiler_flag_if_available("-Wclobbered")
204+
add_compiler_flag_if_available("-Wempty-body")
205+
add_compiler_flag_if_available("-Wformat-security")
206+
add_compiler_flag_if_available("-Wignored-qualifiers")
207+
add_compiler_flag_if_available("-Wimplicit-fallthrough=5")
208+
add_compiler_flag_if_available("-Wmissing-field-initializers")
209+
add_compiler_flag_if_available("-Wpointer-arith")
210+
add_compiler_flag_if_available("-Wshift-negative-value")
211+
add_compiler_flag_if_available("-Wtype-limits")
212+
add_compiler_flag_if_available("-Wunused-but-set-parameter")
168213

169214
if( WIN32 )
170215

171216
message( STATUS "Configuring BitShares on WIN32")
172-
set( DB_VERSION 60 )
173-
set( BDB_STATIC_LIBS 1 )
174217

175-
set( ZLIB_LIBRARIES "" )
176-
SET( DEFAULT_EXECUTABLE_INSTALL_DIR bin/ )
218+
if ( MINGW )
219+
message( STATUS "Windows build using MinGW" )
220+
set( FULL_STATIC_BUILD TRUE )
221+
else( MINGW )
222+
set( ZLIB_LIBRARIES "" )
223+
endif( MINGW )
177224

178-
set(CRYPTO_LIB)
225+
SET( DEFAULT_EXECUTABLE_INSTALL_DIR bin/ )
179226

180227
if( MSVC )
181-
add_definitions(-DWIN32_LEAN_AND_MEAN)
228+
add_definitions(-DWIN32_LEAN_AND_MEAN)
182229
#looks like this flag can have different default on some machines.
183230
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
184231
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
@@ -187,44 +234,32 @@ if( WIN32 )
187234
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /DEBUG")
188235
endif ( MSVC )
189236

190-
# On windows tcl should be installed to the directory pointed by setenv.bat script
191-
SET(TCL_INCLUDE_PATH $ENV{TCL_ROOT}/include)
192-
MESSAGE(STATUS "tcl INCLUDE PATH: ${TCL_INCLUDE_PATH}")
193-
194-
FIND_PACKAGE(TCL)
195-
MESSAGE(STATUS "tcl_library: ${TCL_LIBRARY}")
196-
197-
SET(TCL_LIBS "optimized;${TCL_LIBRARY};debug;")
198-
get_filename_component(TCL_LIB_PATH "${TCL_LIBRARY}" PATH)
199-
get_filename_component(TCL_LIB_NAME "${TCL_LIBRARY}" NAME_WE)
200-
get_filename_component(TCL_LIB_EXT "${TCL_LIBRARY}" EXT)
201-
202-
SET(TCL_LIBS "${TCL_LIBS}${TCL_LIB_PATH}/${TCL_LIB_NAME}g${TCL_LIB_EXT}")
203-
SET(TCL_LIBRARY ${TCL_LIBS})
204-
205237
else( WIN32 ) # Apple AND Linux
206238

207239
if( APPLE )
208240
# Apple Specific Options Here
209241
message( STATUS "Configuring BitShares on OS X" )
210242
set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -stdlib=libc++ -Wall" )
211243
else( APPLE )
212-
# Linux Specific Options Here
213-
message( STATUS "Configuring BitShares on Linux" )
244+
if ( "${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD" )
245+
# OpenBSD Specific Options
246+
message( STATUS "Configuring BitShares on OpenBSD" )
247+
else()
248+
# Linux Specific Options Here
249+
message( STATUS "Configuring BitShares on Linux" )
250+
set( rt_library rt )
251+
endif()
252+
# Common Linux & OpenBSD Options
214253
set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wall" )
215254
if(USE_PROFILER)
216255
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg" )
217256
endif( USE_PROFILER )
218-
set( rt_library rt )
219257
set( pthread_library pthread)
220258
if ( NOT DEFINED crypto_library )
221259
# I'm not sure why this is here, I guess someone has openssl and can't detect it with find_package()?
222260
# if you have a normal install, you can define crypto_library to the empty string to avoid a build error
223261
set( crypto_library crypto)
224262
endif ()
225-
if ( FULL_STATIC_BUILD )
226-
set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc")
227-
endif ( FULL_STATIC_BUILD )
228263
endif( APPLE )
229264

230265
if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" )
@@ -247,6 +282,10 @@ else( WIN32 ) # Apple AND Linux
247282

248283
endif( WIN32 )
249284

285+
if ( NOT MSVC AND FULL_STATIC_BUILD )
286+
set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static -static-libstdc++ -static-libgcc" )
287+
endif ( NOT MSVC AND FULL_STATIC_BUILD )
288+
250289
set(ENABLE_COVERAGE_TESTING FALSE CACHE BOOL "Build BitShares for code coverage analysis")
251290

252291
if(ENABLE_COVERAGE_TESTING)

CMakeModules/Utils.cmake

+12
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,15 @@ macro(add_linker_flag _FLAG)
1111
add_flag_append(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-Wl,${_FLAG}")
1212
endmacro(add_linker_flag _FLAG)
1313

14+
include(CheckCXXCompilerFlag)
15+
16+
macro(add_compiler_flag_if_available _FLAG)
17+
string(TOUPPER "${_FLAG}" _TEMPVAR1)
18+
string(REPLACE "-" "_" _TEMPVAR2 "${_TEMPVAR1}")
19+
string(CONCAT _TEMPVAR3 "HAVE" "${_TEMPVAR2}")
20+
set(CMAKE_REQUIRED_FLAGS "${_FLAG}")
21+
check_cxx_compiler_flag("${_FLAG}" ${_TEMPVAR3})
22+
if(${_TEMPVAR3})
23+
add_flag_append(CMAKE_CXX_FLAGS ${_FLAG})
24+
endif()
25+
endmacro(add_compiler_flag_if_available _VAR_NAME _FLAG)

0 commit comments

Comments
 (0)