2021-08-29 17:13:22 +08:00
|
|
|
if(MSVC)
|
2022-08-26 10:48:53 +08:00
|
|
|
set(opencv_CXXFLAGS "/DWIN32 /D_WINDOWS /W3 /GR /EHsc /std:c++17")
|
2021-08-29 17:13:22 +08:00
|
|
|
set(opencv_CFLAGS "${CMAKE_C_FLAGS}")
|
|
|
|
set(opencv_LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
|
2022-09-29 11:02:44 +08:00
|
|
|
if(DEBUG_MODE)
|
|
|
|
set(opencv_Debug ON)
|
|
|
|
endif()
|
2021-08-29 17:13:22 +08:00
|
|
|
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
2020-04-13 19:42:12 +08:00
|
|
|
set(opencv_CXXFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2")
|
|
|
|
set(opencv_CFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2")
|
|
|
|
set(opencv_LDFLAGS "-Wl")
|
2021-01-23 20:20:31 +08:00
|
|
|
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
2020-04-15 17:36:48 +08:00
|
|
|
set(opencv_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2")
|
|
|
|
set(opencv_CFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2")
|
2020-04-16 21:44:20 +08:00
|
|
|
set(opencv_CXXFLAGS "${opencv_CXXFLAGS} -Wno-attributes -Wno-unknown-pragmas")
|
|
|
|
set(opencv_CXXFLAGS "${opencv_CXXFLAGS} -Wno-unused-value -Wno-implicit-fallthrough")
|
2020-04-13 19:42:12 +08:00
|
|
|
else()
|
2021-03-17 19:54:42 +08:00
|
|
|
set(opencv_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2")
|
2021-03-20 19:56:45 +08:00
|
|
|
set(opencv_CXXFLAGS "${opencv_CXXFLAGS} -O2")
|
|
|
|
if(NOT ENABLE_GLIBCXX)
|
|
|
|
set(opencv_CXXFLAGS "${opencv_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
|
|
|
|
endif()
|
2020-04-13 19:42:12 +08:00
|
|
|
set(opencv_CFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2")
|
2021-09-16 17:31:45 +08:00
|
|
|
set(opencv_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack -s")
|
2020-04-13 19:42:12 +08:00
|
|
|
endif()
|
2020-03-27 14:49:12 +08:00
|
|
|
|
2022-03-15 20:20:44 +08:00
|
|
|
if(ENABLE_GITEE_EULER)
|
|
|
|
set(GIT_REPOSITORY "https://gitee.com/src-openeuler/opencv.git")
|
|
|
|
set(GIT_TAG "openEuler-22.03-LTS")
|
2022-11-02 17:39:06 +08:00
|
|
|
set(SHA256 "d8b00a5440c8e5d275aa5b141f89d69ee196d9dcd2d2032ddd8ef4b04010999a")
|
2022-03-15 20:20:44 +08:00
|
|
|
set(OPENCV_SRC "${TOP_DIR}/build/mindspore/_deps/opencv-src")
|
2022-11-02 17:39:06 +08:00
|
|
|
__download_pkg_with_git(opencv ${GIT_REPOSITORY} ${GIT_TAG} ${SHA256})
|
2022-03-15 20:20:44 +08:00
|
|
|
execute_process(COMMAND tar -xf ${OPENCV_SRC}/opencv-4.5.2.tar.gz --strip-components 1 -C ${OPENCV_SRC})
|
|
|
|
else()
|
2021-01-23 20:20:31 +08:00
|
|
|
if(ENABLE_GITEE)
|
2021-12-17 10:49:07 +08:00
|
|
|
set(REQ_URL "https://gitee.com/mirrors/opencv/repository/archive/4.5.2.tar.gz")
|
2022-11-02 17:39:06 +08:00
|
|
|
set(SHA256 "ae258ed50aa039279c3d36afdea5c6ecf762515836b27871a8957c610d0424f8")
|
2020-10-15 11:24:39 +08:00
|
|
|
else()
|
2021-12-17 10:49:07 +08:00
|
|
|
set(REQ_URL "https://github.com/opencv/opencv/archive/4.5.2.tar.gz")
|
2022-11-02 17:39:06 +08:00
|
|
|
set(SHA256 "ae258ed50aa039279c3d36afdea5c6ecf762515836b27871a8957c610d0424f8")
|
2021-01-23 20:20:31 +08:00
|
|
|
endif()
|
2022-03-15 20:20:44 +08:00
|
|
|
endif()
|
2020-10-15 11:24:39 +08:00
|
|
|
|
2021-08-29 17:13:22 +08:00
|
|
|
if(MSVC)
|
|
|
|
mindspore_add_pkg(opencv
|
2021-12-17 10:49:07 +08:00
|
|
|
VER 4.5.2
|
2022-10-09 14:49:46 +08:00
|
|
|
LIBS opencv_core452 opencv_imgcodecs452 opencv_imgproc452
|
2021-09-16 17:31:45 +08:00
|
|
|
LIB_PATH x64/*/lib
|
2021-08-29 17:13:22 +08:00
|
|
|
URL ${REQ_URL}
|
2022-11-02 17:39:06 +08:00
|
|
|
SHA256 ${SHA256}
|
2021-08-29 17:13:22 +08:00
|
|
|
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DWITH_PROTOBUF=OFF -DWITH_WEBP=OFF -DWITH_IPP=OFF
|
|
|
|
-DWITH_ADE=OFF
|
|
|
|
-DBUILD_ZLIB=ON
|
|
|
|
-DBUILD_JPEG=ON
|
|
|
|
-DBUILD_PNG=ON
|
2022-05-21 14:51:22 +08:00
|
|
|
-DWITH_OPENEXR=OFF
|
2021-08-29 17:13:22 +08:00
|
|
|
-DBUILD_TESTS=OFF
|
|
|
|
-DBUILD_PERF_TESTS=OFF
|
|
|
|
-DBUILD_opencv_apps=OFF
|
|
|
|
-DCMAKE_SKIP_RPATH=TRUE
|
|
|
|
-DBUILD_opencv_python3=OFF
|
|
|
|
-DBUILD_opencv_videoio=OFF
|
|
|
|
-DWITH_FFMPEG=OFF
|
|
|
|
-DWITH_TIFF=ON
|
2022-05-21 14:51:22 +08:00
|
|
|
-DBUILD_TIFF=ON
|
2021-08-29 17:13:22 +08:00
|
|
|
-DWITH_JASPER=OFF
|
|
|
|
-DBUILD_JASPER=OFF
|
2021-11-13 09:40:44 +08:00
|
|
|
-DCV_TRACE=OFF # cause memory usage increacing
|
2022-05-21 14:51:22 +08:00
|
|
|
PATCHES ${TOP_DIR}/third_party/patch/opencv/libtiff/CVE-2022-0561_and_CVE-2022-0562.patch001
|
|
|
|
PATCHES ${TOP_DIR}/third_party/patch/opencv/libtiff/CVE-2022-0908.patch002)
|
2021-08-29 17:13:22 +08:00
|
|
|
elseif(WIN32)
|
2021-12-17 10:49:07 +08:00
|
|
|
mindspore_add_pkg(opencv
|
|
|
|
VER 4.5.2
|
|
|
|
LIBS libopencv_core452.dll.a libopencv_imgcodecs452.dll.a libopencv_imgproc452.dll.a
|
2021-03-04 10:50:37 +08:00
|
|
|
LIB_PATH x64/mingw/lib
|
|
|
|
URL ${REQ_URL}
|
2022-11-02 17:39:06 +08:00
|
|
|
SHA256 ${SHA256}
|
2021-03-04 10:50:37 +08:00
|
|
|
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DWITH_PROTOBUF=OFF -DWITH_WEBP=OFF -DWITH_IPP=OFF
|
|
|
|
-DWITH_ADE=OFF
|
|
|
|
-DBUILD_ZLIB=ON
|
|
|
|
-DBUILD_JPEG=ON
|
|
|
|
-DBUILD_PNG=ON
|
2022-05-21 14:51:22 +08:00
|
|
|
-DWITH_OPENEXR=OFF
|
2021-03-04 10:50:37 +08:00
|
|
|
-DBUILD_TESTS=OFF
|
|
|
|
-DBUILD_PERF_TESTS=OFF
|
|
|
|
-DBUILD_opencv_apps=OFF
|
|
|
|
-DCMAKE_SKIP_RPATH=TRUE
|
|
|
|
-DBUILD_opencv_python3=OFF
|
|
|
|
-DBUILD_opencv_videoio=OFF
|
|
|
|
-DWITH_FFMPEG=OFF
|
|
|
|
-DWITH_TIFF=ON
|
2022-05-21 14:51:22 +08:00
|
|
|
-DBUILD_TIFF=ON
|
2021-03-04 10:50:37 +08:00
|
|
|
-DWITH_JASPER=OFF
|
|
|
|
-DBUILD_JASPER=OFF
|
2021-11-13 09:40:44 +08:00
|
|
|
-DCV_TRACE=OFF # cause memory usage increacing
|
2021-03-04 10:50:37 +08:00
|
|
|
-DWITH_LAPACK=OFF
|
2022-05-21 14:51:22 +08:00
|
|
|
PATCHES ${TOP_DIR}/third_party/patch/opencv/libtiff/CVE-2022-0561_and_CVE-2022-0562.patch001
|
|
|
|
PATCHES ${TOP_DIR}/third_party/patch/opencv/libtiff/CVE-2022-0908.patch002)
|
2020-04-15 17:36:48 +08:00
|
|
|
else()
|
2021-12-17 10:49:07 +08:00
|
|
|
mindspore_add_pkg(opencv
|
|
|
|
VER 4.5.2
|
2021-03-04 10:50:37 +08:00
|
|
|
LIBS opencv_core opencv_imgcodecs opencv_imgproc
|
|
|
|
URL ${REQ_URL}
|
2022-11-02 17:39:06 +08:00
|
|
|
SHA256 ${SHA256}
|
2021-03-04 10:50:37 +08:00
|
|
|
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DWITH_PROTOBUF=OFF -DWITH_WEBP=OFF -DWITH_IPP=OFF
|
|
|
|
-DWITH_ADE=OFF
|
|
|
|
-DBUILD_ZLIB=ON
|
|
|
|
-DBUILD_JPEG=ON
|
|
|
|
-DBUILD_PNG=ON
|
2022-05-21 14:51:22 +08:00
|
|
|
-DWITH_OPENEXR=OFF
|
2021-03-04 10:50:37 +08:00
|
|
|
-DBUILD_TESTS=OFF
|
|
|
|
-DBUILD_PERF_TESTS=OFF
|
|
|
|
-DBUILD_opencv_apps=OFF
|
|
|
|
-DCMAKE_SKIP_RPATH=TRUE
|
|
|
|
-DBUILD_opencv_python3=OFF
|
|
|
|
-DWITH_FFMPEG=OFF
|
|
|
|
-DWITH_TIFF=ON
|
2022-05-21 14:51:22 +08:00
|
|
|
-DBUILD_TIFF=ON
|
2021-03-04 10:50:37 +08:00
|
|
|
-DWITH_JASPER=OFF
|
|
|
|
-DBUILD_JASPER=OFF
|
2021-11-13 09:40:44 +08:00
|
|
|
-DCV_TRACE=OFF # cause memory usage increacing
|
2021-03-04 10:50:37 +08:00
|
|
|
-DWITH_LAPACK=OFF
|
2022-05-21 14:51:22 +08:00
|
|
|
PATCHES ${TOP_DIR}/third_party/patch/opencv/libtiff/CVE-2022-0561_and_CVE-2022-0562.patch001
|
|
|
|
PATCHES ${TOP_DIR}/third_party/patch/opencv/libtiff/CVE-2022-0908.patch002)
|
2020-04-15 17:36:48 +08:00
|
|
|
endif()
|
|
|
|
|
2021-08-29 17:13:22 +08:00
|
|
|
if(MSVC)
|
|
|
|
include_directories(${opencv_INC})
|
2022-10-09 14:49:46 +08:00
|
|
|
add_library(mindspore::opencv_core ALIAS opencv::opencv_core452)
|
|
|
|
add_library(mindspore::opencv_imgcodecs ALIAS opencv::opencv_imgcodecs452)
|
|
|
|
add_library(mindspore::opencv_imgproc ALIAS opencv::opencv_imgproc452)
|
2021-08-29 17:13:22 +08:00
|
|
|
elseif(WIN32)
|
2021-12-17 10:49:07 +08:00
|
|
|
include_directories(${opencv_INC})
|
|
|
|
add_library(mindspore::opencv_core ALIAS opencv::libopencv_core452.dll.a)
|
|
|
|
add_library(mindspore::opencv_imgcodecs ALIAS opencv::libopencv_imgcodecs452.dll.a)
|
|
|
|
add_library(mindspore::opencv_imgproc ALIAS opencv::libopencv_imgproc452.dll.a)
|
2020-04-15 17:36:48 +08:00
|
|
|
else()
|
|
|
|
include_directories(${opencv_INC}/opencv4)
|
|
|
|
add_library(mindspore::opencv_core ALIAS opencv::opencv_core)
|
|
|
|
add_library(mindspore::opencv_imgcodecs ALIAS opencv::opencv_imgcodecs)
|
|
|
|
add_library(mindspore::opencv_imgproc ALIAS opencv::opencv_imgproc)
|
|
|
|
endif()
|