diff Resources/CMake/JsonCppConfiguration.cmake @ 2497:0611aa383e62

Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 22 Mar 2018 15:27:00 +0100
parents fe90b3ec9d4a
children 64e3d4ab158d
line wrap: on
line diff
--- a/Resources/CMake/JsonCppConfiguration.cmake	Thu Mar 22 12:53:20 2018 +0100
+++ b/Resources/CMake/JsonCppConfiguration.cmake	Thu Mar 22 15:27:00 2018 +0100
@@ -1,7 +1,18 @@
+set(JSONCPP_CXX11 OFF)
+
 if (STATIC_BUILD OR NOT USE_SYSTEM_JSONCPP)
-  set(JSONCPP_SOURCES_DIR ${CMAKE_BINARY_DIR}/jsoncpp-0.10.5)
-  set(JSONCPP_URL "http://www.orthanc-server.com/downloads/third-party/jsoncpp-0.10.5.tar.gz")
-  set(JSONCPP_MD5 "db146bac5a126ded9bd728ab7b61ed6b")
+  if (USE_LEGACY_JSONCPP)
+    set(JSONCPP_SOURCES_DIR ${CMAKE_BINARY_DIR}/jsoncpp-0.10.6)
+    set(JSONCPP_URL "http://www.orthanc-server.com/downloads/third-party/jsoncpp-0.10.6.tar.gz")
+    set(JSONCPP_MD5 "13d1991d79697df8cadbc25c93e37c83")
+    add_definitions(-DORTHANC_LEGACY_JSONCPP=1)
+  else()
+    set(JSONCPP_SOURCES_DIR ${CMAKE_BINARY_DIR}/jsoncpp-1.8.4)
+    set(JSONCPP_URL "http://www.orthanc-server.com/downloads/third-party/jsoncpp-1.8.4.tar.gz")
+    set(JSONCPP_MD5 "fa47a3ab6b381869b6a5f20811198662")
+    add_definitions(-DORTHANC_LEGACY_JSONCPP=0)
+    set(JSONCPP_CXX11 ON)
+  endif()
 
   DownloadPackage(${JSONCPP_MD5} ${JSONCPP_URL} "${JSONCPP_SOURCES_DIR}")
 
@@ -48,14 +59,24 @@
       JSONCPP_VERSION_MAJOR ${JSONCPP_VERSION_MAJOR1})
     message("JsonCpp major version: ${JSONCPP_VERSION_MAJOR}")
 
-    if ((CMAKE_COMPILER_IS_GNUCXX OR
-          "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") AND 
-        JSONCPP_VERSION_MAJOR GREATER 0)
-      message("Switching to C++11 standard in gcc/clang, as version of JsonCpp is >= 1.0.0")
-      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-deprecated-declarations")
+    if (JSONCPP_VERSION_MAJOR GREATER 0)
+      set(JSONCPP_CXX11 ON)
     endif()
   else()
     message("Unable to detect the major version of JsonCpp, assuming < 1.0.0")
   endif()
+endif()
 
+
+if (JSONCPP_CXX11)
+  # Osimis has encountered problems when this macro is left at its
+  # default value (1000), so we increase this limit
+  # https://gitlab.kitware.com/third-party/jsoncpp/commit/56df2068470241f9043b676bfae415ed62a0c172
+  add_definitions(-DJSONCPP_DEPRECATED_STACK_LIMIT=5000)
+
+  if (CMAKE_COMPILER_IS_GNUCXX OR
+      "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+    message("Switching to C++11 standard in gcc/clang, as version of JsonCpp is >= 1.0.0")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-deprecated-declarations")
+  endif()
 endif()