annotate Resources/CMake/JsonCppConfiguration.cmake @ 2733:a2536c0d72de Orthanc-1.4.0

set version
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 13 Jul 2018 14:55:47 +0200
parents 0611aa383e62
children 64e3d4ab158d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2497
0611aa383e62 Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2429
diff changeset
1 set(JSONCPP_CXX11 OFF)
0611aa383e62 Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2429
diff changeset
2
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
3 if (STATIC_BUILD OR NOT USE_SYSTEM_JSONCPP)
2497
0611aa383e62 Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2429
diff changeset
4 if (USE_LEGACY_JSONCPP)
0611aa383e62 Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2429
diff changeset
5 set(JSONCPP_SOURCES_DIR ${CMAKE_BINARY_DIR}/jsoncpp-0.10.6)
0611aa383e62 Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2429
diff changeset
6 set(JSONCPP_URL "http://www.orthanc-server.com/downloads/third-party/jsoncpp-0.10.6.tar.gz")
0611aa383e62 Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2429
diff changeset
7 set(JSONCPP_MD5 "13d1991d79697df8cadbc25c93e37c83")
0611aa383e62 Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2429
diff changeset
8 add_definitions(-DORTHANC_LEGACY_JSONCPP=1)
0611aa383e62 Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2429
diff changeset
9 else()
0611aa383e62 Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2429
diff changeset
10 set(JSONCPP_SOURCES_DIR ${CMAKE_BINARY_DIR}/jsoncpp-1.8.4)
0611aa383e62 Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2429
diff changeset
11 set(JSONCPP_URL "http://www.orthanc-server.com/downloads/third-party/jsoncpp-1.8.4.tar.gz")
0611aa383e62 Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2429
diff changeset
12 set(JSONCPP_MD5 "fa47a3ab6b381869b6a5f20811198662")
0611aa383e62 Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2429
diff changeset
13 add_definitions(-DORTHANC_LEGACY_JSONCPP=0)
0611aa383e62 Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2429
diff changeset
14 set(JSONCPP_CXX11 ON)
0611aa383e62 Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2429
diff changeset
15 endif()
1537
fbf763bb1fa3 error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1502
diff changeset
16
fbf763bb1fa3 error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1502
diff changeset
17 DownloadPackage(${JSONCPP_MD5} ${JSONCPP_URL} "${JSONCPP_SOURCES_DIR}")
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
18
1414
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1405
diff changeset
19 set(JSONCPP_SOURCES
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
20 ${JSONCPP_SOURCES_DIR}/src/lib_json/json_reader.cpp
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
21 ${JSONCPP_SOURCES_DIR}/src/lib_json/json_value.cpp
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
22 ${JSONCPP_SOURCES_DIR}/src/lib_json/json_writer.cpp
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
23 )
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
24
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
25 include_directories(
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
26 ${JSONCPP_SOURCES_DIR}/include
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
27 )
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
28
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
29 source_group(ThirdParty\\JsonCpp REGULAR_EXPRESSION ${JSONCPP_SOURCES_DIR}/.*)
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
30
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
31 else()
1344
c86ad9b58eed jsoncpp lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 735
diff changeset
32 find_path(JSONCPP_INCLUDE_DIR json/reader.h
c86ad9b58eed jsoncpp lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 735
diff changeset
33 /usr/include/jsoncpp
c86ad9b58eed jsoncpp lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 735
diff changeset
34 /usr/local/include/jsoncpp
c86ad9b58eed jsoncpp lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 735
diff changeset
35 )
c86ad9b58eed jsoncpp lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 735
diff changeset
36
c86ad9b58eed jsoncpp lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 735
diff changeset
37 message("JsonCpp include dir: ${JSONCPP_INCLUDE_DIR}")
c86ad9b58eed jsoncpp lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 735
diff changeset
38 include_directories(${JSONCPP_INCLUDE_DIR})
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
39 link_libraries(jsoncpp)
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
40
1405
dae2e28951c6 fix freebsd build
jodogne
parents: 1344
diff changeset
41 CHECK_INCLUDE_FILE_CXX(${JSONCPP_INCLUDE_DIR}/json/reader.h HAVE_JSONCPP_H)
dae2e28951c6 fix freebsd build
jodogne
parents: 1344
diff changeset
42 if (NOT HAVE_JSONCPP_H)
dae2e28951c6 fix freebsd build
jodogne
parents: 1344
diff changeset
43 message(FATAL_ERROR "Please install the libjsoncpp-dev package")
dae2e28951c6 fix freebsd build
jodogne
parents: 1344
diff changeset
44 endif()
dae2e28951c6 fix freebsd build
jodogne
parents: 1344
diff changeset
45
1947
c1053112b323 Switch to the C++11 standard if the version of JsonCpp is 1.y.z
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1537
diff changeset
46 # Switch to the C++11 standard if the version of JsonCpp is 1.y.z
c1053112b323 Switch to the C++11 standard if the version of JsonCpp is 1.y.z
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1537
diff changeset
47 if (EXISTS ${JSONCPP_INCLUDE_DIR}/json/version.h)
c1053112b323 Switch to the C++11 standard if the version of JsonCpp is 1.y.z
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1537
diff changeset
48 file(STRINGS
c1053112b323 Switch to the C++11 standard if the version of JsonCpp is 1.y.z
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1537
diff changeset
49 "${JSONCPP_INCLUDE_DIR}/json/version.h"
c1053112b323 Switch to the C++11 standard if the version of JsonCpp is 1.y.z
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1537
diff changeset
50 JSONCPP_VERSION_MAJOR1 REGEX
1948
jodogne
parents: 1947
diff changeset
51 ".*define JSONCPP_VERSION_MAJOR.*")
jodogne
parents: 1947
diff changeset
52
jodogne
parents: 1947
diff changeset
53 if (NOT JSONCPP_VERSION_MAJOR1)
jodogne
parents: 1947
diff changeset
54 message(FATAL_ERROR "Unable to extract the major version of JsonCpp")
jodogne
parents: 1947
diff changeset
55 endif()
jodogne
parents: 1947
diff changeset
56
1947
c1053112b323 Switch to the C++11 standard if the version of JsonCpp is 1.y.z
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1537
diff changeset
57 string(REGEX REPLACE
1948
jodogne
parents: 1947
diff changeset
58 ".*JSONCPP_VERSION_MAJOR.*([0-9]+)$" "\\1"
1947
c1053112b323 Switch to the C++11 standard if the version of JsonCpp is 1.y.z
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1537
diff changeset
59 JSONCPP_VERSION_MAJOR ${JSONCPP_VERSION_MAJOR1})
c1053112b323 Switch to the C++11 standard if the version of JsonCpp is 1.y.z
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1537
diff changeset
60 message("JsonCpp major version: ${JSONCPP_VERSION_MAJOR}")
c1053112b323 Switch to the C++11 standard if the version of JsonCpp is 1.y.z
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1537
diff changeset
61
2497
0611aa383e62 Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2429
diff changeset
62 if (JSONCPP_VERSION_MAJOR GREATER 0)
0611aa383e62 Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2429
diff changeset
63 set(JSONCPP_CXX11 ON)
1947
c1053112b323 Switch to the C++11 standard if the version of JsonCpp is 1.y.z
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1537
diff changeset
64 endif()
c1053112b323 Switch to the C++11 standard if the version of JsonCpp is 1.y.z
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1537
diff changeset
65 else()
c1053112b323 Switch to the C++11 standard if the version of JsonCpp is 1.y.z
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1537
diff changeset
66 message("Unable to detect the major version of JsonCpp, assuming < 1.0.0")
c1053112b323 Switch to the C++11 standard if the version of JsonCpp is 1.y.z
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1537
diff changeset
67 endif()
2497
0611aa383e62 Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2429
diff changeset
68 endif()
1947
c1053112b323 Switch to the C++11 standard if the version of JsonCpp is 1.y.z
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1537
diff changeset
69
2497
0611aa383e62 Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2429
diff changeset
70
0611aa383e62 Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2429
diff changeset
71 if (JSONCPP_CXX11)
0611aa383e62 Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2429
diff changeset
72 # Osimis has encountered problems when this macro is left at its
0611aa383e62 Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2429
diff changeset
73 # default value (1000), so we increase this limit
0611aa383e62 Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2429
diff changeset
74 # https://gitlab.kitware.com/third-party/jsoncpp/commit/56df2068470241f9043b676bfae415ed62a0c172
0611aa383e62 Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2429
diff changeset
75 add_definitions(-DJSONCPP_DEPRECATED_STACK_LIMIT=5000)
0611aa383e62 Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2429
diff changeset
76
0611aa383e62 Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2429
diff changeset
77 if (CMAKE_COMPILER_IS_GNUCXX OR
0611aa383e62 Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2429
diff changeset
78 "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
0611aa383e62 Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2429
diff changeset
79 message("Switching to C++11 standard in gcc/clang, as version of JsonCpp is >= 1.0.0")
0611aa383e62 Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2429
diff changeset
80 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-deprecated-declarations")
0611aa383e62 Upgrade to JsonCpp 1.8.4, and USE_LEGACY_JSONCPP option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2429
diff changeset
81 endif()
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
82 endif()