In this final example, we will demonstrate how packets can be marshaled using JSON to safely reduce the size of a network packet, at the expense of some additional processing. To support this example, the following C++ JSON library will be used: https://github.com/nlohmann/json.
To incorporate this JSON library into our example, the following will have to be added to our CMakeLists.txt, which downloads this header-only library and installs it into our build folder to be used:
list(APPEND JSON_CMAKE_ARGS
-DBUILD_TESTING=OFF
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}
)
ExternalProject_Add(
json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_SHALLOW 1
CMAKE_ARGS ${JSON_CMAKE_ARGS}
PREFIX ${CMAKE_BINARY_DIR}/external/json/prefix
TMP_DIR ${CMAKE_BINARY_DIR}/external/json/tmp
STAMP_DIR ${CMAKE_BINARY_DIR}/external...