|
| 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 | + |
1 | 13 | cmake_minimum_required(VERSION 3.0.0) |
2 | 14 |
|
3 | | -project(jsonrpcpp VERSION 1.1.1 LANGUAGES CXX) |
| 15 | +project(jsonrpcpp VERSION 1.2.0 LANGUAGES CXX) |
4 | 16 | set(PROJECT_DESCRIPTION "C++ JSON-RPC 2.0 library") |
5 | 17 | set(PROJECT_URL "https://github.com/badaix/jsonrpcpp") |
6 | 18 |
|
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) |
10 | 20 |
|
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) |
15 | 23 |
|
16 | | -if(NOT DEFINED CMAKE_INSTALL_LIBDIR) |
17 | | - SET(CMAKE_INSTALL_LIBDIR lib CACHE PATH "Output directory for libraries") |
18 | | -endif() |
19 | 24 |
|
20 | 25 | 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") |
23 | 28 | endif() |
24 | 29 |
|
25 | | -include_directories(lib) |
26 | | -set(JSONRPCPP_SOURCES lib/jsonrp.cpp) |
27 | 30 |
|
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 | +) |
38 | 34 |
|
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) |
45 | 38 |
|
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) |
55 | 39 |
|
56 | | -install(FILES lib/jsonrp.hpp lib/json.hpp |
| 40 | +install(FILES include/jsonrpcpp.hpp include/json.hpp |
57 | 41 | DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/jsonrpcpp") |
58 | 42 |
|
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") |
0 commit comments