FindQCA.cmake 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. # Find QCA (Qt Cryptography Architecture 2+)
  2. # ~~~~~~~~~~~~~~~~
  3. # When run this will define
  4. #
  5. # QCA_FOUND - system has QCA
  6. # QCA_LIBRARY - the QCA library or framework
  7. # QCA_INCLUDE_DIR - the QCA include directory
  8. # QCA_VERSION_STR - e.g. "2.0.3"
  9. #
  10. # Copyright (c) 2006, Michael Larouche, <michael.larouche@kdemail.net>
  11. # Copyright (c) 2014, Larry Shaffer, <larrys (at) dakotacarto (dot) com>
  12. #
  13. # Redistribution and use is allowed according to the terms of the BSD license.
  14. # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
  15. if(ANDROID)
  16. set(QCA_INCLUDE_DIR ${OSGEO4A_STAGE_DIR}/${ANDROID_ABI}/include/Qca-qt5/QtCrypto CACHE PATH "")
  17. set(QCA_LIBRARY ${OSGEO4A_STAGE_DIR}/${ANDROID_ABI}/lib/libqca-qt5_${ANDROID_ABI}.so CACHE PATH "")
  18. set(QCA_FOUND TRUE)
  19. else()
  20. if(QCA_INCLUDE_DIR AND QCA_LIBRARY)
  21. set(QCA_FOUND TRUE)
  22. else(QCA_INCLUDE_DIR AND QCA_LIBRARY)
  23. set(QCA_LIBRARY_NAMES qca-qt5 qca2-qt5 qca-qt6 qca qca-qt5_${ANDROID_ABI})
  24. find_library(QCA_LIBRARY
  25. NAMES ${QCA_LIBRARY_NAMES}
  26. PATHS
  27. ${LIB_DIR}
  28. $ENV{LIB}
  29. "$ENV{LIB_DIR}"
  30. $ENV{LIB_DIR}/lib
  31. /usr/local/lib
  32. ${OSGEO4A_STAGE_DIR}/${ANDROID_ABI}/lib
  33. )
  34. set(_qca_fw)
  35. if(QCA_LIBRARY MATCHES "/qca.*\\.framework")
  36. string(REGEX REPLACE "^(.*/qca.*\\.framework).*$" "\\1" _qca_fw "${QCA_LIBRARY}")
  37. endif()
  38. find_path(QCA_INCLUDE_DIR
  39. NAMES QtCrypto
  40. PATHS
  41. "${_qca_fw}/Headers"
  42. ${LIB_DIR}/include
  43. "$ENV{LIB_DIR}/include"
  44. $ENV{INCLUDE}
  45. /usr/local/include
  46. ${OSGEO4A_STAGE_DIR}/${ANDROID_ABI}/include
  47. PATH_SUFFIXES QtCrypto qt5/QtCrypto Qca-qt5/QtCrypto qt/Qca-qt5/QtCrypto qt5/Qca-qt5/QtCrypto Qca-qt6/QtCrypto
  48. )
  49. if(QCA_LIBRARY AND QCA_INCLUDE_DIR)
  50. set(QCA_FOUND TRUE)
  51. endif()
  52. endif(QCA_INCLUDE_DIR AND QCA_LIBRARY)
  53. endif()
  54. if(NOT QCA_FOUND)
  55. if(QCA_FIND_REQUIRED)
  56. message(FATAL_ERROR "Could not find QCA")
  57. else()
  58. message(STATUS "Could not find QCA")
  59. endif()
  60. else(NOT QCA_FOUND)
  61. # Check version is valid (>= 2.0.3)
  62. # find_package(QCA 2.0.3) works with 2.1.0+, which has a QcaConfigVersion.cmake, but 2.0.3 does not
  63. # qca_version.h header only available with 2.1.0+
  64. set(_qca_version_h "${QCA_INCLUDE_DIR}/qca_version.h")
  65. if(EXISTS "${_qca_version_h}")
  66. file(STRINGS "${_qca_version_h}" _qca_version_str REGEX "^.*QCA_VERSION_STR +\"[^\"]+\".*$")
  67. string(REGEX REPLACE "^.*QCA_VERSION_STR +\"([^\"]+)\".*$" "\\1" QCA_VERSION_STR "${_qca_version_str}")
  68. else()
  69. # qca_core.h contains hexadecimal version in <= 2.0.3
  70. set(_qca_core_h "${QCA_INCLUDE_DIR}/qca_core.h")
  71. if(EXISTS "${_qca_core_h}")
  72. file(STRINGS "${_qca_core_h}" _qca_version_str REGEX "^#define +QCA_VERSION +0x[0-9a-fA-F]+.*")
  73. string(REGEX REPLACE "^#define +QCA_VERSION +0x([0-9a-fA-F]+)$" "\\1" _qca_version_int "${_qca_version_str}")
  74. if("${_qca_version_int}" STREQUAL "020003")
  75. set(QCA_VERSION_STR "2.0.3")
  76. endif()
  77. endif()
  78. endif()
  79. if(NOT QCA_VERSION_STR)
  80. set(QCA_FOUND FALSE)
  81. if(QCA_FIND_REQUIRED)
  82. message(FATAL_ERROR "Could not find QCA >= 2.0.3")
  83. else()
  84. message(STATUS "Could not find QCA >= 2.0.3")
  85. endif()
  86. else()
  87. if(NOT QCA_FIND_QUIETLY)
  88. message(STATUS "Found QCA: ${QCA_LIBRARY} (${QCA_VERSION_STR})")
  89. endif()
  90. endif()
  91. endif(NOT QCA_FOUND)