vcpkg/ports/opencv3/portfile.cmake
Billy O'Neal 80d52af7c8
[quirc, opencv4] Build fixes from 2021-01-18 build (#15788)
* [quirc, opencv4] Use a cmake package for quirc and devendor quirc from opencv4.

* Build fixes from 2020-01-18 build

https://dev.azure.com/vcpkg/public/_build/results?buildId=48065

> PASSING, REMOVE FROM FAIL LIST: chartdir:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: cmark:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: cppcms:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: cudnn:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: devicenameresolver:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: dxut:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: epsilon:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: fann:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: getopt-win32:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: glib:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: graphqlparser:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: halide:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: hpx:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: jemalloc:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: libepoxy:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: libhsplasma:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: libmodman:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: libpcap:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: libplist:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: milerius-sfml-imgui:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: monkeys-audio:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: moos-core:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: msix:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: ngspice:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: openni2:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: openvr:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: pmdk:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: pngpp:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: qpid-proton:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: qt5-tools:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: sciter:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: scylla-wrapper:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: soundtouch:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: spirv-tools:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: torch-th:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: treehopper:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: unrar:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: urdfdom:x64-windows-static-md (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: xalan-c:x64-windows-static-md (.\scripts\ci.baseline.txt)

These look like they have always passed since we turned on x64-windows-static-md in nightly CI.

>PASSING, REMOVE FROM FAIL LIST: osgearth:x64-windows (.\scripts\ci.baseline.txt)
>PASSING, REMOVE FROM FAIL LIST: osgearth:x86-windows (.\scripts\ci.baseline.txt)

Maybe addressed by https://github.com/microsoft/vcpkg/pull/15777

>REGRESSION: gettext:arm-uwp. If expected, add gettext:arm-uwp=fail to .\scripts\ci.baseline.txt.
>REGRESSION: gettext:arm64-windows. If expected, add gettext:arm64-windows=fail to .\scripts\ci.baseline.txt.

Probably fixed by https://github.com/microsoft/vcpkg/pull/15740

> PASSING, REMOVE FROM FAIL LIST: directxmesh:x64-linux (.\scripts\ci.baseline.txt)
> PASSING, REMOVE FROM FAIL LIST: uvatlas:x64-linux (.\scripts\ci.baseline.txt)

Probably an error in the authoring of https://github.com/microsoft/vcpkg/pull/15554/

> REGRESSION: dcmtk:x86-windows. If expected, add dcmtk:x86-windows=fail to .\scripts\ci.baseline.txt.
>
> "C:\PROGRA~2\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29333\bin\Hostx64\x86\cl.exe"   /TP -DDCMTK_BUILD_IN_PROGRESS -DNOMINMAX -DUSE_NULL_SAFE_OFSTRING -D_CRT_FAR_MAPPINGS_NO_DEPRECATE -D_CRT_IS_WCTYPE_NO_DEPRECATE -D_CRT_MANAGED_FP_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE_GLOBALS -D_CRT_SETERRORMODE_BEEP_SLEEP_NO_DEPRECATE -D_CRT_TIME_FUNCTIONS_NO_DEPRECATE -D_CRT_VCCLRIT_NO_DEPRECATE -D_REENTRANT -D_SCL_SECURE_NO_DEPRECATE -Dofstd_EXPORTS -ID:\installed\x86-windows\include -Iconfig\include -ID:\buildtrees\dcmtk\src\95da808b49-b82aa35f79.clean\ofstd\include -ID:\buildtrees\dcmtk\src\95da808b49-b82aa35f79.clean\oflog\include -ID:\buildtrees\dcmtk\src\95da808b49-b82aa35f79.clean\dcmdata\include -ID:\buildtrees\dcmtk\src\95da808b49-b82aa35f79.clean\dcmimgle\include -ID:\buildtrees\dcmtk\src\95da808b49-b82aa35f79.clean\dcmimage\include -ID:\buildtrees\dcmtk\src\95da808b49-b82aa35f79.clean\dcmjpeg\include -ID:\buildtrees\dcmtk\src\95da808b49-b82aa35f79.clean\dcmjpls\include -ID:\buildtrees\dcmtk\src\95da808b49-b82aa35f79.clean\dcmtls\include -ID:\buildtrees\dcmtk\src\95da808b49-b82aa35f79.clean\dcmnet\include -ID:\buildtrees\dcmtk\src\95da808b49-b82aa35f79.clean\dcmsr\include -ID:\buildtrees\dcmtk\src\95da808b49-b82aa35f79.clean\dcmsign\include -ID:\buildtrees\dcmtk\src\95da808b49-b82aa35f79.clean\dcmwlm\include -ID:\buildtrees\dcmtk\src\95da808b49-b82aa35f79.clean\dcmqrdb\include -ID:\buildtrees\dcmtk\src\95da808b49-b82aa35f79.clean\dcmpstat\include -ID:\buildtrees\dcmtk\src\95da808b49-b82aa35f79.clean\dcmrt\include -ID:\buildtrees\dcmtk\src\95da808b49-b82aa35f79.clean\dcmiod\include -ID:\buildtrees\dcmtk\src\95da808b49-b82aa35f79.clean\dcmfg\include -ID:\buildtrees\dcmtk\src\95da808b49-b82aa35f79.clean\dcmseg\include -ID:\buildtrees\dcmtk\src\95da808b49-b82aa35f79.clean\dcmtract\include -ID:\buildtrees\dcmtk\src\95da808b49-b82aa35f79.clean\dcmpmap\include -ID:\buildtrees\dcmtk\src\95da808b49-b82aa35f79.clean\dcmect\include /nologo /DWIN32 /D_WINDOWS /W3 /utf-8 /GR /EHsc /MP  /D_DEBUG /MDd /Z7 /Ob0 /Od /RTC1  -DDEBUG /showIncludes /Foofstd\libsrc\CMakeFiles\ofstd.dir\offilsys.cc.obj /Fdofstd\libsrc\CMakeFiles\ofstd.dir\ofstd.pdb /FS -c D:\buildtrees\dcmtk\src\95da808b49-b82aa35f79.clean\ofstd\libsrc\offilsys.cc
> D:\buildtrees\dcmtk\src\95da808b49-b82aa35f79.clean\ofstd\libsrc\offilsys.cc(376): error C2039: 'DIR': is not a member of '`global namespace''
>
> REGRESSION: tesseract:x64-windows-static-md. If expected, add tesseract:x64-windows-static-md=fail to .\scripts\ci.baseline.txt.
> REGRESSION: tesseract:x64-windows-static. If expected, add tesseract:x64-windows-static=fail to .\scripts\ci.baseline.txt.
> REGRESSION: tesseract:x64-windows. If expected, add tesseract:x64-windows=fail to .\scripts\ci.baseline.txt.
> REGRESSION: tesseract:x86-windows. If expected, add tesseract:x86-windows=fail to .\scripts\ci.baseline.txt.
> [2/241] "C:\PROGRA~2\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29333\bin\Hostx64\x86\cl.exe"   /TP -DHAVE_CONFIG_H -DTESS_EXPORTS -D_CRT_SECURE_NO_WARNINGS -D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS=1 -D__AVX2__ -D__AVX__ -D__BMI2__ -D__FMA__ -D__SSE2__ -D__SSE3__ -D__SSE4A__ -D__SSE4_1__ -D__SSE4_2__ -D__SSSE3__ -Dlibtesseract_EXPORTS -ID:\installed\x86-windows\share\leptonica\..\..\include -ID:\installed\x86-windows\share\leptonica\..\..\include\leptonica -I. -ID:\buildtrees\tesseract\src\4.1.1-3a7d5a1d2b.clean\src\api -Iapi -ID:\buildtrees\tesseract\src\4.1.1-3a7d5a1d2b.clean\src\arch -ID:\buildtrees\tesseract\src\4.1.1-3a7d5a1d2b.clean\src\ccmain -ID:\buildtrees\tesseract\src\4.1.1-3a7d5a1d2b.clean\src\ccstruct -ID:\buildtrees\tesseract\src\4.1.1-3a7d5a1d2b.clean\src\ccutil -ID:\buildtrees\tesseract\src\4.1.1-3a7d5a1d2b.clean\src\classify -ID:\buildtrees\tesseract\src\4.1.1-3a7d5a1d2b.clean\src\cutil -ID:\buildtrees\tesseract\src\4.1.1-3a7d5a1d2b.clean\src\dict -ID:\buildtrees\tesseract\src\4.1.1-3a7d5a1d2b.clean\src\lstm -ID:\buildtrees\tesseract\src\4.1.1-3a7d5a1d2b.clean\src\opencl -ID:\buildtrees\tesseract\src\4.1.1-3a7d5a1d2b.clean\src\textord -ID:\buildtrees\tesseract\src\4.1.1-3a7d5a1d2b.clean\src\viewer -ID:\buildtrees\tesseract\src\4.1.1-3a7d5a1d2b.clean\src\wordrec -ID:\buildtrees\tesseract\src\4.1.1-3a7d5a1d2b.clean\src\training -ID:\buildtrees\tesseract\src\4.1.1-3a7d5a1d2b.clean\src\vs2010\tesseract -ID:\installed\x86-windows\include /nologo /DWIN32 /D_WINDOWS /W3 /utf-8 /GR /EHsc /MP  /utf-8 /MP /D_DEBUG /MDd /Z7 /Ob0 /Od /RTC1  /W4 /bigobj -std:c++17 /showIncludes /FoCMakeFiles\libtesseract.dir\src\classify\shapetable.cpp.obj /FdCMakeFiles\libtesseract.dir\ /FS -c D:\buildtrees\tesseract\src\4.1.1-3a7d5a1d2b.clean\src\classify\shapetable.cpp
> FAILED: CMakeFiles/libtesseract.dir/src/classify/shapetable.cpp.obj
> "C:\PROGRA~2\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29333\bin\Hostx64\x86\cl.exe"   /TP -DHAVE_CONFIG_H -DTESS_EXPORTS -D_CRT_SECURE_NO_WARNINGS -D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS=1 -D__AVX2__ -D__AVX__ -D__BMI2__ -D__FMA__ -D__SSE2__ -D__SSE3__ -D__SSE4A__ -D__SSE4_1__ -D__SSE4_2__ -D__SSSE3__ -Dlibtesseract_EXPORTS -ID:\installed\x86-windows\share\leptonica\..\..\include -ID:\installed\x86-windows\share\leptonica\..\..\include\leptonica -I. -ID:\buildtrees\tesseract\src\4.1.1-3a7d5a1d2b.clean\src\api -Iapi -ID:\buildtrees\tesseract\src\4.1.1-3a7d5a1d2b.clean\src\arch -ID:\buildtrees\tesseract\src\4.1.1-3a7d5a1d2b.clean\src\ccmain -ID:\buildtrees\tesseract\src\4.1.1-3a7d5a1d2b.clean\src\ccstruct -ID:\buildtrees\tesseract\src\4.1.1-3a7d5a1d2b.clean\src\ccutil -ID:\buildtrees\tesseract\src\4.1.1-3a7d5a1d2b.clean\src\classify -ID:\buildtrees\tesseract\src\4.1.1-3a7d5a1d2b.clean\src\cutil -ID:\buildtrees\tesseract\src\4.1.1-3a7d5a1d2b.clean\src\dict -ID:\buildtrees\tesseract\src\4.1.1-3a7d5a1d2b.clean\src\lstm -ID:\buildtrees\tesseract\src\4.1.1-3a7d5a1d2b.clean\src\opencl -ID:\buildtrees\tesseract\src\4.1.1-3a7d5a1d2b.clean\src\textord -ID:\buildtrees\tesseract\src\4.1.1-3a7d5a1d2b.clean\src\viewer -ID:\buildtrees\tesseract\src\4.1.1-3a7d5a1d2b.clean\src\wordrec -ID:\buildtrees\tesseract\src\4.1.1-3a7d5a1d2b.clean\src\training -ID:\buildtrees\tesseract\src\4.1.1-3a7d5a1d2b.clean\src\vs2010\tesseract -ID:\installed\x86-windows\include /nologo /DWIN32 /D_WINDOWS /W3 /utf-8 /GR /EHsc /MP  /utf-8 /MP /D_DEBUG /MDd /Z7 /Ob0 /Od /RTC1  /W4 /bigobj -std:c++17 /showIncludes /FoCMakeFiles\libtesseract.dir\src\classify\shapetable.cpp.obj /FdCMakeFiles\libtesseract.dir\ /FS -c D:\buildtrees\tesseract\src\4.1.1-3a7d5a1d2b.clean\src\classify\shapetable.cpp
> cl : Command line warning D9025 : overriding '/W3' with '/W4'
> D:\installed\x86-windows\include\params.h(36): error C2143: syntax error: missing ';' before '*'

https://github.com/microsoft/vcpkg/pull/15785

> REGRESSION: fluidsynth:x64-windows-static-md. If expected, add fluidsynth:x64-windows-static-md=fail to .\scripts\ci.baseline.txt.

Was previously a cascaded failure from glib.

REGRESSION: libevent:x86-windows. If expected, add libevent:x86-windows=fail to .\scripts\ci.baseline.txt.

> REGRESSION: ideviceinstaller:x64-windows-static-md. If expected, add ideviceinstaller:x64-windows-static-md=fail to .\scripts\ci.baseline.txt.
> REGRESSION: libcrafter:x64-windows-static-md. If expected, add libcrafter:x64-windows-static-md=fail to .\scripts\ci.baseline.txt.
> REGRESSION: libirecovery:x64-windows-static-md. If expected, add libirecovery:x64-windows-static-md=fail to .\scripts\ci.baseline.txt.
> REGRESSION: moos-essential:x64-windows-static-md. If expected, add moos-essential:x64-windows-static-md=fail to .\scripts\ci.baseline.txt.
> REGRESSION: openmama:x64-windows-static-md. If expected, add openmama:x64-windows-static-md=fail to .\scripts\ci.baseline.txt.
> REGRESSION: sdformat10:x64-windows-static-md. If expected, add sdformat10:x64-windows-static-md=fail to .\scripts\ci.baseline.txt.
> REGRESSION: sdformat6:x64-windows-static-md. If expected, add sdformat6:x64-windows-static-md=fail to .\scripts\ci.baseline.txt.
> REGRESSION: sdformat9:x64-windows-static-md. If expected, add sdformat9:x64-windows-static-md=fail to .\scripts\ci.baseline.txt.

I'm going to assume these were cascaded failures for now.

> REGRESSION: mesa:x64-windows-static-md. If expected, add mesa:x64-windows-static-md=fail to .\scripts\ci.baseline.txt.
> REGRESSION: mesa:x64-windows. If expected, add mesa:x64-windows=fail to .\scripts\ci.baseline.txt.
> REGRESSION: mesa:x86-windows. If expected, add mesa:x86-windows=fail to .\scripts\ci.baseline.txt.

Nancy is working on this https://github.com/microsoft/vcpkg/pull/15729

> REGRESSION: quirc:x64-linux. If expected, add quirc:x64-linux=fail to .\scripts\ci.baseline.txt.
> REGRESSION: quirc:x64-osx. If expected, add quirc:x64-osx=fail to .\scripts\ci.baseline.txt.
> Starting package 1166/1442: quirc:x64-linux
> Building package quirc[core]:x64-linux...
> -- Downloading 7e7ab596e4.tar.gz -> dlbeer-quirc-7e7ab596e4d0988faf1c12ae89c354b114181c40.tar.gz...
> -- Extracting source /mnt/vcpkg-ci/downloads/dlbeer-quirc-7e7ab596e4d0988faf1c12ae89c354b114181c40.tar.gz
> -- Using source at /mnt/vcpkg-ci/buildtrees/quirc/src/b114181c40-f1e71e0d5b.clean
> -- Configuring x64-linux-dbg
> -- Configuring x64-linux-rel
> -- Building x64-linux-dbg
> -- Building x64-linux-rel
> -- Installing: /mnt/vcpkg-ci/packages/quirc_x64-linux/share/quirc/copyright/LICENSE
> -- Performing post-build validation
> -- Performing post-build validation done
> Uploaded binaries to 1 HTTP remotes.
> Building package quirc[core]:x64-linux... done
> Installing package quirc[core]:x64-linux...
> The following files are already installed in /mnt/vcpkg-ci/installed/x64-linux and are in conflict with quirc:x64-linux
>
> Installed by opencv4:x64-linux
>     lib/libquirc.a
>
> Elapsed time for package quirc:x64-linux: 2.531 s

Probably broken by https://github.com/microsoft/vcpkg/pull/15089, fix here

> REGRESSION: spatialite-tools:x64-linux. If expected, add spatialite-tools:x64-linux=fail to .\scripts\ci.baseline.txt.
> REGRESSION: spatialite-tools:x64-osx. If expected, add spatialite-tools:x64-osx=fail to .\scripts\ci.baseline.txt.

These are spewing linker errors, probably triggered by https://github.com/microsoft/vcpkg/pull/15768/ although that PR removed them from ci.baseline.txt?

* Fixup spurious / and format-manifest.

* x-add-version

* Add missing =fails.

* Update opencv4 devendor patch for 4.5

* Transform quirc into a feature.

* Repeat changes for opencv3.

* Repeat for opencv. Also fix version for "opencv".

* [dxut] Use vcpkg_from_github, correct "supports",

if(NOT VCPKG_CRT_LINKAGE STREQUAL "dynamic")
  message(FATAL_ERROR "DXUT only supports dynamic CRT linkage")
endif()

* [epsilon] Skip in ci.baseline.txt for now because it has "vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY)" but also checks against the CRT linkage making the right fix unclear.

* Fix flipped supports:

* Update ports/opencv3/portfile.cmake

* x-add-version

Co-authored-by: nicole mazzuca <mazzucan@outlook.com>
2021-01-26 14:33:06 -08:00

455 lines
17 KiB
CMake

if (EXISTS "${CURRENT_INSTALLED_DIR}/share/opencv2")
message(FATAL_ERROR "OpenCV 2 is installed, please uninstall and try again:\n vcpkg remove opencv2")
endif()
if (EXISTS "${CURRENT_INSTALLED_DIR}/share/opencv4")
message(FATAL_ERROR "OpenCV 4 is installed, please uninstall and try again:\n vcpkg remove opencv4")
endif()
set(OPENCV_VERSION "3.4.12")
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO opencv/opencv
REF ${OPENCV_VERSION}
SHA512 e69ff4869a8128b7d2a0537d198ec7f287fb821a8965df26339bec662da1888860941f50a269db7693309b9861f986c219288bb5856de76a6c7bc4c0a7026bee
HEAD_REF master
PATCHES
0001-disable-downloading.patch
0002-install-options.patch
0003-force-package-requirements.patch
0005-fix-vtk9.patch
0009-fix-uwp.patch
0010-devendor-quirc.patch
)
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
set(TARGET_IS_AARCH64 1)
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm")
set(TARGET_IS_ARM 1)
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
set(TARGET_IS_X86_64 1)
else()
set(TARGET_IS_X86 1)
endif()
file(REMOVE "${SOURCE_PATH}/cmake/FindCUDNN.cmake")
string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" BUILD_WITH_STATIC_CRT)
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
"contrib" WITH_CONTRIB
"cuda" WITH_CUBLAS
"cuda" WITH_CUDA
"dnn" BUILD_opencv_dnn
"eigen" WITH_EIGEN
"ffmpeg" WITH_FFMPEG
"flann" BUILD_opencv_flann
"gdcm" WITH_GDCM
"halide" WITH_HALIDE
"jasper" WITH_JASPER
"jpeg" WITH_JPEG
"lapack" WITH_LAPACK
"nonfree" OPENCV_ENABLE_NONFREE
"openexr" WITH_OPENEXR
"opengl" WITH_OPENGL
"png" WITH_PNG
"qt" WITH_QT
"quirc" WITH_QUIRC
"sfm" BUILD_opencv_sfm
"tiff" WITH_TIFF
"vtk" WITH_VTK
"webp" WITH_WEBP
"world" BUILD_opencv_world
)
# Cannot use vcpkg_check_features() for "dnn", "ipp", ovis", "tbb"
# As the respective value of their variables can be unset conditionally.
set(BUILD_opencv_dnn OFF)
if("dnn" IN_LIST FEATURES)
if(NOT VCPKG_TARGET_IS_ANDROID)
set(BUILD_opencv_dnn ON)
else()
message(WARNING "The dnn module cannot be enabled on Android")
endif()
endif()
set(WITH_IPP OFF)
if("ipp" IN_LIST FEATURES)
set(WITH_IPP ON)
endif()
set(BUILD_opencv_ovis OFF)
if("ovis" IN_LIST FEATURES)
set(BUILD_opencv_ovis ON)
endif()
set(WITH_TBB OFF)
if("tbb" IN_LIST FEATURES)
set(WITH_TBB ON)
endif()
if("dnn" IN_LIST FEATURES)
vcpkg_download_distfile(TINYDNN_ARCHIVE
URLS "https://github.com/tiny-dnn/tiny-dnn/archive/v1.0.0a3.tar.gz"
FILENAME "opencv-cache/tiny_dnn/adb1c512e09ca2c7a6faef36f9c53e59-v1.0.0a3.tar.gz"
SHA512 5f2c1a161771efa67e85b1fea395953b7744e29f61187ac5a6c54c912fb195b3aef9a5827135c3668bd0eeea5ae04a33cc433e1f6683e2b7955010a2632d168b
)
endif()
# Build image quality module when building with 'contrib' feature and not UWP.
set(BUILD_opencv_quality OFF)
if("contrib" IN_LIST FEATURES)
if (VCPKG_TARGET_IS_UWP)
set(BUILD_opencv_quality OFF)
message(WARNING "The image quality module (quality) does not build for UWP, the module has been disabled.")
# The hdf module is silently disabled by OpenCVs buildsystem if HDF5 is not detected.
message(WARNING "The hierarchical data format module (hdf) depends on HDF5 which doesn't support UWP, the module has been disabled.")
else()
set(BUILD_opencv_quality CMAKE_DEPENDS_IN_PROJECT_ONLY)
endif()
vcpkg_from_github(
OUT_SOURCE_PATH CONTRIB_SOURCE_PATH
REPO opencv/opencv_contrib
REF ${OPENCV_VERSION}
SHA512 0191b1d49d5a50195ed94951c570da03dc33677b682e61a65b34d40f355c36a58441034730ea7eca78dcb4af4c821983754250f93fdf3adb2b4a20e71806eb03
HEAD_REF master
PATCHES
0004-add-missing-stdexcept-include.patch
)
set(BUILD_WITH_CONTRIB_FLAG "-DOPENCV_EXTRA_MODULES_PATH=${CONTRIB_SOURCE_PATH}/modules")
vcpkg_download_distfile(OCV_DOWNLOAD
URLS "https://raw.githubusercontent.com/opencv/opencv_3rdparty/8afa57abc8229d611c4937165d20e2a2d9fc5a12/face_landmark_model.dat"
FILENAME "opencv-cache/data/7505c44ca4eb54b4ab1e4777cb96ac05-face_landmark_model.dat"
SHA512 c16e60a6c4bb4de3ab39b876ae3c3f320ea56f69c93e9303bd2dff8760841dcd71be4161fff8bc71e8fe4fe8747fa8465d49d6bd8f5ebcdaea161f4bc2da7c93
)
function(download_opencv_3rdparty ID COMMIT HASH)
if(NOT EXISTS "${DOWNLOADS}/opencv-cache/${ID}/${COMMIT}.stamp")
vcpkg_download_distfile(OCV_DOWNLOAD
URLS "https://github.com/opencv/opencv_3rdparty/archive/${COMMIT}.zip"
FILENAME "opencv_3rdparty-${COMMIT}.zip"
SHA512 ${HASH}
)
vcpkg_extract_source_archive(${OCV_DOWNLOAD})
file(MAKE_DIRECTORY "${DOWNLOADS}/opencv-cache/${ID}")
file(GLOB XFEATURES2D_I ${CURRENT_BUILDTREES_DIR}/src/opencv_3rdparty-${COMMIT}/*)
foreach(FILE ${XFEATURES2D_I})
file(COPY ${FILE} DESTINATION "${DOWNLOADS}/opencv-cache/${ID}")
get_filename_component(XFEATURES2D_I_NAME "${FILE}" NAME)
file(MD5 "${FILE}" FILE_HASH)
file(RENAME "${DOWNLOADS}/opencv-cache/${ID}/${XFEATURES2D_I_NAME}" "${DOWNLOADS}/opencv-cache/${ID}/${FILE_HASH}-${XFEATURES2D_I_NAME}")
endforeach()
file(WRITE "${DOWNLOADS}/opencv-cache/${ID}/${COMMIT}.stamp")
endif()
endfunction()
# Used for opencv's xfeature2d module
download_opencv_3rdparty(
xfeatures2d/boostdesc
34e4206aef44d50e6bbcd0ab06354b52e7466d26
2ccdc8fb59da55eabc73309a80a4d3b1e73e2341027cdcdd2d714e0f519e60f243f38f79b13ed3de32f595aa23e4f86418eed42e741f32a81b1e6e0879190601
)
# Used for opencv's xfeature2d module
download_opencv_3rdparty(
xfeatures2d/vgg
fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d
7051f5d6ccb938d296b919dd6d5dcddc5afb527aed456639c9984276a8f64565c084d96a72499a7756f127f8d2b1ce9ab70e4cbb3f89c4e16f82296c2a15daed
)
endif()
if(WITH_IPP)
if(VCPKG_TARGET_IS_OSX)
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
vcpkg_download_distfile(OCV_DOWNLOAD
URLS "https://raw.githubusercontent.com/opencv/opencv_3rdparty/a56b6ac6f030c312b2dce17430eef13aed9af274/ippicv/ippicv_2020_mac_intel64_20191018_general.tgz"
FILENAME "opencv-cache/ippicv/1c3d675c2a2395d094d523024896e01b-ippicv_2020_mac_intel64_20191018_general.tgz"
SHA512 454dfaaa245e3a3b2f1ffb1aa8e27e280b03685009d66e147482b14e5796fdf2d332cac0f9b0822caedd5760fda4ee0ce2961889597456bbc18202f10bf727cd
)
else()
message(WARNING "This target architecture is not supported IPPICV")
set(WITH_IPP OFF)
endif()
elseif(VCPKG_TARGET_IS_LINUX)
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
vcpkg_download_distfile(OCV_DOWNLOAD
URLS "https://raw.githubusercontent.com/opencv/opencv_3rdparty/a56b6ac6f030c312b2dce17430eef13aed9af274/ippicv/ippicv_2020_lnx_intel64_20191018_general.tgz"
FILENAME "opencv-cache/ippicv/7421de0095c7a39162ae13a6098782f9-ippicv_2020_lnx_intel64_20191018_general.tgz"
SHA512 de6d80695cd6deef359376476edc4ff85fdddcf94972b936e0017f8a48aaa5d18f55c4253ae37deb83bff2f71410f68408063c88b5f3bf4df3c416aa93ceca87
)
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
vcpkg_download_distfile(OCV_DOWNLOAD
URLS "https://raw.githubusercontent.com/opencv/opencv_3rdparty/a56b6ac6f030c312b2dce17430eef13aed9af274/ippicv/ippicv_2020_lnx_ia32_20191018_general.tgz"
FILENAME "opencv-cache/ippicv/ad189a940fb60eb71f291321322fe3e8-ippicv_2020_lnx_ia32_20191018_general.tgz"
SHA512 5ca9dafc3a634e2a5f83f6a498611c990ef16d54358e9b44574b01694e9d64b118d46d6e2011506e40d37e5a9865f576f790e37ff96b7c8b503507633631a296
)
else()
message(WARNING "This target architecture is not supported IPPICV")
set(WITH_IPP OFF)
endif()
elseif(VCPKG_TARGET_IS_WINDOWS)
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
vcpkg_download_distfile(OCV_DOWNLOAD
URLS "https://raw.githubusercontent.com/opencv/opencv_3rdparty/a56b6ac6f030c312b2dce17430eef13aed9af274/ippicv/ippicv_2020_win_intel64_20191018_general.zip"
FILENAME "opencv-cache/ippicv/879741a7946b814455eee6c6ffde2984-ippicv_2020_win_intel64_20191018_general.zip"
SHA512 50c4af4b7fe2161d652264230389dad2330e8c95b734d04fb7565bffdab855c06d43085e480da554c56b04f8538087d49503538d5943221ee2a772ee7be4c93c
)
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
vcpkg_download_distfile(OCV_DOWNLOAD
URLS "https://raw.githubusercontent.com/opencv/opencv_3rdparty/a56b6ac6f030c312b2dce17430eef13aed9af274/ippicv/ippicv_2020_win_ia32_20191018_general.zip"
FILENAME "opencv-cache/ippicv/cd39bdf0c2e1cac9a61101dad7a2413e-ippicv_2020_win_ia32_20191018_general.zip"
SHA512 058d00775d9f16955c7a557d554b8c2976ab9dbad4ba3fdb9823c0f768809edbd835e4397f01dc090a9bc80d81de834375e7006614d2a898f42e8004de0e04bf
)
else()
message(WARNING "This target architecture is not supported IPPICV")
set(WITH_IPP OFF)
endif()
else()
message(WARNING "This target architecture is not supported IPPICV")
set(WITH_IPP OFF)
endif()
endif()
set(WITH_MSMF ON)
if(NOT VCPKG_TARGET_IS_WINDOWS OR VCPKG_TARGET_IS_UWP)
set(WITH_MSMF OFF)
endif()
if (VCPKG_LIBRARY_LINKAGE STREQUAL static)
if (WITH_TBB)
message(WARNING "TBB is currently unsupported in this build configuration, turning it off")
set(WITH_TBB OFF)
endif()
if (VCPKG_TARGET_IS_WINDOWS AND BUILD_opencv_ovis)
message(WARNING "OVIS is currently unsupported in this build configuration, turning it off")
set(BUILD_opencv_ovis OFF)
endif()
endif()
if("ffmpeg" IN_LIST FEATURES)
if(VCPKG_TARGET_IS_UWP)
set(VCPKG_C_FLAGS "/sdl- ${VCPKG_C_FLAGS}")
set(VCPKG_CXX_FLAGS "/sdl- ${VCPKG_CXX_FLAGS}")
endif()
endif()
if("qt" IN_LIST FEATURES)
list(APPEND ADDITIONAL_BUILD_FLAGS "-DCMAKE_AUTOMOC=ON")
endif()
set(BUILD_opencv_line_descriptor ON)
set(BUILD_opencv_saliency ON)
set(BUILD_opencv_bgsegm ON)
if(VCPKG_TARGET_ARCHITECTURE MATCHES "arm")
set(BUILD_opencv_line_descriptor OFF)
set(BUILD_opencv_saliency OFF)
set(BUILD_opencv_bgsegm OFF)
endif()
vcpkg_configure_cmake(
PREFER_NINJA
SOURCE_PATH ${SOURCE_PATH}
OPTIONS
###### opencv cpu recognition is broken, always using host and not target: here we bypass that
-DOPENCV_SKIP_SYSTEM_PROCESSOR_DETECTION=TRUE
-DAARCH64=${TARGET_IS_AARCH64}
-DX86_64=${TARGET_IS_X86_64}
-DX86=${TARGET_IS_X86}
-DARM=${TARGET_IS_ARM}
###### ocv_options
-DOpenCV_INSTALL_BINARIES_PREFIX=
-DOPENCV_BIN_INSTALL_PATH=bin
-DOPENCV_INCLUDE_INSTALL_PATH=include
-DOPENCV_LIB_INSTALL_PATH=lib
-DOPENCV_3P_LIB_INSTALL_PATH=lib
-DOPENCV_CONFIG_INSTALL_PATH=share/opencv
-DINSTALL_TO_MANGLED_PATHS=OFF
-DOPENCV_FFMPEG_USE_FIND_PACKAGE=FFMPEG
-DOPENCV_FFMPEG_SKIP_BUILD_CHECK=TRUE
-DCMAKE_DEBUG_POSTFIX=d
-DOPENCV_DLLVERSION=
-DOPENCV_DEBUG_POSTFIX=d
-DOPENCV_GENERATE_SETUPVARS=OFF
# Do not build docs/examples
-DBUILD_DOCS=OFF
-DBUILD_EXAMPLES=OFF
###### Disable build 3rd party libs
-DBUILD_JASPER=OFF
-DBUILD_JPEG=OFF
-DBUILD_OPENEXR=OFF
-DBUILD_PNG=OFF
-DBUILD_TIFF=OFF
-DBUILD_WEBP=OFF
-DBUILD_ZLIB=OFF
-DBUILD_TBB=OFF
-DBUILD_IPP_IW=OFF
-DBUILD_ITT=OFF
###### Disable build 3rd party components
-DBUILD_PROTOBUF=OFF
###### OpenCV Build components
-DBUILD_opencv_apps=OFF
-DBUILD_opencv_bgsegm=${BUILD_opencv_bgsegm}
-DBUILD_opencv_line_descriptor=${BUILD_opencv_line_descriptor}
-DBUILD_opencv_saliency=${BUILD_opencv_saliency}
-DBUILD_ANDROID_PROJECT=OFF
-DBUILD_ANDROID_EXAMPLES=OFF
-DBUILD_PACKAGE=OFF
-DBUILD_PERF_TESTS=OFF
-DBUILD_TESTS=OFF
-DBUILD_WITH_DEBUG_INFO=ON
-DBUILD_WITH_STATIC_CRT=${BUILD_WITH_STATIC_CRT}
-DBUILD_JAVA=OFF
-DCURRENT_INSTALLED_DIR=${CURRENT_INSTALLED_DIR}
###### PROTOBUF
-DPROTOBUF_UPDATE_FILES=${BUILD_opencv_flann}
-DUPDATE_PROTO_FILES=${BUILD_opencv_flann}
###### PYLINT/FLAKE8
-DENABLE_PYLINT=OFF
-DENABLE_FLAKE8=OFF
# CMAKE
-DCMAKE_DISABLE_FIND_PACKAGE_Git=ON
-DCMAKE_DISABLE_FIND_PACKAGE_JNI=ON
# ENABLE
-DENABLE_CXX11=ON
###### OPENCV vars
"-DOPENCV_DOWNLOAD_PATH=${DOWNLOADS}/opencv-cache"
${BUILD_WITH_CONTRIB_FLAG}
-DOPENCV_OTHER_INSTALL_PATH=share/opencv
###### customized properties
## Options from vcpkg_check_features()
${FEATURE_OPTIONS}
-DCMAKE_DISABLE_FIND_PACKAGE_Halide=ON
-DHALIDE_ROOT_DIR=${CURRENT_INSTALLED_DIR}
-DWITH_GTK=OFF
-DWITH_IPP=${WITH_IPP}
-DWITH_MATLAB=OFF
-DWITH_MSMF=${WITH_MSMF}
-DWITH_OPENMP=OFF
-DWITH_PROTOBUF=${BUILD_opencv_flann}
-DWITH_OPENCLAMDBLAS=OFF
-DWITH_TBB=${WITH_TBB}
-DWITH_OPENJPEG=OFF
###### BUILD_options (mainly modules which require additional libraries)
-DBUILD_opencv_ovis=${BUILD_opencv_ovis}
-DBUILD_opencv_dnn=${BUILD_opencv_dnn}
###### The following modules are disabled for UWP
-DBUILD_opencv_quality=${BUILD_opencv_quality}
###### Additional build flags
${ADDITIONAL_BUILD_FLAGS}
)
vcpkg_install_cmake()
vcpkg_fixup_cmake_targets(CONFIG_PATH "share/opencv" TARGET_PATH "share/opencv")
vcpkg_copy_pdbs()
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
file(READ ${CURRENT_PACKAGES_DIR}/share/opencv/OpenCVModules.cmake OPENCV_MODULES)
set(DEPS_STRING "include(CMakeFindDependencyMacro)
find_dependency(protobuf CONFIG)
if(protobuf_FOUND)
if(TARGET protobuf::libprotobuf)
add_library (libprotobuf INTERFACE IMPORTED)
set_target_properties(libprotobuf PROPERTIES
INTERFACE_LINK_LIBRARIES protobuf::libprotobuf
)
else()
add_library (libprotobuf UNKNOWN IMPORTED)
set_target_properties(libprotobuf PROPERTIES
IMPORTED_LOCATION \"${Protobuf_LIBRARY}\"
INTERFACE_INCLUDE_DIRECTORIES \"${Protobuf_INCLUDE_DIR}\"
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES \"${Protobuf_INCLUDE_DIR}\"
)
endif()
endif()
find_dependency(Threads)")
if("tiff" IN_LIST FEATURES)
string(APPEND DEPS_STRING "\nfind_dependency(TIFF)")
endif()
if("cuda" IN_LIST FEATURES)
string(APPEND DEPS_STRING "\nfind_dependency(CUDA)")
endif()
if(BUILD_opencv_quality)
string(APPEND DEPS_STRING "
# C language is required for try_compile tests in FindHDF5
enable_language(C)
find_dependency(HDF5)
find_dependency(Tesseract)")
endif()
if(WITH_TBB)
string(APPEND DEPS_STRING "\nfind_dependency(TBB)")
endif()
if("vtk" IN_LIST FEATURES)
string(APPEND DEPS_STRING "\nfind_dependency(VTK)")
endif()
if("sfm" IN_LIST FEATURES)
string(APPEND DEPS_STRING "\nfind_dependency(gflags CONFIG)\nfind_dependency(Ceres CONFIG)")
endif()
if("eigen" IN_LIST FEATURES)
string(APPEND DEPS_STRING "\nfind_dependency(Eigen3 CONFIG)")
endif()
if("lapack" IN_LIST FEATURES)
string(APPEND DEPS_STRING "\nfind_dependency(LAPACK)")
endif()
if("openexr" IN_LIST FEATURES)
string(APPEND DEPS_STRING "\nfind_dependency(OpenEXR CONFIG)")
endif()
if(WITH_OPENMP)
string(APPEND DEPS_STRING "\nfind_dependency(OpenMP)")
endif()
if(BUILD_opencv_ovis)
string(APPEND DEPS_STRING "\nfind_dependency(Ogre)\nfind_dependency(Freetype)")
endif()
if("quirc" IN_LIST FEATURES)
string(APPEND DEPS_STRING "\nfind_dependency(quirc)")
endif()
if("qt" IN_LIST FEATURES)
string(APPEND DEPS_STRING "
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
find_dependency(Qt5 COMPONENTS OpenGL Concurrent Test)")
endif()
if("ade" IN_LIST FEATURES)
string(APPEND DEPS_STRING "\nfind_dependency(ade)")
endif()
if("gdcm" IN_LIST FEATURES)
string(APPEND DEPS_STRING "\nfind_dependency(GDCM)")
endif()
string(REPLACE "set(CMAKE_IMPORT_FILE_VERSION 1)"
"set(CMAKE_IMPORT_FILE_VERSION 1)\n${DEPS_STRING}" OPENCV_MODULES "${OPENCV_MODULES}")
if(WITH_OPENMP)
string(REPLACE "set_target_properties(opencv_core PROPERTIES
INTERFACE_LINK_LIBRARIES \""
"set_target_properties(opencv_core PROPERTIES
INTERFACE_LINK_LIBRARIES \"\$<LINK_ONLY:OpenMP::OpenMP_CXX>;" OPENCV_MODULES "${OPENCV_MODULES}")
endif()
if(BUILD_opencv_ovis)
string(REPLACE "OgreGLSupportStatic"
"OgreGLSupport" OPENCV_MODULES "${OPENCV_MODULES}")
endif()
file(WRITE ${CURRENT_PACKAGES_DIR}/share/opencv/OpenCVModules.cmake "${OPENCV_MODULES}")
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/debug/bin)
endif()
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(REMOVE ${CURRENT_PACKAGES_DIR}/LICENSE)
file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/LICENSE)
if(VCPKG_TARGET_IS_ANDROID)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/README.android)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/README.android)
endif()
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)