File: OpenCVDetectWebNN.cmake

package info (click to toggle)
opencv 4.10.0%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 282,092 kB
  • sloc: cpp: 1,178,079; xml: 682,621; python: 49,092; lisp: 31,150; java: 25,469; ansic: 11,039; javascript: 6,085; sh: 1,214; cs: 601; perl: 494; objc: 210; makefile: 173
file content (49 lines) | stat: -rw-r--r-- 1,539 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
if(NOT EMSCRIPTEN)
  if(WITH_WEBNN)
    ocv_check_environment_variables(WEBNN_HEADER_DIRS)
    ocv_check_environment_variables(WEBNN_INCLUDE_DIRS)
    ocv_check_environment_variables(WEBNN_LIBRARIES)
    if(NOT DEFINED WEBNN_HEADER_DIRS)
      set(WEBNN_HEADER_DIRS "$ENV{WEBNN_NATIVE_DIR}/gen/src/include")
    endif()
    if(NOT DEFINED WEBNN_INCLUDE_DIRS)
      set(WEBNN_INCLUDE_DIRS "$ENV{WEBNN_NATIVE_DIR}/../../src/include")
    endif()
    if(NOT DEFINED WEBNN_LIBRARIES)
      set(WEBNN_LIBRARIES "$ENV{WEBNN_NATIVE_DIR}/libwebnn_native.so;$ENV{WEBNN_NATIVE_DIR}/libwebnn_proc.so")
    endif()
  endif()
  try_compile(VALID_WEBNN
        "${OpenCV_BINARY_DIR}"
        SOURCES "${OpenCV_SOURCE_DIR}/cmake/checks/webnn.cpp"
                "$ENV{WEBNN_NATIVE_DIR}/gen/src/webnn/webnn_cpp.cpp"
        CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${WEBNN_INCLUDE_DIRS}\;${WEBNN_HEADER_DIRS}"
                    "-DLINK_LIBRARIES:STRING=${WEBNN_LIBRARIES}"
        OUTPUT_VARIABLE TRY_OUT
        )
else()
  try_compile(VALID_WEBNN
    "${OpenCV_BINARY_DIR}"
    SOURCES "${OpenCV_SOURCE_DIR}/cmake/checks/webnn.cpp"
    OUTPUT_VARIABLE TRY_OUT
    )
endif()

if(NOT VALID_WEBNN)
  if(NOT EMSCRIPTEN)
    message(WARNING "Can't use WebNN-native")
    return()
  else()
    message(WARNING "Can't use WebNN")
    return()
  endif()
else()
  set(HAVE_WEBNN ON)
  message(STATUS "Set HAVE_WEBNN = ${HAVE_WEBNN}")
endif()

if(NOT EMSCRIPTEN)
  message(AUTHOR_WARNING "Use WebNN-native")
else()
  message(AUTHOR_WARNING "Use WebNN")
endif()