0003-Link-with-shared-libyajl-in-a-shared-build.patch 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. From 425b25993ef58d07aa18c5d4938876a90e22c47a Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?J=C3=B6rg=20Krause?= <joerg.krause@embedded.rocks>
  3. Date: Sat, 9 Apr 2016 23:24:27 +0200
  4. Subject: [PATCH] Link with shared libyajl in a shared build
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. Building yajl in a static context fails in a parallel build:
  9. [ 21%] Linking C executable gen-extra-close
  10. [ 26%] Building C object src/CMakeFiles/yajl_s.dir/yajl_buf.c.o
  11. /home/test/autobuild/instance-3/output/host/opt/ext-toolchain/bfin-uclinux/bfin-uclinux/bin/ld.real: cannot find -lyajl
  12. Fix this issue by linking against the shared libyail in a shared build. Apply
  13. this fix also to all other build targets who are linking against the library.
  14. Upstream status: Pending
  15. https://github.com/lloyd/yajl/pull/187
  16. [Update: align with commit 302563539dacb284576a443401cdfd061eb2e1e8 and remove
  17. linking with libm from test/api/CMakeLists.txt]
  18. Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
  19. ---
  20. example/CMakeLists.txt | 7 ++++++-
  21. perf/CMakeLists.txt | 6 +++++-
  22. reformatter/CMakeLists.txt | 6 +++++-
  23. test/api/CMakeLists.txt | 6 +++++-
  24. test/parsing/CMakeLists.txt | 6 +++++-
  25. verify/CMakeLists.txt | 6 +++++-
  26. 6 files changed, 31 insertions(+), 6 deletions(-)
  27. diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt
  28. index 0a7f622..8cfcef8 100644
  29. --- a/example/CMakeLists.txt
  30. +++ b/example/CMakeLists.txt
  31. @@ -20,4 +20,9 @@ LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/lib)
  32. ADD_EXECUTABLE(parse_config ${SRCS})
  33. -TARGET_LINK_LIBRARIES(parse_config yajl_s)
  34. +IF(BUILD_SHARED_LIBS)
  35. + TARGET_LINK_LIBRARIES(parse_config yajl)
  36. +ELSE()
  37. + TARGET_LINK_LIBRARIES(parse_config yajl_s)
  38. +ENDIF()
  39. +
  40. diff --git a/perf/CMakeLists.txt b/perf/CMakeLists.txt
  41. index b438d7a..40ba363 100644
  42. --- a/perf/CMakeLists.txt
  43. +++ b/perf/CMakeLists.txt
  44. @@ -20,4 +20,8 @@ LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/lib)
  45. ADD_EXECUTABLE(perftest ${SRCS})
  46. -TARGET_LINK_LIBRARIES(perftest yajl_s)
  47. +IF(BUILD_SHARED_LIBS)
  48. + TARGET_LINK_LIBRARIES(perftest yajl)
  49. +ELSE()
  50. + TARGET_LINK_LIBRARIES(perftest yajl_s)
  51. +ENDIF()
  52. diff --git a/reformatter/CMakeLists.txt b/reformatter/CMakeLists.txt
  53. index 52a9bee..7629094 100644
  54. --- a/reformatter/CMakeLists.txt
  55. +++ b/reformatter/CMakeLists.txt
  56. @@ -26,7 +26,11 @@ LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/lib)
  57. ADD_EXECUTABLE(json_reformat ${SRCS})
  58. -TARGET_LINK_LIBRARIES(json_reformat yajl_s)
  59. +IF(BUILD_SHARED_LIBS)
  60. + TARGET_LINK_LIBRARIES(json_reformat yajl)
  61. +ELSE()
  62. + TARGET_LINK_LIBRARIES(json_reformat yajl_s)
  63. +ENDIF()
  64. # In some environments, we must explicitly link libm (like qnx,
  65. # thanks @shahbag)
  66. diff --git a/test/api/CMakeLists.txt b/test/api/CMakeLists.txt
  67. index cd65a54..0c9debf 100644
  68. --- a/test/api/CMakeLists.txt
  69. +++ b/test/api/CMakeLists.txt
  70. @@ -21,5 +21,9 @@ LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../../${YAJL_DIST_NAME}/lib)
  71. FOREACH (test ${TESTS})
  72. GET_FILENAME_COMPONENT(testProg ${test} NAME_WE)
  73. ADD_EXECUTABLE(${testProg} ${test})
  74. - TARGET_LINK_LIBRARIES(${testProg} yajl)
  75. + IF(BUILD_SHARED_LIBS)
  76. + TARGET_LINK_LIBRARIES(${testProg} yajl)
  77. + ELSE()
  78. + TARGET_LINK_LIBRARIES(${testProg} yajl_s)
  79. + ENDIF()
  80. ENDFOREACH()
  81. diff --git a/test/parsing/CMakeLists.txt b/test/parsing/CMakeLists.txt
  82. index c22a388..285f048 100644
  83. --- a/test/parsing/CMakeLists.txt
  84. +++ b/test/parsing/CMakeLists.txt
  85. @@ -20,4 +20,8 @@ LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../../${YAJL_DIST_NAME}/lib)
  86. ADD_EXECUTABLE(yajl_test ${SRCS})
  87. -TARGET_LINK_LIBRARIES(yajl_test yajl_s)
  88. +IF(BUILD_SHARED_LIBS)
  89. + TARGET_LINK_LIBRARIES(yajl_test yajl)
  90. +ELSE()
  91. + TARGET_LINK_LIBRARIES(yajl_test yajl_s)
  92. +ENDIF()
  93. diff --git a/verify/CMakeLists.txt b/verify/CMakeLists.txt
  94. index 967fca1..06cb2dc 100644
  95. --- a/verify/CMakeLists.txt
  96. +++ b/verify/CMakeLists.txt
  97. @@ -26,7 +26,11 @@ LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/lib)
  98. ADD_EXECUTABLE(json_verify ${SRCS})
  99. -TARGET_LINK_LIBRARIES(json_verify yajl_s)
  100. +IF(BUILD_SHARED_LIBS)
  101. + TARGET_LINK_LIBRARIES(json_verify yajl)
  102. +ELSE()
  103. + TARGET_LINK_LIBRARIES(json_verify yajl_s)
  104. +ENDIF()
  105. # copy in the binary
  106. GET_TARGET_PROPERTY(binPath json_verify LOCATION)
  107. --
  108. 2.8.0