diff --git a/CMakeLists.txt b/CMakeLists.txt index b3f0b11340..55a198408a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,6 +104,8 @@ if(SHARED_MODEL_DISABLE_COMPATIBILITY) add_definitions(-DDISABLE_BACKWARD) endif() +SET(IROHA_ROOT_PROJECT ON) + add_subdirectory(schema) add_subdirectory(libs) add_subdirectory(irohad) diff --git a/libs/generator/CMakeLists.txt b/libs/generator/CMakeLists.txt index 3d7898a1a6..0a97ca3f00 100644 --- a/libs/generator/CMakeLists.txt +++ b/libs/generator/CMakeLists.txt @@ -1,4 +1 @@ add_library(generator generator.cpp) -target_link_libraries(generator - common - ) diff --git a/schema/CMakeLists.txt b/schema/CMakeLists.txt index f29184c989..53225520c6 100644 --- a/schema/CMakeLists.txt +++ b/schema/CMakeLists.txt @@ -21,10 +21,14 @@ compile_proto_to_cpp(primitive.proto) compile_proto_to_cpp(commands.proto) compile_proto_to_cpp(queries.proto) compile_proto_to_cpp(responses.proto) -compile_proto_to_grpc_cpp(endpoint.proto) -compile_proto_to_grpc_cpp(yac.proto) -compile_proto_to_grpc_cpp(ordering.proto) -compile_proto_to_grpc_cpp(loader.proto) +compile_proto_to_cpp(endpoint.proto) + +if (IROHA_ROOT_PROJECT) + compile_proto_to_grpc_cpp(endpoint.proto) + compile_proto_to_grpc_cpp(yac.proto) + compile_proto_to_grpc_cpp(ordering.proto) + compile_proto_to_grpc_cpp(loader.proto) +endif () add_library(schema block.pb.cc @@ -35,46 +39,49 @@ add_library(schema endpoint.pb.cc proposal.pb.cc ) + target_link_libraries(schema protobuf ) target_include_directories(schema PUBLIC - . + ${CMAKE_CURRENT_SOURCE_DIR} ) -add_library(endpoint - endpoint.pb.cc - endpoint.grpc.pb.cc - ) -target_link_libraries(endpoint - protobuf - grpc++ - schema - ) +if (IROHA_ROOT_PROJECT) + add_library(endpoint + endpoint.pb.cc + endpoint.grpc.pb.cc + ) + target_link_libraries(endpoint + protobuf + grpc++ + schema + ) -add_library(yac_grpc - yac.pb.cc - yac.grpc.pb.cc - ) -target_link_libraries(yac_grpc - protobuf - grpc++ - ) + add_library(yac_grpc + yac.pb.cc + yac.grpc.pb.cc + ) + target_link_libraries(yac_grpc + protobuf + grpc++ + ) -add_library(ordering_grpc - ordering.pb.cc - ordering.grpc.pb.cc - ) -target_link_libraries(ordering_grpc - schema - grpc++ - ) + add_library(ordering_grpc + ordering.pb.cc + ordering.grpc.pb.cc + ) + target_link_libraries(ordering_grpc + schema + grpc++ + ) -add_library(loader_grpc - loader.pb.cc - loader.grpc.pb.cc - ) -target_link_libraries(loader_grpc - schema - grpc++ - ) + add_library(loader_grpc + loader.pb.cc + loader.grpc.pb.cc + ) + target_link_libraries(loader_grpc + schema + grpc++ + ) +endif () diff --git a/shared_model/.gitignore b/shared_model/.gitignore new file mode 100644 index 0000000000..eb57c4f343 --- /dev/null +++ b/shared_model/.gitignore @@ -0,0 +1,2 @@ +build/* +external/* diff --git a/shared_model/CMakeLists.txt b/shared_model/CMakeLists.txt index 36b9532865..7ff225bb55 100644 --- a/shared_model/CMakeLists.txt +++ b/shared_model/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2017 Soramitsu Co., Ltd. +# Copyright 2018 Soramitsu Co., Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,13 +12,45 @@ # See the License for the specific language governing permissions and # limitations under the License. +cmake_minimum_required(VERSION 3.5.1) + +project(shared_model C CXX) + +set(IROHA_SCHEMA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../schema") +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR}/../libs + ${IROHA_SCHEMA_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} +) + +if (NOT IROHA_ROOT_PROJECT) + set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) + set(CMAKE_CXX_FLAGS "-std=c++14 -Wall") + set(CMAKE_CXX_FLAGS_RELEASE "-O3") + set(CMAKE_CXX_FLAGS_DEBUG "-g -Wextra -Wno-unused-parameter -Wno-deprecated-declarations -O0") + + option(TESTING "Build tests" ON) + + set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/Modules) + + set(SHARED_MODEL_DISABLE_COMPATIBILITY ON) + add_definitions(-DDISABLE_BACKWARD) + + include(FeatureSummary) + include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/functions.cmake) + include(cmake/dependencies.cmake) + + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../schema schema) + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../libs/generator generator) + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../libs/amount amount) +endif () add_library(old_model INTERFACE) if (NOT SHARED_MODEL_DISABLE_COMPATIBILITY) - target_link_libraries(old_model INTERFACE - model - ) -endif() + target_link_libraries(old_model INTERFACE + model + ) +endif () add_subdirectory(backend) add_subdirectory(bindings) @@ -27,3 +59,10 @@ add_subdirectory(converters) add_subdirectory(cryptography) add_subdirectory(interfaces) add_subdirectory(validators) + +if (NOT IROHA_ROOT_PROJECT) + if (TESTING) + enable_testing() + add_subdirectory(test) + endif () +endif () diff --git a/shared_model/backend/protobuf/CMakeLists.txt b/shared_model/backend/protobuf/CMakeLists.txt index bbaa66d3f3..0fdc3ad7dc 100644 --- a/shared_model/backend/protobuf/CMakeLists.txt +++ b/shared_model/backend/protobuf/CMakeLists.txt @@ -5,4 +5,5 @@ add_library(shared_model_proto_backend target_link_libraries(shared_model_proto_backend schema model_interfaces + iroha_amount ) diff --git a/shared_model/backend/protobuf/block.hpp b/shared_model/backend/protobuf/block.hpp index cc578616d8..da6f89380e 100644 --- a/shared_model/backend/protobuf/block.hpp +++ b/shared_model/backend/protobuf/block.hpp @@ -26,7 +26,6 @@ #include "backend/protobuf/util.hpp" #include "common_objects/trivial_proto.hpp" #include "interfaces/common_objects/types.hpp" -#include "model/block.hpp" #include "block.pb.h" #include "utils/lazy_initializer.hpp" diff --git a/shared_model/backend/protobuf/proposal.hpp b/shared_model/backend/protobuf/proposal.hpp index 48ce47f242..2589099ac0 100644 --- a/shared_model/backend/protobuf/proposal.hpp +++ b/shared_model/backend/protobuf/proposal.hpp @@ -23,7 +23,6 @@ #include #include "common_objects/trivial_proto.hpp" -#include "model/proposal.hpp" #include "block.pb.h" #include "interfaces/common_objects/types.hpp" diff --git a/shared_model/clean.sh b/shared_model/clean.sh new file mode 100755 index 0000000000..e0e2b76a27 --- /dev/null +++ b/shared_model/clean.sh @@ -0,0 +1,4 @@ +#!/bin/bash +rm ../schema/*.{cc,h} +rm -rf external +rm -rf build diff --git a/shared_model/cmake/dependencies.cmake b/shared_model/cmake/dependencies.cmake new file mode 100644 index 0000000000..43d574a35f --- /dev/null +++ b/shared_model/cmake/dependencies.cmake @@ -0,0 +1,38 @@ +find_package(PackageHandleStandardArgs) + +include(ExternalProject) +set(EP_PREFIX "${PROJECT_SOURCE_DIR}/external") +set_directory_properties(PROPERTIES + EP_PREFIX ${EP_PREFIX} + ) + +# Project dependencies. +find_package(Threads REQUIRED) + +################################ +# protobuf # +################################ +option(FIND_PROTOBUF "Try to find protobuf in system" ON) +find_package(protobuf) + +########################## +# boost # +########################## +find_package(Boost 1.65.0 REQUIRED) +add_library(boost INTERFACE IMPORTED) +set_target_properties(boost PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIRS} + ) + +################################### +# ed25519/sha3 # +################################### +find_package(ed25519) + +########################## +# gtest # +########################## +# testing is an option. Look at the main CMakeLists.txt for details. +if (TESTING) + find_package(gtest) +endif () diff --git a/shared_model/cryptography/ed25519_sha3_impl/internal/CMakeLists.txt b/shared_model/cryptography/ed25519_sha3_impl/internal/CMakeLists.txt index 09a6ec1509..6219e7a34b 100644 --- a/shared_model/cryptography/ed25519_sha3_impl/internal/CMakeLists.txt +++ b/shared_model/cryptography/ed25519_sha3_impl/internal/CMakeLists.txt @@ -20,7 +20,6 @@ add_library(hash ) target_link_libraries(hash - common ed25519 ) diff --git a/shared_model/interfaces/query_responses/account_detail_response.hpp b/shared_model/interfaces/query_responses/account_detail_response.hpp index 8eb05bfcd0..216f62194f 100644 --- a/shared_model/interfaces/query_responses/account_detail_response.hpp +++ b/shared_model/interfaces/query_responses/account_detail_response.hpp @@ -21,7 +21,6 @@ #include "interfaces/base/primitive.hpp" #include "interfaces/common_objects/account_asset.hpp" #include "interfaces/common_objects/types.hpp" -#include "model/queries/responses/account_detail_response.hpp" #include "utils/string_builder.hpp" #include "utils/visitor_apply_for_all.hpp" diff --git a/shared_model/test/CMakeLists.txt b/shared_model/test/CMakeLists.txt new file mode 100644 index 0000000000..3aeb9bd6b2 --- /dev/null +++ b/shared_model/test/CMakeLists.txt @@ -0,0 +1,7 @@ +SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/test_bin) + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR}/../../test +) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../test/module/shared_model shared_model_test) diff --git a/test/module/shared_model/backend_proto/CMakeLists.txt b/test/module/shared_model/backend_proto/CMakeLists.txt index a82b1827a7..adf28b20f7 100644 --- a/test/module/shared_model/backend_proto/CMakeLists.txt +++ b/test/module/shared_model/backend_proto/CMakeLists.txt @@ -36,7 +36,6 @@ target_link_libraries(shared_proto_transaction_test shared_model_proto_backend shared_model_cryptography shared_model_stateless_validation - iroha_amount ) addtest(shared_proto_queries_test