comparison 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
comparison
equal deleted inserted replaced
1946:40b7a0176305 1947:c1053112b323
30 CHECK_INCLUDE_FILE_CXX(${JSONCPP_INCLUDE_DIR}/json/reader.h HAVE_JSONCPP_H) 30 CHECK_INCLUDE_FILE_CXX(${JSONCPP_INCLUDE_DIR}/json/reader.h HAVE_JSONCPP_H)
31 if (NOT HAVE_JSONCPP_H) 31 if (NOT HAVE_JSONCPP_H)
32 message(FATAL_ERROR "Please install the libjsoncpp-dev package") 32 message(FATAL_ERROR "Please install the libjsoncpp-dev package")
33 endif() 33 endif()
34 34
35 # Switch to the C++11 standard if the version of JsonCpp is 1.y.z
36 message(${JSONCPP_INCLUDE_DIR}/json/version.h)
37 if (EXISTS ${JSONCPP_INCLUDE_DIR}/json/version.h)
38 file(STRINGS
39 "${JSONCPP_INCLUDE_DIR}/json/version.h"
40 JSONCPP_VERSION_MAJOR1 REGEX
41 ".*JSONCPP_VERSION_MAJOR .*")
42 string(REGEX REPLACE
43 ".*JSONCPP_VERSION_MAJOR ([0-9]+)\\s*$" "\\1"
44 JSONCPP_VERSION_MAJOR ${JSONCPP_VERSION_MAJOR1})
45 message("JsonCpp major version: ${JSONCPP_VERSION_MAJOR}")
46
47 if (CMAKE_COMPILER_IS_GNUCXX AND
48 JSONCPP_VERSION_MAJOR GREATER 0)
49 message("Switching to C++11 standard, as version of JsonCpp is >= 1.0.0")
50 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
51 endif()
52 else()
53 message("Unable to detect the major version of JsonCpp, assuming < 1.0.0")
54 endif()
55
35 endif() 56 endif()