0001-cmake-FindLibMagic.cmake-fix-static-linking.patch 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. From 64f49c6131f4112e5efd8b69094235f13882ccf5 Mon Sep 17 00:00:00 2001
  2. From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  3. Date: Fri, 31 Jan 2020 17:14:11 +0100
  4. Subject: [PATCH] cmake/FindLibMagic.cmake: fix static linking
  5. libmagic can optionally depends on xz (for lzma) or bzip2 since version
  6. 5.38 and
  7. https://github.com/file/file/commit/b259a07ea95827f565faa20f0316e5b2704064f7
  8. so use pkg-config to retrieve those static dependencies and avoid the
  9. following build failure:
  10. [100%] Linking CXX executable gerbera
  11. /home/br-user/autobuild/run/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/arm-buildroot-linux-uclibcgnueabi/8.3.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: /home/br-user/autobuild/run/instance-0/output-1/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib/libmagic.a(compress.o): in function `uncompressbuf':
  12. compress.c:(.text+0x69c): undefined reference to `BZ2_bzDecompressInit'
  13. /home/br-user/autobuild/run/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/arm-buildroot-linux-uclibcgnueabi/8.3.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: compress.c:(.text+0x710): undefined reference to `BZ2_bzDecompress'
  14. /home/br-user/autobuild/run/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/arm-buildroot-linux-uclibcgnueabi/8.3.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: compress.c:(.text+0x730): undefined reference to `BZ2_bzDecompressEnd'
  15. /home/br-user/autobuild/run/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/arm-buildroot-linux-uclibcgnueabi/8.3.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: compress.c:(.text+0x7bc): undefined reference to `lzma_auto_decoder'
  16. /home/br-user/autobuild/run/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/arm-buildroot-linux-uclibcgnueabi/8.3.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: compress.c:(.text+0x828): undefined reference to `lzma_code'
  17. /home/br-user/autobuild/run/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/arm-buildroot-linux-uclibcgnueabi/8.3.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: compress.c:(.text+0x848): undefined reference to `lzma_end'
  18. Fixes:
  19. - http://autobuild.buildroot.org/results/37b1ef54dc41100689f311fbc31fc9300dc6ae63
  20. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  21. ---
  22. cmake/FindLibMagic.cmake | 15 +++++++++++++--
  23. 1 file changed, 13 insertions(+), 2 deletions(-)
  24. diff --git a/cmake/FindLibMagic.cmake b/cmake/FindLibMagic.cmake
  25. index f68ab923..04995af4 100644
  26. --- a/cmake/FindLibMagic.cmake
  27. +++ b/cmake/FindLibMagic.cmake
  28. @@ -1,11 +1,22 @@
  29. INCLUDE (FindPackageHandleStandardArgs)
  30. -FIND_PATH(MAGIC_INCLUDE_DIR magic.h)
  31. -FIND_LIBRARY(MAGIC_LIBRARIES NAMES magic)
  32. +find_package(PkgConfig QUIET)
  33. +
  34. +pkg_check_modules(PC_MAGIC QUIET libmagic)
  35. +
  36. +FIND_PATH(MAGIC_INCLUDE_DIR magic.h
  37. + HINTS ${PC_MAGIC_INCLUDEDIR} ${PC_MAGIC_INCLUDE_DIRS})
  38. +FIND_LIBRARY(MAGIC_LIBRARIES NAMES magic
  39. + HINTS ${PC_MAGIC_LIBDIR} ${PC_MAGIC_LIBRARY_DIRS})
  40. # handle the QUIETLY and REQUIRED arguments and set MAGIC_FOUND to TRUE
  41. find_package_handle_standard_args(MAGIC DEFAULT_MSG MAGIC_LIBRARIES)
  42. +if (MAGIC_FOUND)
  43. + set (MAGIC_LIBRARIES ${MAGIC_LIBRARY} ${PC_MAGIC_LIBRARIES})
  44. + set (MAGIC_INCLUDE_DIRS ${MAGIC_INCLUDE_DIR} )
  45. +endif ()
  46. +
  47. MARK_AS_ADVANCED(
  48. MAGIC_LIBRARIES
  49. MAGIC_INCLUDE_DIRS )
  50. --
  51. 2.24.1