tengine.cmake 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. # qli@openailab.com
  22. # sqfu@openailab.com
  23. SET(TENGINE_COMMIT_VERSION "e89cf8870de2ff0a80cfe626c0b52b2a16fb302e")
  24. SET(OCV_TENGINE_DIR "${OpenCV_BINARY_DIR}/3rdparty/libtengine")
  25. SET(OCV_TENGINE_SOURCE_PATH "${OCV_TENGINE_DIR}/Tengine-${TENGINE_COMMIT_VERSION}")
  26. IF(EXISTS "${OCV_TENGINE_SOURCE_PATH}")
  27. MESSAGE(STATUS "Tengine is exist already at: ${OCV_TENGINE_SOURCE_PATH}")
  28. SET(Tengine_FOUND ON)
  29. SET(BUILD_TENGINE ON)
  30. ELSE()
  31. SET(OCV_TENGINE_FILENAME "${TENGINE_COMMIT_VERSION}.zip")#name
  32. SET(OCV_TENGINE_URL "https://github.com/OAID/Tengine/archive/") #url
  33. SET(tengine_md5sum 23f61ebb1dd419f1207d8876496289c5) #md5sum
  34. ocv_download(FILENAME ${OCV_TENGINE_FILENAME}
  35. HASH ${tengine_md5sum}
  36. URL
  37. "${OPENCV_TENGINE_URL}"
  38. "$ENV{OPENCV_TENGINE_URL}"
  39. "${OCV_TENGINE_URL}"
  40. DESTINATION_DIR "${OCV_TENGINE_DIR}"
  41. ID TENGINE
  42. STATUS res
  43. UNPACK RELATIVE_URL)
  44. if (NOT res)
  45. MESSAGE(STATUS "TENGINE DOWNLOAD FAILED. Turning Tengine_FOUND off.")
  46. SET(Tengine_FOUND OFF)
  47. else ()
  48. MESSAGE(STATUS "TENGINE DOWNLOAD success . ")
  49. SET(Tengine_FOUND ON)
  50. SET(BUILD_TENGINE ON)
  51. endif()
  52. ENDIF()
  53. if(BUILD_TENGINE)
  54. SET(HAVE_TENGINE 1)
  55. if(NOT ANDROID)
  56. # linux system
  57. if(CMAKE_SYSTEM_PROCESSOR STREQUAL arm)
  58. SET(TENGINE_TOOLCHAIN_FLAG "-march=armv7-a")
  59. elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64) ## AARCH64
  60. SET(TENGINE_TOOLCHAIN_FLAG "-march=armv8-a")
  61. endif()
  62. endif()
  63. SET(BUILT_IN_OPENCV ON) ## set for tengine compile discern .
  64. SET(Tengine_INCLUDE_DIR "${OCV_TENGINE_SOURCE_PATH}/include" CACHE INTERNAL "")
  65. if(EXISTS "${OCV_TENGINE_SOURCE_PATH}/CMakeLists.txt")
  66. add_subdirectory("${OCV_TENGINE_SOURCE_PATH}" "${OCV_TENGINE_DIR}/build")
  67. else()
  68. message(WARNING "TENGINE: Missing 'CMakeLists.txt' in source code package: ${OCV_TENGINE_SOURCE_PATH}")
  69. endif()
  70. SET(Tengine_LIB "tengine" CACHE INTERNAL "")
  71. endif()