mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Basic vcpkg integration.
This commit is contained in:
parent
c4909e99c1
commit
c296f1664f
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[submodule "vcpkg"]
|
||||||
|
path = vcpkg
|
||||||
|
url = https://github.com/aarlt/vcpkg.git
|
@ -1,5 +1,21 @@
|
|||||||
cmake_minimum_required(VERSION 3.13.0)
|
cmake_minimum_required(VERSION 3.13.0)
|
||||||
|
|
||||||
|
#set(vcpkg "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
|
||||||
|
#if (NOT CMAKE_TOOLCHAIN_FILE)
|
||||||
|
# if (EXISTS "${vcpkg}")
|
||||||
|
# set(CMAKE_TOOLCHAIN_FILE "${vcpkg}"
|
||||||
|
# CACHE FILEPATH "CMake toolchain file")
|
||||||
|
# else()
|
||||||
|
# set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake"
|
||||||
|
# CACHE FILEPATH "CMake toolchain file")
|
||||||
|
# endif()
|
||||||
|
# message(STATUS "vcpkg toolchain found: ${CMAKE_TOOLCHAIN_FILE}")
|
||||||
|
#endif ()
|
||||||
|
|
||||||
|
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake"
|
||||||
|
CACHE FILEPATH "CMake toolchain file")
|
||||||
|
message(STATUS "vcpkg toolchain found: ${CMAKE_TOOLCHAIN_FILE}")
|
||||||
|
|
||||||
set(ETH_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}/cmake" CACHE PATH "The the path to the cmake directory")
|
set(ETH_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}/cmake" CACHE PATH "The the path to the cmake directory")
|
||||||
list(APPEND CMAKE_MODULE_PATH ${ETH_CMAKE_DIR})
|
list(APPEND CMAKE_MODULE_PATH ${ETH_CMAKE_DIR})
|
||||||
|
|
||||||
@ -41,10 +57,9 @@ include(EthCcache)
|
|||||||
|
|
||||||
# Let's find our dependencies
|
# Let's find our dependencies
|
||||||
include(EthDependencies)
|
include(EthDependencies)
|
||||||
include(fmtlib)
|
find_package(fmt CONFIG REQUIRED)
|
||||||
include(jsoncpp)
|
find_package(jsoncpp CONFIG REQUIRED)
|
||||||
include(range-v3)
|
find_package(range-v3 CONFIG REQUIRED)
|
||||||
include_directories(SYSTEM ${JSONCPP_INCLUDE_DIR})
|
|
||||||
|
|
||||||
find_package(Threads)
|
find_package(Threads)
|
||||||
|
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
find_library(CLN_LIBRARY NAMES cln)
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
find_package_handle_standard_args(CLN DEFAULT_MSG CLN_LIBRARY)
|
|
||||||
|
|
||||||
if(CLN_FOUND AND NOT TARGET CLN::CLN)
|
|
||||||
add_library(CLN::CLN UNKNOWN IMPORTED)
|
|
||||||
set_property(TARGET CLN::CLN PROPERTY IMPORTED_LOCATION ${CLN_LIBRARY})
|
|
||||||
endif()
|
|
@ -1,33 +0,0 @@
|
|||||||
if (USE_CVC4)
|
|
||||||
find_path(CVC4_INCLUDE_DIR cvc4/cvc4.h)
|
|
||||||
find_library(CVC4_LIBRARY NAMES cvc4)
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
find_package_handle_standard_args(CVC4 DEFAULT_MSG CVC4_LIBRARY CVC4_INCLUDE_DIR)
|
|
||||||
if(CVC4_FOUND)
|
|
||||||
# CVC4 may depend on either CLN or GMP.
|
|
||||||
# We can assume that the one it requires is present on the system,
|
|
||||||
# so we quietly try to find both and link against them, if they are
|
|
||||||
# present.
|
|
||||||
find_package(CLN QUIET)
|
|
||||||
find_package(GMP QUIET)
|
|
||||||
|
|
||||||
set(CVC4_LIBRARIES ${CVC4_LIBRARY})
|
|
||||||
|
|
||||||
if (CLN_FOUND)
|
|
||||||
set(CVC4_LIBRARIES ${CVC4_LIBRARIES} CLN::CLN)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (GMP_FOUND)
|
|
||||||
set(CVC4_LIBRARIES ${CVC4_LIBRARIES} GMP::GMP)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (NOT TARGET CVC4::CVC4)
|
|
||||||
add_library(CVC4::CVC4 UNKNOWN IMPORTED)
|
|
||||||
set_property(TARGET CVC4::CVC4 PROPERTY IMPORTED_LOCATION ${CVC4_LIBRARY})
|
|
||||||
set_property(TARGET CVC4::CVC4 PROPERTY INTERFACE_LINK_LIBRARIES ${CVC4_LIBRARIES})
|
|
||||||
set_property(TARGET CVC4::CVC4 PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${CVC4_INCLUDE_DIR})
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
set(CVC4_FOUND FALSE)
|
|
||||||
endif()
|
|
@ -1,8 +0,0 @@
|
|||||||
find_library(GMP_LIBRARY NAMES gmp)
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
find_package_handle_standard_args(GMP DEFAULT_MSG GMP_LIBRARY)
|
|
||||||
|
|
||||||
if(GMP_FOUND AND NOT TARGET GMP::GMP)
|
|
||||||
add_library(GMP::GMP UNKNOWN IMPORTED)
|
|
||||||
set_property(TARGET GMP::GMP PROPERTY IMPORTED_LOCATION ${GMP_LIBRARY})
|
|
||||||
endif()
|
|
@ -1,51 +0,0 @@
|
|||||||
if (USE_Z3)
|
|
||||||
# Save and clear Z3_FIND_VERSION, since the
|
|
||||||
# Z3 config module cannot handle version requirements.
|
|
||||||
set(Z3_FIND_VERSION_ORIG ${Z3_FIND_VERSION})
|
|
||||||
set(Z3_FIND_VERSION)
|
|
||||||
# Try to find Z3 using its stock cmake files.
|
|
||||||
find_package(Z3 QUIET CONFIG)
|
|
||||||
# Restore Z3_FIND_VERSION for find_package_handle_standard_args.
|
|
||||||
set(Z3_FIND_VERSION ${Z3_FIND_VERSION_ORIG})
|
|
||||||
set(Z3_FIND_VERSION_ORIG)
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
|
|
||||||
if (Z3_FOUND)
|
|
||||||
set(Z3_VERSION ${Z3_VERSION_STRING})
|
|
||||||
find_package_handle_standard_args(Z3 CONFIG_MODE)
|
|
||||||
else()
|
|
||||||
find_path(Z3_INCLUDE_DIR NAMES z3++.h PATH_SUFFIXES z3)
|
|
||||||
find_library(Z3_LIBRARY NAMES z3)
|
|
||||||
find_program(Z3_EXECUTABLE z3 PATH_SUFFIXES bin)
|
|
||||||
|
|
||||||
if(Z3_INCLUDE_DIR AND Z3_LIBRARY)
|
|
||||||
if(Z3_EXECUTABLE)
|
|
||||||
execute_process (COMMAND ${Z3_EXECUTABLE} -version
|
|
||||||
OUTPUT_VARIABLE libz3_version_str
|
|
||||||
ERROR_QUIET
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
||||||
|
|
||||||
string(REGEX REPLACE "^Z3 version ([0-9.]+).*" "\\1"
|
|
||||||
Z3_VERSION_STRING "${libz3_version_str}")
|
|
||||||
unset(libz3_version_str)
|
|
||||||
else()
|
|
||||||
message(WARNING "Could not determine the version of z3, since the z3 executable was not found.")
|
|
||||||
set(Z3_VERSION_STRING "0.0.0")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
mark_as_advanced(Z3_VERSION_STRING z3_DIR)
|
|
||||||
|
|
||||||
find_package_handle_standard_args(Z3
|
|
||||||
REQUIRED_VARS Z3_LIBRARY Z3_INCLUDE_DIR
|
|
||||||
VERSION_VAR Z3_VERSION_STRING)
|
|
||||||
|
|
||||||
if (NOT TARGET z3::libz3)
|
|
||||||
add_library(z3::libz3 UNKNOWN IMPORTED)
|
|
||||||
set_property(TARGET z3::libz3 PROPERTY IMPORTED_LOCATION ${Z3_LIBRARY})
|
|
||||||
set_property(TARGET z3::libz3 PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${Z3_INCLUDE_DIR})
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
set(Z3_FOUND FALSE)
|
|
||||||
endif()
|
|
@ -1,20 +0,0 @@
|
|||||||
include(FetchContent)
|
|
||||||
|
|
||||||
FetchContent_Declare(
|
|
||||||
fmtlib
|
|
||||||
PREFIX "${CMAKE_BINARY_DIR}/deps"
|
|
||||||
DOWNLOAD_DIR "${CMAKE_SOURCE_DIR}/deps/downloads"
|
|
||||||
DOWNLOAD_NAME fmt-8.0.1.tar.gz
|
|
||||||
URL https://github.com/fmtlib/fmt/archive/8.0.1.tar.gz
|
|
||||||
URL_HASH SHA256=b06ca3130158c625848f3fb7418f235155a4d389b2abc3a6245fb01cb0eb1e01
|
|
||||||
)
|
|
||||||
|
|
||||||
if (CMAKE_VERSION VERSION_LESS "3.14.0")
|
|
||||||
FetchContent_GetProperties(fmtlib)
|
|
||||||
if (NOT fmtlib_POPULATED)
|
|
||||||
FetchContent_Populate(fmtlib)
|
|
||||||
add_subdirectory(${fmtlib_SOURCE_DIR} ${fmtlib_BINARY_DIR})
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
FetchContent_MakeAvailable(fmtlib)
|
|
||||||
endif()
|
|
@ -1,70 +0,0 @@
|
|||||||
include(ExternalProject)
|
|
||||||
|
|
||||||
if (${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten")
|
|
||||||
set(JSONCPP_CMAKE_COMMAND emcmake cmake)
|
|
||||||
else()
|
|
||||||
set(JSONCPP_CMAKE_COMMAND ${CMAKE_COMMAND})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(prefix "${CMAKE_BINARY_DIR}/deps")
|
|
||||||
set(JSONCPP_LIBRARY "${prefix}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}jsoncpp${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
|
||||||
set(JSONCPP_INCLUDE_DIR "${prefix}/include")
|
|
||||||
|
|
||||||
# TODO: Investigate why this breaks some emscripten builds and
|
|
||||||
# check whether this can be removed after updating the emscripten
|
|
||||||
# versions used in the CI runs.
|
|
||||||
if(EMSCRIPTEN)
|
|
||||||
# Do not include all flags in CMAKE_CXX_FLAGS for emscripten,
|
|
||||||
# but only use -std=c++17. Using all flags causes build failures
|
|
||||||
# at the moment.
|
|
||||||
set(JSONCPP_CXX_FLAGS -std=c++17)
|
|
||||||
else()
|
|
||||||
# jsoncpp uses implicit casts for comparing integer and
|
|
||||||
# floating point numbers. This causes clang-10 (used by ossfuzz builder)
|
|
||||||
# to error on the implicit conversions. Here, we request jsoncpp
|
|
||||||
# to unconditionally use static casts for these conversions by defining the
|
|
||||||
# JSON_USE_INT64_DOUBLE_CONVERSION preprocessor macro. Doing so,
|
|
||||||
# not only gets rid of the implicit conversion error that clang-10 produces
|
|
||||||
# but also forces safer behavior in general.
|
|
||||||
set(JSONCPP_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DJSON_USE_INT64_DOUBLE_CONVERSION")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(byproducts "")
|
|
||||||
if(CMAKE_VERSION VERSION_GREATER 3.1)
|
|
||||||
set(byproducts BUILD_BYPRODUCTS "${JSONCPP_LIBRARY}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Propagate CMAKE_MSVC_RUNTIME_LIBRARY on Windows builds, if set.
|
|
||||||
if (WIN32 AND POLICY CMP0091 AND CMAKE_MSVC_RUNTIME_LIBRARY)
|
|
||||||
list(APPEND JSONCPP_CMAKE_ARGS "-DCMAKE_POLICY_DEFAULT_CMP0091:STRING=NEW")
|
|
||||||
list(APPEND JSONCPP_CMAKE_ARGS "-DCMAKE_MSVC_RUNTIME_LIBRARY=${CMAKE_MSVC_RUNTIME_LIBRARY}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
ExternalProject_Add(jsoncpp-project
|
|
||||||
PREFIX "${prefix}"
|
|
||||||
DOWNLOAD_DIR "${CMAKE_SOURCE_DIR}/deps/downloads"
|
|
||||||
DOWNLOAD_NAME jsoncpp-1.9.3.tar.gz
|
|
||||||
URL https://github.com/open-source-parsers/jsoncpp/archive/1.9.3.tar.gz
|
|
||||||
URL_HASH SHA256=8593c1d69e703563d94d8c12244e2e18893eeb9a8a9f8aa3d09a327aa45c8f7d
|
|
||||||
CMAKE_COMMAND ${JSONCPP_CMAKE_COMMAND}
|
|
||||||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
|
|
||||||
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
|
||||||
-DCMAKE_INSTALL_LIBDIR=lib
|
|
||||||
# Build static lib but suitable to be included in a shared lib.
|
|
||||||
-DCMAKE_POSITION_INDEPENDENT_CODE=${BUILD_SHARED_LIBS}
|
|
||||||
-DJSONCPP_WITH_EXAMPLE=OFF
|
|
||||||
-DJSONCPP_WITH_TESTS=OFF
|
|
||||||
-DJSONCPP_WITH_PKGCONFIG_SUPPORT=OFF
|
|
||||||
-DCMAKE_CXX_FLAGS=${JSONCPP_CXX_FLAGS}
|
|
||||||
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
|
||||||
${JSONCPP_CMAKE_ARGS}
|
|
||||||
${byproducts}
|
|
||||||
)
|
|
||||||
|
|
||||||
# Create jsoncpp imported library
|
|
||||||
add_library(jsoncpp STATIC IMPORTED)
|
|
||||||
file(MAKE_DIRECTORY ${JSONCPP_INCLUDE_DIR}) # Must exist.
|
|
||||||
set_property(TARGET jsoncpp PROPERTY IMPORTED_LOCATION ${JSONCPP_LIBRARY})
|
|
||||||
set_property(TARGET jsoncpp PROPERTY INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${JSONCPP_INCLUDE_DIR})
|
|
||||||
set_property(TARGET jsoncpp PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${JSONCPP_INCLUDE_DIR})
|
|
||||||
add_dependencies(jsoncpp jsoncpp-project)
|
|
@ -1,38 +0,0 @@
|
|||||||
include(ExternalProject)
|
|
||||||
|
|
||||||
if (${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten")
|
|
||||||
set(RANGE_V3_CMAKE_COMMAND emcmake cmake)
|
|
||||||
else()
|
|
||||||
set(RANGE_V3_CMAKE_COMMAND ${CMAKE_COMMAND})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(prefix "${CMAKE_BINARY_DIR}/deps")
|
|
||||||
set(RANGE_V3_INCLUDE_DIR "${prefix}/include")
|
|
||||||
|
|
||||||
ExternalProject_Add(range-v3-project
|
|
||||||
PREFIX "${prefix}"
|
|
||||||
DOWNLOAD_DIR "${CMAKE_SOURCE_DIR}/deps/downloads"
|
|
||||||
DOWNLOAD_NAME range-v3-0.11.0.tar.gz
|
|
||||||
URL https://github.com/ericniebler/range-v3/archive/0.11.0.tar.gz
|
|
||||||
URL_HASH SHA256=376376615dbba43d3bef75aa590931431ecb49eb36d07bb726a19f680c75e20c
|
|
||||||
CMAKE_COMMAND ${RANGE_V3_CMAKE_COMMAND}
|
|
||||||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
|
|
||||||
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
|
||||||
-DBUILD_TESTING=OFF
|
|
||||||
-DRANGES_CXX_STD=${CMAKE_CXX_STANDARD}
|
|
||||||
-DRANGE_V3_DOCS=OFF
|
|
||||||
-DRANGE_V3_EXAMPLES=OFF
|
|
||||||
-DRANGE_V3_TESTS=OFF
|
|
||||||
-DRANGES_BUILD_CALENDAR_EXAMPLE=OFF
|
|
||||||
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
|
||||||
BUILD_BYPRODUCTS "${RANGE_V3_INCLUDE_DIR}/range/v3/all.hpp"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Create range-v3 imported library
|
|
||||||
add_library(range-v3 INTERFACE IMPORTED)
|
|
||||||
file(MAKE_DIRECTORY ${RANGE_V3_INCLUDE_DIR}) # Must exist.
|
|
||||||
set_target_properties(range-v3 PROPERTIES
|
|
||||||
INTERFACE_COMPILE_OPTIONS "\$<\$<CXX_COMPILER_ID:MSVC>:/permissive->"
|
|
||||||
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${RANGE_V3_INCLUDE_DIR}
|
|
||||||
INTERFACE_INCLUDE_DIRECTORIES ${RANGE_V3_INCLUDE_DIR})
|
|
||||||
add_dependencies(range-v3 range-v3-project)
|
|
@ -42,7 +42,7 @@ set(sources
|
|||||||
)
|
)
|
||||||
|
|
||||||
add_library(solutil ${sources})
|
add_library(solutil ${sources})
|
||||||
target_link_libraries(solutil PUBLIC jsoncpp Boost::boost Boost::filesystem Boost::system range-v3)
|
target_link_libraries(solutil PRIVATE Boost::boost Boost::filesystem Boost::system range-v3 jsoncpp_static)
|
||||||
target_include_directories(solutil PUBLIC "${CMAKE_SOURCE_DIR}")
|
target_include_directories(solutil PUBLIC "${CMAKE_SOURCE_DIR}")
|
||||||
add_dependencies(solutil solidity_BuildInfo.h)
|
add_dependencies(solutil solidity_BuildInfo.h)
|
||||||
|
|
||||||
|
@ -33,8 +33,8 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
(JSONCPP_VERSION_MAJOR == 1) && (JSONCPP_VERSION_MINOR == 9) && (JSONCPP_VERSION_PATCH == 3),
|
(JSONCPP_VERSION_MAJOR == 1) && (JSONCPP_VERSION_MINOR == 9) && (JSONCPP_VERSION_PATCH == 5),
|
||||||
"Unexpected jsoncpp version: " JSONCPP_VERSION_STRING ". Expecting 1.9.3."
|
"Unexpected jsoncpp version: " JSONCPP_VERSION_STRING ". Expecting 1.9.5."
|
||||||
);
|
);
|
||||||
|
|
||||||
namespace solidity::util
|
namespace solidity::util
|
||||||
|
1
vcpkg
Submodule
1
vcpkg
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit c1dc3a6125284a9e0c60e95aee05cd809db9fa0b
|
19
vcpkg.json
Normal file
19
vcpkg.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json",
|
||||||
|
"name": "solidity",
|
||||||
|
"version": "0.8.13",
|
||||||
|
"dependencies": [
|
||||||
|
"boost-system",
|
||||||
|
"boost-filesystem",
|
||||||
|
"boost-test",
|
||||||
|
"boost-program-options",
|
||||||
|
"boost-multiprecision",
|
||||||
|
"boost-bimap",
|
||||||
|
"boost-assign",
|
||||||
|
"boost-process",
|
||||||
|
"range-v3",
|
||||||
|
"fmt",
|
||||||
|
"jsoncpp",
|
||||||
|
"z3"
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user