|
diff --git a/cmake/clang-format.cmake b/cmake/clang-format.cmake |
|
index be90d44..82f0f89 100644 |
|
--- a/cmake/clang-format.cmake |
|
+++ b/cmake/clang-format.cmake |
|
@@ -8,10 +8,10 @@ file(GLOB_RECURSE |
|
|
|
# Adding clang-format target if executable is found |
|
if(NOT CLANG_FORMAT_BIN) |
|
- find_program(CLANG_FORMAT_BIN "clang-format") |
|
+ find_program(CLANG_FORMAT_BIN NAMES clang-format clang-format-9 clang-format-8 clang-format-7) |
|
endif() |
|
|
|
-if(CLANG_FORMAT_BIN) |
|
+if(CLANG_FORMAT_BIN AND NOT TARGET clang-format) |
|
message(STATUS "Target clang-format enabled") |
|
add_custom_target( |
|
clang-format |
|
diff --git a/cmake/functions.cmake b/cmake/functions.cmake |
|
index b0a40f8..dcc9a35 100644 |
|
--- a/cmake/functions.cmake |
|
+++ b/cmake/functions.cmake |
|
@@ -45,7 +45,7 @@ function(add_flag flag) |
|
endif () |
|
endfunction() |
|
|
|
-function(compile_proto_to_cpp PROTO_LIBRARY_NAME PB_H PB_CC PROTO) |
|
+function(compile_proto_to_cpp_libp2p PROTO_LIBRARY_NAME PB_H PB_CC PROTO) |
|
if (NOT Protobuf_INCLUDE_DIR) |
|
get_target_property(Protobuf_INCLUDE_DIR protobuf::libprotobuf INTERFACE_INCLUDE_DIRECTORIES) |
|
endif() |
|
@@ -63,7 +63,7 @@ function(compile_proto_to_cpp PROTO_LIBRARY_NAME PB_H PB_CC PROTO) |
|
|
|
get_filename_component(PROTO_ABS "${PROTO}" REALPATH) |
|
# get relative (to CMAKE_BINARY_DIR) path of current proto file |
|
- file(RELATIVE_PATH SCHEMA_REL "${CMAKE_BINARY_DIR}/src" "${CMAKE_CURRENT_BINARY_DIR}") |
|
+ file(RELATIVE_PATH SCHEMA_REL "${CMAKE_BINARY_DIR}/libs/libp2p/src" "${CMAKE_CURRENT_BINARY_DIR}") |
|
|
|
set(SCHEMA_OUT_DIR ${CMAKE_BINARY_DIR}/pb/${PROTO_LIBRARY_NAME}/generated) |
|
file(MAKE_DIRECTORY ${SCHEMA_OUT_DIR}) |
|
@@ -92,18 +92,20 @@ function(compile_proto_to_cpp PROTO_LIBRARY_NAME PB_H PB_CC PROTO) |
|
set(${PB_CC} ${SCHEMA_OUT_DIR}/${SCHEMA_REL}/${GEN_PB} PARENT_SCOPE) |
|
endfunction() |
|
|
|
-add_custom_target(generated |
|
- COMMENT "Building generated files..." |
|
- ) |
|
+if (NOT TARGET generated) |
|
+ add_custom_target(generated |
|
+ COMMENT "Building generated files..." |
|
+ ) |
|
+endif() |
|
|
|
-function(add_proto_library NAME) |
|
+function(add_proto_library_p2p NAME) |
|
set(SOURCES "") |
|
foreach (PROTO IN ITEMS ${ARGN}) |
|
- compile_proto_to_cpp(${NAME} H C ${PROTO}) |
|
+ compile_proto_to_cpp_libp2p(${NAME} H C ${PROTO}) |
|
list(APPEND SOURCES ${H} ${C}) |
|
endforeach () |
|
|
|
- add_library(${NAME} |
|
+ libp2p_add_library(${NAME} |
|
${SOURCES} |
|
) |
|
target_link_libraries(${NAME} |
|
@@ -117,7 +119,7 @@ function(add_proto_library NAME) |
|
) |
|
|
|
disable_clang_tidy(${NAME}) |
|
- libp2p_install(${NAME}) |
|
+ # libp2p_install(${NAME}) |
|
|
|
add_dependencies(generated ${NAME}) |
|
endfunction() |
|
diff --git a/cmake/install.cmake b/cmake/install.cmake |
|
index 4163e67..f8527ad 100644 |
|
--- a/cmake/install.cmake |
|
+++ b/cmake/install.cmake |
|
@@ -9,10 +9,11 @@ function(libp2p_install targets) |
|
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} |
|
FRAMEWORK DESTINATION ${CMAKE_INSTALL_PREFIX} |
|
) |
|
+ kagome_install(${targets}) |
|
endfunction() |
|
|
|
install( |
|
- DIRECTORY ${CMAKE_SOURCE_DIR}/include/libp2p |
|
+ DIRECTORY ${CMAKE_SOURCE_DIR}/libs/libp2p |
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} |
|
) |
|
install( |
|
diff --git a/cmake/libp2p_add_library.cmake b/cmake/libp2p_add_library.cmake |
|
index ee360fa..456d14f 100644 |
|
--- a/cmake/libp2p_add_library.cmake |
|
+++ b/cmake/libp2p_add_library.cmake |
|
@@ -2,5 +2,10 @@ function(libp2p_add_library target) |
|
add_library(${target} |
|
${ARGN} |
|
) |
|
+ target_include_directories(${target} |
|
+ INTERFACE |
|
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/libs/libp2p/include> |
|
+ $<INSTALL_INTERFACE:libp2p/include> |
|
+ ) |
|
libp2p_install(${target}) |
|
endfunction() |
|
diff --git a/src/crypto/protobuf/CMakeLists.txt b/src/crypto/protobuf/CMakeLists.txt |
|
index 4a9144c..01894b6 100644 |
|
--- a/src/crypto/protobuf/CMakeLists.txt |
|
+++ b/src/crypto/protobuf/CMakeLists.txt |
|
@@ -3,6 +3,7 @@ |
|
# SPDX-License-Identifier: Apache-2.0 |
|
# |
|
|
|
-add_proto_library(p2p_keys_proto |
|
+add_proto_library_p2p(p2p_keys_proto |
|
keys.proto |
|
) |
|
+# libp2p_install(p2p_keys_proto) |
|
diff --git a/src/protocol/gossip/protobuf/CMakeLists.txt b/src/protocol/gossip/protobuf/CMakeLists.txt |
|
index 864e4e6..13cfa11 100644 |
|
--- a/src/protocol/gossip/protobuf/CMakeLists.txt |
|
+++ b/src/protocol/gossip/protobuf/CMakeLists.txt |
|
@@ -1,6 +1,6 @@ |
|
# Copyright Soramitsu Co., Ltd. All Rights Reserved. |
|
# SPDX-License-Identifier: Apache-2.0 |
|
|
|
-add_proto_library(p2p_gossip_proto |
|
+add_proto_library_p2p(p2p_gossip_proto |
|
rpc.proto |
|
) |
|
diff --git a/src/protocol/identify/protobuf/CMakeLists.txt b/src/protocol/identify/protobuf/CMakeLists.txt |
|
index a93a8fe..5f83908 100644 |
|
--- a/src/protocol/identify/protobuf/CMakeLists.txt |
|
+++ b/src/protocol/identify/protobuf/CMakeLists.txt |
|
@@ -3,6 +3,6 @@ |
|
# SPDX-License-Identifier: Apache-2.0 |
|
# |
|
|
|
-add_proto_library(p2p_identify_proto |
|
+add_proto_library_p2p(p2p_identify_proto |
|
identify.proto |
|
) |
|
diff --git a/src/protocol/kademlia/protobuf/CMakeLists.txt b/src/protocol/kademlia/protobuf/CMakeLists.txt |
|
index f477c7d..b5a74f7 100644 |
|
--- a/src/protocol/kademlia/protobuf/CMakeLists.txt |
|
+++ b/src/protocol/kademlia/protobuf/CMakeLists.txt |
|
@@ -1,6 +1,6 @@ |
|
# Copyright Soramitsu Co., Ltd. All Rights Reserved. |
|
# SPDX-License-Identifier: Apache-2.0 |
|
|
|
-add_proto_library(p2p_kademlia_proto |
|
+add_proto_library_p2p(p2p_kademlia_proto |
|
kademlia.proto |
|
) |
|
diff --git a/src/security/noise/protobuf/CMakeLists.txt b/src/security/noise/protobuf/CMakeLists.txt |
|
index 593ce69..190aede 100644 |
|
--- a/src/security/noise/protobuf/CMakeLists.txt |
|
+++ b/src/security/noise/protobuf/CMakeLists.txt |
|
@@ -3,6 +3,6 @@ |
|
# SPDX-License-Identifier: Apache-2.0 |
|
# |
|
|
|
-add_proto_library(p2p_noise_proto |
|
+add_proto_library_p2p(p2p_noise_proto |
|
noise.proto |
|
) |
|
diff --git a/src/security/plaintext/protobuf/CMakeLists.txt b/src/security/plaintext/protobuf/CMakeLists.txt |
|
index 81e48ce..3e11f0c 100644 |
|
--- a/src/security/plaintext/protobuf/CMakeLists.txt |
|
+++ b/src/security/plaintext/protobuf/CMakeLists.txt |
|
@@ -3,7 +3,7 @@ |
|
# SPDX-License-Identifier: Apache-2.0 |
|
# |
|
|
|
-add_proto_library(p2p_plaintext_proto |
|
+add_proto_library_p2p(p2p_plaintext_proto |
|
plaintext.proto |
|
) |
|
target_link_libraries(p2p_plaintext_proto |
|
diff --git a/src/security/secio/protobuf/CMakeLists.txt b/src/security/secio/protobuf/CMakeLists.txt |
|
index 4666569..19d24a5 100644 |
|
--- a/src/security/secio/protobuf/CMakeLists.txt |
|
+++ b/src/security/secio/protobuf/CMakeLists.txt |
|
@@ -3,6 +3,6 @@ |
|
# SPDX-License-Identifier: Apache-2.0 |
|
# |
|
|
|
-add_proto_library(p2p_secio_proto |
|
+add_proto_library_p2p(p2p_secio_proto |
|
secio.proto |
|
) |
|
diff --git a/test/deps/CMakeLists.txt b/test/deps/CMakeLists.txt |
|
index 17da20c..f039059 100644 |
|
--- a/test/deps/CMakeLists.txt |
|
+++ b/test/deps/CMakeLists.txt |
|
@@ -3,12 +3,12 @@ |
|
# SPDX-License-Identifier: Apache-2.0 |
|
# |
|
|
|
-addtest(outcome_test outcome_test.cpp) |
|
-target_link_libraries(outcome_test |
|
+addtest(p2p_outcome_test outcome_test.cpp) |
|
+target_link_libraries(p2p_outcome_test |
|
Boost::boost |
|
) |
|
|
|
-addtest(di_test di_test.cpp) |
|
-target_link_libraries(di_test |
|
+addtest(p2p_di_test di_test.cpp) |
|
+target_link_libraries(p2p_di_test |
|
Boost::Boost.DI |
|
) |
|
diff --git a/test/libp2p/basic/CMakeLists.txt b/test/libp2p/basic/CMakeLists.txt |
|
index 4812e19..aa045a4 100644 |
|
--- a/test/libp2p/basic/CMakeLists.txt |
|
+++ b/test/libp2p/basic/CMakeLists.txt |
|
@@ -3,10 +3,10 @@ |
|
# SPDX-License-Identifier: Apache-2.0 |
|
# |
|
|
|
-addtest(message_read_writer_test |
|
+addtest(p2p_message_read_writer_test |
|
message_read_writer_test.cpp |
|
) |
|
-target_link_libraries(message_read_writer_test |
|
+target_link_libraries(p2p_message_read_writer_test |
|
p2p_message_read_writer |
|
p2p_protobuf_message_read_writer |
|
p2p_message_read_writer_error |
|
diff --git a/test/libp2p/common/CMakeLists.txt b/test/libp2p/common/CMakeLists.txt |
|
index 19e1d0e..7c4114e 100644 |
|
--- a/test/libp2p/common/CMakeLists.txt |
|
+++ b/test/libp2p/common/CMakeLists.txt |
|
@@ -3,10 +3,10 @@ |
|
# SPDX-License-Identifier: Apache-2.0 |
|
## |
|
|
|
-addtest(hexutil_test |
|
+addtest(p2p_hexutil_test |
|
hexutil_test.cpp |
|
) |
|
-target_link_libraries(hexutil_test |
|
+target_link_libraries(p2p_hexutil_test |
|
p2p_hexutil |
|
p2p_literals |
|
) |