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
|
From 425b25993ef58d07aa18c5d4938876a90e22c47a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6rg=20Krause?= <joerg.krause@embedded.rocks>
Date: Sat, 9 Apr 2016 23:24:27 +0200
Subject: [PATCH] Link with shared libyajl in a shared build
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Building yajl in a static context fails in a parallel build:
[ 21%] Linking C executable gen-extra-close
[ 26%] Building C object src/CMakeFiles/yajl_s.dir/yajl_buf.c.o
/home/test/autobuild/instance-3/output/host/opt/ext-toolchain/bfin-uclinux/bfin-uclinux/bin/ld.real: cannot find -lyajl
Fix this issue by linking against the shared libyail in a shared build. Apply
this fix also to all other build targets who are linking against the library.
Upstream status: Pending
https://github.com/lloyd/yajl/pull/187
[Update: align with commit 302563539dacb284576a443401cdfd061eb2e1e8 and remove
linking with libm from test/api/CMakeLists.txt]
Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
---
example/CMakeLists.txt | 7 ++++++-
perf/CMakeLists.txt | 6 +++++-
reformatter/CMakeLists.txt | 6 +++++-
test/api/CMakeLists.txt | 6 +++++-
test/parsing/CMakeLists.txt | 6 +++++-
verify/CMakeLists.txt | 6 +++++-
6 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt
index 0a7f622..8cfcef8 100644
--- a/example/CMakeLists.txt
+++ b/example/CMakeLists.txt
@@ -20,4 +20,9 @@ LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/lib)
ADD_EXECUTABLE(parse_config ${SRCS})
-TARGET_LINK_LIBRARIES(parse_config yajl_s)
+IF(BUILD_SHARED_LIBS)
+ TARGET_LINK_LIBRARIES(parse_config yajl)
+ELSE()
+ TARGET_LINK_LIBRARIES(parse_config yajl_s)
+ENDIF()
+
diff --git a/perf/CMakeLists.txt b/perf/CMakeLists.txt
index b438d7a..40ba363 100644
--- a/perf/CMakeLists.txt
+++ b/perf/CMakeLists.txt
@@ -20,4 +20,8 @@ LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/lib)
ADD_EXECUTABLE(perftest ${SRCS})
-TARGET_LINK_LIBRARIES(perftest yajl_s)
+IF(BUILD_SHARED_LIBS)
+ TARGET_LINK_LIBRARIES(perftest yajl)
+ELSE()
+ TARGET_LINK_LIBRARIES(perftest yajl_s)
+ENDIF()
diff --git a/reformatter/CMakeLists.txt b/reformatter/CMakeLists.txt
index 52a9bee..7629094 100644
--- a/reformatter/CMakeLists.txt
+++ b/reformatter/CMakeLists.txt
@@ -26,7 +26,11 @@ LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/lib)
ADD_EXECUTABLE(json_reformat ${SRCS})
-TARGET_LINK_LIBRARIES(json_reformat yajl_s)
+IF(BUILD_SHARED_LIBS)
+ TARGET_LINK_LIBRARIES(json_reformat yajl)
+ELSE()
+ TARGET_LINK_LIBRARIES(json_reformat yajl_s)
+ENDIF()
# In some environments, we must explicitly link libm (like qnx,
# thanks @shahbag)
diff --git a/test/api/CMakeLists.txt b/test/api/CMakeLists.txt
index cd65a54..0c9debf 100644
--- a/test/api/CMakeLists.txt
+++ b/test/api/CMakeLists.txt
@@ -21,5 +21,9 @@ LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../../${YAJL_DIST_NAME}/lib)
FOREACH (test ${TESTS})
GET_FILENAME_COMPONENT(testProg ${test} NAME_WE)
ADD_EXECUTABLE(${testProg} ${test})
- TARGET_LINK_LIBRARIES(${testProg} yajl)
+ IF(BUILD_SHARED_LIBS)
+ TARGET_LINK_LIBRARIES(${testProg} yajl)
+ ELSE()
+ TARGET_LINK_LIBRARIES(${testProg} yajl_s)
+ ENDIF()
ENDFOREACH()
diff --git a/test/parsing/CMakeLists.txt b/test/parsing/CMakeLists.txt
index c22a388..285f048 100644
--- a/test/parsing/CMakeLists.txt
+++ b/test/parsing/CMakeLists.txt
@@ -20,4 +20,8 @@ LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../../${YAJL_DIST_NAME}/lib)
ADD_EXECUTABLE(yajl_test ${SRCS})
-TARGET_LINK_LIBRARIES(yajl_test yajl_s)
+IF(BUILD_SHARED_LIBS)
+ TARGET_LINK_LIBRARIES(yajl_test yajl)
+ELSE()
+ TARGET_LINK_LIBRARIES(yajl_test yajl_s)
+ENDIF()
diff --git a/verify/CMakeLists.txt b/verify/CMakeLists.txt
index 967fca1..06cb2dc 100644
--- a/verify/CMakeLists.txt
+++ b/verify/CMakeLists.txt
@@ -26,7 +26,11 @@ LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/lib)
ADD_EXECUTABLE(json_verify ${SRCS})
-TARGET_LINK_LIBRARIES(json_verify yajl_s)
+IF(BUILD_SHARED_LIBS)
+ TARGET_LINK_LIBRARIES(json_verify yajl)
+ELSE()
+ TARGET_LINK_LIBRARIES(json_verify yajl_s)
+ENDIF()
# copy in the binary
GET_TARGET_PROPERTY(binPath json_verify LOCATION)
--
2.8.0
|