You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

137 lines
3.8 KiB

1 year ago
  1. # Find the Vision Labs Liveness SDK & Face SDK.
  2. # Sets the usual variables expected for find_package scripts:
  3. # LSDK_INCLUDE_DIRS - headers location
  4. # LSDK_LIBRARIES - libraries to link against
  5. # LSDK_FOUND - true if Liveness SDK was found.
  6. # This is the directory where the Liveness SDK is located.
  7. # By default LSDKDIR environment variable value is taken.
  8. find_package(FaceEngineSDK REQUIRED)
  9. set(LSDK_ROOT "$ENV{LSDKDIR}" CACHE PATH "Vision Labs Liveness SDK root directory.")
  10. # Look for headers.
  11. find_path(LSDK_INCLUDE_DIRS
  12. NAMES lsdk/LivenessEngine.h lsdk/ILiveness.h
  13. HINTS $ENV{LSDKDIR}
  14. PATHS ${LSDK_ROOT}
  15. PATH_SUFFIXES include)
  16. # iOS framework have different header structure: not flower/header.h, but Headers/header.h. But when you link against framework it's name is used as prefix for includes, so you still use its includes as flower/header.h in c++ code.
  17. # Now the reason to set this variable is that its used for every other platform and its easier to fake it than rewrite most cmakelists
  18. if(IOS)
  19. set(LSDK_INCLUDE_DIRS ${LSDK_ROOT}/include)
  20. endif()
  21. #message(STATUS "LSDK [DEBUG]: LSDK_INCLUDE_DIRS = ${LSDK_INCLUDE_DIRS}.")
  22. # Determine compiler version and architecture.
  23. # ios has no architechture/compiler branching, because only can only use clang
  24. # and if you need multiple architechtures there still compiled into single universal binary
  25. if(NOT IOS)
  26. if(MSVC10)
  27. set(LSDK_COMPILER_NAME vs2010)
  28. elseif(MSVC11)
  29. set(LSDK_COMPILER_NAME vs2012)
  30. elseif(MSVC12)
  31. set(LSDK_COMPILER_NAME vs2013)
  32. elseif(MSVC14)
  33. set(LSDK_COMPILER_NAME vs2015)
  34. elseif(CMAKE_COMPILER_IS_GNUCXX)
  35. set(LSDK_COMPILER_NAME gcc4)
  36. elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
  37. set(LSDK_COMPILER_NAME clang)
  38. else()
  39. message(SEND_ERROR "Unsupported compiler: ${LSDK_COMPILER_NAME}")
  40. endif()
  41. if(CMAKE_SIZEOF_VOID_P EQUAL 8)
  42. set(LSDK_TARGET_NAME x64)
  43. else()
  44. set(LSDK_TARGET_NAME x86)
  45. endif()
  46. # What version of Face SDK to use.
  47. set(LSDK_LIB_PREFIX ${LSDK_COMPILER_NAME}/${LSDK_TARGET_NAME})
  48. endif()
  49. if(IOS)
  50. # List of all SDK libraries.
  51. set(LSDK_LIB_NAMES
  52. LivenessEngine)
  53. else()
  54. # List of all SDK libraries.
  55. set(LSDK_LIB_NAMES
  56. LivenessEngineSDK)
  57. endif()
  58. if(IOS)
  59. set(LSDK_LIB_PATH_SUFFIX Frameworks)
  60. set(LSDK_BIN_PATH_SUFFIX Frameworks)
  61. else()
  62. set(LSDK_LIB_PATH_SUFFIX lib/${LSDK_LIB_PREFIX})
  63. set(LSDK_BIN_PATH_SUFFIX bin/${LSDK_LIB_PREFIX})
  64. endif()
  65. # Find optimized libraries.
  66. set(LSDK_LIB)
  67. foreach(LIB ${LSDK_LIB_NAMES})
  68. set(LIB_PATH ${LIB}-NOTFOUND)
  69. find_library(LIB_PATH
  70. NAMES ${LIB}
  71. HINTS $ENV{LSDKDIR}
  72. PATHS ${LSDK_ROOT}
  73. PATH_SUFFIXES
  74. ${LSDK_LIB_PATH_SUFFIX}
  75. NO_DEFAULT_PATH
  76. )
  77. list(APPEND LSDK_LIB ${LIB_PATH})
  78. endforeach()
  79. # Find debug libraries (may be missing in your distribution).
  80. set(LSDK_LIBD)
  81. foreach(LIB ${LSDK_LIB_NAMES})
  82. set(LIB_PATH ${LIB}-NOTFOUND)
  83. find_library(LIB_PATH
  84. NAMES ${LIB}d
  85. HINTS $ENV{LSDKDIR}
  86. PATHS ${LSDK_ROOT}
  87. PATH_SUFFIXES
  88. ${LSDK_LIB_PATH_SUFFIX}
  89. NO_DEFAULT_PATH
  90. )
  91. list(APPEND LSDK_LIBD ${LIB_PATH})
  92. endforeach()
  93. #link components
  94. if(LSDK_LIB AND LSDK_LIBD)
  95. set(LSDK_LIBRARIES optimized ${LSDK_LIB} debug ${LSDK_LIBD})
  96. elseif(LSDK_LIBD)
  97. set(LSDK_LIBRARIES ${LSDK_LIBD})
  98. message(STATUS "LSDK [WARN]: Release libraries were not found")
  99. elseif(LSDK_LIB)
  100. set(LSDK_LIBRARIES ${LSDK_LIB})
  101. message(STATUS "LSDK [WARN]: Debug libraries were not found")
  102. endif()
  103. # Support the REQUIRED and QUIET arguments, and set LSDK_FOUND if found.
  104. include(FindPackageHandleStandardArgs)
  105. FIND_PACKAGE_HANDLE_STANDARD_ARGS(LSDK DEFAULT_MSG
  106. LSDK_LIBRARIES
  107. LSDK_INCLUDE_DIRS)
  108. # Don't show in GUI
  109. mark_as_advanced(
  110. LSDK_INCLUDE_DIRS
  111. LSDK_LIBRARIES
  112. LSDK_COMPILER_NAME
  113. LSDK_TARGET_NAME
  114. LSDK_LIB_PREFIX
  115. LSDK_LIB_NAMES
  116. LSDK_LIB_NAMESD
  117. LSDK_LIB
  118. LSDK_LIBD
  119. LIB_PATH
  120. )