FindLibKS.cmake 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # LIBKS_FOUND
  2. # LIBKS_LIBRARIES
  3. # LIBKS_LIBRARY_DIRS
  4. # LIBKS_LDFLAGS
  5. # LIBKS_INCLUDE_DIRS
  6. # LIBKS_CFLAGS
  7. # LIBKS_CMAKE_DIR
  8. if (NOT TARGET ks)
  9. if (NOT WIN32)
  10. include(FindPkgConfig)
  11. # Use the pkg-config system to locate our libks configs
  12. pkg_check_modules(LIBKS libks REQUIRED)
  13. else()
  14. if ("${LIBKS_INCLUDE_DIRS}" STREQUAL "")
  15. message(FATAL_ERROR "Can't find Libks. Try setting LIBKS_INCLUDE_DIRS.")
  16. endif()
  17. endif()
  18. # From here we can bootstrap into cmake stuff
  19. set(LIBKS_CMAKE_DIR ${LIBKS_INCLUDE_DIRS}/cmake)
  20. # Load ks utils for our build macros
  21. include(${LIBKS_CMAKE_DIR}/ksutil.cmake)
  22. # Now load the package with a hint on where to look
  23. set(LibKS_DIR ${LIBKS_CMAKE_DIR})
  24. if (NOT WIN32)
  25. find_package(LibKS REQUIRED VERSION)
  26. else()
  27. if(LIBKS_INCLUDE_DIRS AND EXISTS "${LIBKS_INCLUDE_DIRS}/CMakeLists.txt")
  28. file(STRINGS "${LIBKS_INCLUDE_DIRS}/CMakeLists.txt" libks_version_str
  29. REGEX "^[\t ]*project[\t (]*LibKS[\t ]+VERSION[\t ]+([0-9a-fA-F]\.[0-9a-fA-F]).*")
  30. string(COMPARE EQUAL "${libks_version_str}" "" _is_empty)
  31. if(_is_empty)
  32. message(
  33. FATAL_ERROR
  34. "Incorrect LibKS VERSION in project command of LibKS's CMakeLists.txt"
  35. ": ${LIBKS_INCLUDE_DIRS}/CMakeLists.txt")
  36. endif()
  37. string(REGEX REPLACE "^[\t ]*project[\t (]*LibKS[\t ]+VERSION[\t ]+([0-9a-fA-F]\.[0-9a-fA-F]).*$"
  38. "\\1;" LIBKS_VERSION_LIST "${libks_version_str}")
  39. list(GET LIBKS_VERSION_LIST 0 LIBKS_VERSION)
  40. endif()
  41. endif()
  42. message("Found LibKS ${LIBKS_VERSION} package at path ${LIBKS_INCLUDE_DIRS}")
  43. if (${LIBKS_VERSION} VERSION_LESS 2.0)
  44. message(FATAL "Libks version 2.0 or greater is required")
  45. endif()
  46. else()
  47. get_target_property(KS_SOURCE_DIR ks SOURCE_DIR)
  48. message("Switchblade ${KS_SOURCE_DIR}")
  49. set(LIBKS_CMAKE_DIR ${KS_SOURCE_DIR}/cmake)
  50. # Load ks utils for our build macros
  51. include(${LIBKS_CMAKE_DIR}/ksutil.cmake)
  52. endif()
  53. # Let ks define some fundamentals across all cmake setups
  54. ksutil_setup_platform()
  55. # We'll need to load openssl as well
  56. if (KS_PLAT_MAC)
  57. set(OPENSSL_ROOT_DIR /usr/local/opt/openssl)
  58. endif()
  59. if (WIN32)
  60. include(FindOpenSSL)
  61. endif()
  62. find_package(OpenSSL REQUIRED Crypto SSL)