mirror of
https://github.com/XRPLF/rippled.git
synced 2026-08-21 22:30:57 +00:00
60 lines
2.5 KiB
CMake
60 lines
2.5 KiB
CMake
set(CORROSION_VERSION 0.6.1)
|
|
|
|
find_package(Corrosion ${CORROSION_VERSION} QUIET)
|
|
if(NOT Corrosion_FOUND)
|
|
include(FetchContent)
|
|
FetchContent_Declare(
|
|
Corrosion
|
|
GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git
|
|
GIT_TAG v${CORROSION_VERSION}
|
|
)
|
|
FetchContent_MakeAvailable(Corrosion)
|
|
endif()
|
|
|
|
corrosion_import_crate(MANIFEST_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Cargo.toml)
|
|
|
|
file(
|
|
WRITE "${CMAKE_CURRENT_BINARY_DIR}/.clang-tidy"
|
|
"# Auto-generated by crates/CMakeLists.txt. Do not edit.\n"
|
|
"# Neutralizes clang-tidy for corrosion/cxxbridge-generated C++.\n"
|
|
"# One check kept enabled to avoid clang-tidy's \"no checks enabled\" error.\n"
|
|
"Checks: '-*,google-readability-todo'\n"
|
|
"WarningsAsErrors: ''\n"
|
|
"HeaderFilterRegex: ''\n"
|
|
"InheritParentConfig: false\n"
|
|
)
|
|
|
|
# Umbrella target that aggregates all crate-generated code (cxxbridge headers,
|
|
# etc.). Build this before running clang-tidy so generated headers are present.
|
|
add_custom_target(xrpl_crates)
|
|
|
|
# add_xrpl_crate(<name> CRATE <crate> FILES <file>...) Creates a cxxbridge
|
|
# target <name>_cxxbridge and registers it with xrpl_crates.
|
|
function(add_xrpl_crate name)
|
|
cmake_parse_arguments(ARG "" "CRATE" "FILES" ${ARGN})
|
|
corrosion_add_cxxbridge(${name}_cxxbridge CRATE ${ARG_CRATE} FILES
|
|
${ARG_FILES}
|
|
)
|
|
# Generated cxxbridge headers don't exist at configure time; CMake 3.28+
|
|
# validates INTERFACE_SOURCES on consuming targets. Clear it to skip the
|
|
# existence check — build-time ordering is enforced by the custom commands.
|
|
set_target_properties(${name}_cxxbridge PROPERTIES INTERFACE_SOURCES "")
|
|
add_dependencies(xrpl_crates ${name}_cxxbridge)
|
|
endfunction()
|
|
|
|
add_xrpl_crate(xrpl_wasm_vm_ffi CRATE xrpl_wasm_vm_ffi FILES lib.rs)
|
|
|
|
# Test-only, and deliberately not part of xrpl_wasm_vm_ffi: it carries the `wat` assembler,
|
|
# which the engine's `wasmi default-features = false` exists to keep out of the consensus
|
|
# path. Linked from src/tests/libxrpl only, so the shipped node cannot contain it.
|
|
add_xrpl_crate(xrpl_wasm_testkit CRATE xrpl_wasm_testkit FILES lib.rs)
|
|
|
|
# The wasm bridge `include!`s a project header, so its generated translation unit needs
|
|
# the project's include root. Deliberately only that: a header reached from here must
|
|
# stay light enough to compile without the Boost paths this target does not get, which
|
|
# is why `HostContext.h` forward-declares `xrpl::HostFunctions` instead of including it.
|
|
target_include_directories(
|
|
xrpl_wasm_vm_ffi_cxxbridge
|
|
PRIVATE ${CMAKE_SOURCE_DIR}/include
|
|
)
|