Skip to content

Commit

Permalink
Merge branch 'cmakeproto3' of github.com:zilliqa/zilliqa into cmake3c…
Browse files Browse the repository at this point in the history
…ontractmap
  • Loading branch information
kaikawaliu committed Aug 30, 2019
2 parents 3e10ed9 + 9341285 commit b39f0a4
Show file tree
Hide file tree
Showing 15 changed files with 662 additions and 512 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Expand Up @@ -4,3 +4,7 @@
[submodule "src/depends/openssl"]
path = src/depends/openssl
url = https://github.com/openssl/openssl.git
[submodule "src/depends/protobuf"]
path = src/depends/protobuf
url = https://github.com/google/protobuf.git
branch = 3.9.x
6 changes: 4 additions & 2 deletions CMakeLists.txt
Expand Up @@ -183,8 +183,10 @@ if(SJ_TEST_SJ_TXNBLKS_PROCESS_SLOW)
endif()

include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
set(protobuf_MODULE_COMPATIBLE TRUE)
find_package(Protobuf CONFIG REQUIRED)
include_directories(${PROTOBUF_INSTALL_DIR}/include)
set(PROTOBUF_LIBRARY ${PROTOBUF_INSTALL_DIR}/lib)

include_directories(${CMAKE_SOURCE_DIR}/src/depends/libethash/include/)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -80,7 +80,7 @@ To run Zilliqa, we recommend the minimum system requirements specified in our [M
sudo apt-get install git libboost-system-dev libboost-filesystem-dev libboost-test-dev \
libssl-dev libleveldb-dev libjsoncpp-dev libsnappy-dev cmake libmicrohttpd-dev \
libjsonrpccpp-dev build-essential pkg-config libevent-dev libminiupnpc-dev \
libprotobuf-dev protobuf-compiler libcurl4-openssl-dev libboost-program-options-dev gawk
libcurl4-openssl-dev libboost-program-options-dev gawk
```

## Build from Source Code
Expand Down
74 changes: 74 additions & 0 deletions cmake/FindProtobuf.cmake
@@ -0,0 +1,74 @@
set(PROTOBUF_SOURCE_DIR ${CMAKE_SOURCE_DIR}/src/depends/protobuf/cmake)
set(PROTOBUF_BINARY_DIR ${CMAKE_BINARY_DIR}/src/depends/protobuf)
set(PROTOBUF_INSTALL_DIR ${CMAKE_BINARY_DIR}/protobuf)
set(PROTOBUF_INSTALL_LOG ${CMAKE_BINARY_DIR}/install_protobuf.log)

file(MAKE_DIRECTORY ${PROTOBUF_INSTALL_DIR})
file(MAKE_DIRECTORY ${PROTOBUF_BINARY_DIR})

message(STATUS "Building and installing protobuf")

# download, check and untar
execute_process(
COMMAND git submodule update --init src/depends/protobuf
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE PROTOBUF_INSTALL_RET
OUTPUT_FILE ${PROTOBUF_INSTALL_LOG}
ERROR_FILE ${PROTOBUF_INSTALL_LOG}
)

if(NOT "${PROTOBUF_INSTALL_RET}" STREQUAL "0")
message(FATAL_ERROR "Error when building and installing protobuf (1), see more in log ${PROTOBUF_INSTALL_LOG}")
endif()

set(protobuf_BUILD_TESTS OFF CACHE BOOL "Build protobuf tests")
set(protobuf_WITH_ZLIB OFF CACHE BOOL "Build protobuf with zlib.")
set(protobuf_MODULE_COMPATIBLE ON CACHE BOOL "")

# generate build directory
execute_process(
COMMAND ${CMAKE_COMMAND}
-H${PROTOBUF_SOURCE_DIR}
-B${PROTOBUF_BINARY_DIR}
-Dprotobuf_BUILD_TESTS:BOOL=OFF
-Dprotobuf_WITH_ZLIB:BOOL=OFF
-Dprotobuf_MSVC_STATIC_RUNTIME:BOOL=OFF
-Dprotobuf_MODULE_COMPATIBLE:BOOL=ON
-DCMAKE_INSTALL_PREFIX=${PROTOBUF_INSTALL_DIR}
-DCMAKE_BUILD_TYPE:STRING=Release
-Wno-dev
RESULT_VARIABLE PROTOBUF_INSTALL_RET
OUTPUT_FILE ${PROTOBUF_INSTALL_LOG}
ERROR_FILE ${PROTOBUF_INSTALL_LOG}
)

if(NOT "${PROTOBUF_INSTALL_RET}" STREQUAL "0")
message(FATAL_ERROR "Error when building and installing protobuf (2), see more in log ${PROTOBUF_INSTALL_LOG}")
endif()

# build and install proto
execute_process(
COMMAND ${CMAKE_COMMAND} --build ${PROTOBUF_BINARY_DIR} -- -j${N}
RESULT_VARIABLE PROTOBUF_INSTALL_RET
OUTPUT_FILE ${PROTOBUF_INSTALL_LOG}
ERROR_FILE ${PROTOBUF_INSTALL_LOG}
)

if(NOT "${PROTOBUF_INSTALL_RET}" STREQUAL "0")
message(FATAL_ERROR "Error when building and installing protobuf (3), see more in log ${PROTOBUF_INSTALL_LOG}")
endif()

execute_process(
COMMAND ${CMAKE_COMMAND} --build ${PROTOBUF_BINARY_DIR} --target install
RESULT_VARIABLE PROTOBUF_INSTALL_RET
OUTPUT_FILE ${PROTOBUF_INSTALL_LOG}
ERROR_FILE ${PROTOBUF_INSTALL_LOG}
)

if(NOT "${PROTOBUF_INSTALL_RET}" STREQUAL "0")
message(FATAL_ERROR "Error when building and installing protobuf (4), see more in log ${PROTOBUF_INSTALL_LOG}")
endif()

list(APPEND CMAKE_PREFIX_PATH ${PROTOBUF_INSTALL_DIR})
list(APPEND CMAKE_MODULE_PATH "${PROTOBUF_INSTALL_DIR}/lib/cmake/protobuf")
link_directories(${PROTOBUF_INSTALL_DIR}/lib)
2 changes: 0 additions & 2 deletions docker/Dockerfile
Expand Up @@ -39,13 +39,11 @@ RUN apt-get update \
libleveldb-dev \
libmicrohttpd-dev \
libminiupnpc-dev \
libprotobuf-dev \
libsnappy-dev \
libssl-dev \
libtool \
ocl-icd-opencl-dev \
pkg-config \
protobuf-compiler \
python \
python-pip \
libsecp256k1-dev \
Expand Down
85 changes: 0 additions & 85 deletions scripts/download_proto3.sh

This file was deleted.

2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Expand Up @@ -13,7 +13,7 @@ add_subdirectory (libNetwork)
add_subdirectory (libNode)
add_subdirectory (libPersistence)
add_subdirectory (libPOW)
add_subdirectory (libProtoServer)
#add_subdirectory (libProtoServer)
add_subdirectory (libRumorSpreading)
add_subdirectory (libServer)
add_subdirectory (libUtils)
Expand Down
1 change: 1 addition & 0 deletions src/depends/protobuf
Submodule protobuf added at 655310
22 changes: 16 additions & 6 deletions src/libMessage/CMakeLists.txt
@@ -1,13 +1,23 @@
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER ZilliqaMessage.proto)

add_library (Message ${PROTO_HEADER} ${PROTO_SRC} Messenger.cpp MessengerAccountStoreBase.cpp MessengerAccountStoreTrie.cpp)
target_compile_options(Message PRIVATE "-Wno-unused-variable")
target_compile_options(Message PRIVATE "-Wno-unused-parameter")
#target_compile_options(Message PRIVATE "-Wno-unused-variable")
#target_compile_options(Message PRIVATE "-Wno-unused-parameter")
get_target_property(MESSAGE_COMPILE_FLAGS Message COMPILE_OPTIONS )
message(STATUS "Message compile flags old = ${MESSAGE_COMPILE_FLAGS}")
list(REMOVE_ITEM MESSAGE_COMPILE_FLAGS -Wextra -Werror)
message(STATUS "Message compile flags new = ${MESSAGE_COMPILE_FLAGS}")
set_target_properties(Message PROPERTIES COMPILE_OPTIONS "${MESSAGE_COMPILE_FLAGS}")
target_include_directories (Message PUBLIC ${PROJECT_SOURCE_DIR}/src ${CMAKE_BINARY_DIR}/src)
target_link_libraries (Message PUBLIC ${PROTOBUF_LIBRARY} AccountData Block BlockHeader MiningData Utils)
target_link_libraries (Message PUBLIC protobuf AccountData Block BlockHeader MiningData Utils)

add_library (MessageSWInfo ${PROTO_HEADER} ${PROTO_SRC} MessengerSWInfo.cpp)
target_compile_options(MessageSWInfo PRIVATE "-Wno-unused-variable")
target_compile_options(MessageSWInfo PRIVATE "-Wno-unused-parameter")
#target_compile_options(MessageSWInfo PRIVATE "-Wno-unused-variable")
#target_compile_options(MessageSWInfo PRIVATE "-Wno-unused-parameter")
get_target_property(MESSAGESWINFO_COMPILE_FLAGS MessageSWInfo COMPILE_OPTIONS )
message(STATUS "MessageSWInfo compile flags old = ${MESSAGESWINFO_COMPILE_FLAGS}")
list(REMOVE_ITEM MESSAGESWINFO_COMPILE_FLAGS -Wextra -Werror)
message(STATUS "MessageSWInfo compile flags new = ${MESSAGESWINFO_COMPILE_FLAGS}")
set_target_properties(MessageSWInfo PROPERTIES COMPILE_OPTIONS "${MESSAGESWINFO_COMPILE_FLAGS}")
target_include_directories (MessageSWInfo PUBLIC ${PROJECT_SOURCE_DIR}/src ${CMAKE_BINARY_DIR}/src)
target_link_libraries (MessageSWInfo PUBLIC ${PROTOBUF_LIBRARY} Utils)
target_link_libraries (MessageSWInfo PUBLIC protobuf Utils)

0 comments on commit b39f0a4

Please sign in to comment.