2022-04-06 02:50:48 +08:00
|
|
|
file(READ "${CMAKE_CURRENT_LIST_DIR}/vcpkg.json" _contents)
|
|
|
|
string(JSON OPENCV_VERSION GET "${_contents}" version)
|
2020-05-07 06:26:16 +08:00
|
|
|
|
|
|
|
vcpkg_from_github(
|
|
|
|
OUT_SOURCE_PATH SOURCE_PATH
|
|
|
|
REPO opencv/opencv
|
|
|
|
REF ${OPENCV_VERSION}
|
|
|
|
SHA512 de7d24ac7ed78ac14673011cbecc477cae688b74222a972e553c95a557b5cb8e5913f97db525421d6a72af30998ca300112fa0b285daed65f65832eb2cf7241a
|
|
|
|
HEAD_REF master
|
|
|
|
PATCHES
|
2022-08-05 08:21:59 +08:00
|
|
|
0001-install-options.patch
|
|
|
|
0002-fix-paths-containing-symbols.patch
|
2020-05-07 06:26:16 +08:00
|
|
|
0003-force-package-requirements.patch
|
|
|
|
0004-add-ffmpeg-missing-defines.patch
|
|
|
|
0005-fix-cuda.patch
|
2022-08-05 08:21:59 +08:00
|
|
|
0006-fix-jasper.patch
|
|
|
|
0007-fix-config.patch
|
2022-09-26 14:45:07 +08:00
|
|
|
0019-fix-openexr.patch
|
2020-05-07 06:26:16 +08:00
|
|
|
)
|
2022-09-26 14:45:07 +08:00
|
|
|
# Disallow accidental build of vendored copies
|
|
|
|
file(REMOVE_RECURSE "${SOURCE_PATH}/3rdparty/openexr")
|
2020-05-07 06:26:16 +08:00
|
|
|
|
|
|
|
file(REMOVE "${SOURCE_PATH}/cmake/FindCUDA.cmake")
|
|
|
|
file(REMOVE_RECURSE "${SOURCE_PATH}/cmake/FindCUDA")
|
|
|
|
|
|
|
|
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
|
2021-08-13 23:46:11 +08:00
|
|
|
FEATURES
|
2020-05-07 06:26:16 +08:00
|
|
|
"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
|
2022-06-10 11:11:05 +08:00
|
|
|
"dc1394" WITH_1394
|
2020-05-07 06:26:16 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
set(WITH_MSMF ON)
|
2022-08-05 08:21:59 +08:00
|
|
|
if(NOT VCPKG_TARGET_IS_WINDOWS OR VCPKG_TARGET_IS_MINGW)
|
2020-05-07 06:26:16 +08:00
|
|
|
set(WITH_MSMF OFF)
|
|
|
|
endif()
|
|
|
|
|
2021-12-02 11:11:01 +08:00
|
|
|
set(WITH_GTK OFF)
|
|
|
|
if("gtk" IN_LIST FEATURES)
|
|
|
|
if(VCPKG_TARGET_IS_LINUX)
|
|
|
|
set(WITH_GTK ON)
|
|
|
|
else()
|
|
|
|
message(WARNING "The gtk module cannot be enabled outside Linux")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2021-12-09 06:03:00 +08:00
|
|
|
set(WITH_PYTHON OFF)
|
|
|
|
if("python" IN_LIST FEATURES)
|
2022-08-05 08:21:59 +08:00
|
|
|
if(VCPKG_TARGET_IS_LINUX OR VCPKG_TARGET_IS_OSX)
|
|
|
|
message(STATUS "You need to manually ensure that python2 virtualenv module is installed")
|
|
|
|
message("This might require running")
|
|
|
|
message("wget https://bootstrap.pypa.io/pip/2.7/get-pip.py")
|
|
|
|
message("and then")
|
|
|
|
message("/usr/bin/python2 get-pip.py")
|
|
|
|
message("and finally")
|
|
|
|
message("pip install virtualenv")
|
|
|
|
message("On some system, these commands must be run as root, otherwise error about virtualenv module missing will persist!")
|
|
|
|
endif()
|
2022-04-15 02:08:23 +08:00
|
|
|
x_vcpkg_get_python_packages(PYTHON_VERSION "2" PACKAGES numpy OUT_PYTHON_VAR "PYTHON2")
|
2021-12-09 06:03:00 +08:00
|
|
|
set(ENV{PYTHON} "${PYTHON2}")
|
2022-04-15 02:08:23 +08:00
|
|
|
set(WITH_PYTHON ON)
|
2021-12-09 06:03:00 +08:00
|
|
|
endif()
|
|
|
|
|
2022-08-05 08:21:59 +08:00
|
|
|
string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" STATIC_CRT_LNK)
|
|
|
|
|
2021-08-13 23:46:11 +08:00
|
|
|
vcpkg_cmake_configure(
|
|
|
|
SOURCE_PATH "${SOURCE_PATH}"
|
2020-05-07 06:26:16 +08:00
|
|
|
OPTIONS
|
|
|
|
###### ocv_options
|
|
|
|
-DCMAKE_DEBUG_POSTFIX=d
|
2022-08-05 08:21:59 +08:00
|
|
|
-DBUILD_WITH_STATIC_CRT=${STATIC_CRT_LNK}
|
|
|
|
-DINSTALL_TO_MANGLED_PATHS=OFF
|
2020-05-07 06:26:16 +08:00
|
|
|
# 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
|
2021-12-09 06:03:00 +08:00
|
|
|
-DWITH_PYTHON=${WITH_PYTHON}
|
2020-05-07 06:26:16 +08:00
|
|
|
-DWITH_ZLIB=ON
|
2021-12-02 11:11:01 +08:00
|
|
|
-WITH_GTK=${WITH_GTK}
|
2020-07-28 08:43:23 +08:00
|
|
|
-DWITH_CUBLAS=OFF # newer libcublas cannot be found by the old cuda cmake script in opencv2, requires a fix
|
2020-05-07 06:26:16 +08:00
|
|
|
)
|
|
|
|
|
2021-08-13 23:46:11 +08:00
|
|
|
vcpkg_cmake_install()
|
2022-08-05 08:21:59 +08:00
|
|
|
vcpkg_cmake_config_fixup()
|
2020-05-07 06:26:16 +08:00
|
|
|
vcpkg_copy_pdbs()
|
|
|
|
|
|
|
|
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
|
2022-08-05 08:21:59 +08:00
|
|
|
file(READ "${CURRENT_PACKAGES_DIR}/share/opencv2/OpenCVModules.cmake" OPENCV_MODULES)
|
2021-12-02 11:11:01 +08:00
|
|
|
|
|
|
|
set(DEPS_STRING "include(CMakeFindDependencyMacro)
|
|
|
|
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("openexr" IN_LIST FEATURES)
|
2022-09-26 14:45:07 +08:00
|
|
|
string(APPEND DEPS_STRING "\nfind_dependency(Imath CONFIG)\nfind_dependency(OpenEXR CONFIG)")
|
2021-12-02 11:11:01 +08:00
|
|
|
endif()
|
|
|
|
if("png" IN_LIST FEATURES)
|
|
|
|
string(APPEND DEPS_STRING "\nfind_dependency(PNG)")
|
|
|
|
endif()
|
|
|
|
if("qt" IN_LIST FEATURES)
|
|
|
|
string(APPEND DEPS_STRING "
|
2020-07-28 08:43:23 +08:00
|
|
|
set(CMAKE_AUTOMOC ON)
|
|
|
|
set(CMAKE_AUTORCC ON)
|
|
|
|
set(CMAKE_AUTOUIC ON)
|
2021-12-02 11:11:01 +08:00
|
|
|
find_dependency(Qt5 COMPONENTS Core Gui Widgets Test Concurrent)")
|
|
|
|
if("opengl" IN_LIST FEATURES)
|
|
|
|
string(APPEND DEPS_STRING "
|
|
|
|
find_dependency(Qt5 COMPONENTS OpenGL)")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
string(REPLACE "set(CMAKE_IMPORT_FILE_VERSION 1)"
|
|
|
|
"set(CMAKE_IMPORT_FILE_VERSION 1)\n${DEPS_STRING}" OPENCV_MODULES "${OPENCV_MODULES}")
|
2020-05-07 06:26:16 +08:00
|
|
|
|
2022-08-05 08:21:59 +08:00
|
|
|
file(WRITE "${CURRENT_PACKAGES_DIR}/share/opencv2/OpenCVModules.cmake" "${OPENCV_MODULES}")
|
2020-05-07 06:26:16 +08:00
|
|
|
|
2021-08-13 23:46:11 +08:00
|
|
|
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin")
|
2020-05-07 06:26:16 +08:00
|
|
|
endif()
|
|
|
|
|
2021-08-13 23:46:11 +08:00
|
|
|
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")
|
2020-05-07 06:26:16 +08:00
|
|
|
|
2022-04-13 00:53:13 +08:00
|
|
|
vcpkg_fixup_pkgconfig()
|
|
|
|
|
2022-12-07 04:45:02 +08:00
|
|
|
configure_file("${CURRENT_PORT_DIR}/usage.in" "${CURRENT_PACKAGES_DIR}/share/${PORT}/usage" @ONLY)
|
2022-08-05 08:21:59 +08:00
|
|
|
|
2021-08-13 23:46:11 +08:00
|
|
|
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
|