diff Resources/CMake/NlohmannJson.cmake @ 0:520cba9a0d42

initial commit
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 13 Jun 2019 14:57:22 +0200
parents
children b388b9d81a1b
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Resources/CMake/NlohmannJson.cmake	Thu Jun 13 14:57:22 2019 +0200
@@ -0,0 +1,32 @@
+# curl -L https://raw.githubusercontent.com/nlohmann/json/v3.4.0/single_include/nlohmann/json.hpp | gzip -9 > nlohmann-json-3.4.0.gz
+set(NLOHMANN_JSON_SOURCE ${CMAKE_BINARY_DIR}/nlohmann-json-3.4.0.hpp)
+set(NLOHMANN_JSON_URL "http://orthanc.osimis.io/ThirdPartyDownloads/google/nlohmann-json-3.4.0.gz")
+set(NLOHMANN_JSON_MD5 "f3346873ec78a0c90f1f05e4c2575412")
+
+if (EXISTS "${NLOHMANN_JSON_SOURCE}")
+  set(FirstRun OFF)
+else()
+  set(FirstRun ON)
+endif()
+
+DownloadCompressedFile(${NLOHMANN_JSON_MD5} ${NLOHMANN_JSON_URL} ${NLOHMANN_JSON_SOURCE})
+
+execute_process(
+  COMMAND ${PATCH_EXECUTABLE} -p0 -N -i
+  ${CMAKE_CURRENT_LIST_DIR}/../Patches/nlohmann-json-3.4.0.patch
+  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+  RESULT_VARIABLE Failure
+  )
+
+if (FirstRun AND Failure)
+  message(FATAL_ERROR "Error while patching a file")
+endif()
+
+configure_file(
+  ${NLOHMANN_JSON_SOURCE}
+  ${AUTOGENERATED_DIR}/google/cloud/storage/internal/nlohmann_json.hpp
+  )
+
+include_directories(
+  ${CMAKE_SOURCE_DIR}/external/nlohmann_json/include/
+  )