1OPTION(JSONCPP_LIB_BUILD_SHARED "Build jsoncpp_lib as a shared library." OFF) 2IF(JSONCPP_LIB_BUILD_SHARED) 3 SET(JSONCPP_LIB_TYPE SHARED) 4 ADD_DEFINITIONS( -DJSON_DLL_BUILD ) 5ELSE(JSONCPP_LIB_BUILD_SHARED) 6 SET(JSONCPP_LIB_TYPE STATIC) 7ENDIF(JSONCPP_LIB_BUILD_SHARED) 8 9 10if( CMAKE_COMPILER_IS_GNUCXX ) 11 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=strict-aliasing") 12endif( CMAKE_COMPILER_IS_GNUCXX ) 13 14SET( JSONCPP_INCLUDE_DIR ../../include ) 15 16SET( PUBLIC_HEADERS 17 ${JSONCPP_INCLUDE_DIR}/json/config.h 18 ${JSONCPP_INCLUDE_DIR}/json/forwards.h 19 ${JSONCPP_INCLUDE_DIR}/json/features.h 20 ${JSONCPP_INCLUDE_DIR}/json/value.h 21 ${JSONCPP_INCLUDE_DIR}/json/reader.h 22 ${JSONCPP_INCLUDE_DIR}/json/writer.h 23 ${JSONCPP_INCLUDE_DIR}/json/assertions.h 24 ${JSONCPP_INCLUDE_DIR}/json/version.h 25 ) 26 27SOURCE_GROUP( "Public API" FILES ${PUBLIC_HEADERS} ) 28 29ADD_LIBRARY( jsoncpp_lib ${JSONCPP_LIB_TYPE} 30 ${PUBLIC_HEADERS} 31 json_tool.h 32 json_reader.cpp 33 json_batchallocator.h 34 json_valueiterator.inl 35 json_value.cpp 36 json_writer.cpp 37 version.h.in 38 ) 39SET_TARGET_PROPERTIES( jsoncpp_lib PROPERTIES OUTPUT_NAME jsoncpp ) 40SET_TARGET_PROPERTIES( jsoncpp_lib PROPERTIES VERSION ${JSONCPP_VERSION} SOVERSION ${JSONCPP_VERSION_MAJOR} ) 41 42# Install instructions for this target 43IF(JSONCPP_WITH_CMAKE_PACKAGE) 44 TARGET_INCLUDE_DIRECTORIES( jsoncpp_lib 45 PUBLIC $<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}> 46 $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/${JSON_INCLUDE_DIR}> 47 ) 48 SET(INSTALL_EXPORT EXPORT jsoncpp) 49ELSE(JSONCPP_WITH_CMAKE_PACKAGE) 50 SET(INSTALL_EXPORT) 51ENDIF(JSONCPP_WITH_CMAKE_PACKAGE) 52 53INSTALL( TARGETS jsoncpp_lib ${INSTALL_EXPORT} 54 RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR} 55 LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR} 56 ARCHIVE DESTINATION ${ARCHIVE_INSTALL_DIR} 57) 58