FindBotan.cmake 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # - Find botan
  2. # Find the botan cryptographic library
  3. #
  4. # This module defines the following variables:
  5. # BOTAN_FOUND - True if library and include directory are found
  6. # If set to TRUE, the following are also defined:
  7. # BOTAN_INCLUDE_DIRS - The directory where to find the header file
  8. # BOTAN_LIBRARIES - Where to find the library files
  9. #
  10. # This file is in the public domain (https://github.com/vistle/vistle/blob/master/cmake/Modules/FindBOTAN.cmake)
  11. include(FindPackageHandleStandardArgs)
  12. set(BOTAN_VERSIONS botan-3 botan-2)
  13. set(BOTAN_NAMES botan-3 botan-2 botan)
  14. set(BOTAN_NAMES_DEBUG botand-3 botand-2 botand botan botan-3)
  15. find_path(
  16. BOTAN_INCLUDE_DIR
  17. NAMES botan/build.h
  18. PATH_SUFFIXES ${BOTAN_VERSIONS}
  19. DOC "The Botan include directory")
  20. if(BOTAN_INCLUDE_DIR)
  21. file(READ "${BOTAN_INCLUDE_DIR}/botan/build.h" build)
  22. string(REGEX MATCH "BOTAN_VERSION_MAJOR ([0-9]*)" _ ${build})
  23. set(BOTAN_VERSION_MAJOR ${CMAKE_MATCH_1})
  24. string(REGEX MATCH "BOTAN_VERSION_MINOR ([0-9]*)" _ ${build})
  25. set(BOTAN_VERSION_MINOR ${CMAKE_MATCH_1})
  26. string(REGEX MATCH "BOTAN_VERSION_PATCH ([0-9]*)" _ ${build})
  27. set(BOTAN_VERSION_PATCH ${CMAKE_MATCH_1})
  28. set(BOTAN_VERSION "${BOTAN_VERSION_MAJOR}.${BOTAN_VERSION_MINOR}.${BOTAN_VERSION_PATCH}")
  29. endif()
  30. find_library(
  31. BOTAN_LIBRARY
  32. NAMES ${BOTAN_NAMES}
  33. PATH_SUFFIXES release/lib lib
  34. DOC "The Botan (release) library")
  35. if(MSVC)
  36. find_library(
  37. BOTAN_LIBRARY_DEBUG
  38. NAMES ${BOTAN_NAMES_DEBUG}
  39. PATH_SUFFIXES debug/lib lib
  40. DOC "The Botan debug library")
  41. find_package_handle_standard_args(
  42. Botan
  43. REQUIRED_VARS BOTAN_LIBRARY BOTAN_LIBRARY_DEBUG BOTAN_INCLUDE_DIR
  44. VERSION_VAR BOTAN_VERSION)
  45. else()
  46. find_package_handle_standard_args(
  47. Botan
  48. REQUIRED_VARS BOTAN_LIBRARY BOTAN_INCLUDE_DIR
  49. VERSION_VAR BOTAN_VERSION)
  50. endif()
  51. if(BOTAN_FOUND)
  52. set(BOTAN_INCLUDE_DIRS ${BOTAN_INCLUDE_DIR})
  53. if(MSVC)
  54. set(BOTAN_LIBRARIES optimized ${BOTAN_LIBRARY} debug ${BOTAN_LIBRARY_DEBUG})
  55. else()
  56. set(BOTAN_LIBRARIES ${BOTAN_LIBRARY})
  57. endif()
  58. endif()
  59. mark_as_advanced(BOTAN_INCLUDE_DIR BOTAN_LIBRARY BOTAN_LIBRARY_DEBUG)