vcpkg/ports/opencv2/portfile.cmake
Stefano Sinigardi f1e7a3f167
[opencv4] update to v4.3 (#11130)
* [opencv4] draft update to v4.3

* restore uwp patch

* fix qt and ipp features

* fix libepoxy and meson on osx

* fix baseline, trigger a full rebuild due to meson tool changes

* remove jpeg feature on windows due to a bug with MSVC

* minor fixes for some features

* ffmpeg x11 lib not required anymore on apple for downstream projects

* small fixes for ogre and qt5

* remove a broken module

* fix installation path

* fix openexr which was broken and regressed opencv downstream projects

* first round of ci passes

* improve compatibility with android toolchain

* [openexr] upgrade to v2.5.0 to fix regressions, might require fixes in dependent projects and might deserve its own PR

* fix OpenEXR link for downstream projects

* do not install unrequested features

* fix compatibility with newer OpenEXR

* [OpenCV3] update to v3.4.10

* fix openexr on windows, was creating symlinks that broke vcpkg

* fix openexr wrapper

* [openexr] cmake config files are installed into a lowered-case folder

* remove mangled paths trying to fix android setup

* disable dnn on android, fix mangled cmake config paths again

* fix downstream CUDA dependency

* fix compatibility with vs16.6

* remove from baseline ports now passing tests

* [alembic] fixes for new openexr

* fix baseline

* [field3d] fixes for new openexr

* [field3d] improve fixes, windows still unsupported despite what is said upstream

* apply fixes required from review

* add missing field3d patch

* [field3d] disable mpi integration

* [opencv2] remove cublas integration

* [vtk] do not create libharu::libharu target if already existing

* Update ports/opencv4/portfile.cmake

Co-authored-by: Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com>

* Update ports/opencv3/portfile.cmake

Co-authored-by: Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com>

* improve compatibility with newer CUDNN

* [OpenCV3, OpenCV4] improve compatibility with CUDA 11

* [OpenCV2] improve compatibility with CUDA 11

* [field3d] regenerate patch ignoring space at eol

* [vcpkg] Use SSH keys instead of password authentication when minting Linux scale sets (#11999)

* [field3d] regenerate patch ignoring space at eol

* [field3d] regenerate patch, again

* [field3d] fixes for windows

* [libass] fix regression

* ci.baseline.txt update

* [CUDA11] use FindCUDA from CMake 3.18 to ease transition later

* re-bump vtk and ffmpeg, which were lost with merges from master

* [OpenCV4] Halide feature is not broken anymore

* [field3d] regenerate hdf5 patch

* [OpenCV4] remove GTK features: it can be built only on *nix but GTK on vcpkg cannot be built on *nix systems...

* merge ci.baseline.txt from master and fix field3d patch

* remove rebuilding

* restore vtk CONTROL file

* update CONTROL files

* Trigger rebuild

* Update ports/freeimage/CONTROL

* Update ports/freeimage/CONTROL

* [opencv3/4] avoid tesseract dependency on uwp builds

* [opencv] add missing module search

Co-authored-by: Billy Robert O'Neal III <bion@microsoft.com>
Co-authored-by: Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com>
2020-07-27 17:43:23 -07:00

140 lines
4.4 KiB
CMake

if (EXISTS "${CURRENT_INSTALLED_DIR}/share/opencv3")
message(FATAL_ERROR "OpenCV 3 is installed, please uninstall and try again:\n vcpkg remove opencv3")
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()
if (VCPKG_TARGET_IS_UWP)
# - opengl feature is broken on UWP
# - jasper and openexr are not available on UWP due to missing dependencies
# - opencv2 code itself fails even if previous conditions are avoided
message(FATAL_ERROR "${PORT} doesn't support UWP")
endif()
set(OPENCV_VERSION "2.4.13.7")
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO opencv/opencv
REF ${OPENCV_VERSION}
SHA512 de7d24ac7ed78ac14673011cbecc477cae688b74222a972e553c95a557b5cb8e5913f97db525421d6a72af30998ca300112fa0b285daed65f65832eb2cf7241a
HEAD_REF master
PATCHES
0002-install-options.patch
0003-force-package-requirements.patch
0004-add-ffmpeg-missing-defines.patch
0005-fix-cuda.patch
)
file(REMOVE "${SOURCE_PATH}/cmake/FindCUDA.cmake")
file(REMOVE_RECURSE "${SOURCE_PATH}/cmake/FindCUDA")
file(COPY ${CMAKE_CURRENT_LIST_DIR}/FindCUDA.cmake DESTINATION ${SOURCE_PATH}/cmake/) #contains fixes for CUDA 11 compat, remove when CMake has support for it
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
"cuda" WITH_CUDA
"eigen" WITH_EIGEN
"ffmpeg" WITH_FFMPEG
"jasper" WITH_JASPER
"jpeg" WITH_JPEG
"openexr" WITH_OPENEXR
"opengl" WITH_OPENGL
"png" WITH_PNG
"qt" WITH_QT
"tiff" WITH_TIFF
"world" BUILD_opencv_world
)
set(WITH_VTK OFF)
if("vtk" IN_LIST FEATURES)
set(WITH_VTK ON)
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_VTK)
message(WARNING "VTK is currently unsupported in this build configuration, turning it off")
set(WITH_VTK 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()
vcpkg_configure_cmake(
PREFER_NINJA
SOURCE_PATH ${SOURCE_PATH}
OPTIONS
###### ocv_options
-DCMAKE_DEBUG_POSTFIX=d
# 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_TBB=OFF
-DBUILD_ZLIB=OFF
###### OpenCV Build components
-DBUILD_opencv_apps=OFF
-DBUILD_PACKAGE=OFF
-DBUILD_PERF_TESTS=OFF
-DBUILD_TESTS=OFF
-DBUILD_WITH_DEBUG_INFO=ON
# CMAKE
-DCMAKE_DISABLE_FIND_PACKAGE_JNI=ON
###### customized properties
## Options from vcpkg_check_features()
${FEATURE_OPTIONS}
-DWITH_1394=OFF
-DWITH_IPP=OFF
-DWITH_LAPACK=OFF
-DWITH_MSMF=${WITH_MSMF}
-DWITH_OPENCLAMDBLAS=OFF
-DWITH_OPENMP=OFF
-DWITH_ZLIB=ON
-DWITH_CUBLAS=OFF # newer libcublas cannot be found by the old cuda cmake script in opencv2, requires a fix
)
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)
string(REPLACE "set(CMAKE_IMPORT_FILE_VERSION 1)"
"set(CMAKE_IMPORT_FILE_VERSION 1)
find_package(CUDA QUIET)
find_package(Threads QUIET)
find_package(PNG QUIET)
find_package(OpenEXR QUIET)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
find_package(Qt5 COMPONENTS OpenGL Concurrent Test QUIET)
find_package(TIFF QUIET)" OPENCV_MODULES "${OPENCV_MODULES}")
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)
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)