OpenCVFindTengine.cmake 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # COPYRIGHT
  2. # Licensed to the Apache Software Foundation (ASF) under one
  3. # or more contributor license agreements. See the NOTICE file
  4. # distributed with this work for additional information
  5. # regarding copyright ownership. The ASF licenses this file
  6. # to you under the Apache License, Version 2.0 (the
  7. # License); you may not use this file except in compliance
  8. # with the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing,
  13. # software distributed under the License is distributed on an
  14. # AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. # KIND, either express or implied. See the License for the
  16. # specific language governing permissions and limitations
  17. # under the License.
  18. #
  19. # Copyright (c) 2020, OPEN AI LAB
  20. # Author: qtang@openailab.com or https://github.com/BUG1989
  21. #
  22. # ----------------------------------------------------------------------------
  23. # Path for Tengine binaries
  24. # ----------------------------------------------------------------------------
  25. set(OPENCV_LIBTENGINE_ROOT_DIR "" CACHE PATH "Path to TENGINE binaries installation")
  26. IF(OPENCV_LIBTENGINE_ROOT_DIR AND NOT BUILD_TENGINE)
  27. MESSAGE(STATUS "TENGINE:-- Use binaries at ${OPENCV_LIBTENGINE_ROOT_DIR}")
  28. SET(Tengine_FOUND ON)
  29. set(BUILD_TENGINE OFF)
  30. SET(Tengine_INCLUDE_DIR "${OPENCV_LIBTENGINE_ROOT_DIR}/include" CACHE PATH "TENGINE include dir")
  31. SET(Tengine_LIB "${OPENCV_LIBTENGINE_ROOT_DIR}/lib/libtengine.a" CACHE PATH "TENGINE library dir")
  32. ELSE()
  33. IF(ANDROID)
  34. IF(OPENCV_TENGINE_FORCE_ANDROID)
  35. # nothing, use Android
  36. ELSEIF(OPENCV_TENGINE_SKIP_ANDROID)
  37. set(Tengine_FOUND OFF)
  38. set(HAVE_TENGINE FALSE)
  39. return()
  40. ELSEIF(NOT DEFINED ANDROID_NDK_REVISION)
  41. MESSAGE(STATUS "Android NDK version Tengine not support: ANDROID_NDK_REVISION is not defined")
  42. set(Tengine_FOUND OFF)
  43. set(HAVE_TENGINE FALSE)
  44. return()
  45. ELSEIF(ANDROID_NDK_REVISION VERSION_LESS 14)
  46. MESSAGE(STATUS "Android NDK version Tengine not support: ANDROID_NDK_REVISION=${ANDROID_NDK_REVISION}")
  47. set(Tengine_FOUND OFF)
  48. set(HAVE_TENGINE FALSE)
  49. return()
  50. ENDIF()
  51. ENDIF()
  52. MESSAGE(STATUS "TENGINE:-- Build Tengine from source code. ")
  53. include("${OpenCV_SOURCE_DIR}/3rdparty/libtengine/tengine.cmake")
  54. ENDIF()
  55. IF(NOT Tengine_LIB)
  56. SET(Tengine_FOUND OFF)
  57. MESSAGE(STATUS "#### Could not find Tengine lib. Turning Tengine_FOUND off")
  58. ENDIF()
  59. IF (Tengine_FOUND)
  60. MESSAGE(STATUS "Found Tengine include: ${Tengine_INCLUDE_DIR}")
  61. MESSAGE(STATUS "Found Tengine libraries: ${Tengine_LIB}")
  62. set(HAVE_TENGINE 1)
  63. set(TENGINE_LIBRARIES ${Tengine_LIB})
  64. set(TENGINE_INCLUDE_DIRS ${Tengine_INCLUDE_DIR})
  65. ENDIF (Tengine_FOUND)
  66. MARK_AS_ADVANCED(
  67. Tengine_INCLUDE_DIR
  68. Tengine_LIB
  69. )