comparison OrthancFramework/Resources/CMake/JsonCppConfiguration.cmake @ 4044:d25f4c0fa160 framework

splitting code into OrthancFramework and OrthancServer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 10 Jun 2020 20:30:34 +0200
parents Resources/CMake/JsonCppConfiguration.cmake@c575fb0adf91
children 304842a0d152
comparison
equal deleted inserted replaced
4043:6c6239aec462 4044:d25f4c0fa160
1 set(JSONCPP_CXX11 OFF)
2
3 if (STATIC_BUILD OR NOT USE_SYSTEM_JSONCPP)
4 if (USE_LEGACY_JSONCPP)
5 set(JSONCPP_SOURCES_DIR ${CMAKE_BINARY_DIR}/jsoncpp-0.10.7)
6 set(JSONCPP_URL "http://orthanc.osimis.io/ThirdPartyDownloads/jsoncpp-0.10.7.tar.gz")
7 set(JSONCPP_MD5 "3a8072ca6a1fa9cbaf7715ae625f134f")
8 add_definitions(-DORTHANC_LEGACY_JSONCPP=1)
9 else()
10 set(JSONCPP_SOURCES_DIR ${CMAKE_BINARY_DIR}/jsoncpp-1.8.4)
11 set(JSONCPP_URL "http://orthanc.osimis.io/ThirdPartyDownloads/jsoncpp-1.8.4.tar.gz")
12 set(JSONCPP_MD5 "fa47a3ab6b381869b6a5f20811198662")
13 add_definitions(-DORTHANC_LEGACY_JSONCPP=0)
14 set(JSONCPP_CXX11 ON)
15 endif()
16
17 DownloadPackage(${JSONCPP_MD5} ${JSONCPP_URL} "${JSONCPP_SOURCES_DIR}")
18
19 set(JSONCPP_SOURCES
20 ${JSONCPP_SOURCES_DIR}/src/lib_json/json_reader.cpp
21 ${JSONCPP_SOURCES_DIR}/src/lib_json/json_value.cpp
22 ${JSONCPP_SOURCES_DIR}/src/lib_json/json_writer.cpp
23 )
24
25 include_directories(
26 ${JSONCPP_SOURCES_DIR}/include
27 )
28
29 if (NOT ENABLE_LOCALE)
30 add_definitions(-DJSONCPP_NO_LOCALE_SUPPORT=1)
31 endif()
32
33 source_group(ThirdParty\\JsonCpp REGULAR_EXPRESSION ${JSONCPP_SOURCES_DIR}/.*)
34
35 else()
36 find_path(JSONCPP_INCLUDE_DIR json/reader.h
37 /usr/include/jsoncpp
38 /usr/local/include/jsoncpp
39 )
40
41 message("JsonCpp include dir: ${JSONCPP_INCLUDE_DIR}")
42 include_directories(${JSONCPP_INCLUDE_DIR})
43 link_libraries(jsoncpp)
44
45 CHECK_INCLUDE_FILE_CXX(${JSONCPP_INCLUDE_DIR}/json/reader.h HAVE_JSONCPP_H)
46 if (NOT HAVE_JSONCPP_H)
47 message(FATAL_ERROR "Please install the libjsoncpp-dev package")
48 endif()
49
50 # Switch to the C++11 standard if the version of JsonCpp is 1.y.z
51 if (EXISTS ${JSONCPP_INCLUDE_DIR}/json/version.h)
52 file(STRINGS
53 "${JSONCPP_INCLUDE_DIR}/json/version.h"
54 JSONCPP_VERSION_MAJOR1 REGEX
55 ".*define JSONCPP_VERSION_MAJOR.*")
56
57 if (NOT JSONCPP_VERSION_MAJOR1)
58 message(FATAL_ERROR "Unable to extract the major version of JsonCpp")
59 endif()
60
61 string(REGEX REPLACE
62 ".*JSONCPP_VERSION_MAJOR.*([0-9]+)$" "\\1"
63 JSONCPP_VERSION_MAJOR ${JSONCPP_VERSION_MAJOR1})
64 message("JsonCpp major version: ${JSONCPP_VERSION_MAJOR}")
65
66 if (JSONCPP_VERSION_MAJOR GREATER 0)
67 set(JSONCPP_CXX11 ON)
68 endif()
69 else()
70 message("Unable to detect the major version of JsonCpp, assuming < 1.0.0")
71 endif()
72 endif()
73
74
75 if (JSONCPP_CXX11)
76 # Osimis has encountered problems when this macro is left at its
77 # default value (1000), so we increase this limit
78 # https://gitlab.kitware.com/third-party/jsoncpp/commit/56df2068470241f9043b676bfae415ed62a0c172
79 add_definitions(-DJSONCPP_DEPRECATED_STACK_LIMIT=5000)
80
81 if (CMAKE_COMPILER_IS_GNUCXX)
82 message("Switching to C++11 standard in gcc, as version of JsonCpp is >= 1.0.0")
83 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11 -Wno-deprecated-declarations")
84 elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
85 message("Switching to C++11 standard in clang, as version of JsonCpp is >= 1.0.0")
86 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-deprecated-declarations")
87 endif()
88 endif()