forked from XRPLF/rippled
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/mpt-stissue
- Loading branch information
Showing
61 changed files
with
351 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
include(isolate_headers) | ||
|
||
# Create an OBJECT library target named | ||
# | ||
# ${PROJECT_NAME}.lib${parent}.${name} | ||
# | ||
# with sources in src/lib${parent}/${name} | ||
# and headers in include/${parent}/${name} | ||
# that cannot include headers from other directories in include/ | ||
# unless they come through linked libraries. | ||
# | ||
# add_module(parent a) | ||
# add_module(parent b) | ||
# target_link_libraries(project.libparent.b PUBLIC project.libparent.a) | ||
function(add_module parent name) | ||
set(target ${PROJECT_NAME}.lib${parent}.${name}) | ||
add_library(${target} OBJECT) | ||
file(GLOB_RECURSE sources CONFIGURE_DEPENDS | ||
"${CMAKE_CURRENT_SOURCE_DIR}/src/lib${parent}/${name}/*.cpp" | ||
) | ||
target_sources(${target} PRIVATE ${sources}) | ||
target_include_directories(${target} PUBLIC | ||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>" | ||
) | ||
isolate_headers( | ||
${target} | ||
"${CMAKE_CURRENT_SOURCE_DIR}/include" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/include/${parent}/${name}" | ||
PUBLIC | ||
) | ||
isolate_headers( | ||
${target} | ||
"${CMAKE_CURRENT_SOURCE_DIR}/src" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/src/lib${parent}/${name}" | ||
PRIVATE | ||
) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# file(CREATE_SYMLINK) only works on Windows with administrator privileges. | ||
# https://stackoverflow.com/a/61244115/618906 | ||
function(create_symbolic_link target link) | ||
if(WIN32) | ||
if(NOT IS_SYMLINK "${link}") | ||
if(NOT IS_ABSOLUTE "${target}") | ||
# Relative links work do not work on Windows. | ||
set(target "${link}/../${target}") | ||
endif() | ||
file(TO_NATIVE_PATH "${target}" target) | ||
file(TO_NATIVE_PATH "${link}" link) | ||
execute_process(COMMAND cmd.exe /c mklink /J "${link}" "${target}") | ||
endif() | ||
else() | ||
file(CREATE_LINK "${target}" "${link}" SYMBOLIC) | ||
endif() | ||
if(NOT IS_SYMLINK "${link}") | ||
message(ERROR "failed to create symlink: <${link}>") | ||
endif() | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
include(create_symbolic_link) | ||
|
||
# Consider include directory B nested under prefix A: | ||
# | ||
# /path/to/A/then/to/B/... | ||
# | ||
# Call C the relative path from A to B. | ||
# C is what we want to write in `#include` directives: | ||
# | ||
# #include <then/to/B/...> | ||
# | ||
# Examples, all from the `jobqueue` module: | ||
# | ||
# - Library public headers: | ||
# B = /include/xrpl/jobqueue | ||
# A = /include/ | ||
# C = xrpl/jobqueue | ||
# | ||
# - Library private headers: | ||
# B = /src/libxrpl/jobqueue | ||
# A = /src/ | ||
# C = libxrpl/jobqueue | ||
# | ||
# - Test private headers: | ||
# B = /tests/jobqueue | ||
# A = / | ||
# C = tests/jobqueue | ||
# | ||
# To isolate headers from each other, | ||
# we want to create a symlink Y that points to B, | ||
# within a subdirectory X of the `CMAKE_BINARY_DIR`, | ||
# that has the same relative path C between X and Y, | ||
# and then add X as an include directory of the target, | ||
# sometimes `PUBLIC` and sometimes `PRIVATE`. | ||
# The Cs are all guaranteed to be unique. | ||
# We can guarantee a unique X per target by using | ||
# `${CMAKE_CURRENT_BINARY_DIR}/include/${target}`. | ||
# | ||
# isolate_headers(target A B scope) | ||
function(isolate_headers target A B scope) | ||
file(RELATIVE_PATH C "${A}" "${B}") | ||
set(X "${CMAKE_CURRENT_BINARY_DIR}/modules/${target}") | ||
set(Y "${X}/${C}") | ||
cmake_path(GET Y PARENT_PATH parent) | ||
file(MAKE_DIRECTORY "${parent}") | ||
create_symbolic_link("${B}" "${Y}") | ||
target_include_directories(${target} ${scope} "$<BUILD_INTERFACE:${X}>") | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Link a library to its modules (see: `add_module`) | ||
# and remove the module sources from the library's sources. | ||
# | ||
# add_module(parent a) | ||
# add_module(parent b) | ||
# target_link_libraries(project.libparent.b PUBLIC project.libparent.a) | ||
# add_library(project.libparent) | ||
# target_link_modules(parent PUBLIC a b) | ||
function(target_link_modules parent scope) | ||
set(library ${PROJECT_NAME}.lib${parent}) | ||
foreach(name ${ARGN}) | ||
set(module ${library}.${name}) | ||
get_target_property(sources ${library} SOURCES) | ||
list(LENGTH sources before) | ||
get_target_property(dupes ${module} SOURCES) | ||
list(LENGTH dupes expected) | ||
list(REMOVE_ITEM sources ${dupes}) | ||
list(LENGTH sources after) | ||
math(EXPR actual "${before} - ${after}") | ||
message(STATUS "${module} with ${expected} sources took ${actual} sources from ${library}") | ||
set_target_properties(${library} PROPERTIES SOURCES "${sources}") | ||
target_link_libraries(${library} ${scope} ${module}) | ||
endforeach() | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.