2
0

cmake-pkgconfig-find-deps.patch 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. diff --git a/CMakeLists.txt b/CMakeLists.txt
  2. index 94e4292..7d0e142 100644
  3. --- a/CMakeLists.txt
  4. +++ b/CMakeLists.txt
  5. @@ -169,27 +169,12 @@ endif()
  6. if(MSVC)
  7. - if((NOT CBOR_INCLUDE_DIRS) OR (NOT CBOR_LIBRARY_DIRS) OR
  8. - (NOT CRYPTO_INCLUDE_DIRS) OR (NOT CRYPTO_LIBRARY_DIRS) OR
  9. - (NOT ZLIB_INCLUDE_DIRS) OR (NOT ZLIB_LIBRARY_DIRS))
  10. - message(FATAL_ERROR "please define "
  11. - "{CBOR,CRYPTO,ZLIB}_{INCLUDE,LIBRARY}_DIRS when "
  12. - "building under msvc")
  13. - endif()
  14. - if(BUILD_TESTS AND BUILD_SHARED_LIBS AND
  15. - ((NOT CBOR_BIN_DIRS) OR (NOT ZLIB_BIN_DIRS) OR (NOT CRYPTO_BIN_DIRS)))
  16. - message(FATAL_ERROR "please define {CBOR,CRYPTO,ZLIB}_BIN_DIRS "
  17. - "when building tests")
  18. - endif()
  19. - if(NOT CBOR_LIBRARIES)
  20. - set(CBOR_LIBRARIES cbor)
  21. - endif()
  22. - if(NOT ZLIB_LIBRARIES)
  23. - set(ZLIB_LIBRARIES zlib1)
  24. - endif()
  25. - if(NOT CRYPTO_LIBRARIES)
  26. - set(CRYPTO_LIBRARIES crypto)
  27. - endif()
  28. + include(FindPkgConfig)
  29. + pkg_search_module(libcbor REQUIRED IMPORTED_TARGET libcbor)
  30. + find_package(OpenSSL REQUIRED)
  31. + find_package(ZLIB REQUIRED)
  32. + set(CBOR_LIBRARIES PkgConfig::libcbor)
  33. + set(CRYPTO_LIBRARIES OpenSSL::SSL OpenSSL::Crypto)
  34. set(MSVC_DISABLED_WARNINGS_LIST
  35. "C4152" # nonstandard extension used: function/data pointer
  36. @@ -218,26 +203,22 @@ if(MSVC)
  37. set(NFC_LINUX OFF)
  38. else()
  39. include(FindPkgConfig)
  40. - pkg_search_module(CBOR libcbor)
  41. - pkg_search_module(CRYPTO libcrypto)
  42. - pkg_search_module(ZLIB zlib)
  43. + pkg_search_module(libcbor REQUIRED IMPORTED_TARGET libcbor)
  44. + find_package(OpenSSL REQUIRED)
  45. + find_package(ZLIB REQUIRED)
  46. if(NOT CBOR_FOUND AND NOT HAVE_CBOR_H)
  47. - message(FATAL_ERROR "could not find libcbor")
  48. + # message(FATAL_ERROR "could not find libcbor")
  49. endif()
  50. if(NOT CRYPTO_FOUND AND NOT HAVE_OPENSSLV_H)
  51. - message(FATAL_ERROR "could not find libcrypto")
  52. + # message(FATAL_ERROR "could not find libcrypto")
  53. endif()
  54. if(NOT ZLIB_FOUND)
  55. message(FATAL_ERROR "could not find zlib")
  56. endif()
  57. - if(NOT CBOR_LIBRARIES)
  58. - set(CBOR_LIBRARIES "cbor")
  59. - endif()
  60. - if(NOT CRYPTO_LIBRARIES)
  61. - set(CRYPTO_LIBRARIES "crypto")
  62. - endif()
  63. + set(CBOR_LIBRARIES PkgConfig::libcbor)
  64. + set(CRYPTO_LIBRARIES OpenSSL::SSL OpenSSL::Crypto)
  65. if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
  66. pkg_search_module(UDEV libudev REQUIRED)
  67. @@ -277,8 +258,8 @@ else()
  68. if(USE_HIDAPI)
  69. add_definitions(-DUSE_HIDAPI)
  70. - pkg_search_module(HIDAPI hidapi${HIDAPI_SUFFIX} REQUIRED)
  71. - set(HIDAPI_LIBRARIES hidapi${HIDAPI_SUFFIX})
  72. + pkg_search_module(hidapi REQUIRED IMPORTED_TARGET hidapi)
  73. + set(HIDAPI_LIBRARIES PkgConfig::hidapi)
  74. endif()
  75. if(NFC_LINUX)