json test

Committer:
tgw
Date:
Fri Jan 26 06:05:31 2018 +0000
Revision:
0:2ee762ea11b3
json

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tgw 0:2ee762ea11b3 1 IF( CMAKE_COMPILER_IS_GNUCXX )
tgw 0:2ee762ea11b3 2 #Get compiler version.
tgw 0:2ee762ea11b3 3 EXECUTE_PROCESS( COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
tgw 0:2ee762ea11b3 4 OUTPUT_VARIABLE GNUCXX_VERSION )
tgw 0:2ee762ea11b3 5
tgw 0:2ee762ea11b3 6 #-Werror=* was introduced -after- GCC 4.1.2
tgw 0:2ee762ea11b3 7 IF( GNUCXX_VERSION VERSION_GREATER 4.1.2 )
tgw 0:2ee762ea11b3 8 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=strict-aliasing")
tgw 0:2ee762ea11b3 9 ENDIF()
tgw 0:2ee762ea11b3 10 ENDIF( CMAKE_COMPILER_IS_GNUCXX )
tgw 0:2ee762ea11b3 11
tgw 0:2ee762ea11b3 12 INCLUDE(CheckIncludeFileCXX)
tgw 0:2ee762ea11b3 13 INCLUDE(CheckTypeSize)
tgw 0:2ee762ea11b3 14 INCLUDE(CheckStructHasMember)
tgw 0:2ee762ea11b3 15 INCLUDE(CheckCXXSymbolExists)
tgw 0:2ee762ea11b3 16
tgw 0:2ee762ea11b3 17 check_include_file_cxx(clocale HAVE_CLOCALE)
tgw 0:2ee762ea11b3 18 check_cxx_symbol_exists(localeconv clocale HAVE_LOCALECONV)
tgw 0:2ee762ea11b3 19
tgw 0:2ee762ea11b3 20 IF(CMAKE_VERSION VERSION_LESS 3.0.0)
tgw 0:2ee762ea11b3 21 # The "LANGUAGE CXX" parameter is not supported in CMake versions below 3,
tgw 0:2ee762ea11b3 22 # so the C compiler and header has to be used.
tgw 0:2ee762ea11b3 23 check_include_file(locale.h HAVE_LOCALE_H)
tgw 0:2ee762ea11b3 24 SET(CMAKE_EXTRA_INCLUDE_FILES locale.h)
tgw 0:2ee762ea11b3 25 check_type_size("struct lconv" LCONV_SIZE)
tgw 0:2ee762ea11b3 26 UNSET(CMAKE_EXTRA_INCLUDE_FILES)
tgw 0:2ee762ea11b3 27 check_struct_has_member("struct lconv" decimal_point locale.h HAVE_DECIMAL_POINT)
tgw 0:2ee762ea11b3 28 ELSE()
tgw 0:2ee762ea11b3 29 SET(CMAKE_EXTRA_INCLUDE_FILES clocale)
tgw 0:2ee762ea11b3 30 check_type_size(lconv LCONV_SIZE LANGUAGE CXX)
tgw 0:2ee762ea11b3 31 UNSET(CMAKE_EXTRA_INCLUDE_FILES)
tgw 0:2ee762ea11b3 32 check_struct_has_member(lconv decimal_point clocale HAVE_DECIMAL_POINT LANGUAGE CXX)
tgw 0:2ee762ea11b3 33 ENDIF()
tgw 0:2ee762ea11b3 34
tgw 0:2ee762ea11b3 35 IF(NOT (HAVE_CLOCALE AND HAVE_LCONV_SIZE AND HAVE_DECIMAL_POINT AND HAVE_LOCALECONV))
tgw 0:2ee762ea11b3 36 MESSAGE(WARNING "Locale functionality is not supported")
tgw 0:2ee762ea11b3 37 ADD_DEFINITIONS(-DJSONCPP_NO_LOCALE_SUPPORT)
tgw 0:2ee762ea11b3 38 ENDIF()
tgw 0:2ee762ea11b3 39
tgw 0:2ee762ea11b3 40 SET( JSONCPP_INCLUDE_DIR ../../include )
tgw 0:2ee762ea11b3 41
tgw 0:2ee762ea11b3 42 SET( PUBLIC_HEADERS
tgw 0:2ee762ea11b3 43 ${JSONCPP_INCLUDE_DIR}/json/config.h
tgw 0:2ee762ea11b3 44 ${JSONCPP_INCLUDE_DIR}/json/forwards.h
tgw 0:2ee762ea11b3 45 ${JSONCPP_INCLUDE_DIR}/json/features.h
tgw 0:2ee762ea11b3 46 ${JSONCPP_INCLUDE_DIR}/json/value.h
tgw 0:2ee762ea11b3 47 ${JSONCPP_INCLUDE_DIR}/json/reader.h
tgw 0:2ee762ea11b3 48 ${JSONCPP_INCLUDE_DIR}/json/writer.h
tgw 0:2ee762ea11b3 49 ${JSONCPP_INCLUDE_DIR}/json/assertions.h
tgw 0:2ee762ea11b3 50 ${JSONCPP_INCLUDE_DIR}/json/version.h
tgw 0:2ee762ea11b3 51 )
tgw 0:2ee762ea11b3 52
tgw 0:2ee762ea11b3 53 SOURCE_GROUP( "Public API" FILES ${PUBLIC_HEADERS} )
tgw 0:2ee762ea11b3 54
tgw 0:2ee762ea11b3 55 SET(jsoncpp_sources
tgw 0:2ee762ea11b3 56 json_tool.h
tgw 0:2ee762ea11b3 57 json_reader.cpp
tgw 0:2ee762ea11b3 58 json_valueiterator.inl
tgw 0:2ee762ea11b3 59 json_value.cpp
tgw 0:2ee762ea11b3 60 json_writer.cpp
tgw 0:2ee762ea11b3 61 version.h.in)
tgw 0:2ee762ea11b3 62
tgw 0:2ee762ea11b3 63 # Install instructions for this target
tgw 0:2ee762ea11b3 64 IF(JSONCPP_WITH_CMAKE_PACKAGE)
tgw 0:2ee762ea11b3 65 SET(INSTALL_EXPORT EXPORT jsoncpp)
tgw 0:2ee762ea11b3 66 ELSE(JSONCPP_WITH_CMAKE_PACKAGE)
tgw 0:2ee762ea11b3 67 SET(INSTALL_EXPORT)
tgw 0:2ee762ea11b3 68 ENDIF()
tgw 0:2ee762ea11b3 69
tgw 0:2ee762ea11b3 70 IF(BUILD_SHARED_LIBS)
tgw 0:2ee762ea11b3 71 ADD_DEFINITIONS( -DJSON_DLL_BUILD )
tgw 0:2ee762ea11b3 72 ADD_LIBRARY(jsoncpp_lib SHARED ${PUBLIC_HEADERS} ${jsoncpp_sources})
tgw 0:2ee762ea11b3 73 SET_TARGET_PROPERTIES( jsoncpp_lib PROPERTIES VERSION ${JSONCPP_VERSION} SOVERSION ${JSONCPP_SOVERSION})
tgw 0:2ee762ea11b3 74 SET_TARGET_PROPERTIES( jsoncpp_lib PROPERTIES OUTPUT_NAME jsoncpp
tgw 0:2ee762ea11b3 75 DEBUG_OUTPUT_NAME jsoncpp${DEBUG_LIBNAME_SUFFIX} )
tgw 0:2ee762ea11b3 76
tgw 0:2ee762ea11b3 77 # Set library's runtime search path on OSX
tgw 0:2ee762ea11b3 78 IF(APPLE)
tgw 0:2ee762ea11b3 79 SET_TARGET_PROPERTIES( jsoncpp_lib PROPERTIES INSTALL_RPATH "@loader_path/." )
tgw 0:2ee762ea11b3 80 ENDIF()
tgw 0:2ee762ea11b3 81
tgw 0:2ee762ea11b3 82 INSTALL( TARGETS jsoncpp_lib ${INSTALL_EXPORT}
tgw 0:2ee762ea11b3 83 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
tgw 0:2ee762ea11b3 84 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
tgw 0:2ee762ea11b3 85 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
tgw 0:2ee762ea11b3 86
tgw 0:2ee762ea11b3 87 IF(NOT CMAKE_VERSION VERSION_LESS 2.8.11)
tgw 0:2ee762ea11b3 88 TARGET_INCLUDE_DIRECTORIES( jsoncpp_lib PUBLIC
tgw 0:2ee762ea11b3 89 $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
tgw 0:2ee762ea11b3 90 $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/${JSONCPP_INCLUDE_DIR}>)
tgw 0:2ee762ea11b3 91 ENDIF()
tgw 0:2ee762ea11b3 92
tgw 0:2ee762ea11b3 93 ENDIF()
tgw 0:2ee762ea11b3 94
tgw 0:2ee762ea11b3 95 IF(BUILD_STATIC_LIBS)
tgw 0:2ee762ea11b3 96 ADD_LIBRARY(jsoncpp_lib_static STATIC ${PUBLIC_HEADERS} ${jsoncpp_sources})
tgw 0:2ee762ea11b3 97 SET_TARGET_PROPERTIES( jsoncpp_lib_static PROPERTIES VERSION ${JSONCPP_VERSION} SOVERSION ${JSONCPP_SOVERSION})
tgw 0:2ee762ea11b3 98 # avoid name clashes on windows as the shared import lib is also named jsoncpp.lib
tgw 0:2ee762ea11b3 99 if (NOT DEFINED STATIC_SUFFIX AND BUILD_SHARED_LIBS)
tgw 0:2ee762ea11b3 100 set (STATIC_SUFFIX "_static")
tgw 0:2ee762ea11b3 101 endif ()
tgw 0:2ee762ea11b3 102 set_target_properties (jsoncpp_lib_static PROPERTIES OUTPUT_NAME jsoncpp${STATIC_SUFFIX}
tgw 0:2ee762ea11b3 103 DEBUG_OUTPUT_NAME jsoncpp${STATIC_SUFFIX}${DEBUG_LIBNAME_SUFFIX})
tgw 0:2ee762ea11b3 104
tgw 0:2ee762ea11b3 105 INSTALL( TARGETS jsoncpp_lib_static ${INSTALL_EXPORT}
tgw 0:2ee762ea11b3 106 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
tgw 0:2ee762ea11b3 107 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
tgw 0:2ee762ea11b3 108 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
tgw 0:2ee762ea11b3 109
tgw 0:2ee762ea11b3 110 IF(NOT CMAKE_VERSION VERSION_LESS 2.8.11)
tgw 0:2ee762ea11b3 111 TARGET_INCLUDE_DIRECTORIES( jsoncpp_lib_static PUBLIC
tgw 0:2ee762ea11b3 112 $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
tgw 0:2ee762ea11b3 113 $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/${JSONCPP_INCLUDE_DIR}>
tgw 0:2ee762ea11b3 114 )
tgw 0:2ee762ea11b3 115 ENDIF()
tgw 0:2ee762ea11b3 116
tgw 0:2ee762ea11b3 117 ENDIF()