Browse Source

Build json-rpc-cpp from sources

cl-refactor
Paweł Bylica 8 years ago
parent
commit
e71aa579ae
No known key found for this signature in database GPG Key ID: 7A0C037434FE77EF
  1. 2
      CMakeLists.txt
  2. 8
      cmake/EthDependencies.cmake
  3. 50
      cmake/FindJsoncpp.cmake
  4. 123
      cmake/Findjson_rpc_cpp.cmake
  5. 44
      cmake/scripts/jsonrpcstub.cmake
  6. 15
      ethminer/CMakeLists.txt

2
CMakeLists.txt

@ -144,6 +144,8 @@ find_package(Boost CONFIG REQUIRED COMPONENTS system)
hunter_add_package(jsoncpp)
find_package(jsoncpp CONFIG REQUIRED)
include(ProjectJsonRpcCpp)
include(EthDependencies)
configureProject()

8
cmake/EthDependencies.cmake

@ -22,16 +22,8 @@ set(ETH_SCRIPTS_DIR ${CMAKE_CURRENT_LIST_DIR}/scripts)
find_program(CTEST_COMMAND ctest)
message(STATUS "ctest path: ${CTEST_COMMAND}")
find_package (json_rpc_cpp 0.4 REQUIRED)
message (" - json-rpc-cpp header: ${JSON_RPC_CPP_INCLUDE_DIRS}")
message (" - json-rpc-cpp lib : ${JSON_RPC_CPP_LIBRARIES}")
find_package (CUDA)
if (CUDA_FOUND)
message(" - CUDA header: ${CUDA_INCLUDE_DIRS}")
message(" - CUDA lib : ${CUDA_LIBRARIES}")
endif()
# find location of jsonrpcstub
find_program(ETH_JSON_RPC_STUB jsonrpcstub)
message(" - jsonrpcstub location : ${ETH_JSON_RPC_STUB}")

50
cmake/FindJsoncpp.cmake

@ -1,50 +0,0 @@
# Find jsoncpp
#
# Find the jsoncpp includes and library
#
# if you nee to add a custom library search path, do it via via CMAKE_PREFIX_PATH
#
# This module defines
# JSONCPP_INCLUDE_DIRS, where to find header, etc.
# JSONCPP_LIBRARIES, the libraries needed to use jsoncpp.
# JSONCPP_FOUND, If false, do not try to use jsoncpp.
# only look in default directories
find_path(
JSONCPP_INCLUDE_DIR
NAMES json/json.h
PATH_SUFFIXES jsoncpp
DOC "jsoncpp include dir"
)
find_library(
JSONCPP_LIBRARY
NAMES jsoncpp
DOC "jsoncpp library"
)
set(JSONCPP_INCLUDE_DIRS ${JSONCPP_INCLUDE_DIR})
set(JSONCPP_LIBRARIES ${JSONCPP_LIBRARY})
# debug library on windows
# same naming convention as in qt (appending debug library with d)
# boost is using the same "hack" as us with "optimized" and "debug"
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
find_library(
JSONCPP_LIBRARY_DEBUG
NAMES jsoncppd
DOC "jsoncpp debug library"
)
set(JSONCPP_LIBRARIES optimized ${JSONCPP_LIBRARIES} debug ${JSONCPP_LIBRARY_DEBUG})
endif()
# handle the QUIETLY and REQUIRED arguments and set JSONCPP_FOUND to TRUE
# if all listed variables are TRUE, hide their existence from configuration view
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(jsoncpp DEFAULT_MSG
JSONCPP_INCLUDE_DIR JSONCPP_LIBRARY)
mark_as_advanced (JSONCPP_INCLUDE_DIR JSONCPP_LIBRARY)

123
cmake/Findjson_rpc_cpp.cmake

@ -1,123 +0,0 @@
# Find json-rcp-cpp
#
# Find the json-rpc-cpp includes and library
#
# if you nee to add a custom library search path, do it via via CMAKE_PREFIX_PATH
#
# This module defines
# JSON_RCP_CPP_INCLUDE_DIRS, where to find header, etc.
# JSON_RCP_CPP_LIBRARIES, the libraries needed to use json-rpc-cpp.
# JSON_RPC_CPP_SERVER_LIBRARIES, the libraries needed to use json-rpc-cpp-server
# JSON_RPC_CPP_CLIENT_LIBRARIES, the libraries needed to use json-rpc-cpp-client
# JSON_RCP_CPP_FOUND, If false, do not try to use json-rpc-cpp.
# JSON_RPC_CPP_VERSION, version of library
# JSON_RPC_CPP_VERSION_MAJOR
# JSON_RPC_CPP_VERSION_MINOR
# JSON_RPC_CPP_VERSION_PATCH
# only look in default directories
find_path(
JSON_RPC_CPP_INCLUDE_DIR
NAMES jsonrpccpp/server.h jsonrpc/server.h
PATH_SUFFIXES jsonrpc
DOC "json-rpc-cpp include dir"
)
find_library(
JSON_RPC_CPP_COMMON_LIBRARY
NAMES jsonrpccpp-common
DOC "json-rpc-cpp common library"
)
find_library(
JSON_RPC_CPP_SERVER_LIBRARY
NAMES jsonrpccpp-server
DOC "json-rpc-cpp server library"
)
find_library(
JSON_RPC_CPP_CLIENT_LIBRARY
NAMES jsonrpccpp-client
DOC "json-rpc-cpp client library"
)
# these are the variables to be uses by the calling script
set (JSON_RPC_CPP_INCLUDE_DIRS ${JSON_RPC_CPP_INCLUDE_DIR})
set (JSON_RPC_CPP_LIBRARIES ${JSON_RPC_CPP_COMMON_LIBRARY} ${JSON_RPC_CPP_SERVER_LIBRARY} ${JSON_RPC_CPP_CLIENT_LIBRARY})
set (JSON_RPC_CPP_SERVER_LIBRARIES ${JSON_RPC_CPP_COMMON_LIBRARY} ${JSON_RPC_CPP_SERVER_LIBRARY})
set (JSON_RPC_CPP_CLIENT_LIBRARIES ${JSON_RPC_CPP_COMMON_LIBRARY} ${JSON_RPC_CPP_CLIENT_LIBRARY})
# debug library on windows
# same naming convention as in qt (appending debug library with d)
# boost is using the same "hack" as us with "optimized" and "debug"
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
find_library(
JSON_RPC_CPP_COMMON_LIBRARY_DEBUG
NAMES jsonrpccpp-commond
DOC "json-rpc-cpp common debug library"
)
find_library(
JSON_RPC_CPP_SERVER_LIBRARY_DEBUG
NAMES jsonrpccpp-serverd
DOC "json-rpc-cpp server debug library"
)
find_library(
JSON_RPC_CPP_CLIENT_LIBRARY_DEBUG
NAMES jsonrpccpp-clientd
DOC "json-rpc-cpp client debug library"
)
set (JSON_RPC_CPP_LIBRARIES
optimized ${JSON_RPC_CPP_COMMON_LIBRARY}
optimized ${JSON_RPC_CPP_SERVER_LIBRARY}
optimized ${JSON_RPC_CPP_CLIENT_LIBRARY}
debug ${JSON_RPC_CPP_COMMON_LIBRARY_DEBUG}
debug ${JSON_RPC_CPP_SERVER_LIBRARY_DEBUG}
debug ${JSON_RPC_CPP_CLIENT_LIBRARY_DEBUG}
)
set (JSON_RPC_CPP_SERVER_LIBRARIES
optimized ${JSON_RPC_CPP_COMMON_LIBRARY}
optimized ${JSON_RPC_CPP_SERVER_LIBRARY}
debug ${JSON_RPC_CPP_COMMON_LIBRARY_DEBUG}
debug ${JSON_RPC_CPP_SERVER_LIBRARY_DEBUG}
)
set (JSON_RPC_CPP_CLIENT_LIBRARIES
optimized ${JSON_RPC_CPP_COMMON_LIBRARY}
optimized ${JSON_RPC_CPP_CLIENT_LIBRARY}
debug ${JSON_RPC_CPP_COMMON_LIBRARY_DEBUG}
debug ${JSON_RPC_CPP_CLIENT_LIBRARY_DEBUG}
)
endif()
if (JSON_RPC_CPP_INCLUDE_DIR)
set (JSON_RPC_CPP_VERSION_HEADER "${JSON_RPC_CPP_INCLUDE_DIR}/jsonrpccpp/version.h")
if (EXISTS ${JSON_RPC_CPP_VERSION_HEADER})
file (STRINGS ${JSON_RPC_CPP_VERSION_HEADER} JSON_RPC_CPP_VERSION_MAJOR REGEX "^#define JSONRPC_CPP_MAJOR_VERSION[ \t]+[0-9]+$")
file (STRINGS ${JSON_RPC_CPP_VERSION_HEADER} JSON_RPC_CPP_VERSION_MINOR REGEX "^#define JSONRPC_CPP_MINOR_VERSION[ \t]+[0-9]+$")
file (STRINGS ${JSON_RPC_CPP_VERSION_HEADER} JSON_RPC_CPP_VERSION_PATCH REGEX "^#define JSONRPC_CPP_PATCH_VERSION[ \t]+[0-9]+$")
string (REGEX REPLACE "^#define JSONRPC_CPP_MAJOR_VERSION[ \t]+([0-9]+)" "\\1" JSON_RPC_CPP_VERSION_MAJOR ${JSON_RPC_CPP_VERSION_MAJOR})
string (REGEX REPLACE "^#define JSONRPC_CPP_MINOR_VERSION[ \t]+([0-9]+)" "\\1" JSON_RPC_CPP_VERSION_MINOR ${JSON_RPC_CPP_VERSION_MINOR})
string (REGEX REPLACE "^#define JSONRPC_CPP_PATCH_VERSION[ \t]+([0-9]+)" "\\1" JSON_RPC_CPP_VERSION_PATCH ${JSON_RPC_CPP_VERSION_PATCH})
set (JSON_RPC_CPP_VERSION ${JSON_RPC_CPP_VERSION_MAJOR}.${JSON_RPC_CPP_VERSION_MINOR}.${JSON_RPC_CPP_VERSION_PATCH})
endif()
endif()
# handle the QUIETLY and REQUIRED arguments and set JSON_RPC_CPP_FOUND to TRUE
# if all listed variables are TRUE, hide their existence from configuration view
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
json_rpc_cpp
REQUIRED_VARS JSON_RPC_CPP_INCLUDE_DIR JSON_RPC_CPP_COMMON_LIBRARY JSON_RPC_CPP_SERVER_LIBRARY JSON_RPC_CPP_CLIENT_LIBRARY
VERSION_VAR JSON_RPC_CPP_VERSION
)
mark_as_advanced (JSON_RPC_CPP_INCLUDE_DIR JSON_RPC_CPP_COMMON_LIBRARY JSON_RPC_CPP_SERVER_LIBRARY JSON_RPC_CPP_CLIENT_LIBRARY)

44
cmake/scripts/jsonrpcstub.cmake

@ -1,44 +0,0 @@
# generates JSONRPC Stub Server && Client
#
# this script expects
# ETH_SOURCE_DIR - main CMAKE_SOURCE_DIR
# ETH_SPEC_PATH
# ETH_SERVER_DIR
# ETH_CLIENT_DIR
# ETH_SERVER_NAME
# ETH_CLIENT_NAME
# ETH_JSON_RPC_STUB
#
# example usage:
# cmake -DETH_SPEC_PATH=spec.json -DETH_SERVER_DIR=libweb3jsonrpc -DETH_CLIENT_DIR=test
# -DETH_SERVER_NAME=AbstractWebThreeStubServer -DETH_CLIENT_NAME=WebThreeStubClient -DETH_JSON_RPC_STUB=/usr/local/bin/jsonrpcstub
# by default jsonrpcstub produces files in lowercase, we want to stick to this
string(TOLOWER ${ETH_SERVER_NAME} ETH_SERVER_NAME_LOWER)
string(TOLOWER ${ETH_CLIENT_NAME} ETH_CLIENT_NAME_LOWER)
# setup names
set(SERVER_TMPFILE "${ETH_SERVER_DIR}/${ETH_SERVER_NAME_LOWER}.h.tmp")
set(SERVER_OUTFILE "${ETH_SERVER_DIR}/${ETH_SERVER_NAME_LOWER}.h")
set(CLIENT_TMPFILE "${ETH_CLIENT_DIR}/${ETH_CLIENT_NAME_LOWER}.h.tmp")
set(CLIENT_OUTFILE "${ETH_CLIENT_DIR}/${ETH_CLIENT_NAME_LOWER}.h")
# create tmp files
execute_process(
COMMAND ${ETH_JSON_RPC_STUB} ${ETH_SPEC_PATH}
--cpp-server=${ETH_SERVER_NAME} --cpp-server-file=${SERVER_TMPFILE}
--cpp-client=${ETH_CLIENT_NAME} --cpp-client-file=${CLIENT_TMPFILE}
OUTPUT_VARIABLE ERR ERROR_QUIET
)
# don't throw fatal error on jsonrpcstub error, someone might have old version of jsonrpcstub,
# he does not need to upgrade it if he is not working on JSON RPC
# show him warning instead
if (ERR)
message(WARNING "Your version of jsonrcpstub tool is not supported. Please upgrade it.")
message(WARNING "${ERR}")
else()
include("${ETH_SOURCE_DIR}/cmake/EthUtils.cmake")
replace_if_different("${SERVER_TMPFILE}" "${SERVER_OUTFILE}")
replace_if_different("${CLIENT_TMPFILE}" "${CLIENT_OUTFILE}")
endif()

15
ethminer/CMakeLists.txt

@ -4,11 +4,6 @@ aux_source_directory(. SRC_LIST)
include_directories(BEFORE ..)
if (JSONRPC)
include_directories(BEFORE ${JSONCPP_INCLUDE_DIRS})
include_directories(${JSON_RPC_CPP_INCLUDE_DIRS})
endif()
if (ETHASHCUDA)
include_directories(${CUDA_INCLUDE_DIRS})
endif ()
@ -21,17 +16,9 @@ add_executable(${EXECUTABLE} ${SRC_LIST} ${HEADERS})
add_dependencies(${EXECUTABLE} BuildInfo.h)
if (JSONRPC)
target_link_libraries(${EXECUTABLE} ${JSON_RPC_CPP_CLIENT_LIBRARIES})
target_link_libraries(${EXECUTABLE} ${CURL_LIBRARIES})
if (DEFINED WIN32 AND NOT DEFINED CMAKE_COMPILER_IS_MINGW)
eth_copy_dlls(${EXECUTABLE} CURL_DLLS)
endif()
endif()
target_link_libraries(${EXECUTABLE} ethcore)
target_link_libraries(${EXECUTABLE} ethash)
target_link_libraries(${EXECUTABLE} devcore)
target_link_libraries(${EXECUTABLE} devcore JsonRpcCpp::Client)
if (ETHSTRATUM)
target_link_libraries(${EXECUTABLE} ethstratum)

Loading…
Cancel
Save