2020-12-07 17:23:45 +00:00
|
|
|
cmake_minimum_required(VERSION 3.13.0)
|
2015-08-19 12:57:25 +00:00
|
|
|
|
2016-08-01 05:25:37 +00:00
|
|
|
set(ETH_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}/cmake" CACHE PATH "The the path to the cmake directory")
|
2015-08-19 12:57:25 +00:00
|
|
|
list(APPEND CMAKE_MODULE_PATH ${ETH_CMAKE_DIR})
|
|
|
|
|
2021-01-14 09:22:50 +00:00
|
|
|
# Set the build type, if none was specified.
|
|
|
|
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
|
|
|
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
|
|
|
set(DEFAULT_BUILD_TYPE "RelWithDebInfo")
|
|
|
|
else()
|
|
|
|
set(DEFAULT_BUILD_TYPE "Release")
|
|
|
|
endif()
|
|
|
|
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel" FORCE)
|
|
|
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "RelWithDebInfo" "MinSizeRel")
|
|
|
|
endif()
|
|
|
|
|
2017-08-28 15:04:41 +00:00
|
|
|
include(EthToolchains)
|
|
|
|
|
2015-08-24 13:51:52 +00:00
|
|
|
# Set cmake_policies
|
|
|
|
include(EthPolicy)
|
|
|
|
eth_policy()
|
|
|
|
|
|
|
|
# project name and version should be set after cmake_policy CMP0048
|
2021-12-20 15:17:07 +00:00
|
|
|
set(PROJECT_VERSION "0.8.12")
|
2020-03-24 16:19:00 +00:00
|
|
|
# OSX target needed in order to support std::visit
|
|
|
|
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14")
|
2019-07-08 14:04:52 +00:00
|
|
|
project(solidity VERSION ${PROJECT_VERSION} LANGUAGES C CXX)
|
2015-08-19 22:55:41 +00:00
|
|
|
|
2019-06-06 11:50:43 +00:00
|
|
|
include(TestBigEndian)
|
|
|
|
TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
|
|
|
|
if (IS_BIG_ENDIAN)
|
|
|
|
message(FATAL_ERROR "${PROJECT_NAME} currently does not support big endian systems.")
|
|
|
|
endif()
|
|
|
|
|
2017-08-22 20:50:03 +00:00
|
|
|
option(SOLC_LINK_STATIC "Link solc executable statically on supported platforms" OFF)
|
2020-12-03 01:06:30 +00:00
|
|
|
option(SOLC_STATIC_STDLIBS "Link solc against static versions of libgcc and libstdc++ on supported platforms" OFF)
|
2021-09-16 19:40:00 +00:00
|
|
|
option(STRICT_Z3_VERSION "Use the latest version of Z3" ON)
|
2017-08-22 20:50:03 +00:00
|
|
|
|
2017-09-20 14:39:41 +00:00
|
|
|
# Setup cccache.
|
|
|
|
include(EthCcache)
|
|
|
|
|
2015-08-19 22:55:41 +00:00
|
|
|
# Let's find our dependencies
|
2015-08-19 12:57:25 +00:00
|
|
|
include(EthDependencies)
|
2021-04-20 12:12:07 +00:00
|
|
|
include(fmtlib)
|
2017-09-18 15:33:32 +00:00
|
|
|
include(jsoncpp)
|
2021-01-11 17:14:23 +00:00
|
|
|
include(range-v3)
|
2018-05-15 13:14:59 +00:00
|
|
|
include_directories(SYSTEM ${JSONCPP_INCLUDE_DIR})
|
2015-08-19 22:55:41 +00:00
|
|
|
|
2017-08-22 14:37:27 +00:00
|
|
|
find_package(Threads)
|
|
|
|
|
2015-08-19 22:55:41 +00:00
|
|
|
# Figure out what compiler and system are we using
|
2015-08-19 12:57:25 +00:00
|
|
|
include(EthCompilerSettings)
|
|
|
|
|
2015-08-24 13:51:52 +00:00
|
|
|
# Include utils
|
|
|
|
include(EthUtils)
|
2015-08-19 12:57:25 +00:00
|
|
|
|
2017-06-08 09:56:14 +00:00
|
|
|
# Create license.h from LICENSE.txt and template
|
2017-06-14 10:42:48 +00:00
|
|
|
# Converting to char array is required due to MSVC's string size limit.
|
|
|
|
file(READ ${CMAKE_SOURCE_DIR}/LICENSE.txt LICENSE_TEXT HEX)
|
|
|
|
string(REGEX MATCHALL ".." LICENSE_TEXT "${LICENSE_TEXT}")
|
2017-06-14 12:17:53 +00:00
|
|
|
string(REGEX REPLACE ";" ",\n\t0x" LICENSE_TEXT "${LICENSE_TEXT}")
|
|
|
|
set(LICENSE_TEXT "0x${LICENSE_TEXT}")
|
2017-06-14 10:42:48 +00:00
|
|
|
|
2017-09-26 20:44:57 +00:00
|
|
|
configure_file("${CMAKE_SOURCE_DIR}/cmake/templates/license.h.in" include/license.h)
|
2017-06-08 09:56:14 +00:00
|
|
|
|
2015-09-11 11:43:58 +00:00
|
|
|
include(EthOptions)
|
2015-09-16 13:55:25 +00:00
|
|
|
configure_project(TESTS)
|
2021-11-23 17:07:59 +00:00
|
|
|
set(LATEST_Z3_VERSION "4.8.13")
|
2021-09-16 19:40:00 +00:00
|
|
|
set(MINIMUM_Z3_VERSION "4.8.0")
|
|
|
|
find_package(Z3)
|
|
|
|
if (${Z3_FOUND})
|
|
|
|
if (${STRICT_Z3_VERSION})
|
|
|
|
if (NOT ("${Z3_VERSION_STRING}" VERSION_EQUAL ${LATEST_Z3_VERSION}))
|
|
|
|
message(
|
|
|
|
FATAL_ERROR
|
|
|
|
"SMTChecker tests require Z3 ${LATEST_Z3_VERSION} for all tests to pass.\n\
|
|
|
|
Build with -DSTRICT_Z3_VERSION=OFF if you want to use a different version. \
|
|
|
|
You can also use -DUSE_Z3=OFF to build without Z3. In both cases use --no-smt when running tests."
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
if ("${Z3_VERSION_STRING}" VERSION_LESS ${MINIMUM_Z3_VERSION})
|
|
|
|
message(
|
|
|
|
FATAL_ERROR
|
|
|
|
"Solidity requires Z3 ${MINIMUM_Z3_VERSION} or newer. You can also use -DUSE_Z3=OFF to build without Z3."
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
2015-09-11 11:43:58 +00:00
|
|
|
|
2020-12-03 01:06:30 +00:00
|
|
|
if(${USE_Z3_DLOPEN})
|
|
|
|
add_definitions(-DHAVE_Z3)
|
|
|
|
add_definitions(-DHAVE_Z3_DLOPEN)
|
|
|
|
find_package(Python3 COMPONENTS Interpreter)
|
|
|
|
if(${Z3_FOUND})
|
|
|
|
get_target_property(Z3_HEADER_HINTS z3::libz3 INTERFACE_INCLUDE_DIRECTORIES)
|
|
|
|
endif()
|
|
|
|
find_path(Z3_HEADER_PATH z3.h HINTS ${Z3_HEADER_HINTS})
|
|
|
|
if(Z3_HEADER_PATH)
|
|
|
|
set(Z3_FOUND TRUE)
|
|
|
|
else()
|
|
|
|
message(SEND_ERROR "Dynamic loading of Z3 requires Z3 headers to be present at build time.")
|
|
|
|
endif()
|
|
|
|
if(NOT ${Python3_FOUND})
|
|
|
|
message(SEND_ERROR "Dynamic loading of Z3 requires Python 3 to be present at build time.")
|
|
|
|
endif()
|
|
|
|
if(${SOLC_LINK_STATIC})
|
|
|
|
message(SEND_ERROR "solc cannot be linked statically when dynamically loading Z3.")
|
|
|
|
endif()
|
|
|
|
elseif (${Z3_FOUND})
|
2020-05-18 15:42:24 +00:00
|
|
|
add_definitions(-DHAVE_Z3)
|
|
|
|
message("Z3 SMT solver found. This enables optional SMT checking with Z3.")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
find_package(CVC4 QUIET)
|
|
|
|
if (${CVC4_FOUND})
|
|
|
|
add_definitions(-DHAVE_CVC4)
|
|
|
|
message("CVC4 SMT solver found. This enables optional SMT checking with CVC4.")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (NOT (${Z3_FOUND} OR ${CVC4_FOUND}))
|
|
|
|
message("No SMT solver found (or it has been forcefully disabled). Optional SMT checking will not be available.\
|
|
|
|
\nPlease install Z3 or CVC4 or remove the option disabling them (USE_Z3, USE_CVC4).")
|
|
|
|
endif()
|
|
|
|
|
2020-01-06 10:52:23 +00:00
|
|
|
add_subdirectory(libsolutil)
|
2018-11-14 16:15:39 +00:00
|
|
|
add_subdirectory(liblangutil)
|
2020-05-18 15:42:24 +00:00
|
|
|
add_subdirectory(libsmtutil)
|
2016-03-21 18:37:15 +00:00
|
|
|
add_subdirectory(libevmasm)
|
2018-11-23 10:39:40 +00:00
|
|
|
add_subdirectory(libyul)
|
2015-08-19 22:55:41 +00:00
|
|
|
add_subdirectory(libsolidity)
|
2017-09-16 02:50:16 +00:00
|
|
|
add_subdirectory(libsolc)
|
2019-12-09 16:01:31 +00:00
|
|
|
add_subdirectory(tools)
|
2016-04-06 21:47:38 +00:00
|
|
|
|
2015-09-14 16:36:39 +00:00
|
|
|
if (NOT EMSCRIPTEN)
|
2017-09-16 02:50:16 +00:00
|
|
|
add_subdirectory(solc)
|
2016-03-21 18:32:42 +00:00
|
|
|
endif()
|
2015-08-19 12:57:25 +00:00
|
|
|
|
2016-04-06 21:47:38 +00:00
|
|
|
if (TESTS AND NOT EMSCRIPTEN)
|
|
|
|
add_subdirectory(test)
|
|
|
|
endif()
|