1
0

vcpkg-cmake-wrapper.cmake.in 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. cmake_policy(PUSH)
  2. cmake_policy(SET CMP0012 NEW)
  3. cmake_policy(SET CMP0054 NEW)
  4. cmake_policy(SET CMP0057 NEW)
  5. set(OPENSSL_VERSION_MAJOR 3)
  6. set(OPENSSL_VERSION_MINOR 0)
  7. set(OPENSSL_VERSION_FIX 5)
  8. if(OPENSSL_USE_STATIC_LIBS)
  9. if("@VCPKG_LIBRARY_LINKAGE@" STREQUAL "dynamic")
  10. message(WARNING "OPENSSL_USE_STATIC_LIBS is set, but vcpkg port openssl was built with dynamic linkage")
  11. endif()
  12. set(OPENSSL_USE_STATIC_LIBS_BAK "${OPENSSL_USE_STATIC_LIBS}")
  13. set(OPENSSL_USE_STATIC_LIBS FALSE)
  14. endif()
  15. if(DEFINED OPENSSL_ROOT_DIR)
  16. set(OPENSSL_ROOT_DIR_BAK "${OPENSSL_ROOT_DIR}")
  17. endif()
  18. get_filename_component(OPENSSL_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}" DIRECTORY)
  19. get_filename_component(OPENSSL_ROOT_DIR "${OPENSSL_ROOT_DIR}" DIRECTORY)
  20. find_path(OPENSSL_INCLUDE_DIR NAMES openssl/ssl.h PATH "${OPENSSL_ROOT_DIR}/include" NO_DEFAULT_PATH)
  21. if(MSVC)
  22. find_library(LIB_EAY_DEBUG NAMES libcrypto PATHS "${OPENSSL_ROOT_DIR}/debug/lib" NO_DEFAULT_PATH)
  23. find_library(LIB_EAY_RELEASE NAMES libcrypto PATHS "${OPENSSL_ROOT_DIR}/lib" NO_DEFAULT_PATH)
  24. find_library(SSL_EAY_DEBUG NAMES libssl PATHS "${OPENSSL_ROOT_DIR}/debug/lib" NO_DEFAULT_PATH)
  25. find_library(SSL_EAY_RELEASE NAMES libssl PATHS "${OPENSSL_ROOT_DIR}/lib" NO_DEFAULT_PATH)
  26. elseif(WIN32)
  27. find_library(LIB_EAY NAMES libcrypto crypto NAMES_PER_DIR)
  28. find_library(SSL_EAY NAMES libssl ssl NAMES_PER_DIR)
  29. else()
  30. find_library(OPENSSL_CRYPTO_LIBRARY NAMES crypto)
  31. find_library(OPENSSL_SSL_LIBRARY NAMES ssl)
  32. endif()
  33. _find_package(${ARGS})
  34. unset(OPENSSL_ROOT_DIR)
  35. if(DEFINED OPENSSL_ROOT_DIR_BAK)
  36. set(OPENSSL_ROOT_DIR "${OPENSSL_ROOT_DIR_BAK}")
  37. unset(OPENSSL_ROOT_DIR_BAK)
  38. endif()
  39. if(DEFINED OPENSSL_USE_STATIC_LIBS_BAK)
  40. set(OPENSSL_USE_STATIC_LIBS "${OPENSSL_USE_STATIC_LIBS_BAK}")
  41. unset(OPENSSL_USE_STATIC_LIBS_BAK)
  42. endif()
  43. if(OPENSSL_FOUND AND "@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static")
  44. if(WIN32)
  45. list(APPEND OPENSSL_LIBRARIES crypt32 ws2_32)
  46. if(TARGET OpenSSL::Crypto)
  47. set_property(TARGET OpenSSL::Crypto APPEND PROPERTY INTERFACE_LINK_LIBRARIES "crypt32;ws2_32")
  48. endif()
  49. if(TARGET OpenSSL::SSL)
  50. set_property(TARGET OpenSSL::SSL APPEND PROPERTY INTERFACE_LINK_LIBRARIES "crypt32;ws2_32")
  51. endif()
  52. else()
  53. find_library(OPENSSL_DL_LIBRARY NAMES dl)
  54. if(OPENSSL_DL_LIBRARY)
  55. list(APPEND OPENSSL_LIBRARIES "dl")
  56. if(TARGET OpenSSL::Crypto)
  57. set_property(TARGET OpenSSL::Crypto APPEND PROPERTY INTERFACE_LINK_LIBRARIES "dl")
  58. endif()
  59. endif()
  60. if("REQUIRED" IN_LIST ARGS)
  61. find_package(Threads REQUIRED)
  62. else()
  63. find_package(Threads)
  64. endif()
  65. list(APPEND OPENSSL_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
  66. if(TARGET OpenSSL::Crypto)
  67. set_property(TARGET OpenSSL::Crypto APPEND PROPERTY INTERFACE_LINK_LIBRARIES "Threads::Threads")
  68. endif()
  69. if(TARGET OpenSSL::SSL)
  70. set_property(TARGET OpenSSL::SSL APPEND PROPERTY INTERFACE_LINK_LIBRARIES "Threads::Threads")
  71. endif()
  72. endif()
  73. endif()
  74. cmake_policy(POP)