@@ -22,6 +22,18 @@ if(CCACHE_FOUND)
2222 message ("Using ccache" )
2323endif (CCACHE_FOUND )
2424
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+
2537if (("${CMAKE_CXX_COMPILER_ID } " MATCHES "GNU" ) OR ("${CMAKE_CXX_COMPILER_ID } " MATCHES "Clang" ))
2638
2739 # Use ISO C++11 standard language.
@@ -63,13 +75,6 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
6375 # Applying -fpermissive to a C command-line (ie. secp256k1) gives a build error.
6476 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS } -fpermissive" )
6577
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-
7378 # Configuration-specific compiler settings.
7479 set (CMAKE_CXX_FLAGS_DEBUG "-O0 -g -DETH_DEBUG" )
7580 set (CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG" )
@@ -86,14 +91,6 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
8691 message (FATAL_ERROR "${PROJECT_NAME } requires g++ 4.7 or greater." )
8792 endif ()
8893
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-
9794 # Until https://github.com/ethereum/solidity/issues/2479 is handled
9895 # disable all implicit fallthrough warnings in the codebase for GCC > 7.0
9996 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
103100 # Additional Clang-specific compiler settings.
104101 elseif ("${CMAKE_CXX_COMPILER_ID } " MATCHES "Clang" )
105102
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-
131103 # A couple of extra warnings suppressions which we seemingly
132104 # need when building with Clang.
133105 #
@@ -198,7 +170,6 @@ elseif (DEFINED MSVC)
198170 add_compile_options (/wd4800 ) # disable forcing value to bool 'true' or 'false' (performance warning) (4800)
199171 add_compile_options (-D_WIN32_WINNT=0x0600 ) # declare Windows Vista API requirement
200172 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
202173
203174 # Always use Release variant of C++ runtime.
204175 # We don't want to provide Debug variants of all dependencies. Some default
@@ -218,12 +189,6 @@ elseif (DEFINED MSVC)
218189 # stack size 16MB
219190 set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS } /ignore:4099,4075 /STACK:16777216" )
220191
221- # windows likes static
222- if (NOT ETH_STATIC)
223- message ("Forcing static linkage for MSVC." )
224- set (ETH_STATIC 1)
225- endif ()
226-
227192# If you don't have GCC, Clang or VC++ then you are on your own. Good luck!
228193else ()
229194 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
262227 endif ()
263228 endif ()
264229endif ()
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