0001-CMakeLists.txt-use-pkg-config-to-detect-openssl-when.patch 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. From b860de9e207d8fe2ea37dad28fdd014493d87703 Mon Sep 17 00:00:00 2001
  2. From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  3. Date: Tue, 27 Dec 2022 16:29:16 +0100
  4. Subject: [PATCH] build: Fix CMake to use pkg-config openssl when possible
  5. (#2290)
  6. In order to take into account the libraries used by openssl when
  7. building statically, using pkg-config is recommended. This patch
  8. therefore improves the CMakeLists.txt to use pkg-config to detect
  9. openssl when pkg-config is available. This will avoid
  10. static build failure when openssl needs to link with -latomic.
  11. Fixes:
  12. - http://autobuild.buildroot.org/results/417c86963ffe038aa052ea3cf19fd52c3e9b7396
  13. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  14. [Retrieved from:
  15. https://github.com/merbanan/rtl_433/commit/b860de9e207d8fe2ea37dad28fdd014493d87703]
  16. ---
  17. CMakeLists.txt | 9 ++++++++-
  18. 1 file changed, 8 insertions(+), 1 deletion(-)
  19. diff --git a/CMakeLists.txt b/CMakeLists.txt
  20. index d47a3eda2..cf30d8be2 100644
  21. --- a/CMakeLists.txt
  22. +++ b/CMakeLists.txt
  23. @@ -175,7 +175,14 @@ set(ENABLE_OPENSSL AUTO CACHE STRING "Enable OpenSSL TLS support")
  24. set_property(CACHE ENABLE_OPENSSL PROPERTY STRINGS AUTO ON OFF)
  25. if(ENABLE_OPENSSL) # AUTO / ON
  26. -find_package(OpenSSL)
  27. +find_package(PkgConfig)
  28. +if(PKG_CONFIG_FOUND)
  29. + pkg_check_modules(OPENSSL openssl)
  30. + set(OPENSSL_LIBRARIES ${OPENSSL_LINK_LIBRARIES})
  31. + set(OPENSSL_INCLUDE_DIR ${OPENSSL_INCLUDE_DIRS})
  32. +else()
  33. + find_package(OpenSSL)
  34. +endif()
  35. if(OPENSSL_FOUND)
  36. message(STATUS "OpenSSL TLS support will be compiled. Found version ${OPENSSL_VERSION}")
  37. include_directories(${OPENSSL_INCLUDE_DIR})