Make inclusion of jsoncpp source optional (#50)

This commit is contained in:
Toni Solarin-Sodara 2021-03-16 00:53:40 +00:00 коммит произвёл GitHub
Родитель ea4ad5b0a5
Коммит f8ab4dfd2a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 19 добавлений и 3 удалений

Просмотреть файл

@ -10,6 +10,7 @@ include(CTest)
set(WERROR true CACHE BOOL "Enable warnings as errors.")
set(WALL true CACHE BOOL "Enable all warnings.")
set(INCLUDE_JSONCPP true CACHE BOOL "Include jsoncpp source")
set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries")
if(NOT WIN32)
@ -34,6 +35,14 @@ if(USE_CPPRESTSDK)
set(CPPREST_LIB "cpprestsdk::cpprest")
endif()
if(NOT INCLUDE_JSONCPP)
find_package(jsoncpp REQUIRED)
# jsoncpp has different target names depending on whether it
# was built as a shared or static library. We make this override-able
# so we can be resilient to the changes between versions.
set(JSONCPP_LIB "jsoncpp_lib" CACHE STRING "jsoncpp target name")
endif()
include_directories (include)
# TODO: We shouldn't use this, it makes the dll/lib export all symbols

Просмотреть файл

@ -21,6 +21,7 @@ Below are instructions to build on different OS's. You can also use the followin
| -DBUILD_SAMPLES | Build the included sample project | false |
| -DBUILD_TESTING | Builds the test project | true |
| -DUSE_CPPRESTSDK | Includes the CppRestSDK (default http stack) | false |
| -DINCLUDE_JSONCPP | Builds jsoncpp source code as part of the output binary | true |
| -DWERROR | Enables warnings as errors | true |
| -DWALL | Enables all warnings | true |
| -DINJECT_HEADER_AFTER_STDAFX=`<header path>` | Adds the provided header to the library compilation in stdafx.cpp, intended to allow "new" and "delete" to be replaced. | `<none>` |

Просмотреть файл

@ -22,12 +22,11 @@ set (SOURCES
websocket_transport.cpp
../../third_party_code/cpprestsdk/uri.cpp
../../third_party_code/cpprestsdk/uri_builder.cpp
../../third_party_code/jsoncpp/jsoncpp.cpp
)
include_directories(
../../third_party_code/cpprestsdk
../../third_party_code/jsoncpp)
../../third_party_code/cpprestsdk
)
add_library (signalrclient ${SOURCES})
@ -61,6 +60,13 @@ else()
target_compile_options(signalrclient PRIVATE -Wextra -Wpedantic -Wno-unknown-pragmas)
endif()
if(INCLUDE_JSONCPP)
target_sources(signalrclient PRIVATE ../../third_party_code/jsoncpp/jsoncpp.cpp)
target_include_directories(signalrclient PRIVATE ../../third_party_code/jsoncpp)
else()
target_link_libraries(signalrclient PUBLIC ${JSONCPP_LIB})
endif()
if(NOT USE_CPPRESTSDK)
target_link_libraries(signalrclient)
else()