1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

Merge branch 4.x

This commit is contained in:
Alexander Smorkalov
2023-07-27 18:38:25 +03:00
151 changed files with 5199 additions and 1111 deletions
+15
View File
@@ -16,7 +16,22 @@ if(ONNXRT_ROOT_DIR)
CMAKE_FIND_ROOT_PATH_BOTH)
endif()
macro(detect_onxxrt_ep filename dir have_ep_var)
find_path(ORT_EP_INCLUDE ${filename} ${dir} CMAKE_FIND_ROOT_PATH_BOTH)
if(ORT_EP_INCLUDE)
set(${have_ep_var} TRUE)
endif()
endmacro()
if(ORT_LIB AND ORT_INCLUDE)
# Check DirectML Execution Provider availability
get_filename_component(dml_dir ${ONNXRT_ROOT_DIR}/include/onnxruntime/core/providers/dml ABSOLUTE)
detect_onxxrt_ep(
dml_provider_factory.h
${dml_dir}
HAVE_ONNX_DML
)
set(HAVE_ONNX TRUE)
# For CMake output only
set(ONNX_LIBRARIES "${ORT_LIB}" CACHE STRING "ONNX Runtime libraries")
+6 -1
View File
@@ -108,6 +108,7 @@ elseif(CV_ICC)
elseif(CV_GCC OR CV_CLANG)
if(ENABLE_FAST_MATH)
add_extra_compiler_option(-ffast-math)
add_extra_compiler_option(-fno-finite-math-only)
endif()
endif()
@@ -260,7 +261,11 @@ if(CV_GCC OR CV_CLANG)
endif()
if(ENABLE_LTO)
add_extra_compiler_option(-flto)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12)
add_extra_compiler_option(-flto=auto)
else()
add_extra_compiler_option(-flto)
endif()
endif()
if(ENABLE_THIN_LTO)
add_extra_compiler_option(-flto=thin)
+38 -7
View File
@@ -5,13 +5,24 @@ if("cann${CANN_INSTALL_DIR}" STREQUAL "cann" AND DEFINED ENV{ASCEND_TOOLKIT_HOME
message(STATUS "CANN: updated CANN_INSTALL_DIR from ASCEND_TOOLKIT_HOME=$ENV{ASCEND_TOOLKIT_HOME}")
endif()
if(EXISTS "${CANN_INSTALL_DIR}/opp/op_proto/built-in/inc")
set(CANN_VERSION_BELOW_6_3_ALPHA002 "YES" )
add_definitions(-DCANN_VERSION_BELOW_6_3_ALPHA002="YES")
endif()
if(CANN_INSTALL_DIR)
# Supported system: UNIX
if(NOT UNIX)
set(HAVE_CANN OFF)
message(WARNING "CANN: CANN toolkit supports unix but not ${CMAKE_SYSTEM_NAME}. Turning off HAVE_CANN")
return()
endif()
# Supported platforms: x86-64, arm64
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64")
else()
set(HAVE_CANN OFF)
message(STATUS "CANN: CANN toolkit supports x86-64 and arm64 but not ${CMAKE_SYSTEM_PROCESSOR}. Turning off HAVE_CANN")
message(WARNING "CANN: CANN toolkit supports x86-64 and arm64 but not ${CMAKE_SYSTEM_PROCESSOR}. Turning off HAVE_CANN")
return()
endif()
@@ -31,7 +42,7 @@ if(CANN_INSTALL_DIR)
set(lib_ascendcl ${found_lib_ascendcl})
message(STATUS "CANN: libascendcl.so is found at ${lib_ascendcl}")
else()
message(STATUS "CANN: Missing libascendcl.so. Turning off HAVE_CANN")
message(WARNING "CANN: Missing libascendcl.so. Turning off HAVE_CANN")
set(HAVE_CANN OFF)
return()
endif()
@@ -42,7 +53,7 @@ if(CANN_INSTALL_DIR)
set(lib_graph ${found_lib_graph})
message(STATUS "CANN: libgraph.so is found at ${lib_graph}")
else()
message(STATUS "CANN: Missing libgraph.so. Turning off HAVE_CANN")
message(WARNING "CANN: Missing libgraph.so. Turning off HAVE_CANN")
set(HAVE_CANN OFF)
return()
endif()
@@ -53,29 +64,49 @@ if(CANN_INSTALL_DIR)
set(lib_ge_compiler ${found_lib_ge_compiler})
message(STATUS "CANN: libge_compiler.so is found at ${lib_ge_compiler}")
else()
message(STATUS "CANN: Missing libge_compiler.so. Turning off HAVE_CANN")
message(WARNING "CANN: Missing libge_compiler.so. Turning off HAVE_CANN")
set(HAVE_CANN OFF)
return()
endif()
# * libopsproto.so
set(lib_opsproto "${CANN_INSTALL_DIR}/opp/op_proto/built-in")
if (CANN_VERSION_BELOW_6_3_ALPHA002)
set(lib_opsproto "${CANN_INSTALL_DIR}/opp/op_proto/built-in/")
else()
if(EXISTS "${CANN_INSTALL_DIR}/opp/built-in/op_proto/lib/linux")
set(lib_opsproto "${CANN_INSTALL_DIR}/opp/built-in/op_proto/lib/linux/${CMAKE_HOST_SYSTEM_PROCESSOR}")
else()
set(lib_opsproto "${CANN_INSTALL_DIR}/opp/built-in/op_proto")
endif()
endif()
find_library(found_lib_opsproto NAMES opsproto PATHS ${lib_opsproto} NO_DEFAULT_PATH)
if(found_lib_opsproto)
set(lib_opsproto ${found_lib_opsproto})
message(STATUS "CANN: libopsproto.so is found at ${lib_opsproto}")
else()
message(STATUS "CANN: Missing libopsproto.so. Turning off HAVE_CANN")
message(WARNING "CANN: Missing libopsproto.so can't found at ${lib_opsproto}. Turning off HAVE_CANN")
set(HAVE_CANN OFF)
return()
endif()
set(libs_cann "")
list(APPEND libs_cann ${lib_ascendcl})
list(APPEND libs_cann ${lib_opsproto})
list(APPEND libs_cann ${lib_graph})
list(APPEND libs_cann ${lib_ge_compiler})
# * lib_graph_base.so
if(NOT CANN_VERSION_BELOW_6_3_ALPHA002)
set(lib_graph_base "${CANN_INSTALL_DIR}/compiler/lib64")
find_library(found_libgraph_base NAMES graph_base PATHS ${lib_graph_base} NO_DEFAULT_PATH)
if(found_libgraph_base)
set(lib_graph_base ${found_libgraph_base})
message(STATUS "CANN: lib_graph_base.so is found at ${lib_graph_base}")
list(APPEND libs_cann ${lib_graph_base})
else()
message(STATUS "CANN: Missing lib_graph_base.so. It is only required after cann version 6.3.RC1.alpha002")
endif()
endif()
try_compile(VALID_ASCENDCL
"${OpenCV_BINARY_DIR}"
"${OpenCV_SOURCE_DIR}/cmake/checks/cann.cpp"
+2 -2
View File
@@ -52,8 +52,8 @@ else()
set(OPENCV_PACKAGE_ARCH_SUFFIX ${CMAKE_SYSTEM_PROCESSOR})
endif()
set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${OPENCV_VCSVERSION}-${OPENCV_PACKAGE_ARCH_SUFFIX}")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${OPENCV_VCSVERSION}-${OPENCV_PACKAGE_ARCH_SUFFIX}")
set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION}-${OPENCV_PACKAGE_ARCH_SUFFIX}")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION}-${OPENCV_PACKAGE_ARCH_SUFFIX}")
#rpm options
set(CPACK_RPM_COMPONENT_INSTALL TRUE)
+7 -1
View File
@@ -1632,13 +1632,19 @@ function(ocv_add_external_target name inc link def)
endif()
endfunction()
set(__OPENCV_EXPORTED_EXTERNAL_TARGETS "" CACHE INTERNAL "")
function(ocv_install_used_external_targets)
if(NOT BUILD_SHARED_LIBS
AND NOT (CMAKE_VERSION VERSION_LESS "3.13.0") # upgrade CMake: https://gitlab.kitware.com/cmake/cmake/-/merge_requests/2152
)
foreach(tgt in ${ARGN})
if(tgt MATCHES "^ocv\.3rdparty\.")
install(TARGETS ${tgt} EXPORT OpenCVModules)
list(FIND __OPENCV_EXPORTED_EXTERNAL_TARGETS "${tgt}" _found)
if(_found EQUAL -1) # don't export target twice
install(TARGETS ${tgt} EXPORT OpenCVModules)
list(APPEND __OPENCV_EXPORTED_EXTERNAL_TARGETS "${tgt}")
set(__OPENCV_EXPORTED_EXTERNAL_TARGETS "${__OPENCV_EXPORTED_EXTERNAL_TARGETS}" CACHE INTERNAL "")
endif()
endif()
endforeach()
endif()
+6 -6
View File
@@ -21,7 +21,7 @@ macro(copy_file_ src dst prefix)
endif()
if(use_symlink)
if(local_update OR NOT IS_SYMLINK "${dst}")
message("${prefix}Symlink: '${dst_name}' ...")
#message("${prefix}Symlink: '${dst_name}' ...")
endif()
get_filename_component(target_path "${dst}" PATH)
file(MAKE_DIRECTORY "${target_path}")
@@ -38,7 +38,7 @@ macro(copy_file_ src dst prefix)
set(local_update 1)
endif()
if(local_update)
message("${prefix}Copying: '${dst_name}' ...")
#message("${prefix}Copying: '${dst_name}' ...")
configure_file(${src} ${dst} COPYONLY)
else()
#message("${prefix}Up-to-date: '${dst_name}'")
@@ -55,7 +55,7 @@ if(NOT DEFINED COPYLIST_VAR)
set(COPYLIST_VAR "COPYLIST")
endif()
list(LENGTH ${COPYLIST_VAR} __length)
message("${prefix}... ${__length} entries (${COPYLIST_VAR})")
#message("${prefix}... ${__length} entries (${COPYLIST_VAR})")
foreach(id ${${COPYLIST_VAR}})
set(src "${${COPYLIST_VAR}_SRC_${id}}")
set(dst "${${COPYLIST_VAR}_DST_${id}}")
@@ -80,7 +80,7 @@ foreach(id ${${COPYLIST_VAR}})
endif()
file(GLOB_RECURSE _files RELATIVE "${src}" ${src_glob})
list(LENGTH _files __length)
message("${prefix} ... directory '.../${src_name2}/${src_name}' with ${__length} files")
#message("${prefix} ... directory '.../${src_name2}/${src_name}' with ${__length} files")
foreach(f ${_files})
if(NOT EXISTS "${src}/${f}")
message(FATAL_ERROR "COPY ERROR: Source file is missing: ${src}/${f}")
@@ -98,12 +98,12 @@ else()
endif()
if(NOT "${__state}" STREQUAL "${__prev_state}")
file(WRITE "${STATE_FILE}" "${__state}")
message("${prefix}Updated!")
#message("${prefix}Updated!")
set(update_dephelper 1)
endif()
if(NOT update_dephelper)
message("${prefix}All files are up-to-date.")
#message("${prefix}All files are up-to-date.")
elseif(DEFINED DEPHELPER)
file(WRITE "${DEPHELPER}" "")
endif()