1From d8986cb065e770017ee1622fb7324387ead60203 Mon Sep 17 00:00:00 2001 2From: Ming Liu <peter.x.liu@external.atlascopco.com> 3Date: Tue, 7 Mar 2017 11:46:52 +0100 4Subject: [PATCH] Adjust the cmake files 5 6- Remove json_test which can not build with boost 1.61.0. 7- Build shared library as well with the original static library. 8- Add FindLibJsonSpirit.cmake to be able to be found by the dependers. 9 10Upstream-Status: Inappropriate [configuration] 11 12Signed-off-by: Ming Liu <peter.x.liu@external.atlascopco.com> 13--- 14 CMakeLists.txt | 8 +++--- 15 FindLibJsonSpirit.cmake | 64 ++++++++++++++++++++++++++++++++++++++++++++++ 16 json_spirit/CMakeLists.txt | 16 +++++++++++- 17 3 files changed, 83 insertions(+), 5 deletions(-) 18 create mode 100644 FindLibJsonSpirit.cmake 19 20diff --git a/CMakeLists.txt b/CMakeLists.txt 21index 4637a6c..b292f0f 100644 22--- a/CMakeLists.txt 23+++ b/CMakeLists.txt 24@@ -1,7 +1,7 @@ 25 CMAKE_MINIMUM_REQUIRED(VERSION 2.6) 26 27 PROJECT(json_spirit) 28-SUBDIRS(json_spirit json_demo json_headers_only_demo json_map_demo json_test) 29+SUBDIRS(json_spirit json_demo json_headers_only_demo json_map_demo) 30 INCLUDE_DIRECTORIES(json_spirit) 31 32 INSTALL( 33@@ -16,11 +16,11 @@ INSTALL( 34 ${CMAKE_SOURCE_DIR}/json_spirit/json_spirit_writer.h 35 ${CMAKE_SOURCE_DIR}/json_spirit/json_spirit_writer_template.h 36 ${CMAKE_SOURCE_DIR}/json_spirit/json_spirit_writer_options.h 37- DESTINATION include) 38+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) 39 40 INSTALL( 41 FILES 42- ${CMAKE_BINARY_DIR}/json_spirit/libjson_spirit.a 43- DESTINATION lib) 44+ ${CMAKE_SOURCE_DIR}/FindLibJsonSpirit.cmake 45+ DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/Modules) 46 47 INCLUDE(CPack) 48diff --git a/FindLibJsonSpirit.cmake b/FindLibJsonSpirit.cmake 49new file mode 100644 50index 0000000..7ee7687 51--- /dev/null 52+++ b/FindLibJsonSpirit.cmake 53@@ -0,0 +1,64 @@ 54+# FindLibJsonSpirit - Find libjson_spirit headers and libraries. 55+# 56+# Sample: 57+# 58+# SET( LibJsonSpirit_USE_STATIC_LIBS OFF ) 59+# FIND_PACKAGE( LibJsonSpirit REQUIRED ) 60+# IF( LibJsonSpirit_FOUND ) 61+# INCLUDE_DIRECTORIES( ${LibJsonSpirit_INCLUDE_DIRS} ) 62+# TARGET_LINK_LIBRARIES( ... ${LibJsonSpirit_LIBRARIES} ) 63+# ENDIF() 64+# 65+# Variables used by this module need to be set before calling find_package 66+# 67+# LibJsonSpirit_USE_STATIC_LIBS Can be set to ON to force the use of the static 68+# libjson_spirit libraries. Defaults to OFF. 69+# 70+# Variables provided by this module: 71+# 72+# LibJsonSpirit_FOUND Include dir, libjson_spirit libraries. 73+# 74+# LibJsonSpirit_LIBRARIES Link to these to use all the libraries you specified. 75+# 76+# LibJsonSpirit_INCLUDE_DIRS Include directories. 77+# 78+# For each component you specify in find_package(), the following (UPPER-CASE) 79+# variables are set to pick and choose components instead of just using 80+# LibJsonSpirit_LIBRARIES: 81+# 82+# LIBJSONSPIRIT_FOUND TRUE if libjson_spirit was found 83+# LIBJSONSPIRIT_LIBRARY libjson_spirit library 84+# 85+ 86+# Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES 87+IF(LibJsonSpirit_USE_STATIC_LIBS) 88+ SET( _ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) 89+ SET(CMAKE_FIND_LIBRARY_SUFFIXES .a ) 90+ENDIF() 91+ 92+# Look for the header files 93+UNSET(LibJsonSpirit_INCLUDE_DIRS CACHE) 94+FIND_PATH(LibJsonSpirit_INCLUDE_DIRS NAMES json_spirit.h) 95+ 96+# Look for the core library 97+UNSET(LIBJSONSPIRIT_LIBRARY CACHE) 98+FIND_LIBRARY(LIBJSONSPIRIT_LIBRARY NAMES json_spirit) 99+FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibJsonSpirit DEFAULT_MSG LIBJSONSPIRIT_LIBRARY LibJsonSpirit_INCLUDE_DIRS) 100+MARK_AS_ADVANCED( 101+ LIBJSONSPIRIT_FOUND 102+ LIBJSONSPIRIT_LIBRARY 103+) 104+ 105+# Prepare return values and collectiong more components 106+SET(LibJsonSpirit_FOUND ${LIBJSONSPIRIT_FOUND}) 107+SET(LibJsonSpirit_LIBRARIES ${LIBJSONSPIRIT_LIBRARY}) 108+MARK_AS_ADVANCED( 109+ LibJsonSpirit_FOUND 110+ LibJsonSpirit_LIBRARIES 111+ LibJsonSpirit_INCLUDE_DIRS 112+) 113+ 114+# Restore CMAKE_FIND_LIBRARY_SUFFIXES 115+IF(LibJsonSpirit_USE_STATIC_LIBS) 116+ SET(CMAKE_FIND_LIBRARY_SUFFIXES ${_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES} ) 117+ENDIF() 118diff --git a/json_spirit/CMakeLists.txt b/json_spirit/CMakeLists.txt 119index fb52818..c1613b2 100644 120--- a/json_spirit/CMakeLists.txt 121+++ b/json_spirit/CMakeLists.txt 122@@ -13,5 +13,19 @@ json_spirit_writer_template.h ) 123 FIND_PACKAGE(Boost 1.34 REQUIRED) 124 INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR}) 125 126-ADD_LIBRARY(json_spirit STATIC ${JSON_SPIRIT_SRCS}) 127+SET(JSONSPIRIT_SOVERSION_MAJOR "4") 128+SET(JSONSPIRIT_SOVERSION_MINOR "0") 129+SET(JSONSPIRIT_SOVERSION_PATCH "8") 130 131+ADD_LIBRARY(json_spirit SHARED ${JSON_SPIRIT_SRCS}) 132+SET_TARGET_PROPERTIES(json_spirit PROPERTIES PROJECT_LABEL "Json Spirit Library") 133+SET_TARGET_PROPERTIES(json_spirit PROPERTIES COMPILE_FLAGS ${CMAKE_SHARED_LIBRARY_C_FLAGS}) 134+SET_TARGET_PROPERTIES(json_spirit PROPERTIES VERSION ${JSONSPIRIT_SOVERSION_MAJOR}.${JSONSPIRIT_SOVERSION_MINOR}.${JSONSPIRIT_SOVERSION_PATCH}) 135+SET_TARGET_PROPERTIES(json_spirit PROPERTIES SOVERSION ${JSONSPIRIT_SOVERSION_MAJOR}) 136+INSTALL(TARGETS json_spirit DESTINATION ${CMAKE_INSTALL_LIBDIR}) 137+ 138+ADD_LIBRARY(json_spirit_static STATIC ${JSON_SPIRIT_SRCS}) 139+SET_TARGET_PROPERTIES(json_spirit_static PROPERTIES PROJECT_LABEL "Json Spirit Static Library") 140+SET_TARGET_PROPERTIES(json_spirit_static PROPERTIES OUTPUT_NAME "json_spirit") 141+SET_TARGET_PROPERTIES(json_spirit_static PROPERTIES SOVERSION ${JSONSPIRIT_SOVERSION_MAJOR}) 142+INSTALL(TARGETS json_spirit_static DESTINATION ${CMAKE_INSTALL_LIBDIR}) 143-- 1441.9.1 145 146