Skip to content

Commit a820bd6

Browse files
committed
make jsonrpc++ header only
1 parent a7d208f commit a820bd6

File tree

8 files changed

+1500
-1532
lines changed

8 files changed

+1500
-1532
lines changed

CMakeLists.txt

Lines changed: 25 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,42 @@
1+
# __ ____ __ __ _ ____ ____ ___ _ _
2+
# _( )/ ___) / \ ( ( \( _ \( _ \ / __)( ) ( )
3+
# / \) \\___ \( O )/ / ) / ) __/( (__(_ _)(_ _)
4+
# \____/(____/ \__/ \_)__)(__\_)(__) \___)(_) (_)
5+
6+
# This file is part of jsonrpc++
7+
# Copyright (C) 2017-2018 Johannes Pohl
8+
9+
# This software may be modified and distributed under the terms
10+
# of the MIT license. See the LICENSE file for details.
11+
12+
113
cmake_minimum_required(VERSION 3.0.0)
214

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

7-
option(BUILD_SHARED_LIBS "Build jsonrpcpp as a shared library" ON)
8-
option(BUILD_STATIC_LIBS "Build jsonrpcpp as a static library" ON)
9-
option(BUILD_TESTS "Build tests (run tests with make test)" ON)
19+
option(BUILD_EXAMPLE "Build example (build jsonrpcpp_example demo)" ON)
1020

11-
if (NOT BUILD_SHARED_LIBS AND NOT BUILD_STATIC_LIBS)
12-
message(FATAL_ERROR "One or both of BUILD_SHARED_LIBS or BUILD_STATIC_LIBS"
13-
"must be set to ON to build")
14-
endif()
21+
set(CMAKE_CXX_STANDARD 11)
22+
set(CMAKE_CXX_EXTENSIONS OFF)
1523

16-
if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
17-
SET(CMAKE_INSTALL_LIBDIR lib CACHE PATH "Output directory for libraries")
18-
endif()
1924

2025
if(NOT DEFINED CMAKE_INSTALL_INCLUDEDIR)
21-
SET(CMAKE_INSTALL_INCLUDEDIR include CACHE
22-
PATH "Output directory for header files")
26+
SET(CMAKE_INSTALL_INCLUDEDIR include CACHE
27+
PATH "Output directory for header files")
2328
endif()
2429

25-
include_directories(lib)
26-
set(JSONRPCPP_SOURCES lib/jsonrp.cpp)
2730

28-
if (BUILD_SHARED_LIBS)
29-
add_library(jsonrpcpp SHARED "${JSONRPCPP_SOURCES}")
30-
target_compile_features(jsonrpcpp PUBLIC cxx_std_11)
31-
if(WIN32)
32-
install(TARGETS jsonrpcpp RUNTIME DESTINATION "${CMAKE_INSTALL_LIBDIR}")
33-
else()
34-
install(TARGETS jsonrpcpp LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
35-
endif()
36-
37-
endif (BUILD_SHARED_LIBS)
31+
include_directories(
32+
"include"
33+
)
3834

39-
if (BUILD_STATIC_LIBS)
40-
add_library(jsonrpcpp-static STATIC "${JSONRPCPP_SOURCES}")
41-
set_target_properties(jsonrpcpp-static PROPERTIES OUTPUT_NAME jsonrpcpp)
42-
target_compile_features(jsonrpcpp-static PUBLIC cxx_std_11)
43-
install(TARGETS jsonrpcpp-static ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
44-
endif (BUILD_STATIC_LIBS)
35+
if (BUILD_EXAMPLE)
36+
add_executable(jsonrpcpp_example jsonrpcpp_example.cpp)
37+
endif (BUILD_EXAMPLE)
4538

46-
if (BUILD_TESTS)
47-
if (NOT BUILD_STATIC_LIBS)
48-
message(FATAL_ERROR "Tests can only be built against static libraries "
49-
"(set BUILD_STATIC_LIBS=ON)")
50-
endif (NOT BUILD_STATIC_LIBS)
51-
add_executable(jsonrpctest jsonrpctest.cpp)
52-
target_link_libraries(jsonrpctest jsonrpcpp-static)
53-
target_compile_features(jsonrpctest PUBLIC cxx_std_11)
54-
endif (BUILD_TESTS)
5539

56-
install(FILES lib/jsonrp.hpp lib/json.hpp
40+
install(FILES include/jsonrpcpp.hpp include/json.hpp
5741
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/jsonrpcpp")
5842

59-
configure_file(
60-
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/jsonrpcpp.pc.cmake"
61-
"${CMAKE_CURRENT_BINARY_DIR}/jsonrpcpp.pc"
62-
@ONLY)
63-
64-
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/jsonrpcpp.pc"
65-
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2017 Johannes Pohl
3+
Copyright (c) 2017-2018 Johannes Pohl
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
BIN = jsonrpctest
1+
BIN = jsonrpcpp_example
22

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

7-
OBJ = jsonrpctest.o lib/jsonrp.o
7+
OBJ = jsonrpcpp_example.o
88

99

1010
all: $(OBJ)
File renamed without changes.

0 commit comments

Comments
 (0)