Mercurial > hg > orthanc
annotate Resources/CMake/JsonCppConfiguration.cmake @ 1947:c1053112b323
Switch to the C++11 standard if the version of JsonCpp is 1.y.z
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 05 Apr 2016 10:11:40 +0200 |
parents | fbf763bb1fa3 |
children | 326fdda31b42 |
rev | line source |
---|---|
735 | 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 | 7 |
1414 | 8 set(JSONCPP_SOURCES |
735 | 9 ${JSONCPP_SOURCES_DIR}/src/lib_json/json_reader.cpp |
10 ${JSONCPP_SOURCES_DIR}/src/lib_json/json_value.cpp | |
11 ${JSONCPP_SOURCES_DIR}/src/lib_json/json_writer.cpp | |
12 ) | |
13 | |
14 include_directories( | |
15 ${JSONCPP_SOURCES_DIR}/include | |
16 ) | |
17 | |
18 source_group(ThirdParty\\JsonCpp REGULAR_EXPRESSION ${JSONCPP_SOURCES_DIR}/.*) | |
19 | |
20 else() | |
1344 | 21 find_path(JSONCPP_INCLUDE_DIR json/reader.h |
22 /usr/include/jsoncpp | |
23 /usr/local/include/jsoncpp | |
24 ) | |
25 | |
26 message("JsonCpp include dir: ${JSONCPP_INCLUDE_DIR}") | |
27 include_directories(${JSONCPP_INCLUDE_DIR}) | |
735 | 28 link_libraries(jsoncpp) |
29 | |
1405 | 30 CHECK_INCLUDE_FILE_CXX(${JSONCPP_INCLUDE_DIR}/json/reader.h HAVE_JSONCPP_H) |
31 if (NOT HAVE_JSONCPP_H) | |
32 message(FATAL_ERROR "Please install the libjsoncpp-dev package") | |
33 endif() | |
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 message(${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 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
|
38 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
|
39 "${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
|
40 JSONCPP_VERSION_MAJOR1 REGEX |
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
|
41 ".*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
|
42 string(REGEX REPLACE |
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
|
43 ".*JSONCPP_VERSION_MAJOR ([0-9]+)\\s*$" "\\1" |
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
|
44 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
|
45 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
|
46 |
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 (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
|
48 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
|
49 message("Switching to C++11 standard, as version of JsonCpp is >= 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
|
50 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") |
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 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
|
52 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
|
53 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
|
54 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
|
55 |
735 | 56 endif() |