aboutsummaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-devtools/json-spirit/json-spirit/0001-Adjust-the-cmake-files.patch
blob: f7030c553001c0bb986515243b4e5416677af2c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
From d8986cb065e770017ee1622fb7324387ead60203 Mon Sep 17 00:00:00 2001
From: Ming Liu <peter.x.liu@external.atlascopco.com>
Date: Tue, 7 Mar 2017 11:46:52 +0100
Subject: [PATCH] Adjust the cmake files

- Remove json_test which can not build with boost 1.61.0.
- Build shared library as well with the original static library.
- Add FindLibJsonSpirit.cmake to be able to be found by the dependers.

Upstream-Status: Inappropriate [configuration]

Signed-off-by: Ming Liu <peter.x.liu@external.atlascopco.com>
---
 CMakeLists.txt             |  8 +++---
 FindLibJsonSpirit.cmake    | 64 ++++++++++++++++++++++++++++++++++++++++++++++
 json_spirit/CMakeLists.txt | 16 +++++++++++-
 3 files changed, 83 insertions(+), 5 deletions(-)
 create mode 100644 FindLibJsonSpirit.cmake

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4637a6c..b292f0f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,7 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 
 PROJECT(json_spirit)
-SUBDIRS(json_spirit json_demo json_headers_only_demo json_map_demo json_test)
+SUBDIRS(json_spirit json_demo json_headers_only_demo json_map_demo)
 INCLUDE_DIRECTORIES(json_spirit)
 
 INSTALL(
@@ -16,11 +16,11 @@ INSTALL(
   ${CMAKE_SOURCE_DIR}/json_spirit/json_spirit_writer.h
   ${CMAKE_SOURCE_DIR}/json_spirit/json_spirit_writer_template.h
   ${CMAKE_SOURCE_DIR}/json_spirit/json_spirit_writer_options.h
-  DESTINATION include)
+  DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
 
 INSTALL(
   FILES
-  ${CMAKE_BINARY_DIR}/json_spirit/libjson_spirit.a
-  DESTINATION lib)
+  ${CMAKE_SOURCE_DIR}/FindLibJsonSpirit.cmake
+  DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/Modules)
 
 INCLUDE(CPack)
diff --git a/FindLibJsonSpirit.cmake b/FindLibJsonSpirit.cmake
new file mode 100644
index 0000000..7ee7687
--- /dev/null
+++ b/FindLibJsonSpirit.cmake
@@ -0,0 +1,64 @@
+# FindLibJsonSpirit - Find libjson_spirit headers and libraries.
+#
+# Sample:
+#
+#   SET( LibJsonSpirit_USE_STATIC_LIBS OFF )
+#   FIND_PACKAGE( LibJsonSpirit REQUIRED )
+#   IF( LibJsonSpirit_FOUND )
+#      INCLUDE_DIRECTORIES( ${LibJsonSpirit_INCLUDE_DIRS} )
+#      TARGET_LINK_LIBRARIES( ... ${LibJsonSpirit_LIBRARIES} )
+#   ENDIF()
+#
+# Variables used by this module need to be set before calling find_package
+#
+#   LibJsonSpirit_USE_STATIC_LIBS	Can be set to ON to force the use of the static
+#					libjson_spirit libraries. Defaults to OFF.
+#
+# Variables provided by this module:
+#
+#   LibJsonSpirit_FOUND		Include dir, libjson_spirit libraries.
+#
+#   LibJsonSpirit_LIBRARIES	Link to these to use all the libraries you specified.
+#
+#   LibJsonSpirit_INCLUDE_DIRS	Include directories.
+#
+# For each component you specify in find_package(), the following (UPPER-CASE)
+# variables are set to pick and choose components instead of just using
+# LibJsonSpirit_LIBRARIES:
+#
+#   LIBJSONSPIRIT_FOUND			TRUE if libjson_spirit was found
+#   LIBJSONSPIRIT_LIBRARY		libjson_spirit library
+#
+
+# Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES
+IF(LibJsonSpirit_USE_STATIC_LIBS)
+    SET( _ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
+    SET(CMAKE_FIND_LIBRARY_SUFFIXES .a )
+ENDIF()
+
+# Look for the header files
+UNSET(LibJsonSpirit_INCLUDE_DIRS CACHE)
+FIND_PATH(LibJsonSpirit_INCLUDE_DIRS NAMES json_spirit.h)
+
+# Look for the core library
+UNSET(LIBJSONSPIRIT_LIBRARY CACHE)
+FIND_LIBRARY(LIBJSONSPIRIT_LIBRARY NAMES json_spirit)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibJsonSpirit DEFAULT_MSG LIBJSONSPIRIT_LIBRARY LibJsonSpirit_INCLUDE_DIRS)
+MARK_AS_ADVANCED(
+    LIBJSONSPIRIT_FOUND
+    LIBJSONSPIRIT_LIBRARY
+)
+
+# Prepare return values and collectiong more components
+SET(LibJsonSpirit_FOUND ${LIBJSONSPIRIT_FOUND})
+SET(LibJsonSpirit_LIBRARIES ${LIBJSONSPIRIT_LIBRARY})
+MARK_AS_ADVANCED(
+    LibJsonSpirit_FOUND
+    LibJsonSpirit_LIBRARIES
+    LibJsonSpirit_INCLUDE_DIRS
+)
+
+# Restore CMAKE_FIND_LIBRARY_SUFFIXES
+IF(LibJsonSpirit_USE_STATIC_LIBS)
+    SET(CMAKE_FIND_LIBRARY_SUFFIXES ${_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES} )
+ENDIF()
diff --git a/json_spirit/CMakeLists.txt b/json_spirit/CMakeLists.txt
index fb52818..c1613b2 100644
--- a/json_spirit/CMakeLists.txt
+++ b/json_spirit/CMakeLists.txt
@@ -13,5 +13,19 @@ json_spirit_writer_template.h )
 FIND_PACKAGE(Boost 1.34 REQUIRED)
 INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
 
-ADD_LIBRARY(json_spirit STATIC ${JSON_SPIRIT_SRCS})
+SET(JSONSPIRIT_SOVERSION_MAJOR "4")
+SET(JSONSPIRIT_SOVERSION_MINOR "0")
+SET(JSONSPIRIT_SOVERSION_PATCH "8")
 
+ADD_LIBRARY(json_spirit SHARED ${JSON_SPIRIT_SRCS})
+SET_TARGET_PROPERTIES(json_spirit PROPERTIES PROJECT_LABEL "Json Spirit Library")
+SET_TARGET_PROPERTIES(json_spirit PROPERTIES COMPILE_FLAGS ${CMAKE_SHARED_LIBRARY_C_FLAGS})
+SET_TARGET_PROPERTIES(json_spirit PROPERTIES VERSION ${JSONSPIRIT_SOVERSION_MAJOR}.${JSONSPIRIT_SOVERSION_MINOR}.${JSONSPIRIT_SOVERSION_PATCH})
+SET_TARGET_PROPERTIES(json_spirit PROPERTIES SOVERSION ${JSONSPIRIT_SOVERSION_MAJOR})
+INSTALL(TARGETS json_spirit DESTINATION ${CMAKE_INSTALL_LIBDIR})
+
+ADD_LIBRARY(json_spirit_static STATIC ${JSON_SPIRIT_SRCS})
+SET_TARGET_PROPERTIES(json_spirit_static PROPERTIES PROJECT_LABEL "Json Spirit Static Library")
+SET_TARGET_PROPERTIES(json_spirit_static PROPERTIES OUTPUT_NAME "json_spirit")
+SET_TARGET_PROPERTIES(json_spirit_static PROPERTIES SOVERSION ${JSONSPIRIT_SOVERSION_MAJOR})
+INSTALL(TARGETS json_spirit_static DESTINATION ${CMAKE_INSTALL_LIBDIR})
-- 
1.9.1