0004-Link-libyajl-_s-with-libm-when-isnan-is-not-brought-.patch 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. From b47f6a50925efb8c8707b1faed5561a4b66ffdb1 Mon Sep 17 00:00:00 2001
  2. From: Samuel Martin <s.martin49@gmail.com>
  3. Date: Sun, 24 Apr 2016 18:45:27 +0200
  4. Subject: [PATCH] Link libyajl{,_s} with libm when isnan is not brought by the
  5. libc
  6. Check whether isnan is provided by the libc library, otherwise make sure
  7. yajl libraries are link against libm.
  8. Note that setting libm as PUBLIC link libraries enable the transitivity
  9. [1, 2]; therefore it will be automatically passed to target linking
  10. against libyajl{,_s}.
  11. This patch also makes sure the link libraries will appear in the yajl.pc
  12. file.
  13. [1] https://cmake.org/cmake/help/v3.5/command/target_link_libraries.html
  14. [2] https://cmake.org/cmake/help/v3.5/manual/cmake-buildsystem.7.html#target-usage-requirements
  15. Signed-off-by: Samuel Martin <s.martin49@gmail.com>
  16. ---
  17. src/CMakeLists.txt | 10 ++++++++++
  18. src/yajl.pc.cmake | 2 +-
  19. 2 files changed, 11 insertions(+), 1 deletion(-)
  20. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
  21. index b487bfd..a88698f 100644
  22. --- a/src/CMakeLists.txt
  23. +++ b/src/CMakeLists.txt
  24. @@ -35,11 +35,21 @@ SET (shareDir ${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/share/pkgconfig)
  25. # set the output path for libraries
  26. SET(LIBRARY_OUTPUT_PATH ${libDir})
  27. +SET(yajl_lib_link)
  28. +INCLUDE(CheckLibraryExists)
  29. +CHECK_LIBRARY_EXISTS(c isnan "" HAVE_LIBC_ISNAN)
  30. +
  31. +IF(NOT HAVE_LIBC_ISNAN)
  32. + LIST(APPEND yajl_lib_link "-lm")
  33. +ENDIF(NOT HAVE_LIBC_ISNAN)
  34. +
  35. ADD_LIBRARY(yajl_s STATIC ${SRCS} ${HDRS} ${PUB_HDRS})
  36. SET_TARGET_PROPERTIES(yajl_s PROPERTIES OUTPUT_NAME yajl)
  37. +TARGET_LINK_LIBRARIES(yajl_s PUBLIC ${yajl_lib_link})
  38. IF(BUILD_SHARED_LIBS)
  39. ADD_LIBRARY(yajl SHARED ${SRCS} ${HDRS} ${PUB_HDRS})
  40. +TARGET_LINK_LIBRARIES(yajl PUBLIC ${yajl_lib_link})
  41. #### setup shared library version number
  42. SET_TARGET_PROPERTIES(yajl PROPERTIES
  43. diff --git a/src/yajl.pc.cmake b/src/yajl.pc.cmake
  44. index 6eaca14..4681dd4 100644
  45. --- a/src/yajl.pc.cmake
  46. +++ b/src/yajl.pc.cmake
  47. @@ -6,4 +6,4 @@ Name: Yet Another JSON Library
  48. Description: A Portable JSON parsing and serialization library in ANSI C
  49. Version: ${YAJL_MAJOR}.${YAJL_MINOR}.${YAJL_MICRO}
  50. Cflags: -I${dollar}{includedir}
  51. -Libs: -L${dollar}{libdir} -lyajl
  52. +Libs: -L${dollar}{libdir} -lyajl ${yajl_lib_link}
  53. --
  54. 2.8.0