comparison OrthancFramework/Resources/CMake/JsonCppConfiguration.cmake @ 4842:044573b90881

stop forcing C++11 in CMake
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 07 Dec 2021 12:34:17 +0100
parents 7053502fbf97
children 93ef0342850e
comparison
equal deleted inserted replaced
4841:060b9a789202 4842:044573b90881
66 CHECK_INCLUDE_FILE_CXX(${JSONCPP_INCLUDE_DIR}/json/reader.h HAVE_JSONCPP_H) 66 CHECK_INCLUDE_FILE_CXX(${JSONCPP_INCLUDE_DIR}/json/reader.h HAVE_JSONCPP_H)
67 if (NOT HAVE_JSONCPP_H) 67 if (NOT HAVE_JSONCPP_H)
68 message(FATAL_ERROR "Please install the libjsoncpp-dev package") 68 message(FATAL_ERROR "Please install the libjsoncpp-dev package")
69 endif() 69 endif()
70 70
71 # Switch to the C++11 standard if the version of JsonCpp is 1.y.z 71 # Detect if the version of JsonCpp is >= 1.0.0
72 if (EXISTS ${JSONCPP_INCLUDE_DIR}/json/version.h) 72 if (EXISTS ${JSONCPP_INCLUDE_DIR}/json/version.h)
73 file(STRINGS 73 file(STRINGS
74 "${JSONCPP_INCLUDE_DIR}/json/version.h" 74 "${JSONCPP_INCLUDE_DIR}/json/version.h"
75 JSONCPP_VERSION_MAJOR1 REGEX 75 JSONCPP_VERSION_MAJOR1 REGEX
76 ".*define JSONCPP_VERSION_MAJOR.*") 76 ".*define JSONCPP_VERSION_MAJOR.*")
96 if (JSONCPP_CXX11) 96 if (JSONCPP_CXX11)
97 # Osimis has encountered problems when this macro is left at its 97 # Osimis has encountered problems when this macro is left at its
98 # default value (1000), so we increase this limit 98 # default value (1000), so we increase this limit
99 # https://gitlab.kitware.com/third-party/jsoncpp/commit/56df2068470241f9043b676bfae415ed62a0c172 99 # https://gitlab.kitware.com/third-party/jsoncpp/commit/56df2068470241f9043b676bfae415ed62a0c172
100 add_definitions(-DJSONCPP_DEPRECATED_STACK_LIMIT=5000) 100 add_definitions(-DJSONCPP_DEPRECATED_STACK_LIMIT=5000)
101
102 if (CMAKE_COMPILER_IS_GNUCXX)
103 message("Switching to C++11 standard in gcc, as version of JsonCpp is >= 1.0.0")
104 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
105 elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
106 message("Switching to C++11 standard in clang, as version of JsonCpp is >= 1.0.0")
107 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
108 endif()
109 endif() 101 endif()