annotate Resources/CMake/JsonCppConfiguration.cmake @ 2042:5b93382f88e1

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 22 Jun 2016 15:31:07 +0200
parents 326fdda31b42
children 8b51b133bb8b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
1 if (STATIC_BUILD OR NOT USE_SYSTEM_JSONCPP)
1502
5e9c40419fb9 Upgrade to JsonCpp 0.10.5 for static and Windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1414
diff changeset
2 set(JSONCPP_SOURCES_DIR ${CMAKE_BINARY_DIR}/jsoncpp-0.10.5)
1537
fbf763bb1fa3 error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1502
diff changeset
3 set(JSONCPP_URL "http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/jsoncpp-0.10.5.tar.gz")
fbf763bb1fa3 error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1502
diff changeset
4 set(JSONCPP_MD5 "db146bac5a126ded9bd728ab7b61ed6b")
fbf763bb1fa3 error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1502
diff changeset
5
fbf763bb1fa3 error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1502
diff changeset
6 DownloadPackage(${JSONCPP_MD5} ${JSONCPP_URL} "${JSONCPP_SOURCES_DIR}")
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
7
1414
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1405
diff changeset
8 set(JSONCPP_SOURCES
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
9 ${JSONCPP_SOURCES_DIR}/src/lib_json/json_reader.cpp
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
10 ${JSONCPP_SOURCES_DIR}/src/lib_json/json_value.cpp
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
11 ${JSONCPP_SOURCES_DIR}/src/lib_json/json_writer.cpp
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
12 )
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
13
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
14 include_directories(
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
15 ${JSONCPP_SOURCES_DIR}/include
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
16 )
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
17
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
18 source_group(ThirdParty\\JsonCpp REGULAR_EXPRESSION ${JSONCPP_SOURCES_DIR}/.*)
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
19
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
20 else()
1344
c86ad9b58eed jsoncpp lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 735
diff changeset
21 find_path(JSONCPP_INCLUDE_DIR json/reader.h
c86ad9b58eed jsoncpp lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 735
diff changeset
22 /usr/include/jsoncpp
c86ad9b58eed jsoncpp lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 735
diff changeset
23 /usr/local/include/jsoncpp
c86ad9b58eed jsoncpp lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 735
diff changeset
24 )
c86ad9b58eed jsoncpp lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 735
diff changeset
25
c86ad9b58eed jsoncpp lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 735
diff changeset
26 message("JsonCpp include dir: ${JSONCPP_INCLUDE_DIR}")
c86ad9b58eed jsoncpp lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 735
diff changeset
27 include_directories(${JSONCPP_INCLUDE_DIR})
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
28 link_libraries(jsoncpp)
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
29
1405
dae2e28951c6 fix freebsd build
jodogne
parents: 1344
diff changeset
30 CHECK_INCLUDE_FILE_CXX(${JSONCPP_INCLUDE_DIR}/json/reader.h HAVE_JSONCPP_H)
dae2e28951c6 fix freebsd build
jodogne
parents: 1344
diff changeset
31 if (NOT HAVE_JSONCPP_H)
dae2e28951c6 fix freebsd build
jodogne
parents: 1344
diff changeset
32 message(FATAL_ERROR "Please install the libjsoncpp-dev package")
dae2e28951c6 fix freebsd build
jodogne
parents: 1344
diff changeset
33 endif()
dae2e28951c6 fix freebsd build
jodogne
parents: 1344
diff changeset
34
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
35 # 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
36 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
37 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
38 "${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
39 JSONCPP_VERSION_MAJOR1 REGEX
1948
jodogne
parents: 1947
diff changeset
40 ".*define JSONCPP_VERSION_MAJOR.*")
jodogne
parents: 1947
diff changeset
41
jodogne
parents: 1947
diff changeset
42 if (NOT JSONCPP_VERSION_MAJOR1)
jodogne
parents: 1947
diff changeset
43 message(FATAL_ERROR "Unable to extract the major version of JsonCpp")
jodogne
parents: 1947
diff changeset
44 endif()
jodogne
parents: 1947
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 string(REGEX REPLACE
1948
jodogne
parents: 1947
diff changeset
47 ".*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
48 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
49 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
50
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
51 if (CMAKE_COMPILER_IS_GNUCXX AND
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
52 JSONCPP_VERSION_MAJOR GREATER 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
53 message("Switching to C++11 standard, as version of JsonCpp is >= 1.0.0")
1948
jodogne
parents: 1947
diff changeset
54 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-deprecated-declarations")
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
55 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
56 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
57 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
58 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
59
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
60 endif()