Skip to content

Commit

Permalink
Fixes in cmake files
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Vaneev <[email protected]>
  • Loading branch information
Warchant committed Oct 16, 2017
1 parent adb4688 commit be7e937
Show file tree
Hide file tree
Showing 14 changed files with 120 additions and 70 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ cmake-build*

cmake-build*
.gtm
/.gtm/
22 changes: 16 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ endif()

PROJECT(iroha C CXX)

SET(CMAKE_CXX_FLAGS "-std=c++1y -Wall -fPIC -fPIE")
SET(CMAKE_CXX_FLAGS_RELEASE "-O3")
SET(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
SET(CMAKE_CXX_FLAGS "-std=c++1y -Wall")
SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -s")
SET(CMAKE_CXX_FLAGS_DEBUG "-g -Wextra -Wno-unused-parameter -O0")
SET(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)
SET(CMAKE_INSTALL_RPATH "lib:../lib:.")
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
#SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
#SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)

if(COVERAGE)
set(CMAKE_EXPORT_COMPILE_COMMANDS "ON")
Expand All @@ -34,6 +35,10 @@ option(BENCHMARKING "Build benchmarks" OFF)
option(TESTING "Build tests" ON )
option(COVERAGE "Enable coverage" OFF)
option(FUZZING "Build fuzzing binaries" OFF)
option(PACKAGE_ZIP "Create ZIP package" OFF)
option(PACKAGE_TGZ "Create TGZ package" ON )
option(PACKAGE_RPM "Create RPM package" OFF)
option(PACKAGE_DEB "Create DEB package" OFF)

if (NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Debug)
Expand All @@ -43,6 +48,10 @@ message(STATUS "-DTESTING=${TESTING}")
message(STATUS "-DBENCHMARKING=${BENCHMARKING}")
message(STATUS "-DFUZZING=${FUZZING}")
message(STATUS "-DCOVERAGE=${COVERAGE}")
message(STATUS "-DPACKAGE_ZIP=${PACKAGE_ZIP}")
message(STATUS "-DPACKAGE_TGZ=${PACKAGE_TGZ}")
message(STATUS "-DPACKAGE_RPM=${PACKAGE_RPM}")
message(STATUS "-DPACKAGE_DEB=${PACKAGE_DEB}")

SET(IROHA_SCHEMA_DIR "${PROJECT_SOURCE_DIR}/schema")
include_directories(
Expand All @@ -54,6 +63,8 @@ include_directories(
include(FeatureSummary)
include(cmake/functions.cmake)
include(cmake/dependencies.cmake)
include(cmake/release.cmake)

add_subdirectory(schema)
add_subdirectory(libs)
add_subdirectory(irohad)
Expand All @@ -74,6 +85,5 @@ if (FUZZING)
endif()


# must be in the end
include(cmake/release.cmake)


18 changes: 11 additions & 7 deletions cmake/Modules/Findcpp_redis.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ find_package_handle_standard_args(cpp_redis DEFAULT_MSG
tacopie_LIBRARY
)

set(URL https://github.com/Cylix/tacopie.git)
set(VERSION 290dc38681f346adae41d3cc8feabbe534424675)
set_target_description(cpp_redis "C++ redis client" ${URL} ${VERSION})
set(URL1 https://github.com/Cylix/cpp_redis.git)
set(VERSION1 727aa5f06c8ce498168cbab5a023cad5b9c00bc0)
set_target_description(cpp_redis "C++ redis client" ${URL1} ${VERSION1})

set(URL2 https://github.com/Cylix/tacopie.git)
set(VERSION2 290dc38681f346adae41d3cc8feabbe534424675)
set_target_description(tacopie "C++ tcp library" ${URL2} ${VERSION2})

if (NOT cpp_redis_FOUND)
externalproject_add(cylix_cpp_redis
GIT_REPOSITORY ${URL}
GIT_TAG ${VERSION}
GIT_REPOSITORY ${URL1}
GIT_TAG ${VERSION1}
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
INSTALL_COMMAND "" # remove install step
Expand All @@ -37,8 +41,8 @@ if (NOT cpp_redis_FOUND)
file(MAKE_DIRECTORY ${cpp_redis_INCLUDE_DIR})

externalproject_add(cylix_tacopie
GIT_REPOSITORY https://github.com/Cylix/tacopie
GIT_TAG 290dc38681f346adae41d3cc8feabbe534424675
GIT_REPOSITORY ${URL2}
GIT_TAG ${VERSION2}
SOURCE_DIR ${tacopie_SOURCE_DIR}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
Expand Down
37 changes: 24 additions & 13 deletions cmake/Modules/Findgrpc.cmake
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
add_library(grpc UNKNOWN IMPORTED)
add_library(grpc++ UNKNOWN IMPORTED)
add_library(grpc++_reflection UNKNOWN IMPORTED)
add_library(gpr UNKNOWN IMPORTED)
add_executable(grpc_cpp_plugin IMPORTED)

if (FIND_GRPC)
find_path(grpc_INCLUDE_DIR grpc/grpc.h)
mark_as_advanced(grpc_INCLUDE_DIR)
find_path(grpc_INCLUDE_DIR grpc/grpc.h)
mark_as_advanced(grpc_INCLUDE_DIR)

find_library(grpc_LIBRARY grpc)
mark_as_advanced(grpc_LIBRARY)
find_library(grpc_LIBRARY grpc)
mark_as_advanced(grpc_LIBRARY)

find_library(grpc_grpc++_LIBRARY grpc++)
mark_as_advanced(grpc_grpc++_LIBRARY)
find_library(grpc_grpc++_LIBRARY grpc++)
mark_as_advanced(grpc_grpc++_LIBRARY)

find_library(grpc_grpc++_reflection_LIBRARY grpc++_reflection)
mark_as_advanced(grpc_grpc++_reflection_LIBRARY)
find_library(grpc_grpc++_reflection_LIBRARY grpc++_reflection)
mark_as_advanced(grpc_grpc++_reflection_LIBRARY)

find_program(grpc_CPP_PLUGIN grpc_cpp_plugin)
mark_as_advanced(grpc_CPP_PLUGIN)
endif()
find_library(gpr_LIBRARY gpr)
mark_as_advanced(gpr_LIBRARY)

find_program(grpc_CPP_PLUGIN grpc_cpp_plugin)
mark_as_advanced(grpc_CPP_PLUGIN)

find_package_handle_standard_args(grpc DEFAULT_MSG
grpc_LIBRARY
grpc_INCLUDE_DIR
gpr_LIBRARY
grpc_grpc++_reflection_LIBRARY
grpc_CPP_PLUGIN
)
Expand All @@ -36,7 +39,7 @@ if (NOT grpc_FOUND)
externalproject_add(grpc_grpc
GIT_REPOSITORY ${URL}
GIT_TAG ${VERSION}
CMAKE_ARGS -DgRPC_PROTOBUF_PROVIDER=package -DgRPC_PROTOBUF_PACKAGE_TYPE=CONFIG -DProtobuf_DIR=${EP_PREFIX}/src/google_protobuf-build/lib/cmake/protobuf -DgRPC_ZLIB_PROVIDER=package -DBUILD_SHARED_LIBS=ON
CMAKE_ARGS -DgRPC_PROTOBUF_PROVIDER=package -DgRPC_PROTOBUF_PACKAGE_TYPE=CONFIG -DProtobuf_DIR=${EP_PREFIX}/src/google_protobuf-build/lib/cmake/protobuf -DgRPC_ZLIB_PROVIDER=package -DBUILD_SHARED_LIBS=OFF
PATCH_COMMAND ${GIT_EXECUTABLE} apply ${PROJECT_SOURCE_DIR}/patch/fix-protobuf-package-include.patch || true
INSTALL_COMMAND "" # remove install step
TEST_COMMAND "" # remove test step
Expand Down Expand Up @@ -79,3 +82,11 @@ set_target_properties(grpc++_reflection PROPERTIES
set_target_properties(grpc_cpp_plugin PROPERTIES
IMPORTED_LOCATION ${grpc_CPP_PLUGIN}
)

set_target_properties(gpr PROPERTIES
IMPORTED_LOCATION ${gpr_LIBRARY}
)

add_install_step_for_lib(${grpc_LIBRARY})
add_install_step_for_lib(${grpc_grpc++_LIBRARY})
add_install_step_for_lib(${gpr_LIBRARY})
2 changes: 2 additions & 0 deletions cmake/Modules/Findpq.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,5 @@ set_target_properties(pq PROPERTIES
set_target_properties(pg_config PROPERTIES
IMPORTED_LOCATION ${pg_config_EXECUTABLE}
)

add_install_step_for_lib(${pq_LIBRARY})
2 changes: 1 addition & 1 deletion cmake/Modules/Findrapidjson.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ find_package_handle_standard_args(rapidjson DEFAULT_MSG
rapidjson_INCLUDE_DIR
)

set(GITHUB https://github.com/miloyip/rapidjson.git)
set(URL https://github.com/miloyip/rapidjson.git)
set(VERSION f54b0e47a08782a6131cc3d60f94d038fa6e0a51)
set_target_description(rapidjson "JSON library" ${URL} ${VERSION})

Expand Down
2 changes: 2 additions & 0 deletions cmake/Modules/Findtbb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@ set_target_properties(tbb PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${tbb_INCLUDE_DIR}
IMPORTED_LOCATION ${tbb_LIBRARY}
)

#add_install_step_for_lib(${tbb_LIBRARY})
30 changes: 13 additions & 17 deletions cmake/functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -81,25 +81,31 @@ endmacro()
macro(add_install_step_for_bin target)
install(TARGETS ${target}
RUNTIME DESTINATION bin
CONFIGURATIONS Release
COMPONENT binaries)
endmacro()


# does not work (yet) for system libraries, since we need root
# access to change them.
#macro(strip_at_install_step path)
# # strip library
# find_program(STRIP strip)
# if(NOT STRIP STREQUAL "STRIP-NOTFOUND")
# install(CODE "MESSAGE(STATUS \"stripping ${path}\")")
# install(CODE "execute_process(COMMAND ${STRIP} -s ${path})")
# endif()
#endmacro()


macro(add_install_step_for_lib libpath)
# full path with resolved symlinks:
# /usr/local/lib/libprotobuf.so -> /usr/local/lib/libprotobuf.so.13.0.0
get_filename_component(lib_major_minor_patch ${libpath} REALPATH)
# /usr/local/lib/libprotobuf.so.13.0.0 -> /usr/local/lib/libprotobuf.so.13.0
string(REGEX REPLACE "\\.[0-9]+$" "" lib_major_minor ${lib_major_minor_patch})
# /usr/local/lib/libprotobuf.so.13.0 -> /usr/local/lib/libprotobuf.so.13
string(REGEX REPLACE "\\.[0-9]+$" "" lib_major ${lib_major_minor})

get_filename_component(lib_major_name ${lib_major} NAME)

install(FILES ${lib_major_minor_patch}
DESTINATION lib
CONFIGURATIONS Release
RENAME ${lib_major_name}
COMPONENT libraries)
endmacro()

Expand All @@ -117,13 +123,3 @@ macro(get_git_revision commit)
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
endmacro()


macro(get_current_architecture arch)
execute_process(
COMMAND dpkg --print-architecture
OUTPUT_VARIABLE arch_raw
)

remove_line_terminators(${arch_raw} ${arch})
endmacro()
24 changes: 15 additions & 9 deletions cmake/release.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
INCLUDE(InstallRequiredSystemLibraries)

SET(CPACK_GENERATOR TGZ)
if(PACKAGE_TGZ)
list(APPEND CPACK_GENERATOR TGZ)
endif()
if(PACKAGE_ZIP)
list(APPEND CPACK_GENERATOR ZIP)
endif()

set(CPACK_PACKAGE_NAME "iroha")
set(CPACK_PACKAGE_VENDOR "Soramitsu LLC")
Expand Down Expand Up @@ -28,22 +33,23 @@ SET(CPACK_STRIP_FILES TRUE)

set(CPACK_COMPONENTS_ALL binaries libraries)

if(WIN32)
# cmake is running on windows
elseif (APPLE)
if (APPLE)
message(WARNING "On OSX only TGZ/ZIP packaging is supported")
# cmake is running on mac os
include(cmake/release/osx-bundle.cmake)
# include(cmake/release/osx-bundle.cmake)
elseif(UNIX)
# cmake is running on unix

if(NOT NO_DEB)
include(cmake/release/linux-deb.cmake)
if(PACKAGE_DEB)
include(cmake/release/linux/deb/iroha.cmake)
endif()

if(NOT NO_RPM)
include(cmake/release/linux-rpm.cmake)
if(PACKAGE_RPM)
include(cmake/release/linux/rpm/iroha.cmake)
endif()

else()
message(WARNING "Packaging is supported only for APPLE and UNIX operating systems.")
endif()

INCLUDE(CPack)
10 changes: 0 additions & 10 deletions cmake/release/linux-deb.cmake

This file was deleted.

27 changes: 27 additions & 0 deletions cmake/release/linux/deb/iroha.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
find_program(DPKG dpkg)
if(DPKG STREQUAL "DPKG-NOTFOUND")
message(WARNING "linux-deb can not be build without `dpkg`.")
else()

# add deb to list of generators
list(APPEND CPACK_GENERATOR DEB)

# debian specific
execute_process(
COMMAND dpkg --print-architecture
OUTPUT_VARIABLE arch_raw
)

remove_line_terminators(${arch_raw} arch)

message(STATUS "[package-${arch}] linux-deb standalone will be packaged.")

set(CPACK_DEBIAN_PACKAGE_NAME iroha )
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${arch}) # dpkg --print-architecture
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libtbb-dev")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON)
set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY ON)
# set(CPACK_DEB_COMPONENT_INSTALL ON)

endif()
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
find_program(RPMBUILD rpmbuild)
if(RPMBUILD STREQUAL "RPMBUILD-NOTFOUND")
message(WARNING "linux-rpm can not be build without `rpmbuild`. Use -DNO_RPM to disable.")
message(WARNING "linux-rpm can not be build without `rpmbuild`. ")
else()
# add deb to list of generators
list(APPEND CPACK_GENERATOR RPM)

get_current_architecture(arch)

message(STATUS "[package-${arch}] linux-rpm standalone will be packaged. Use -DNO_RPM to disable.")
message(STATUS "[package] linux-rpm standalone will be packaged.")

SET(CPACK_RPM_PACKAGE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
SET(CPACK_RPM_PACKAGE_REQUIRES "libstdc++5, libpq-dev, libtbb-dev, libboost-system-dev, libboost-filesystem-dev, libc-ares-dev")

endif()

# SET(CPACK_RPM_PACKAGE_REQUIRES "libstdc++5, libpq-dev (>= 9.5), libtbb-dev (>= 4.4), libboost-system-dev (>= 1.56.0), libboost-filesystem-dev (>= 1.56.0), libc-ares-dev (>= 1.10.0)")
File renamed without changes.
7 changes: 5 additions & 2 deletions scripts/swarm-deploy.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/bash

irohad=irohad
cli=iroha-cli

CURDIR="$(cd "$(dirname "$0")"; pwd)"
IROHA_HOME="$(dirname "${CURDIR}")"

Expand Down Expand Up @@ -69,9 +72,9 @@ do
# copy config
docker cp ${IROHA_HOME}/iroha.conf ${COMPOSE_PROJECT_NAME}_node_1:/
# generate genesis block based on list of peers
docker exec ${COMPOSE_PROJECT_NAME}_node_1 iroha-cli --genesis_block --peers_address /peers.list
docker exec ${COMPOSE_PROJECT_NAME}_node_1 $cli --genesis_block --peers_address /peers.list
# run irohad with output redirection to /iroha.log
docker exec -d ${COMPOSE_PROJECT_NAME}_node_1 bash -c "irohad --config /iroha.conf --genesis_block /genesis.block --keypair_name /node${i} > /iroha.log"
docker exec -d ${COMPOSE_PROJECT_NAME}_node_1 bash -c "$irohad --config /iroha.conf --genesis_block /genesis.block --peer_number ${i} > /iroha.log"
((i++))
done < <(docker-machine ls -f "{{.Name}}")

Expand Down

0 comments on commit be7e937

Please sign in to comment.