Skip to content

Commit

Permalink
If we're using Conan, find json-schema-validator package rather than …
Browse files Browse the repository at this point in the history
…building from third_party source

Reorder dependencies consistently in conanfiles, NmosCppDependencies.cmake and Dependencies docs
  • Loading branch information
garethsb committed Aug 14, 2021
1 parent ccf738b commit 0b7689b
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 74 deletions.
90 changes: 54 additions & 36 deletions Development/cmake/NmosCppDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -183,45 +183,63 @@ add_library(nmos-cpp::OpenSSL ALIAS OpenSSL)

# json schema validator library

set(JSON_SCHEMA_VALIDATOR_SOURCES
third_party/nlohmann/json-patch.cpp
third_party/nlohmann/json-schema-draft7.json.cpp
third_party/nlohmann/json-validator.cpp
third_party/nlohmann/json-uri.cpp
)

set(JSON_SCHEMA_VALIDATOR_HEADERS
third_party/nlohmann/json-patch.hpp
third_party/nlohmann/json-schema.hpp
third_party/nlohmann/json.hpp
)

add_library(
json_schema_validator STATIC
${JSON_SCHEMA_VALIDATOR_SOURCES}
${JSON_SCHEMA_VALIDATOR_HEADERS}
)

source_group("Source Files" FILES ${JSON_SCHEMA_VALIDATOR_SOURCES})
source_group("Header Files" FILES ${JSON_SCHEMA_VALIDATOR_HEADERS})
if(NMOS_CPP_USE_CONAN)
set(JSON_SCHEMA_VALIDATOR_VERSION_MIN "2.1.0")
set(JSON_SCHEMA_VALIDATOR_VERSION_CUR "2.1.0")
find_package(nlohmann_json_schema_validator REQUIRED)
if(NOT nlohmann_json_schema_validator_VERSION)
message(STATUS "Found nlohmann_json_schema_validator unknown version; minimum version: " ${JSON_SCHEMA_VALIDATOR_VERSION_MIN})
elseif(nlohmann_json_schema_validator_VERSION VERSION_LESS JSON_SCHEMA_VALIDATOR_VERSION_MIN)
message(FATAL_ERROR "Found nlohmann_json_schema_validator version " ${nlohmann_json_schema_validator_VERSION} " that is lower than the minimum version: " ${JSON_SCHEMA_VALIDATOR_VERSION_MIN})
elseif(nlohmann_json_schema_validator_VERSION VERSION_GREATER JSON_SCHEMA_VALIDATOR_VERSION_CUR)
message(STATUS "Found nlohmann_json_schema_validator version " ${nlohmann_json_schema_validator_VERSION} " that is higher than the current tested version: " ${JSON_SCHEMA_VALIDATOR_VERSION_CUR})
else()
message(STATUS "Found nlohmann_json_schema_validator version " ${nlohmann_json_schema_validator_VERSION})
endif()

if(CMAKE_CXX_COMPILER_ID MATCHES GNU)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
target_compile_definitions(
json_schema_validator PRIVATE
JSON_SCHEMA_BOOST_REGEX
)
add_library(json_schema_validator INTERFACE)
target_link_libraries(json_schema_validator INTERFACE nlohmann_json_schema_validator::nlohmann_json_schema_validator)
else()
set(JSON_SCHEMA_VALIDATOR_SOURCES
third_party/nlohmann/json-patch.cpp
third_party/nlohmann/json-schema-draft7.json.cpp
third_party/nlohmann/json-validator.cpp
third_party/nlohmann/json-uri.cpp
)

set(JSON_SCHEMA_VALIDATOR_HEADERS
third_party/nlohmann/json-patch.hpp
third_party/nlohmann/json-schema.hpp
third_party/nlohmann/json.hpp
)

add_library(
json_schema_validator STATIC
${JSON_SCHEMA_VALIDATOR_SOURCES}
${JSON_SCHEMA_VALIDATOR_HEADERS}
)

source_group("Source Files" FILES ${JSON_SCHEMA_VALIDATOR_SOURCES})
source_group("Header Files" FILES ${JSON_SCHEMA_VALIDATOR_HEADERS})

if(CMAKE_CXX_COMPILER_ID MATCHES GNU)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
target_compile_definitions(
json_schema_validator PRIVATE
JSON_SCHEMA_BOOST_REGEX
)
endif()
endif()
endif()

target_link_libraries(
json_schema_validator PRIVATE
nmos-cpp::compile-settings
)
target_include_directories(json_schema_validator PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/third_party>
$<INSTALL_INTERFACE:${NMOS_CPP_INSTALL_INCLUDEDIR}/third_party>
)
target_link_libraries(
json_schema_validator PRIVATE
nmos-cpp::compile-settings
)
target_include_directories(json_schema_validator PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/third_party>
$<INSTALL_INTERFACE:${NMOS_CPP_INSTALL_INCLUDEDIR}/third_party>
)
endif()

list(APPEND NMOS_CPP_TARGETS json_schema_validator)
add_library(nmos-cpp::json_schema_validator ALIAS json_schema_validator)
Expand Down
8 changes: 4 additions & 4 deletions Development/cmake/NmosCppLibraries.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -957,15 +957,15 @@ target_link_libraries(
)
target_link_libraries(
nmos-cpp PUBLIC
nmos-cpp::mdns
nmos-cpp::slog
nmos-cpp::cpprestsdk
nmos-cpp::nmos_is04_schemas
nmos-cpp::nmos_is05_schemas
nmos-cpp::nmos_is08_schemas
nmos-cpp::nmos_is09_schemas
nmos-cpp::Boost
nmos-cpp::mdns
nmos-cpp::slog
nmos-cpp::OpenSSL
nmos-cpp::cpprestsdk
nmos-cpp::Boost
)
target_link_libraries(
nmos-cpp PRIVATE
Expand Down
3 changes: 3 additions & 0 deletions Development/cmake/nmos-cpp-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ include(CMakeFindDependencyMacro)
find_dependency(Boost COMPONENTS @FIND_BOOST_COMPONENTS@)
find_dependency(cpprestsdk)
find_dependency(OpenSSL)
if(@NMOS_CPP_USE_CONAN@)
find_dependency(nlohmann_json_schema_validator)
endif()

# generate import targets cf. install(EXPORT) call in NmosCppExports.cmake
include("${CMAKE_CURRENT_LIST_DIR}/nmos-cpp-targets.cmake")
Expand Down
3 changes: 2 additions & 1 deletion Development/conanfile.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[requires]
boost/1.76.0
openssl/1.1.1k
cpprestsdk/2.10.18
websocketpp/0.8.2
openssl/1.1.1k
json-schema-validator/2.1.0

[imports]
bin, *.dll -> ./bin
Expand Down
70 changes: 38 additions & 32 deletions Documents/Dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,38 +115,6 @@ sudo ./b2 \

</details>

### WebSocket++

If using Conan, this section can be skipped.
<details>
<summary>If not using Conan...</summary>

WebSocket++ v0.8.2 (latest release at the time) is included as a submodule within the C++ REST SDK source tree, so a separate installation is not necessary.
Note: WebSocket++ v0.5.1 and v0.7.0 have also been tested.

(The [Getting Started](Getting-Started.md) instructions explain how to set ``WEBSOCKETPP_INCLUDE_DIR`` in order to use the included version when building nmos-cpp.)

</details>

### OpenSSL

If using Conan, this section can be skipped.
<details>
<summary>If not using Conan...</summary>

The C++ REST SDK depends on [OpenSSL](https://www.openssl.org/) (to implement secure HTTP and/or secure WebSockets).
It is compatible with the OpenSSL 1.1 API, so the 1.1.1 Long Term Support (LTS) release is recommended.
It is also possible to use OpenSSL 1.0, but the OpenSSL team announced that [users of that release are strongly advised to upgrade to OpenSSL 1.1.1](https://www.openssl.org/blog/blog/2018/09/11/release111/).

1. Download and install a recent release
Notes:
- On Windows, an installer can be downloaded from [Shining Light Productions - Win32 OpenSSL](https://slproweb.com/products/Win32OpenSSL.html)
The Win64 OpenSSL v1.1.1k installer (latest release at the time) has been tested
- On Linux distributions, an OpenSSL package may already be available
The Ubuntu team announced an [OpenSSL 1.1.1 stable release update (SRU) for Ubuntu 18.04 LTS](https://lists.ubuntu.com/archives/ubuntu-devel/2018-December/040567.html)

</details>

### C++ REST SDK

If using Conan, this section can be skipped.
Expand Down Expand Up @@ -235,11 +203,49 @@ sudo make install

</details>

### WebSocket++

If using Conan, this section can be skipped.
<details>
<summary>If not using Conan...</summary>

WebSocket++ v0.8.2 (latest release at the time) is included as a submodule within the C++ REST SDK source tree, so a separate installation is not necessary.
Note: WebSocket++ v0.5.1 and v0.7.0 have also been tested.

(The [Getting Started](Getting-Started.md) instructions explain how to set ``WEBSOCKETPP_INCLUDE_DIR`` in order to use the included version when building nmos-cpp.)

</details>

### OpenSSL

If using Conan, this section can be skipped.
<details>
<summary>If not using Conan...</summary>

The C++ REST SDK depends on [OpenSSL](https://www.openssl.org/) (to implement secure HTTP and/or secure WebSockets).
It is compatible with the OpenSSL 1.1 API, so the 1.1.1 Long Term Support (LTS) release is recommended.
It is also possible to use OpenSSL 1.0, but the OpenSSL team announced that [users of that release are strongly advised to upgrade to OpenSSL 1.1.1](https://www.openssl.org/blog/blog/2018/09/11/release111/).

1. Download and install a recent release
Notes:
- On Windows, an installer can be downloaded from [Shining Light Productions - Win32 OpenSSL](https://slproweb.com/products/Win32OpenSSL.html)
The Win64 OpenSSL v1.1.1k installer (latest release at the time) has been tested
- On Linux distributions, an OpenSSL package may already be available
The Ubuntu team announced an [OpenSSL 1.1.1 stable release update (SRU) for Ubuntu 18.04 LTS](https://lists.ubuntu.com/archives/ubuntu-devel/2018-December/040567.html)

</details>

### Modern C++ JSON schema validator

If using Conan, this section can be skipped.
<details>
<summary>If not using Conan...</summary>

A copy of the source code necessary to use this library is included in the [third_party/nlohmann](../Development/third_party/nlohmann) directory.
No installation is necessary.

</details>

### DNS Service Discovery

**Windows**
Expand Down
3 changes: 2 additions & 1 deletion Sandbox/conan-recipe/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ def config_options(self):
def requirements(self):
# for now, consistent with project's conanfile.txt
self.requires("boost/1.76.0")
self.requires("openssl/1.1.1k")
self.requires("cpprestsdk/2.10.18")
self.requires("websocketpp/0.8.2")
self.requires("openssl/1.1.1k")
self.requires("json-schema-validator/2.1.0")

def source(self):
tools.get(**self.conan_data["sources"][self.version],
Expand Down

0 comments on commit 0b7689b

Please sign in to comment.