@@ -22,6 +22,18 @@ if(CCACHE_FOUND)
22
22
message ("Using ccache" )
23
23
endif (CCACHE_FOUND)
24
24
25
+ include (CheckCXXCompilerFlag)
26
+
27
+ check_cxx_compiler_flag(-fstack-protector-strong have_stack_protector_strong)
28
+ if (have_stack_protector_strong)
29
+ add_compile_options (-fstack-protector-strong)
30
+ else ()
31
+ check_cxx_compiler_flag(-fstack-protector have_stack_protector)
32
+ if (have_stack_protector)
33
+ add_compile_options (-fstack-protector)
34
+ endif ()
35
+ endif ()
36
+
25
37
if (("${CMAKE_CXX_COMPILER_ID} " MATCHES "GNU" ) OR ("${CMAKE_CXX_COMPILER_ID} " MATCHES "Clang" ))
26
38
27
39
# Use ISO C++11 standard language.
@@ -63,13 +75,6 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
63
75
# Applying -fpermissive to a C command-line (ie. secp256k1) gives a build error.
64
76
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive" )
65
77
66
- # Build everything as shared libraries (.so files)
67
- add_definitions (-DSHAREDLIB)
68
-
69
- # If supported for the target machine, emit position-independent code, suitable for dynamic
70
- # linking and avoiding any limit on the size of the global offset table.
71
- add_compile_options (-fPIC)
72
-
73
78
# Configuration-specific compiler settings.
74
79
set (CMAKE_CXX_FLAGS_DEBUG "-O0 -g -DETH_DEBUG" )
75
80
set (CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG" )
@@ -86,14 +91,6 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
86
91
message (FATAL_ERROR "${PROJECT_NAME} requires g++ 4.7 or greater." )
87
92
endif ()
88
93
89
- # Strong stack protection was only added in GCC 4.9.
90
- # Use it if we have the option to do so.
91
- # See https://lwn.net/Articles/584225/
92
- if (GCC_VERSION VERSION_GREATER 4.9 OR GCC_VERSION VERSION_EQUAL 4.9)
93
- add_compile_options (-fstack-protector-strong)
94
- add_compile_options (-fstack-protector)
95
- endif ()
96
-
97
94
# Until https://github.com/ethereum/solidity/issues/2479 is handled
98
95
# disable all implicit fallthrough warnings in the codebase for GCC > 7.0
99
96
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
@@ -103,31 +100,6 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
103
100
# Additional Clang-specific compiler settings.
104
101
elseif ("${CMAKE_CXX_COMPILER_ID} " MATCHES "Clang" )
105
102
106
- add_compile_options (-fstack-protector)
107
-
108
- # Enable strong stack protection only on Mac and only for OS X Yosemite
109
- # or newer (AppleClang 7.0+). We should be able to re-enable this setting
110
- # on non-Apple Clang as well, if we can work out what expression to use for
111
- # the version detection.
112
-
113
- # The fact that the version-reporting for AppleClang loses the original
114
- # Clang versioning is rather annoying. Ideally we could just have
115
- # a single cross-platform "if version >= 3.4.1" check.
116
- #
117
- # There is debug text in the else clause below, to help us work out what
118
- # such an expression should be, if we can get this running on a Trusty box
119
- # with Clang. Greg Colvin previously replicated the issue there too.
120
- #
121
- # See https://github.com/ethereum/webthree-umbrella/issues/594
122
-
123
- if (APPLE )
124
- if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
125
- add_compile_options (-fstack-protector-strong)
126
- endif ()
127
- else ()
128
- message (WARNING "CMAKE_CXX_COMPILER_VERSION = ${CMAKE_CXX_COMPILER_VERSION} " )
129
- endif ()
130
-
131
103
# A couple of extra warnings suppressions which we seemingly
132
104
# need when building with Clang.
133
105
#
@@ -198,7 +170,6 @@ elseif (DEFINED MSVC)
198
170
add_compile_options (/wd4800) # disable forcing value to bool 'true' or 'false' (performance warning) (4800)
199
171
add_compile_options (-D_WIN32_WINNT=0x0600) # declare Windows Vista API requirement
200
172
add_compile_options (-DNOMINMAX) # undefine windows.h MAX && MIN macros cause it cause conflicts with std::min && std::max functions
201
- add_compile_options (-DMINIUPNP_STATICLIB) # define miniupnp static library
202
173
203
174
# Always use Release variant of C++ runtime.
204
175
# We don't want to provide Debug variants of all dependencies. Some default
@@ -218,12 +189,6 @@ elseif (DEFINED MSVC)
218
189
# stack size 16MB
219
190
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ignore:4099,4075 /STACK:16777216" )
220
191
221
- # windows likes static
222
- if (NOT ETH_STATIC)
223
- message ("Forcing static linkage for MSVC." )
224
- set (ETH_STATIC 1)
225
- endif ()
226
-
227
192
# If you don't have GCC, Clang or VC++ then you are on your own. Good luck!
228
193
else ()
229
194
message (WARNING "Your compiler is not tested, if you run into any issues, we'd welcome any patches." )
@@ -262,9 +227,3 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
262
227
endif ()
263
228
endif ()
264
229
endif ()
265
-
266
- if (ETH_STATIC)
267
- set (BUILD_SHARED_LIBS OFF )
268
- else ()
269
- set (BUILD_SHARED_LIBS ON )
270
- endif (ETH_STATIC)
0 commit comments