From 5dc567a4a494a2152658c6586e0d7637ecba85b4 Mon Sep 17 00:00:00 2001 From: redsky17 <rubberduckie3554@gmail.com> Date: Sun, 24 Feb 2019 16:40:00 -0500 Subject: [PATCH] Update JSON build dependency I think I finally worked out the issues w/ linking against the nlohmann JSON library. I have updated the build and the various CI scripts. --- .ci/install.sh | 2 ++ .ci/script.sh | 1 + CMakeLists.txt | 3 ++- Makefile | 2 +- appveyor.yml | 1 + deps/CMakeLists.txt | 14 ++++++++------ deps/cmake/Json.cmake | 19 +++++++++++++++++++ 7 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 deps/cmake/Json.cmake diff --git a/.ci/install.sh b/.ci/install.sh index 6215d94a9..726ee78f3 100755 --- a/.ci/install.sh +++ b/.ci/install.sh @@ -6,4 +6,6 @@ if [ $TRAVIS_OS_NAME == osx ]; then brew update || true brew upgrade boost || true brew install libsodium clang-format + brew tap nlohmann/json + brew install nlohmann_json fi diff --git a/.ci/script.sh b/.ci/script.sh index a2f625126..c92cb40bd 100755 --- a/.ci/script.sh +++ b/.ci/script.sh @@ -32,6 +32,7 @@ if [ $TRAVIS_OS_NAME == osx ]; then cmake -Hdeps -B.deps -DCMAKE_BUILD_TYPE=Release \ -DUSE_BUNDLED_BOOST=OFF \ -DUSE_BUNDLED_GTEST=OFF + -DUSE_BUNDLED_JSON=OFF cmake --build .deps # Build the library. diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b5ab4b3f..71058f033 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -170,7 +170,8 @@ target_link_libraries(matrix_client OpenSSL::Crypto OpenSSL::SSL Olm::Olm - ZLIB::ZLIB) + ZLIB::ZLIB + nlohmann_json::nlohmann_json) if(NOT MSVC AND NOT APPLE) target_link_libraries(matrix_client PUBLIC Threads::Threads) diff --git a/Makefile b/Makefile index 607d04537..a901c8607 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ help: ## This help message @# Change the digit following by an 's' to adjust the width of the help text third-party: ## Build & install third party dependencies - @cmake -GNinja -H${DEPS_SOURCE_DIR} -B${DEPS_BUILD_DIR} -DCMAKE_BUILD_TYPE=Release -DUSE_BUNDLED_BOOST=OFF + @cmake -GNinja -H${DEPS_SOURCE_DIR} -B${DEPS_BUILD_DIR} -DCMAKE_BUILD_TYPE=Release -DUSE_BUNDLED_BOOST=OFF -DUSE_BUNDLED_JSON=OFF @cmake --build ${DEPS_BUILD_DIR} debug: ## Create a debug build diff --git a/appveyor.yml b/appveyor.yml index e3a75c525..8ab686f9c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -38,6 +38,7 @@ build_script: -DUSE_BUNDLED_BOOST=OFF -DUSE_BUNDLED_SPDLOG=OFF -DUSE_BUNDLED_GTEST=OFF + -DUSE_BUNDLED_JSON=OFF - cmake --build .deps --config Release - cmake -G "Visual Studio 15 2017 Win64" -H. -Bbuild diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index dffa616b0..b3bce7624 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -26,6 +26,7 @@ option(USE_BUNDLED_SPDLOG "Use the bundled version of spdlog." ${USE_BUNDLED}) option(USE_BUNDLED_OLM "Use the bundled version of libolm." ${USE_BUNDLED}) option(USE_BUNDLED_GTEST "Use the bundled version of Google Test." ${USE_BUNDLED}) +option(USE_BUNDLED_JSON "Use the bundled version of nlohmann json." ${USE_BUNDLED}) option(USE_EXISTING_SRC_DIR "Skip download of deps sources in case of existing source directory." @@ -53,13 +54,14 @@ set(SPDLOG_URL https://github.com/gabime/spdlog/archive/v1.1.0.tar.gz) set(SPDLOG_HASH 3dbcbfd8c07e25f5e0d662b194d3a7772ef214358c49ada23c044c4747ce8b19) -set(JSON_HEADER_URL - https://github.com/nlohmann/json/releases/download/v3.2.0/json.hpp) -set(JSON_HEADER_HASH - ce6b5610a051ec6795fa11c33854abebb086f0fd67c311f5921c3c07f9531b44) +set(JSON_URL + https://github.com/nlohmann/json.git) +set(JSON_TAG + v3.2.0) -file(DOWNLOAD ${JSON_HEADER_URL} ${DEPS_INSTALL_DIR}/nlohmann/include/json.hpp - EXPECTED_HASH SHA256=${JSON_HEADER_HASH}) +if(USE_BUNDLED_JSON) + include(Json) +endif() if(USE_BUNDLED_BOOST) include(Boost) diff --git a/deps/cmake/Json.cmake b/deps/cmake/Json.cmake new file mode 100644 index 000000000..3b63550e0 --- /dev/null +++ b/deps/cmake/Json.cmake @@ -0,0 +1,19 @@ +ExternalProject_Add( + Json + + GIT_REPOSITORY ${JSON_URL} + GIT_TAG ${JSON_TAG} + + BUILD_IN_SOURCE 1 + SOURCE_DIR ${DEPS_BUILD_DIR}/json + + CONFIGURE_COMMAND ${CMAKE_COMMAND} + -DJSON_BuildTests=OFF + -DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR} + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} + + BUILD_COMMAND ${CMAKE_COMMAND} --build ${DEPS_BUILD_DIR}/json + INSTALL_COMMAND make install +) + +list(APPEND THIRD_PARTY_DEPS Json) -- GitLab