diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e2a2b4a32f1..b9f2ddc36cad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,16 +37,21 @@ option(SOLC_STATIC_STDLIBS "Link solc against static versions of libgcc and libs option(STRICT_Z3_VERSION "Use the latest version of Z3" ON) option(PEDANTIC "Enable extra warnings and pedantic build flags. Treat all warnings as errors." ON) option(PROFILE_OPTIMIZER_STEPS "Output performance metrics for the optimiser steps." OFF) +option(USE_SYSTEM_LIBRARIES "Use system libraries" OFF) +option(ONLY_BUILD_SOLIDITY_LIBRARIES "Only build solidity libraries" OFF) +option(STRICT_JSONCPP_VERSION "Strictly check installed jsoncpp version" ON) # Setup cccache. include(EthCcache) # Let's find our dependencies include(EthDependencies) -include(fmtlib) -include(jsoncpp) -include(range-v3) -include_directories(SYSTEM ${JSONCPP_INCLUDE_DIR}) +if (NOT USE_SYSTEM_LIBRARIES) + include(fmtlib) + include(jsoncpp) + include(range-v3) + include_directories(SYSTEM ${JSONCPP_INCLUDE_DIR}) +endif() find_package(Threads) @@ -58,6 +63,10 @@ if (PROFILE_OPTIMIZER_STEPS) add_definitions(-DPROFILE_OPTIMIZER_STEPS) endif() +if (STRICT_JSONCPP_VERSION) + add_definitions(-DSTRICT_JSONCPP_VERSION_CHECK) +endif() + # Figure out what compiler and system are we using include(EthCompilerSettings) @@ -141,12 +150,16 @@ add_subdirectory(libyul) add_subdirectory(libsolidity) add_subdirectory(libsolc) add_subdirectory(libstdlib) -add_subdirectory(tools) -if (NOT EMSCRIPTEN) - add_subdirectory(solc) -endif() +if (NOT ONLY_BUILD_SOLIDITY_LIBRARIES) + add_subdirectory(tools) -if (TESTS AND NOT EMSCRIPTEN) - add_subdirectory(test) + if (NOT EMSCRIPTEN) + add_subdirectory(solc) + endif() + + if (TESTS AND NOT EMSCRIPTEN) + add_subdirectory(test) + endif() endif() + diff --git a/libsolutil/JSON.cpp b/libsolutil/JSON.cpp index ea75ada0f79f..3a2570d47ec1 100644 --- a/libsolutil/JSON.cpp +++ b/libsolutil/JSON.cpp @@ -30,10 +30,12 @@ #include #include +#ifdef STRICT_JSONCPP_VERSION_CHECK static_assert( (JSONCPP_VERSION_MAJOR == 1) && (JSONCPP_VERSION_MINOR == 9) && (JSONCPP_VERSION_PATCH == 3), "Unexpected jsoncpp version: " JSONCPP_VERSION_STRING ". Expecting 1.9.3." ); +#endif namespace solidity::util { diff --git a/libstdlib/CMakeLists.txt b/libstdlib/CMakeLists.txt index 65a3a1cda16b..b6b22832d6e6 100644 --- a/libstdlib/CMakeLists.txt +++ b/libstdlib/CMakeLists.txt @@ -1,18 +1,18 @@ # This will re-generate the headers if any file within src was modified. -set_directory_properties(PROPERTY CMAKE_CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR}/stdlib/src/) +set_directory_properties(PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/) set(STDLIB stub) set(GENERATED_STDLIB_HEADERS) foreach(src IN LISTS STDLIB) - set(STDLIB_FILE ${PROJECT_SOURCE_DIR}/libstdlib/src/${src}.sol) + set(STDLIB_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/${src}.sol) file(READ ${STDLIB_FILE} STDLIB_FILE_CONTENT HEX) string(REGEX MATCHALL ".." STDLIB_FILE_CONTENT "${STDLIB_FILE_CONTENT}") list(REMOVE_ITEM STDLIB_FILE_CONTENT "0d") string(REGEX REPLACE ";" ",\n\t0x" STDLIB_FILE_CONTENT "${STDLIB_FILE_CONTENT}") set(STDLIB_FILE_CONTENT "0x${STDLIB_FILE_CONTENT}") set(STDLIB_FILE_NAME ${src}) - configure_file("${PROJECT_SOURCE_DIR}/libstdlib/stdlib.src.h.in" ${PROJECT_BINARY_DIR}/include/libstdlib/${src}.h NEWLINE_STYLE LF @ONLY) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/stdlib.src.h.in" ${PROJECT_BINARY_DIR}/include/libstdlib/${src}.h NEWLINE_STYLE LF @ONLY) list(APPEND GENERATED_STDLIB_HEADERS ${PROJECT_BINARY_DIR}/include/libstdlib/${src}.h) endforeach() -configure_file("${PROJECT_SOURCE_DIR}/libstdlib/stdlib.h.in" ${PROJECT_BINARY_DIR}/include/libstdlib/stdlib.h NEWLINE_STYLE LF @ONLY) +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/stdlib.h.in" ${PROJECT_BINARY_DIR}/include/libstdlib/stdlib.h NEWLINE_STYLE LF @ONLY)