Skip to content

Commit

Permalink
make jsonrpc++ header only
Browse files Browse the repository at this point in the history
  • Loading branch information
badaix committed Jul 1, 2018
1 parent a7d208f commit a820bd6
Show file tree
Hide file tree
Showing 8 changed files with 1,500 additions and 1,532 deletions.
73 changes: 25 additions & 48 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,65 +1,42 @@
# __ ____ __ __ _ ____ ____ ___ _ _
# _( )/ ___) / \ ( ( \( _ \( _ \ / __)( ) ( )
# / \) \\___ \( O )/ / ) / ) __/( (__(_ _)(_ _)
# \____/(____/ \__/ \_)__)(__\_)(__) \___)(_) (_)

# This file is part of jsonrpc++
# Copyright (C) 2017-2018 Johannes Pohl

# This software may be modified and distributed under the terms
# of the MIT license. See the LICENSE file for details.


cmake_minimum_required(VERSION 3.0.0)

project(jsonrpcpp VERSION 1.1.1 LANGUAGES CXX)
project(jsonrpcpp VERSION 1.2.0 LANGUAGES CXX)
set(PROJECT_DESCRIPTION "C++ JSON-RPC 2.0 library")
set(PROJECT_URL "https://github.com/badaix/jsonrpcpp")

option(BUILD_SHARED_LIBS "Build jsonrpcpp as a shared library" ON)
option(BUILD_STATIC_LIBS "Build jsonrpcpp as a static library" ON)
option(BUILD_TESTS "Build tests (run tests with make test)" ON)
option(BUILD_EXAMPLE "Build example (build jsonrpcpp_example demo)" ON)

if (NOT BUILD_SHARED_LIBS AND NOT BUILD_STATIC_LIBS)
message(FATAL_ERROR "One or both of BUILD_SHARED_LIBS or BUILD_STATIC_LIBS"
"must be set to ON to build")
endif()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_EXTENSIONS OFF)

if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
SET(CMAKE_INSTALL_LIBDIR lib CACHE PATH "Output directory for libraries")
endif()

if(NOT DEFINED CMAKE_INSTALL_INCLUDEDIR)
SET(CMAKE_INSTALL_INCLUDEDIR include CACHE
PATH "Output directory for header files")
SET(CMAKE_INSTALL_INCLUDEDIR include CACHE
PATH "Output directory for header files")
endif()

include_directories(lib)
set(JSONRPCPP_SOURCES lib/jsonrp.cpp)

if (BUILD_SHARED_LIBS)
add_library(jsonrpcpp SHARED "${JSONRPCPP_SOURCES}")
target_compile_features(jsonrpcpp PUBLIC cxx_std_11)
if(WIN32)
install(TARGETS jsonrpcpp RUNTIME DESTINATION "${CMAKE_INSTALL_LIBDIR}")
else()
install(TARGETS jsonrpcpp LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
endif()

endif (BUILD_SHARED_LIBS)
include_directories(
"include"
)

if (BUILD_STATIC_LIBS)
add_library(jsonrpcpp-static STATIC "${JSONRPCPP_SOURCES}")
set_target_properties(jsonrpcpp-static PROPERTIES OUTPUT_NAME jsonrpcpp)
target_compile_features(jsonrpcpp-static PUBLIC cxx_std_11)
install(TARGETS jsonrpcpp-static ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
endif (BUILD_STATIC_LIBS)
if (BUILD_EXAMPLE)
add_executable(jsonrpcpp_example jsonrpcpp_example.cpp)
endif (BUILD_EXAMPLE)

if (BUILD_TESTS)
if (NOT BUILD_STATIC_LIBS)
message(FATAL_ERROR "Tests can only be built against static libraries "
"(set BUILD_STATIC_LIBS=ON)")
endif (NOT BUILD_STATIC_LIBS)
add_executable(jsonrpctest jsonrpctest.cpp)
target_link_libraries(jsonrpctest jsonrpcpp-static)
target_compile_features(jsonrpctest PUBLIC cxx_std_11)
endif (BUILD_TESTS)

install(FILES lib/jsonrp.hpp lib/json.hpp
install(FILES include/jsonrpcpp.hpp include/json.hpp
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/jsonrpcpp")

configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/jsonrpcpp.pc.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/jsonrpcpp.pc"
@ONLY)

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/jsonrpcpp.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2017 Johannes Pohl
Copyright (c) 2017-2018 Johannes Pohl

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
BIN = jsonrpctest
BIN = jsonrpcpp_example

CXX = clang++
STRIP = strip
CXXFLAGS = -std=c++0x -Wall -O3 -Ilib -isystem lib/externals
CXXFLAGS = -std=c++11 -Wall -O3 -Iinclude -pedantic -Wextra -Wshadow -Wconversion

OBJ = jsonrpctest.o lib/jsonrp.o
OBJ = jsonrpcpp_example.o


all: $(OBJ)
Expand Down
File renamed without changes.
Loading

0 comments on commit a820bd6

Please sign in to comment.