diff --git a/.github/workflows/python-main.yml b/.github/workflows/python-main.yml index 185813c112..addfa5db51 100644 --- a/.github/workflows/python-main.yml +++ b/.github/workflows/python-main.yml @@ -25,6 +25,8 @@ jobs: # Job which builds docstrings for the rest of the wheel builds build-docstrings: runs-on: ubuntu-latest + env: + VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" steps: - name: Cache .hunter folder uses: actions/cache@v3 @@ -33,6 +35,12 @@ jobs: key: hunter-ubuntu-latest-v3-develop - name: List .hunter cache directory run: ls -a -l ~/.hunter/_Base/ || true + - name: Export GitHub Actions cache environment variables + uses: actions/github-script@v7 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); - uses: actions/checkout@v3 with: submodules: 'recursive' @@ -44,7 +52,7 @@ jobs: run: | sudo apt update python -m pip install --upgrade pip - sudo apt install libusb-1.0-0-dev libopencv-dev libpcl-dev + sudo apt install libusb-1.0-0-dev pkg-config bison autoconf libtool libxi-dev libxtst-dev libxrandr-dev libx11-dev libxft-dev libxext-dev nasm flex libudev-dev python -m pip install -r bindings/python/docs/requirements_mkdoc.txt - name: Configure project run: cmake -S . -B build -DDEPTHAI_BUILD_PYTHON=ON -DDEPTHAI_PYTHON_FORCE_DOCSTRINGS=ON -DDEPTHAI_BASALT_SUPPORT=ON -DDEPTHAI_PCL_SUPPORT=ON -DDEPTHAI_RTABMAP_SUPPORT=ON -DDEPTHAI_PYTHON_DOCSTRINGS_OUTPUT="$PWD/bindings/python/docstrings/depthai_python_docstring.hpp" @@ -61,6 +69,8 @@ jobs: # Build and test bindings pytest: needs: build-docstrings + env: + VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" strategy: matrix: # os: [ubuntu-latest, windows-latest, macos-latest] @@ -82,6 +92,12 @@ jobs: with: path: C:/.hunter/ key: hunter-pytest-${{ matrix.os }}-v3-develop + - name: Export GitHub Actions cache environment variables + uses: actions/github-script@v7 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); - uses: actions/checkout@v3 with: @@ -103,28 +119,22 @@ jobs: if: matrix.os == 'ubuntu-latest' run: | python -m pip install --upgrade pip - sudo apt install libusb-1.0-0-dev libopencv-dev + sudo apt install libusb-1.0-0-dev pkg-config bison autoconf libtool libxi-dev libxtst-dev libxrandr-dev libx11-dev libxft-dev libxext-dev nasm flex libudev-dev - name: Install dependencies (MacOS) if: matrix.os == 'macos-latest' run: | python -m pip install --upgrade pip brew install libusb - brew install opencv - name: Setup cmake if: matrix.os == 'macos-latest' uses: jwlawson/actions-setup-cmake@v1.13 - - name: Install dependencies (Windows) - if: matrix.os == 'windows-latest' - run: | - choco install opencv - echo "OpenCV_DIR=C:\tools\opencv\build" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - name: Install pytest run: | - python -m pip install pytest numpy opencv-python + python -m pip install pytest numpy opencv-python jinja2 - name: Compile run: | @@ -194,7 +204,10 @@ jobs: python-architecture: [x64] # TODO(Morato) - re-enable x86 - it complains that OpenCV even though it's 32 bit is not compatible fail-fast: false env: - DEPTHAI_BUILD_BASALT: ON + DEPTHAI_BUILD_BASALT: OFF + DEPTHAI_BUILD_PCL: ON + DEPTHAI_BUILD_RTABMAP: ON + VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" steps: - name: Cache .hunter folder uses: actions/cache@v3 @@ -204,6 +217,12 @@ jobs: - uses: actions/checkout@v3 with: submodules: 'recursive' + - name: Export GitHub Actions cache environment variables + uses: actions/github-script@v7 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); - uses: actions/download-artifact@v3 with: @@ -212,18 +231,6 @@ jobs: - name: Specify docstring to use while building the wheel run: echo "DEPTHAI_PYTHON_DOCSTRINGS_INPUT=$PWD/bindings/python/docstrings/depthai_python_docstring.hpp" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - - name: Install dependencies for x86 - if: matrix.python-architecture == 'x86' - run: | - choco install opencv --x86 - echo "OpenCV_DIR=C:\tools\opencv\build" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - - - name: Install dependencies for x64 - if: matrix.python-architecture == 'x64' - run: | - choco install opencv - echo "OpenCV_DIR=C:\tools\opencv\build" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - - name: Select Windows SDK run: echo "CMAKE_ARGS=-DCMAKE_SYSTEM_VERSION=${{ env.CMAKE_WINDOWS_SDK_VERSION }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append @@ -262,11 +269,11 @@ jobs: os: [macos-13, macos-14] # macos-13 is x64, macos-14 is arm64 fail-fast: false runs-on: ${{ matrix.os }} - # env: - # TODO(Morato) - re-enable basalt, pcl, rtabmap after everything is ported - # DEPTHAI_BUILD_BASALT: ON - # DEPTHAI_BUILD_PCL: ON - # DEPTHAI_BUILD_RTABMAP: ON + env: + VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" + DEPTHAI_BUILD_BASALT: ON + DEPTHAI_BUILD_PCL: ON + DEPTHAI_BUILD_RTABMAP: ON steps: - name: Cache .hunter folder uses: actions/cache@v3 @@ -277,6 +284,12 @@ jobs: run: | ls -a -l ~/.hunter/_Base/ || true echo "PATH=$PATH" + - name: Export GitHub Actions cache environment variables + uses: actions/github-script@v7 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); - uses: actions/checkout@v3 with: @@ -300,8 +313,7 @@ jobs: run: | python -m pip install --upgrade pip brew install libusb - brew install opencv - brew install pcl + brew install nasm python -m pip install delocate - name: Building wheels run: cd bindings/python && python -m pip wheel . -w ./wheelhouse/ --verbose @@ -388,30 +400,34 @@ jobs: needs: build-docstrings runs-on: ubuntu-latest container: - image: mmorato/depthai-manylinux2014:0.4 # TODO(mmorato) temporary location, push to luxonis namespace + image: quay.io/pypa/manylinux_2_28_x86_64 env: - PLAT: manylinux2014_x86_64 + PLAT: manylinux_2_28_x86_64 strategy: matrix: - python-set: ["7..9", "10..12"] + python-set: ["7", "8", "9", "10", "11", "12"] env: - # workaround required for cache@v3, https://github.com/actions/cache/issues/1428 - # to be removed when upgrading the manylinux image - ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true DEPTHAI_BUILD_BASALT: ON DEPTHAI_BUILD_PCL: ON DEPTHAI_BUILD_RTABMAP: ON + VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" steps: - name: Cache .hunter folder uses: actions/cache@v3 with: path: ~/.hunter key: hunter-x86_64-v3-develop + - name: Export GitHub Actions cache environment variables + uses: actions/github-script@v7 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); - uses: actions/checkout@v3 with: submodules: 'recursive' - name: Installing libusb1-devel dependency - run: yum install -y --disableplugin=fastestmirror libusb1-devel perl-core curl zip unzip tar ninja-build + run: yum install -y libusb1-devel perl-core curl zip unzip tar ninja-build zlib-devel curl-devel xcb-util-renderutil-devel xcb-util-devel xcb-util-image-devel xcb-util-keysyms-devel xcb-util-wm-devel mesa-libGL-devel libxkbcommon-devel libxkbcommon-x11-devel libXi-devel libXrandr-devel libXtst-devel libudev-devel lapack-devel nasm libtool autoconf automake - name: Installing cmake dependency run: | cd bindings/python @@ -427,12 +443,6 @@ jobs: - name: Specify docstring to use while building the wheel run: echo "DEPTHAI_PYTHON_DOCSTRINGS_INPUT=$PWD/bindings/python/docstrings/depthai_python_docstring.hpp" >> $GITHUB_ENV - - name: Build and install depthai-core - run: | - cmake -S . -B build_core -D CMAKE_BUILD_TYPE=Release -D CMAKE_TOOLCHAIN_FILE=$PWD/cmake/toolchain/pic.cmake - cmake --build build_core --target install --parallel 4 - echo "DEPTHAI_INSTALLATION_DIR=$PWD/build_core/install/" >> $GITHUB_ENV - - name: Append build hash if not a tagged commit if: startsWith(github.ref, 'refs/tags/v') != true run: echo "BUILD_COMMIT_HASH=${{github.sha}}" >> $GITHUB_ENV @@ -443,7 +453,9 @@ jobs: /opt/python/cp38-cp38/bin/python3.8 setup.py sdist --formats=gztar mv dist/* wheelhouse/audited/ - name: Build wheels - run: cd bindings/python && for PYBIN in /opt/python/cp3{${{ matrix.python-set }}}*/bin; do "${PYBIN}/pip" wheel . -w ./wheelhouse/ --verbose; done + run: | + cd bindings/python && for PYBIN in /opt/python/cp3${{ matrix.python-set }}*/bin; do "${PYBIN}/pip" wheel . -w ./wheelhouse/ --verbose; done + - name: Audit wheels run: cd bindings/python && for whl in wheelhouse/*.whl; do auditwheel repair "$whl" --plat $PLAT -w wheelhouse/audited/; done - name: Archive wheel artifacts @@ -465,35 +477,47 @@ jobs: runs-on: [self-hosted, linux, ARM64] timeout-minutes: 1440 # Set timeout to 24 hours container: - image: mmorato/depthai-manylinux2014_aarch64:0.4 + image: quay.io/pypa/manylinux_2_28_aarch64 env: - PLAT: manylinux2014_aarch64 + PLAT: manylinux_2_28_aarch64 # Mount local hunter cache directory, instead of transfering to Github and back volumes: - /.hunter:/github/home/.hunter strategy: matrix: - python-set: ["7..9", "10..12"] + python-set: ["7", "8", "9", "10", "11", "12"] env: # workaround required for cache@v3, https://github.com/actions/cache/issues/1428 - # to be removed when upgrading the manylinux image - ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true - DEPTHAI_VCPKG_CFLAGS: "-std=c99" # Needed so vpckg can bootstrap itself with the old GCC on the manylinux image VCPKG_FORCE_SYSTEM_BINARIES: "1" # Needed so vpckg can bootstrap itself + VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" DEPTHAI_BUILD_BASALT: ON DEPTHAI_BUILD_PCL: ON DEPTHAI_BUILD_RTABMAP: ON + VCPKG_MAX_CONCURRENCY: "2" steps: + - name: Export GitHub Actions cache environment variables + uses: actions/github-script@v7 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); - uses: actions/checkout@v3 with: submodules: 'recursive' - name: Installing libusb1-devel dependency - run: yum install -y --disableplugin=fastestmirror libusb1-devel perl-core curl zip unzip tar ninja-build + run: yum install -y libusb1-devel perl-core curl zip unzip tar zlib-devel curl-devel xcb-util-renderutil-devel xcb-util-devel xcb-util-image-devel xcb-util-keysyms-devel xcb-util-wm-devel mesa-libGL-devel libxkbcommon-devel libxkbcommon-x11-devel libXi-devel libXrandr-devel libXtst-devel libudev-devel lapack-devel nasm libtool autoconf automake - name: Installing cmake dependency run: | cd bindings/python /opt/python/cp38-cp38/bin/python3.8 -m pip install cmake ln -s /opt/python/cp38-cp38/bin/cmake /bin/ + - name: Setup ninja required for arm64 builds + run: | + git clone https://github.com/ninja-build/ninja.git + cd ninja + git checkout v1.10.2 + cmake -Bbuild-cmake + cmake --build build-cmake --target install - name: Create folder structure run: cd bindings/python && mkdir -p wheelhouse/audited/ @@ -504,17 +528,12 @@ jobs: - name: Specify docstring to use while building the wheel run: echo "DEPTHAI_PYTHON_DOCSTRINGS_INPUT=$PWD/bindings/python/docstrings/depthai_python_docstring.hpp" >> $GITHUB_ENV - - name: Build and install depthai-core - run: | - cmake -S . -B build_core -D CMAKE_BUILD_TYPE=Release -D CMAKE_TOOLCHAIN_FILE=$PWD/cmake/toolchain/pic.cmake - cmake --build build_core --target install --parallel 4 - echo "DEPTHAI_INSTALLATION_DIR=$PWD/build_core/install/" >> $GITHUB_ENV - - name: Append build hash if not a tagged commit if: startsWith(github.ref, 'refs/tags/v') != true run: echo "BUILD_COMMIT_HASH=${{github.sha}}" >> $GITHUB_ENV - name: Building wheels - run: cd bindings/python && for PYBIN in /opt/python/cp3{${{ matrix.python-set }}}*/bin; do "${PYBIN}/pip" wheel . -w ./wheelhouse/ --verbose; done + run: | + cd bindings/python && for PYBIN in /opt/python/cp3${{ matrix.python-set }}*/bin; do "${PYBIN}/pip" wheel . -w ./wheelhouse/ --verbose; done - name: Auditing wheels run: cd bindings/python && for whl in wheelhouse/*.whl; do auditwheel repair "$whl" --plat $PLAT -w wheelhouse/audited/; done - name: Archive wheel artifacts diff --git a/.github/workflows/test.workflow.yml b/.github/workflows/test.workflow.yml index 56ff17009c..e48512e4c2 100644 --- a/.github/workflows/test.workflow.yml +++ b/.github/workflows/test.workflow.yml @@ -20,6 +20,8 @@ jobs: # Testing test: + env: + VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" strategy: matrix: # os: ['windows', 'macos', 'linux'] @@ -42,6 +44,12 @@ jobs: - uses: actions/checkout@v3 with: submodules: 'recursive' + - name: Export GitHub Actions cache environment variables + uses: actions/github-script@v7 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); - name: Create virtual environment run: | @@ -72,6 +80,7 @@ jobs: export DISPLAY=:99 xdpyinfo -display $DISPLAY >/dev/null 2>&1 || (Xvfb $DISPLAY &) source venv/bin/activate # Activate virtual environment + python3 -m pip install jinja2 cmake -S . -B build -D CMAKE_BUILD_TYPE=Release -D HUNTER_ROOT=$HOME/.hun2_${{ matrix.flavor }} -D DEPTHAI_BUILD_EXAMPLES=ON -D DEPTHAI_BUILD_TESTS=ON -D DEPTHAI_TEST_EXAMPLES=ON -D DEPTHAI_BUILD_PYTHON=ON -D DEPTHAI_PYTHON_TEST_EXAMPLES=ON -D DEPTHAI_PYTHON_ENABLE_EXAMPLES=ON cmake --build build --parallel 4 --config Release cd tests diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c74d7538a..46b4d124c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,40 +1,50 @@ -cmake_minimum_required(VERSION 3.4) # For Hunter +cmake_minimum_required(VERSION 3.16) +# Early options +option(DEPTHAI_ENABLE_LIBUSB "Enable usage of libusb and interaction with USB devices" ON) +# Build AprilTag node code (note, that even if set to OFF, an AprilTagNode can be used with setRunOnHost(false)) +option(DEPTHAI_ENABLE_APRIL_TAG "Enable AprilTag node" ON) +option(DEPTHAI_RTABMAP_SUPPORT "Enable optional RTABMap support" OFF) +option(DEPTHAI_BASALT_SUPPORT "Enable optional Basalt support" OFF) +option(DEPTHAI_ENABLE_PROTOBUF "Enable Protobuf support" ON) +option(DEPTHAI_BUILD_PYTHON "Build python bindings" OFF) +option(DEPTHAI_BUILD_TESTS "Build tests" OFF) +option(DEPTHAI_BOOTSTRAP_VCPKG "Automatically bootstrap VCPKG" ON) -# CMP0074 dictates that find_package searches environment variable "[packageName]_ROOT" along with regular variable [packageName]_ROOT -if(POLICY CMP0074) - cmake_policy(SET CMP0074 NEW) # Only introduced in 3.12 -endif() +set(DEPTHAI_HAS_APRIL_TAG ${DEPTHAI_ENABLE_APRIL_TAG}) +if(WIN32) + message(STATUS "AprilTag node is not supported on Windows") + set(DEPTHAI_HAS_APRIL_TAG OFF) -if(POLICY CMP0028) - cmake_policy(SET CMP0028 NEW) -endif() + # Statically compile vcruntime library + add_compile_options(/MT) -option(DEPTHAI_BOOTSTRAP_VCPKG "Automatically bootstrap VCPKG" ON) -if(DEPTHAI_BOOTSTRAP_VCPKG) - message(STATUS "Including vcpkg.cmake") - include(cmake/vcpkg.cmake) +endif() +if(DEPTHAI_HAS_APRIL_TAG) +list(APPEND VCPKG_MANIFEST_FEATURES "apriltag") +endif() +if(DEPTHAI_RTABMAP_SUPPORT) +list(APPEND VCPKG_MANIFEST_FEATURES "rtabmap") +endif() +if(DEPTHAI_BASALT_SUPPORT) +list(APPEND VCPKG_MANIFEST_FEATURES "basalt") +endif() +# Enable backward stack printing on crash +if(ANDROID OR EMSCRIPTEN) + # Backward not supported currently on Android + set(DEPTHAI_ENABLE_BACKWARD OFF CACHE BOOL "" FORCE) else() - message(STATUS "DEPTHAI_BOOTSTRAP_VCPKG is OFF") + option(DEPTHAI_ENABLE_BACKWARD "Enable stacktrace printing on crash using Backward" ON) + # Additional function information for 'backward' stacktrace + if(DEPTHAI_ENABLE_BACKWARD) + set(CMAKE_ENABLE_EXPORTS ON) + list(APPEND VCPKG_MANIFEST_FEATURES "backward") + endif() endif() -# MSVC variable isn't available before 'project' call -# Generalize to Win32 platform for now -if(NOT WIN32) - set(HUNTER_CONFIGURATION_TYPES "Release" CACHE STRING "Hunter dependencies list of build configurations") +if(DEPTHAI_ENABLE_PROTOBUF) + list(APPEND VCPKG_MANIFEST_FEATURES "protobuf-support") endif() -# Early options -option(DEPTHAI_ENABLE_LIBUSB "Enable usage of libusb and interaction with USB devices" ON) - -# Set to use native tls for windows before including Hunter (used for Curl) -if(WIN32) - set(DEPTHAI_CURL_USE_SCHANNEL ON) - set(DEPTHAI_CURL_USE_OPENSSL OFF) - add_compile_definitions(NOMINMAX) -else() - set(DEPTHAI_CURL_USE_SCHANNEL OFF) - set(DEPTHAI_CURL_USE_OPENSSL ON) -endif() # Check if on 32 bit linux - default without CURL support if(CMAKE_SIZEOF_VOID_P EQUAL 4 AND UNIX) @@ -44,17 +54,33 @@ else() endif() option(DEPTHAI_ENABLE_CURL "Enable CURL support" ${DEPTHAI_DEFAULT_CURL_SUPPORT}) - if(DEPTHAI_ENABLE_CURL) list(APPEND VCPKG_MANIFEST_FEATURES "curl-support") endif() +if(DEPTHAI_ENABLE_LIBUSB) + list(APPEND VCPKG_MANIFEST_FEATURES "xlink-usb") +else() + list(APPEND VCPKG_MANIFEST_FEATURES "xlink") +endif() + +# CMP0074 dictates that find_package searches environment variable "[packageName]_ROOT" along with regular variable [packageName]_ROOT +if(POLICY CMP0074) + cmake_policy(SET CMP0074 NEW) # Only introduced in 3.12 +endif() -option(DEPTHAI_ENABLE_PROTOBUF "Enable Protobuf support" ON) -if(DEPTHAI_ENABLE_PROTOBUF) - list(APPEND VCPKG_MANIFEST_FEATURES "protobuf-support") +if(POLICY CMP0028) + cmake_policy(SET CMP0028 NEW) +endif() + +if(DEPTHAI_BOOTSTRAP_VCPKG) + message(STATUS "Including vcpkg.cmake") + include(cmake/vcpkg.cmake) +else() + message(STATUS "DEPTHAI_BOOTSTRAP_VCPKG is OFF") endif() + if(DEPTHAI_ENABLE_PROTOBUF) option(DEPTHAI_ENABLE_REMOTE_CONNECTION "Enable Remote Connection support" ON) else() @@ -62,6 +88,14 @@ else() message(STATUS "Remote Connection support disabled because Protobuf support is disabled.") endif() +if(DEPTHAI_BUILD_PYTHON) + list(APPEND VCPKG_MANIFEST_FEATURES "python-bindings") +endif() + +if(DEPTHAI_BUILD_TESTS) + list(APPEND VCPKG_MANIFEST_FEATURES "tests") +endif() + if(DEPTHAI_ENABLE_REMOTE_CONNECTION) list(APPEND VCPKG_MANIFEST_FEATURES "remote-connection-support") endif() @@ -90,21 +124,6 @@ else() message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}") endif() -# Build AprilTag node code (note, that even if set to OFF, an AprilTagNode can be used with setRunOnHost(false)) -option(DEPTHAI_ENABLE_APRIL_TAG "Enable AprilTag node" ON) -set(DEPTHAI_HAS_APRIL_TAG ${DEPTHAI_ENABLE_APRIL_TAG}) -if(WIN32) - message(STATUS "AprilTag node is not supported on Windows") - set(DEPTHAI_HAS_APRIL_TAG OFF) -endif() - -include("cmake/HunterGate.cmake") -HunterGate( - URL "https://github.com/cpp-pm/hunter/archive/9d9242b60d5236269f894efd3ddd60a9ca83dd7f.tar.gz" - SHA1 "16cc954aa723bccd16ea45fc91a858d0c5246376" - LOCAL # Local config for dependencies -) - # Move binary dir if windows, to shorten the path if(WIN32) set(HUNTER_BINARY_DIR "${HUNTER_GATE_ROOT}/_bin" CACHE STRING "Hunter binary directory") @@ -160,17 +179,6 @@ option(DEPTHAI_INSTALL "Enable install target for depthai-core targets" ON) set(DEPTHAI_XLINK_LOCAL "" CACHE STRING "Path to local XLink source to use instead of Hunter") set(DEPTHAI_BOOTLOADER_SHARED_LOCAL "" CACHE STRING "Path to local depthai-bootloader-shared source to use instead of submodule") -# Enable backward stack printing on crash -if(ANDROID OR EMSCRIPTEN) - # Backward not supported currently on Android - set(DEPTHAI_ENABLE_BACKWARD OFF CACHE BOOL "" FORCE) -else() - option(DEPTHAI_ENABLE_BACKWARD "Enable stacktrace printing on crash using Backward" ON) - # Additional function information for 'backward' stacktrace - if(DEPTHAI_ENABLE_BACKWARD) - set(CMAKE_ENABLE_EXPORTS ON) - endif() -endif() # Force Colored output when using Ninja @@ -231,8 +239,6 @@ endif() option(DEPTHAI_XTENSOR_SUPPORT "Enable optional xtensor support" ON) option(DEPTHAI_OPENCV_SUPPORT "Enable optional OpenCV support" ON) option(DEPTHAI_PCL_SUPPORT "Enable optional PCL support" OFF) -option(DEPTHAI_RTABMAP_SUPPORT "Enable optional RTABMap support" OFF) -option(DEPTHAI_BASALT_SUPPORT "Enable optional Basalt support" OFF) option(DEPTHAI_MERGED_TARGET "Enable merged target build" ON) @@ -266,7 +272,10 @@ set(TARGET_OPENCV_NAME ${PROJECT_NAME}-opencv) set(TARGET_OPENCV_ALIAS opencv) if(DEPTHAI_OPENCV_SUPPORT) # Check if required libraries are available - set(REQUIRED_OPENCV_LIBRARIES "opencv_core" "opencv_imgproc" "opencv_videoio") + if(UNIX AND NOT APPLE) + set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-Bsymbolic") # for FFMPEG + endif() + set(REQUIRED_OPENCV_LIBRARIES "opencv_core" "opencv_imgproc" "opencv_videoio" "opencv_highgui") set(OPENCV_SUPPORT_AVAILABLE ${OpenCV_FOUND}) foreach(lib ${REQUIRED_OPENCV_LIBRARIES}) if(NOT (lib IN_LIST OpenCV_LIBS)) @@ -509,9 +518,10 @@ if(DEPTHAI_HAVE_PCL_SUPPORT AND DEPTHAI_MERGED_TARGET) # Specify that we are building target pcl target_compile_definitions(${TARGET_CORE_NAME} PUBLIC DEPTHAI_TARGET_PCL) target_compile_definitions(${TARGET_CORE_NAME} PUBLIC DEPTHAI_HAVE_PCL_SUPPORT) - - target_include_directories(${TARGET_CORE_NAME} PUBLIC ${PCL_INCLUDE_DIRS}) - target_link_directories(${TARGET_CORE_NAME} PUBLIC ${PCL_LIBRARY_DIRS}) + target_link_directories(${TARGET_CORE_NAME} PUBLIC + $ + $ + ) target_compile_definitions(${TARGET_CORE_NAME} PUBLIC ${PCL_DEFINITIONS}) endif() if(DEPTHAI_MERGED_TARGET) @@ -519,9 +529,7 @@ if(DEPTHAI_MERGED_TARGET) endif() # First specify options -option(DEPTHAI_BUILD_TESTS "Build tests" OFF) option(DEPTHAI_BUILD_EXAMPLES "Build examples - Requires OpenCV library to be installed" OFF) -option(DEPTHAI_BUILD_PYTHON "Build python bindings" OFF) option(DEPTHAI_BUILD_DOCS "Build documentation - requires doxygen to be installed" OFF) # Specify support for FW @@ -695,6 +703,7 @@ target_include_directories(${TARGET_CORE_NAME} "$" "$" "$" + "$" ) target_include_directories(${TARGET_CORE_NAME} SYSTEM @@ -716,17 +725,17 @@ target_link_libraries(${TARGET_CORE_NAME} nlohmann_json::nlohmann_json libnop spdlog::spdlog - yaml-cpp + yaml-cpp::yaml-cpp INTERFACE XLinkPublic PRIVATE XLink Threads::Threads - BZip2::bz2 - FP16::fp16 - archive_static - ZLIB::zlib - LZ4::lz4 + BZip2::BZip2 + LibArchive::LibArchive + liblzma::liblzma + ZLIB::ZLIB + lz4::lz4 httplib::httplib mp4v2::mp4v2 semver::semver @@ -829,7 +838,7 @@ macro(add_runtime_dependencies depending_target dependency) set(dlls ${depthai_dll_libraries} $<$:${dll}>) endforeach() endif() - file(GLOB depthai_dll_libraries "${HUNTER_INSTALL_PREFIX}/bin/*.dll") + set(depthai_dll_libraries "") # Create a list of required dll files set(required_dll_files ${dlls} ${depthai_dll_libraries}) # Copy the required dlls @@ -979,14 +988,13 @@ endif() # Basalt Support ######################## -set(THIRDPARTY_BASALT_LIBRARIES "TBB::tbb;Eigen3::Eigen;basalt_sdk::basalt_sdk" CACHE STRING "Optional libraries to link Basalt support, e.g. TBB::tbb") +set(THIRDPARTY_BASALT_LIBRARIES "basalt_sdk::basalt_sdk" CACHE STRING "Optional libraries to link Basalt support, e.g. TBB::tbb") set(TARGET_BASALT_NAME ${PROJECT_NAME}-basalt) set(TARGET_BASALT_ALIAS basalt) if(DEPTHAI_BASALT_SUPPORT) # Check if required libraries are available find_package(basalt_sdk CONFIG REQUIRED) - find_package(TBB CONFIG REQUIRED) set(BASALT_SUPPORT_AVAILABLE ${basalt_sdk_FOUND}) if(BASALT_SUPPORT_AVAILABLE) @@ -1080,6 +1088,44 @@ if(DEPTHAI_SANITIZE) endif() endif() endif() +function(private_data) + set(one URL SHA1 CREDENTIALS LOCATION FILE) + set(multiple HTTPHEADER) + + cmake_parse_arguments(x "" "${one}" "${multiple}" "${ARGN}") + + if(x_HTTPHEADER) + message(FATAL_ERROR "HTTPHEADER argument of private_data not supported if HUNTER_ENABLED is OFF") + endif() + if(x_CREDENTIALS) + message(FATAL_ERROR "CREDENTIALS argument of private_data not supported if HUNTER_ENABLED is OFF") + endif() + + if(NOT x_URL) + message(FATAL_ERROR "URL not provided to private_data") + endif() + if(NOT x_SHA1) + message(FATAL_ERROR "SHA1 not provided to private_data") + endif() + if(NOT x_FILE) + message(FATAL_ERROR "FILE not provided to private_data") + endif() + if(NOT x_LOCATION) + message(FATAL_ERROR "LOCATION not provided to private_data") + endif() + + set(x_DOWNLOAD_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/_private_data/${x_FILE}") + + file(DOWNLOAD + ${x_URL} + ${x_DOWNLOAD_LOCATION} + EXPECTED_HASH SHA1=${x_SHA1} + TLS_VERIFY ON + ) + + # Set the output variable + set(${x_LOCATION} "${x_DOWNLOAD_LOCATION}" PARENT_SCOPE) +endfunction() ######################## # Testing infrastructure @@ -1147,7 +1193,6 @@ configure_file("cmake/${PROJECT_NAME}Dependencies.cmake" ${PROJECT_NAME}Dependen write_basic_package_version_file(${PROJECT_NAME}ConfigVersion.cmake VERSION ${PROJECT_VERSION} COMPATIBILITY AnyNewerVersion) # Configure config file (one for exporting build directory, one for installation) -file(RELATIVE_PATH DEPTHAI_DEPENDENCIES_INSTALLATION_PATH_REL "${CMAKE_CURRENT_BINARY_DIR}" "${HUNTER_INSTALL_PREFIX}") configure_file(cmake/${PROJECT_NAME}Config.cmake.in ${PROJECT_NAME}Config.cmake @ONLY) # Config for installation @@ -1182,8 +1227,6 @@ if(DEPTHAI_INSTALL) install(DIRECTORY include/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") # Install depthai-bootloader-shared public headers install(DIRECTORY "${DEPTHAI_BOOTLOADER_SHARED_PUBLIC_INCLUDE}/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") - # Install Hunter dependencies - install(DIRECTORY "${HUNTER_INSTALL_PREFIX}/" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/dependencies") # Install depthai-core dependencies install(DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/3rdparty" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake") # Install resources if not RC'd diff --git a/CMakePresets.json b/CMakePresets.json index 758e72c9e9..4d8bc35bc8 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -1,12 +1,13 @@ { - "version": 2, + "version": 3, "configurePresets": [ { "name": "default", "binaryDir": "${sourceDir}/build", "cacheVariables": { - "CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" + "CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", + "VCPKG_INSTALL_OPTIONS": "--clean-buildtrees-after-build;--clean-packages-after-build" } } ] -} \ No newline at end of file +} diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt index 5d2810ab03..1b9155794f 100644 --- a/bindings/python/CMakeLists.txt +++ b/bindings/python/CMakeLists.txt @@ -43,16 +43,11 @@ option(DEPTHAI_PYTHON_EMBEDDED_MODULE "Create an embeddable module" OFF) # Add pybind11 dependency #add_subdirectory(pybind11-2.5.0) -hunter_add_package(pybind11) # Disable LTO if MINGW compiler if(MINGW) set(PYBIND11_LTO_CXX_FLAGS "" CACHE STRING "" FORCE) endif() -find_package(pybind11 CONFIG REQUIRED) - -# Print out the pybind11 version that was found -message(STATUS "Found pybind11 v${pybind11_VERSION}") # Add external dependencies add_subdirectory(external) @@ -195,6 +190,9 @@ if(WIN32) # Disable "d" postfix, so python can import the library as is set_target_properties(${TARGET_NAME} PROPERTIES DEBUG_POSTFIX "") + + # Statically compile CRT + target_compile_options(${TARGET_NAME} PRIVATE "/MT") endif() # Add stubs (pyi) generation step after building bindings @@ -278,6 +276,11 @@ if(DEPTHAI_MERGED_TARGET) target_include_directories(${TARGET_NAME} PRIVATE external/pybind11_opencv_numpy) endif() +if(UNIX AND NOT APPLE) + # Add -Bsymbolic for FFMPEG linking + target_link_options(${TARGET_NAME} PRIVATE "LINKER:-Bsymbolic") +endif() + set(DEPTHAI_LINK_TARGET depthai::core) if(NOT DEPTHAI_MERGED_TARGET) list(APPEND DEPTHAI_LINK_TARGET depthai::opencv) diff --git a/bindings/python/docs/requirements_mkdoc.txt b/bindings/python/docs/requirements_mkdoc.txt index c823ac6cc0..ba2fa6b63b 100644 --- a/bindings/python/docs/requirements_mkdoc.txt +++ b/bindings/python/docs/requirements_mkdoc.txt @@ -1,3 +1,4 @@ git+https://github.com/luxonis/pybind11_mkdoc.git@da6c64251a0ebbc3ffc007477a0b9c9f20cac165 libclang==16.0.6 +jinja2==3.0.3 numpy # Needed because of xtensor-python diff --git a/bindings/python/generate_stubs.py b/bindings/python/generate_stubs.py index 5bd0d2cc31..2ab1c9ee17 100644 --- a/bindings/python/generate_stubs.py +++ b/bindings/python/generate_stubs.py @@ -125,7 +125,6 @@ subprocess.check_call([sys.executable, '-m' 'mypy', f'{DIRECTORY}/{MODULE_NAME}', f'--config-file={config.name}'], env=env) finally: os.unlink(config.name) - # # TODO(thamarpe) - Pylance / Pyright check # subprocess.check_call([sys.executable, '-m' 'pyright', f'{DIRECTORY}/{MODULE_NAME}'], env=env) @@ -164,4 +163,5 @@ def process_init_pyi(file_path, is_depthai_root=False): except subprocess.CalledProcessError as err: exit(err.returncode) -exit(0) +finally: + exit(0) diff --git a/bindings/python/pyproject.toml b/bindings/python/pyproject.toml index 5626df1b4d..78c796a307 100644 --- a/bindings/python/pyproject.toml +++ b/bindings/python/pyproject.toml @@ -1,2 +1,2 @@ [build-system] -requires = ["setuptools", "wheel", "mypy", "numpy", "cmake==3.25"] +requires = ["setuptools", "wheel", "mypy", "numpy", "jinja2", "cmake==3.25"] diff --git a/bindings/python/tests/CMakeLists.txt b/bindings/python/tests/CMakeLists.txt index 7a5a8feb04..29a0ea8a16 100644 --- a/bindings/python/tests/CMakeLists.txt +++ b/bindings/python/tests/CMakeLists.txt @@ -40,6 +40,9 @@ add_custom_target( WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}" USES_TERMINAL ) - +if(UNIX AND NOT APPLE) + # Add -Bsymbolic for FFMPEG linking + target_link_options(${TARGET_TEST_MODULE} PRIVATE "LINKER:-Bsymbolic") +endif() # Link to depthai target_link_libraries(${TARGET_TEST_MODULE} PRIVATE pybind11::pybind11 depthai::core) \ No newline at end of file diff --git a/bindings/python/utilities/requirements.txt b/bindings/python/utilities/requirements.txt index ade6e25c8f..77242602a4 100644 --- a/bindings/python/utilities/requirements.txt +++ b/bindings/python/utilities/requirements.txt @@ -1,6 +1,7 @@ PySimpleGUI==4.60.3 Pillow==9.3.0 psutil==5.9.3 +jinja2==3.0.3 numpy>=1.21.4 # For RPi Buster (last successful build) and macOS M1 (first build). But allow for higher versions, to support Python3.11 (not available in 1.21.4 yet) opencv-contrib-python==4.5.5.62 # Last successful RPi build, also covers M1 with above pinned numpy (otherwise 4.6.0.62 would be required, but that has a bug with charuco boards). Python version not important, abi3 wheels pyqt5>5,<5.15.6 ; platform_machine != "armv6l" and platform_machine != "armv7l" and platform_machine != "aarch64" and platform_machine != "arm64" diff --git a/cmake/Hunter/config.cmake b/cmake/Hunter/config.cmake deleted file mode 100644 index 82ca0a9e3c..0000000000 --- a/cmake/Hunter/config.cmake +++ /dev/null @@ -1,308 +0,0 @@ -# hunter_config( -# nlohmann_json -# VERSION "3.9.1" -# URL "https://github.com/nlohmann/json/archive/v3.9.1.tar.gz" -# SHA1 "f8a20a7e19227906d77de0ede97468fbcfea03e7" -# ) -hunter_config( - nlohmann_json - VERSION "3.9.1" -) - -hunter_config( - XLink - VERSION "luxonis-develop-server" - URL "https://github.com/luxonis/XLink/archive/585a38fe4707e5f023de277135d8cb6ff9c4e0c4.tar.gz" - SHA1 "d82827dec8b6f2702f4b31d8186fd70265cd0ca4" - CMAKE_ARGS - XLINK_ENABLE_LIBUSB=${DEPTHAI_ENABLE_LIBUSB} -) - -hunter_config( - BZip2 - VERSION "1.0.8-p0" -) - -hunter_config( - spdlog - VERSION "1.8.2" - URL "https://github.com/gabime/spdlog/archive/v1.8.2.tar.gz" - SHA1 "4437f350ca7fa89a0cd8faca1198afb36823f775" - CMAKE_ARGS - SPDLOG_BUILD_EXAMPLE=OFF - SPDLOG_FMT_EXTERNAL=OFF - CMAKE_CXX_VISIBILITY_PRESET=hidden - CMAKE_C_VISIBILITY_PRESET=hidden -) - -# libarchive, luxonis fork -hunter_config( - libarchive-luxonis - VERSION "hunter-3.5.2" - URL "https://github.com/luxonis/libarchive/archive/45baa3a3e57104519e1165bcd5ac29c3bd8c9f3a.tar.gz" - SHA1 "ca5cd0f1c31b9c187d7119cb1aa7467f8c231d29" - CMAKE_ARGS - ENABLE_ACL=OFF - ENABLE_BZip2=OFF - ENABLE_CAT=OFF - ENABLE_CAT_SHARED=OFF - ENABLE_CNG=OFF - ENABLE_COVERAGE=OFF - ENABLE_CPIO=OFF - ENABLE_CPIO_SHARED=OFF - ENABLE_EXPAT=OFF - ENABLE_ICONV=OFF - ENABLE_INSTALL=ON - ENABLE_LIBB2=OFF - ENABLE_LIBXML2=OFF - ENABLE_LZ4=OFF - ENABLE_LZMA=ON - ENABLE_LZO=OFF - ENABLE_LibGCC=OFF - ENABLE_MBEDTLS=OFF - ENABLE_NETTLE=OFF - ENABLE_OPENSSL=OFF - ENABLE_PCREPOSIX=OFF - ENABLE_SAFESEH=AUTO - ENABLE_TAR=OFF - ENABLE_TAR_SHARED=OFF - ENABLE_TEST=OFF - ENABLE_WERROR=OFF - ENABLE_XATTR=OFF - ENABLE_ZLIB=OFF - ENABLE_ZSTD=OFF -) - -# Luxonis FP16 fork which doesn't use git cloning for its dependencies -hunter_config( - FP16 - VERSION "luxonis-0.0.0" - URL "https://github.com/luxonis/FP16/archive/c911175d2717e562976e606c6e5f799bf40cf94e.tar.gz" - SHA1 "40e9723c87c2fe21781132c0f2f8b90338500e32" - CMAKE_ARGS - FP16_BUILD_BENCHMARKS=OFF - FP16_BUILD_TESTS=OFF -) - -if(NOT EMSCRIPTEN) - # Backward - Stacktrace printer - hunter_config( - Backward - VERSION "1.6" - URL "https://github.com/bombela/backward-cpp/archive/refs/tags/v1.6.tar.gz" - SHA1 "4ecb711eabfd15bc88ff9dd9342907fc5da46b62" - CMAKE_ARGS - BACKWARD_TESTS=OFF - ) -endif() - -# libnop - Serialization -hunter_config( - libnop - VERSION "1.0-ec8f75a" - URL "https://github.com/luxonis/libnop/archive/ab842f51dc2eb13916dc98417c2186b78320ed10.tar.gz" - SHA1 "32f40f084615ba7940ce9d29f05f3294371aabeb" -) - -# Specific Catch2 version -hunter_config( - Catch2 - VERSION "3.4.0" - URL "https://github.com/catchorg/Catch2/archive/refs/tags/v3.4.0.tar.gz" - SHA1 "4c308576c856a43dc88949a8f64ef90ebf94ae1b" -) - - -# LZ4 for mcap -hunter_config( - lz4-luxonis - VERSION "1.9.4-p2" - URL "https://github.com/luxonis/lz4/archive/ba358ed311d125333d245e4c284464a72a168983.tar.gz" - SHA1 "43ae0d2343147e32cdd8b85cefb5a311c3ee5504" -) - -# TMP, could be read from XLink -# libusb without udev -hunter_config( - libusb-luxonis - VERSION "1.0.24-cmake" - URL "https://github.com/luxonis/libusb/archive/b7e4548958325b18feb73977163ad44398099534.tar.gz" - SHA1 "2d79573d57628fe56d2868d2f6ce756d40906cf4" - CMAKE_ARGS - WITH_UDEV=OFF - # Build shared libs by default to not cause licensing issues - BUILD_SHARED_LIBS=ON -) - -# cpp-httplib -hunter_config( - httplib - VERSION "0.11.2" - URL "https://github.com/luxonis/cpp-httplib/archive/3ba99c06f655a52e701c9a7ae5dc48850582d95b.tar.gz" - SHA1 "84ddd5d58a210b6203c50760d2ebde75b0ff6376" - CMAKE_ARGS - HTTPLIB_USE_OPENSSL_IF_AVAILABLE=OFF - HTTPLIB_USE_BROTLI_IF_AVAILABLE=OFF -) - - -# RTABMap -hunter_config( - rtbmap - VERSION "0.21.4" - URL "https://github.com/introlab/rtabmap/archive/623d056436946c35beb12199831f178a84eaad73.zip" # until fixes are merged to main - SHA1 "98768b5adea093cc5e1bbe74b2ad3749e61de0ef" - CMAKE_ARGS - BUILD_APP=OFF - WITH_UDEV=OFF - BUILD_EXAMPLES=OFF - BUILD_TOOLS=OFF - BUILD_SHARED_LIBS=OFF - WITH_QT=OFF - WITH_ORB_OCTREE=OFF - WITH_TORCH=OFF - WITH_PYTHON=OFF - WITH_PYTHON_THREADING=OFF - WITH_PDAL=OFF - WITH_FREENECT=OFF - WITH_FREENECT2=OFF - WITH_K4W2=OFF - WITH_K4A=OFF - WITH_OPENNI=OFF - WITH_OPENNI2=OFF - WITH_DC1394=OFF - WITH_G2O=ON - WITH_GTSAM=ON - WITH_TORO=ON - WITH_CERES=OFF - WITH_MRPT=OFF - WITH_VERTIGO=ON - WITH_CVSBA=OFF - WITH_POINTMATCHER=ON - WITH_CCCORELIB=OFF - WITH_OPEN3D=OFF - WITH_LOAM=OFF - WITH_FLOAM=OFF - WITH_FLYCAPTURE2=OFF - WITH_ZED=OFF - WITH_ZEDOC=OFF - WITH_REALSENSE=OFF - WITH_REALSENSE_SLAM=OFF - WITH_REALSENSE2=OFF - WITH_MYNTEYE=OFF - WITH_DEPTHAI=OFF - WITH_OCTOMAP=OFF - WITH_GRIDMAP=OFF - WITH_CPUTSDF=OFF - WITH_OPENCHISEL=OFF - WITH_ALICE_VISION=OFF - WITH_FOVIS=OFF - WITH_VISO2=OFF - WITH_DVO=OFF - WITH_ORB_SLAM=OFF - WITH_OKVIS=OFF - WITH_MSCKF_VIO=OFF - WITH_VINS=OFF - WITH_OPENVINS=OFF - WITH_MADGWICK=OFF - WITH_FASTCV=OFF - WITH_OPENMP=OFF - WITH_OPENGV=OFF - PCL_OMP=OFF -) -# Pybind11 2.9.2 -# # Pybind11 2.11.0-smart_holder -# hunter_config( -# pybind11 -# VERSION "2.11.0-smart_holder" -# URL "https://github.com/pybind/pybind11/archive/10283c2ef44a9100bc88d066a4972c4f51ded2b0.tar.gz" -# SHA1 "0da09bdd6987a33feb800e4b7f129df5c9aa5aed" -# ) - -# Pybind11 2.9.2-smart_holder -hunter_config( - pybind11 - VERSION "luxonis_smart_holder" - URL "https://github.com/luxonis/pybind11/archive/f760e2b984b66be2cfa202c93da9d341a557fb5d.tar.gz" - SHA1 "d53247e4d1af52be040b647de0c25eb336bc85c7" -) - -hunter_config( - mp4v2 - VERSION "2.1.3" - URL "https://github.com/luxonis/mp4v2/archive/1dc9f4d24645ea43405582e5c813dec3eaa8fd3e.tar.gz" - SHA1 "2ac9e4348c78d09a3b4fc6e147b9eeb356ba31f1" - CMAKE_ARGS - BUILD_SHARED=OFF - BUILD_UTILS=OFF -) - - -hunter_config( - basalt-headers - VERSION 0.1.0 - URL "https://github.com/luxonis/basalt-headers/archive/e3ee456469f21a356a0a59088779b32721918f11.tar.gz" - SHA1 "73955ab90ae77ee32c88744b945b3fd8b175833b" -) - -hunter_config( - oneTBB - VERSION 2021.12.0 - URL "https://github.com/oneapi-src/oneTBB/archive/refs/tags/v2021.12.0.zip" - SHA1 "f6b0eb4e45af600684282341115a3c2fb9834978" - CMAKE_ARGS - TBB_PREVIEW_GLOBAL_CONTROL=ON - TBB_TEST=OFF - CMAKE_CXX_VISIBILITY_PRESET=hidden - CMAKE_C_VISIBILITY_PRESET=hidden -) - - -hunter_config( - basalt - VERSION 0.1.0 - URL "https://github.com/luxonis/basalt/archive/5763210cd48e2dfc560f80ee0d3648163e69a901.tar.gz" - SHA1 "d5301f8edfce5372962851b3d7928c053f0b1628" - CMAKE_ARGS - BASALT_SDK_ONLY=ON -) - -hunter_config( - Sophus - VERSION 1.22.10 - URL "https://github.com/luxonis/Sophus/archive/54e9b230edc4df47f819cef0d15b1fcc165342df.tar.gz" - SHA1 "4c67d2d3415511446ed65705f00b23854dae6cd6" - CMAKE_ARGS - BUILD_SOPHUS_TESTS=OFF - BUILD_SOPHUS_EXAMPLES=OFF -) - - -hunter_config( - magic_enum - URL "https://github.com/Neargye/magic_enum/archive/3d1f6a5a2a3fbcba077e00ad0ccc2dd9fefc2ca7.zip" - SHA1 "c9a27f6ff8311f0c6b2adb959d0598f079fcc9f3" -) -hunter_config( - yaml-cpp - VERSION "0.6.3l" - URL "https://github.com/jbeder/yaml-cpp/archive/refs/tags/yaml-cpp-0.6.3.tar.gz" - SHA1 "98d98632b3a62fdf1172442f8ad8190fc11cbef7" -) - -hunter_config( - semver - VERSION "v0.3.1" - URL "https://github.com/Neargye/semver/archive/v0.3.1.tar.gz" - SHA1 "c9ac79025cc259d8cca454be0865e88f154402be" -) - -# Only include april tag if needed -if(DEPTHAI_HAS_APRIL_TAG) - hunter_config( - apriltag - VERSION "3.4.2" - URL "https://github.com/AprilRobotics/apriltag/archive/v3.4.2.tar.gz" - SHA1 "5fe51a652e451aedd11f8966abdb8f16bb1faefe" - ) -endif() diff --git a/cmake/HunterGate.cmake b/cmake/HunterGate.cmake deleted file mode 100644 index 6d9cc24019..0000000000 --- a/cmake/HunterGate.cmake +++ /dev/null @@ -1,539 +0,0 @@ -# Copyright (c) 2013-2019, Ruslan Baratov -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -# This is a gate file to Hunter package manager. -# Include this file using `include` command and add package you need, example: -# -# cmake_minimum_required(VERSION 3.2) -# -# include("cmake/HunterGate.cmake") -# HunterGate( -# URL "https://github.com/path/to/hunter/archive.tar.gz" -# SHA1 "798501e983f14b28b10cda16afa4de69eee1da1d" -# ) -# -# project(MyProject) -# -# hunter_add_package(Foo) -# hunter_add_package(Boo COMPONENTS Bar Baz) -# -# Projects: -# * https://github.com/hunter-packages/gate/ -# * https://github.com/ruslo/hunter - -option(HUNTER_ENABLED "Enable Hunter package manager support" ON) - -if(HUNTER_ENABLED) - if(CMAKE_VERSION VERSION_LESS "3.2") - message( - FATAL_ERROR - "At least CMake version 3.2 required for Hunter dependency management." - " Update CMake or set HUNTER_ENABLED to OFF." - ) - endif() -endif() - -include(CMakeParseArguments) # cmake_parse_arguments - -option(HUNTER_STATUS_PRINT "Print working status" ON) -option(HUNTER_STATUS_DEBUG "Print a lot info" OFF) -option(HUNTER_TLS_VERIFY "Enable/disable TLS certificate checking on downloads" ON) - -set(HUNTER_ERROR_PAGE "https://docs.hunter.sh/en/latest/reference/errors") - -function(hunter_gate_status_print) - if(HUNTER_STATUS_PRINT OR HUNTER_STATUS_DEBUG) - foreach(print_message ${ARGV}) - message(STATUS "[hunter] ${print_message}") - endforeach() - endif() -endfunction() - -function(hunter_gate_status_debug) - if(HUNTER_STATUS_DEBUG) - foreach(print_message ${ARGV}) - string(TIMESTAMP timestamp) - message(STATUS "[hunter *** DEBUG *** ${timestamp}] ${print_message}") - endforeach() - endif() -endfunction() - -function(hunter_gate_error_page error_page) - message("------------------------------ ERROR ------------------------------") - message(" ${HUNTER_ERROR_PAGE}/${error_page}.html") - message("-------------------------------------------------------------------") - message("") - message(FATAL_ERROR "") -endfunction() - -function(hunter_gate_internal_error) - message("") - foreach(print_message ${ARGV}) - message("[hunter ** INTERNAL **] ${print_message}") - endforeach() - message("[hunter ** INTERNAL **] [Directory:${CMAKE_CURRENT_LIST_DIR}]") - message("") - hunter_gate_error_page("error.internal") -endfunction() - -function(hunter_gate_fatal_error) - cmake_parse_arguments(hunter "" "ERROR_PAGE" "" "${ARGV}") - if("${hunter_ERROR_PAGE}" STREQUAL "") - hunter_gate_internal_error("Expected ERROR_PAGE") - endif() - message("") - foreach(x ${hunter_UNPARSED_ARGUMENTS}) - message("[hunter ** FATAL ERROR **] ${x}") - endforeach() - message("[hunter ** FATAL ERROR **] [Directory:${CMAKE_CURRENT_LIST_DIR}]") - message("") - hunter_gate_error_page("${hunter_ERROR_PAGE}") -endfunction() - -function(hunter_gate_user_error) - hunter_gate_fatal_error(${ARGV} ERROR_PAGE "error.incorrect.input.data") -endfunction() - -function(hunter_gate_self root version sha1 result) - string(COMPARE EQUAL "${root}" "" is_bad) - if(is_bad) - hunter_gate_internal_error("root is empty") - endif() - - string(COMPARE EQUAL "${version}" "" is_bad) - if(is_bad) - hunter_gate_internal_error("version is empty") - endif() - - string(COMPARE EQUAL "${sha1}" "" is_bad) - if(is_bad) - hunter_gate_internal_error("sha1 is empty") - endif() - - string(SUBSTRING "${sha1}" 0 7 archive_id) - - if(EXISTS "${root}/cmake/Hunter") - set(hunter_self "${root}") - else() - set( - hunter_self - "${root}/_Base/Download/Hunter/${version}/${archive_id}/Unpacked" - ) - endif() - - set("${result}" "${hunter_self}" PARENT_SCOPE) -endfunction() - -# Set HUNTER_GATE_ROOT cmake variable to suitable value. -function(hunter_gate_detect_root) - # Check CMake variable - string(COMPARE NOTEQUAL "${HUNTER_ROOT}" "" not_empty) - if(not_empty) - set(HUNTER_GATE_ROOT "${HUNTER_ROOT}" PARENT_SCOPE) - hunter_gate_status_debug("HUNTER_ROOT detected by cmake variable") - return() - endif() - - # Check environment variable - string(COMPARE NOTEQUAL "$ENV{HUNTER_ROOT}" "" not_empty) - if(not_empty) - set(HUNTER_GATE_ROOT "$ENV{HUNTER_ROOT}" PARENT_SCOPE) - hunter_gate_status_debug("HUNTER_ROOT detected by environment variable") - return() - endif() - - # Check HOME environment variable - string(COMPARE NOTEQUAL "$ENV{HOME}" "" result) - if(result) - set(HUNTER_GATE_ROOT "$ENV{HOME}/.hunter" PARENT_SCOPE) - hunter_gate_status_debug("HUNTER_ROOT set using HOME environment variable") - return() - endif() - - # Check SYSTEMDRIVE and USERPROFILE environment variable (windows only) - if(WIN32) - string(COMPARE NOTEQUAL "$ENV{SYSTEMDRIVE}" "" result) - if(result) - set(HUNTER_GATE_ROOT "$ENV{SYSTEMDRIVE}/.hunter" PARENT_SCOPE) - hunter_gate_status_debug( - "HUNTER_ROOT set using SYSTEMDRIVE environment variable" - ) - return() - endif() - - string(COMPARE NOTEQUAL "$ENV{USERPROFILE}" "" result) - if(result) - set(HUNTER_GATE_ROOT "$ENV{USERPROFILE}/.hunter" PARENT_SCOPE) - hunter_gate_status_debug( - "HUNTER_ROOT set using USERPROFILE environment variable" - ) - return() - endif() - endif() - - hunter_gate_fatal_error( - "Can't detect HUNTER_ROOT" - ERROR_PAGE "error.detect.hunter.root" - ) -endfunction() - -function(hunter_gate_download dir) - string( - COMPARE - NOTEQUAL - "$ENV{HUNTER_DISABLE_AUTOINSTALL}" - "" - disable_autoinstall - ) - if(disable_autoinstall AND NOT HUNTER_RUN_INSTALL) - hunter_gate_fatal_error( - "Hunter not found in '${dir}'" - "Set HUNTER_RUN_INSTALL=ON to auto-install it from '${HUNTER_GATE_URL}'" - "Settings:" - " HUNTER_ROOT: ${HUNTER_GATE_ROOT}" - " HUNTER_SHA1: ${HUNTER_GATE_SHA1}" - ERROR_PAGE "error.run.install" - ) - endif() - string(COMPARE EQUAL "${dir}" "" is_bad) - if(is_bad) - hunter_gate_internal_error("Empty 'dir' argument") - endif() - - string(COMPARE EQUAL "${HUNTER_GATE_SHA1}" "" is_bad) - if(is_bad) - hunter_gate_internal_error("HUNTER_GATE_SHA1 empty") - endif() - - string(COMPARE EQUAL "${HUNTER_GATE_URL}" "" is_bad) - if(is_bad) - hunter_gate_internal_error("HUNTER_GATE_URL empty") - endif() - - set(done_location "${dir}/DONE") - set(sha1_location "${dir}/SHA1") - - set(build_dir "${dir}/Build") - set(cmakelists "${dir}/CMakeLists.txt") - - hunter_gate_status_debug("Locking directory: ${dir}") - file(LOCK "${dir}" DIRECTORY GUARD FUNCTION) - hunter_gate_status_debug("Lock done") - - if(EXISTS "${done_location}") - # while waiting for lock other instance can do all the job - hunter_gate_status_debug("File '${done_location}' found, skip install") - return() - endif() - - file(REMOVE_RECURSE "${build_dir}") - file(REMOVE_RECURSE "${cmakelists}") - - file(MAKE_DIRECTORY "${build_dir}") # check directory permissions - - # Disabling languages speeds up a little bit, reduces noise in the output - # and avoids path too long windows error - file( - WRITE - "${cmakelists}" - "cmake_minimum_required(VERSION 3.2)\n" - "project(HunterDownload LANGUAGES NONE)\n" - "include(ExternalProject)\n" - "ExternalProject_Add(\n" - " Hunter\n" - " URL\n" - " \"${HUNTER_GATE_URL}\"\n" - " URL_HASH\n" - " SHA1=${HUNTER_GATE_SHA1}\n" - " DOWNLOAD_DIR\n" - " \"${dir}\"\n" - " TLS_VERIFY\n" - " ${HUNTER_TLS_VERIFY}\n" - " SOURCE_DIR\n" - " \"${dir}/Unpacked\"\n" - " CONFIGURE_COMMAND\n" - " \"\"\n" - " BUILD_COMMAND\n" - " \"\"\n" - " INSTALL_COMMAND\n" - " \"\"\n" - ")\n" - ) - - if(HUNTER_STATUS_DEBUG) - set(logging_params "") - else() - set(logging_params OUTPUT_QUIET) - endif() - - hunter_gate_status_debug("Run generate") - - # Need to add toolchain file too. - # Otherwise on Visual Studio + MDD this will fail with error: - # "Could not find an appropriate version of the Windows 10 SDK installed on this machine" - if(EXISTS "${CMAKE_TOOLCHAIN_FILE}") - get_filename_component(absolute_CMAKE_TOOLCHAIN_FILE "${CMAKE_TOOLCHAIN_FILE}" ABSOLUTE) - set(toolchain_arg "-DCMAKE_TOOLCHAIN_FILE=${absolute_CMAKE_TOOLCHAIN_FILE}") - else() - # 'toolchain_arg' can't be empty - set(toolchain_arg "-DCMAKE_TOOLCHAIN_FILE=") - endif() - - string(COMPARE EQUAL "${CMAKE_MAKE_PROGRAM}" "" no_make) - if(no_make) - set(make_arg "") - else() - # Test case: remove Ninja from PATH but set it via CMAKE_MAKE_PROGRAM - set(make_arg "-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}") - endif() - - execute_process( - COMMAND - "${CMAKE_COMMAND}" - "-H${dir}" - "-B${build_dir}" - "-G${CMAKE_GENERATOR}" - "${toolchain_arg}" - ${make_arg} - WORKING_DIRECTORY "${dir}" - RESULT_VARIABLE download_result - ${logging_params} - ) - - if(NOT download_result EQUAL 0) - hunter_gate_internal_error( - "Configure project failed." - "To reproduce the error run: ${CMAKE_COMMAND} -H${dir} -B${build_dir} -G${CMAKE_GENERATOR} ${toolchain_arg} ${make_arg}" - "In directory ${dir}" - ) - endif() - - hunter_gate_status_print( - "Initializing Hunter workspace (${HUNTER_GATE_SHA1})" - " ${HUNTER_GATE_URL}" - " -> ${dir}" - ) - execute_process( - COMMAND "${CMAKE_COMMAND}" --build "${build_dir}" - WORKING_DIRECTORY "${dir}" - RESULT_VARIABLE download_result - ${logging_params} - ) - - if(NOT download_result EQUAL 0) - hunter_gate_internal_error("Build project failed") - endif() - - file(REMOVE_RECURSE "${build_dir}") - file(REMOVE_RECURSE "${cmakelists}") - - file(WRITE "${sha1_location}" "${HUNTER_GATE_SHA1}") - file(WRITE "${done_location}" "DONE") - - hunter_gate_status_debug("Finished") -endfunction() - -# Must be a macro so master file 'cmake/Hunter' can -# apply all variables easily just by 'include' command -# (otherwise PARENT_SCOPE magic needed) -macro(HunterGate) - if(HUNTER_GATE_DONE) - # variable HUNTER_GATE_DONE set explicitly for external project - # (see `hunter_download`) - set_property(GLOBAL PROPERTY HUNTER_GATE_DONE YES) - endif() - - # First HunterGate command will init Hunter, others will be ignored - get_property(_hunter_gate_done GLOBAL PROPERTY HUNTER_GATE_DONE SET) - - if(NOT HUNTER_ENABLED) - # Empty function to avoid error "unknown function" - function(hunter_add_package) - endfunction() - - set( - _hunter_gate_disabled_mode_dir - "${CMAKE_CURRENT_LIST_DIR}/cmake/Hunter/disabled-mode" - ) - if(EXISTS "${_hunter_gate_disabled_mode_dir}") - hunter_gate_status_debug( - "Adding \"disabled-mode\" modules: ${_hunter_gate_disabled_mode_dir}" - ) - list(APPEND CMAKE_PREFIX_PATH "${_hunter_gate_disabled_mode_dir}") - endif() - elseif(_hunter_gate_done) - hunter_gate_status_debug("Secondary HunterGate (use old settings)") - hunter_gate_self( - "${HUNTER_CACHED_ROOT}" - "${HUNTER_VERSION}" - "${HUNTER_SHA1}" - _hunter_self - ) - include("${_hunter_self}/cmake/Hunter") - else() - set(HUNTER_GATE_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}") - - string(COMPARE NOTEQUAL "${PROJECT_NAME}" "" _have_project_name) - if(_have_project_name) - hunter_gate_fatal_error( - "Please set HunterGate *before* 'project' command. " - "Detected project: ${PROJECT_NAME}" - ERROR_PAGE "error.huntergate.before.project" - ) - endif() - - cmake_parse_arguments( - HUNTER_GATE "LOCAL" "URL;SHA1;GLOBAL;FILEPATH" "" ${ARGV} - ) - - string(COMPARE EQUAL "${HUNTER_GATE_SHA1}" "" _empty_sha1) - string(COMPARE EQUAL "${HUNTER_GATE_URL}" "" _empty_url) - string( - COMPARE - NOTEQUAL - "${HUNTER_GATE_UNPARSED_ARGUMENTS}" - "" - _have_unparsed - ) - string(COMPARE NOTEQUAL "${HUNTER_GATE_GLOBAL}" "" _have_global) - string(COMPARE NOTEQUAL "${HUNTER_GATE_FILEPATH}" "" _have_filepath) - - if(_have_unparsed) - hunter_gate_user_error( - "HunterGate unparsed arguments: ${HUNTER_GATE_UNPARSED_ARGUMENTS}" - ) - endif() - if(_empty_sha1) - hunter_gate_user_error("SHA1 suboption of HunterGate is mandatory") - endif() - if(_empty_url) - hunter_gate_user_error("URL suboption of HunterGate is mandatory") - endif() - if(_have_global) - if(HUNTER_GATE_LOCAL) - hunter_gate_user_error("Unexpected LOCAL (already has GLOBAL)") - endif() - if(_have_filepath) - hunter_gate_user_error("Unexpected FILEPATH (already has GLOBAL)") - endif() - endif() - if(HUNTER_GATE_LOCAL) - if(_have_global) - hunter_gate_user_error("Unexpected GLOBAL (already has LOCAL)") - endif() - if(_have_filepath) - hunter_gate_user_error("Unexpected FILEPATH (already has LOCAL)") - endif() - endif() - if(_have_filepath) - if(_have_global) - hunter_gate_user_error("Unexpected GLOBAL (already has FILEPATH)") - endif() - if(HUNTER_GATE_LOCAL) - hunter_gate_user_error("Unexpected LOCAL (already has FILEPATH)") - endif() - endif() - - hunter_gate_detect_root() # set HUNTER_GATE_ROOT - - # Beautify path, fix probable problems with windows path slashes - get_filename_component( - HUNTER_GATE_ROOT "${HUNTER_GATE_ROOT}" ABSOLUTE - ) - hunter_gate_status_debug("HUNTER_ROOT: ${HUNTER_GATE_ROOT}") - if(NOT HUNTER_ALLOW_SPACES_IN_PATH) - string(FIND "${HUNTER_GATE_ROOT}" " " _contain_spaces) - if(NOT _contain_spaces EQUAL -1) - hunter_gate_fatal_error( - "HUNTER_ROOT (${HUNTER_GATE_ROOT}) contains spaces." - "Set HUNTER_ALLOW_SPACES_IN_PATH=ON to skip this error" - "(Use at your own risk!)" - ERROR_PAGE "error.spaces.in.hunter.root" - ) - endif() - endif() - - string( - REGEX - MATCH - "[0-9]+\\.[0-9]+\\.[0-9]+[-_a-z0-9]*" - HUNTER_GATE_VERSION - "${HUNTER_GATE_URL}" - ) - string(COMPARE EQUAL "${HUNTER_GATE_VERSION}" "" _is_empty) - if(_is_empty) - set(HUNTER_GATE_VERSION "unknown") - endif() - - hunter_gate_self( - "${HUNTER_GATE_ROOT}" - "${HUNTER_GATE_VERSION}" - "${HUNTER_GATE_SHA1}" - _hunter_self - ) - - set(_master_location "${_hunter_self}/cmake/Hunter") - if(EXISTS "${HUNTER_GATE_ROOT}/cmake/Hunter") - # Hunter downloaded manually (e.g. by 'git clone') - set(_unused "xxxxxxxxxx") - set(HUNTER_GATE_SHA1 "${_unused}") - set(HUNTER_GATE_VERSION "${_unused}") - else() - get_filename_component(_archive_id_location "${_hunter_self}/.." ABSOLUTE) - set(_done_location "${_archive_id_location}/DONE") - set(_sha1_location "${_archive_id_location}/SHA1") - - # Check Hunter already downloaded by HunterGate - if(NOT EXISTS "${_done_location}") - hunter_gate_download("${_archive_id_location}") - endif() - - if(NOT EXISTS "${_done_location}") - hunter_gate_internal_error("hunter_gate_download failed") - endif() - - if(NOT EXISTS "${_sha1_location}") - hunter_gate_internal_error("${_sha1_location} not found") - endif() - file(READ "${_sha1_location}" _sha1_value) - string(COMPARE EQUAL "${_sha1_value}" "${HUNTER_GATE_SHA1}" _is_equal) - if(NOT _is_equal) - hunter_gate_internal_error( - "Short SHA1 collision:" - " ${_sha1_value} (from ${_sha1_location})" - " ${HUNTER_GATE_SHA1} (HunterGate)" - ) - endif() - if(NOT EXISTS "${_master_location}") - hunter_gate_user_error( - "Master file not found:" - " ${_master_location}" - "try to update Hunter/HunterGate" - ) - endif() - endif() - include("${_master_location}") - set_property(GLOBAL PROPERTY HUNTER_GATE_DONE YES) - endif() -endmacro() diff --git a/cmake/depthaiDependencies.cmake b/cmake/depthaiDependencies.cmake index e67341f932..ed1b81676b 100644 --- a/cmake/depthaiDependencies.cmake +++ b/cmake/depthaiDependencies.cmake @@ -9,65 +9,36 @@ if(CONFIG_MODE) set(_QUIET "QUIET") else() set(DEPTHAI_SHARED_LIBS ${BUILD_SHARED_LIBS}) - hunter_add_package(nlohmann_json) - if(NOT DEPTHAI_XLINK_LOCAL) - hunter_add_package(XLink) - endif() - hunter_add_package(BZip2) - hunter_add_package(FP16) - hunter_add_package(libarchive-luxonis) - hunter_add_package(spdlog) - # hunter_add_package(ZLIB) - hunter_add_package(lz4-luxonis) - hunter_add_package(httplib) - hunter_add_package(PNG) - hunter_add_package(TIFF) - hunter_add_package(mp4v2) - if(DEPTHAI_ENABLE_CURL) - # hunter_add_package(CURL) - # hunter_add_package(cpr) - endif() - if(DEPTHAI_ENABLE_BACKWARD) - hunter_add_package(Backward) - endif() - hunter_add_package(libnop) - if(DEPTHAI_RTABMAP_SUPPORT) - hunter_add_package(rtbmap COMPONENTS core utilite) - endif() - if(DEPTHAI_BASALT_SUPPORT) - hunter_add_package(Eigen) - hunter_add_package(basalt-headers) - hunter_add_package(basalt) - hunter_add_package(oneTBB) - endif() - hunter_add_package(yaml-cpp) - hunter_add_package(semver) - if(DEPTHAI_HAS_APRIL_TAG) - hunter_add_package(apriltag) - endif() endif() - # If library was build as static, find all dependencies if(NOT CONFIG_MODE OR (CONFIG_MODE AND NOT DEPTHAI_SHARED_LIBS)) + if(DEPTHAI_BUILD_PYTHON) + find_package(pybind11 CONFIG REQUIRED) + # Print out the pybind11 version that was found + message(STATUS "Found pybind11 v${pybind11_VERSION}") + endif() # BZip2 (for bspatch) - find_package(BZip2 ${_QUIET} CONFIG REQUIRED) + find_package(BZip2 ${_QUIET} REQUIRED) + find_package(FFMPEG REQUIRED) + find_package(lz4 CONFIG REQUIRED) # FP16 for conversions - find_package(FP16 ${_QUIET} CONFIG REQUIRED) + find_path(FP16_INCLUDE_DIR NAMES fp16.h) + find_package(PNG REQUIRED) # libarchive for firmware packages - find_package(archive_static ${_QUIET} CONFIG REQUIRED) - find_package(lzma ${_QUIET} CONFIG REQUIRED) + find_package(LibArchive ${_QUIET} REQUIRED) + find_package(liblzma ${_QUIET} CONFIG REQUIRED) + # httplib for Gate communication + find_package(httplib ${_QUIET} CONFIG REQUIRED) # ZLIB for compressing Apps - find_package(ZLIB CONFIG REQUIRED) - find_package(lz4 CONFIG REQUIRED) + find_package(ZLIB REQUIRED) # spdlog for library and device logging find_package(spdlog ${_QUIET} CONFIG REQUIRED) - # httplib for Gate communication - find_package(httplib ${_QUIET} CONFIG REQUIRED) + find_package(OpenSSL REQUIRED) # Log collection dependencies if(DEPTHAI_ENABLE_CURL) find_package(CURL ${_QUIET} CONFIG REQUIRED) @@ -139,34 +110,19 @@ if(DEPTHAI_PCL_SUPPORT AND NOT TARGET JsonCpp::JsonCpp) find_package(jsoncpp) endif() -set(MODULE_TEMP ${CMAKE_MODULE_PATH}) -set(PREFIX_TEMP ${CMAKE_PREFIX_PATH}) -set(CMAKE_MODULE_PATH ${_DEPTHAI_MODULE_PATH_ORIGINAL}) -set(CMAKE_PREFIX_PATH ${_DEPTHAI_PREFIX_PATH_ORIGINAL}) -set(EIGEN_ROOT_TEMP ${EIGEN_ROOT}) -set(EIGEN_ROOT "") -set(CMAKE_FIND_ROOT_PATH_TMP ${CMAKE_FIND_ROOT_PATH}) -set(CMAKE_FIND_ROOT_PATH "") if(DEPTHAI_PCL_SUPPORT) find_package(PCL CONFIG COMPONENTS common) endif() -set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH_TMP}) if(DEPTHAI_RTABMAP_SUPPORT) find_package(RTABMap ${_QUIET} CONFIG REQUIRED COMPONENTS core utilite) +find_package(g2o ${_QUIET} CONFIG REQUIRED) + find_package(Ceres ${_QUIET} CONFIG REQUIRED) endif() -set(CMAKE_MODULE_PATH ${MODULE_TEMP}) -set(CMAKE_PREFIX_PATH ${PREFIX_TEMP}) -set(EIGEN_ROOT ${EIGEN_ROOT_TEMP}) - if(DEPTHAI_BASALT_SUPPORT) - find_package(Eigen3 ${_QUIET} CONFIG REQUIRED) +find_package(basalt-headers ${_QUIET} CONFIG REQUIRED) find_package(basalt_sdk ${_QUIET} CONFIG REQUIRED) - find_package(TBB 2021.12.0 EXACT CONFIG REQUIRED) - find_package(Sophus ${_QUIET} CONFIG REQUIRED) - find_package(magic_enum ${_QUIET} CONFIG REQUIRED) - find_package(fmt ${_QUIET} CONFIG REQUIRED) endif() # include optional dependency cmake diff --git a/cmake/ports/basalt-headers/portfile.cmake b/cmake/ports/basalt-headers/portfile.cmake new file mode 100644 index 0000000000..358981b078 --- /dev/null +++ b/cmake/ports/basalt-headers/portfile.cmake @@ -0,0 +1,18 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO luxonis/basalt-headers + REF 5392967dc6825838a52fa6d6ed38188a55a6acf7 + SHA512 7b22090aacf609e9b8417dd852607d09f0d0db144980852ec1cd73ae2e5fa0f095ef450011a8d7bf6b630f9af8a8ca5870d590de25b8c0783d843344aa48866b + HEAD_REF vcpkg_deps +) +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" +) + +vcpkg_cmake_install() + +vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/basalt-headers") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/lib" "${CURRENT_PACKAGES_DIR}/lib") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug") +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") diff --git a/cmake/ports/basalt-headers/vcpkg.json b/cmake/ports/basalt-headers/vcpkg.json new file mode 100644 index 0000000000..7de67c49d2 --- /dev/null +++ b/cmake/ports/basalt-headers/vcpkg.json @@ -0,0 +1,20 @@ + +{ + "name": "basalt-headers", + "version-string": "0.1.0", + "description": "Reusable components of Basalt project as header-only library", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + }, + "eigen3", + "sophus", + "cereal", + "fmt" +] +} diff --git a/cmake/ports/basalt/portfile.cmake b/cmake/ports/basalt/portfile.cmake new file mode 100644 index 0000000000..2dba7e7fb5 --- /dev/null +++ b/cmake/ports/basalt/portfile.cmake @@ -0,0 +1,21 @@ + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO luxonis/basalt + REF ac3cd0fbef91e889db27a1a779a5105ba715fef7 + SHA512 1e7694168f92af5f48f462a793fff528c46a4bd01d3417daf2031b651acba70ee9d61d38a33a1be217cc6e97baa67425e1a8fcc4e57a46033954757112326206 + HEAD_REF deps_test + PATCHES + win.patch +) +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DBASALT_SDK_ONLY=ON +) + +vcpkg_cmake_install() + +vcpkg_cmake_config_fixup(PACKAGE_NAME basalt_sdk CONFIG_PATH "lib/cmake/basalt_sdk") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") diff --git a/cmake/ports/basalt/vcpkg.json b/cmake/ports/basalt/vcpkg.json new file mode 100644 index 0000000000..b96f21f399 --- /dev/null +++ b/cmake/ports/basalt/vcpkg.json @@ -0,0 +1,23 @@ + +{ + "name": "basalt", + "version-string": "0.1.0", + "description": "Basalt: Visual-Inertial Mapping with Non-Linear Factor Recovery", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + }, + { + "name": "opencv4", + "default-features": false + }, + "basalt-headers", + "magic-enum", + "tbb" +] +} diff --git a/cmake/ports/basalt/win.patch b/cmake/ports/basalt/win.patch new file mode 100644 index 0000000000..0b853d3f4b --- /dev/null +++ b/cmake/ports/basalt/win.patch @@ -0,0 +1,15 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 4094b79..5735247 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -104,6 +104,10 @@ endif() + # base set of compile flags + set (BASALT_CXX_FLAGS) + ++if(WIN32) ++ set(BASALT_CXX_FLAGS "/bigobj") ++ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) ++endif() + # For avoiding libfmt >9 issues, see https://github.com/strasdat/Sophus/issues/366 #issuecomment-1229178088 + add_definitions(-DFMT_DEPRECATED_OSTREAM=1) + diff --git a/cmake/ports/cpr/portfile.cmake b/cmake/ports/cpr/portfile.cmake index 74b86601ab..af3e9bf1e4 100644 --- a/cmake/ports/cpr/portfile.cmake +++ b/cmake/ports/cpr/portfile.cmake @@ -35,4 +35,4 @@ vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/cpr) file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") -vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") \ No newline at end of file +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") diff --git a/cmake/ports/cpr/vcpkg.json b/cmake/ports/cpr/vcpkg.json index e4354b1921..efc49a5991 100644 --- a/cmake/ports/cpr/vcpkg.json +++ b/cmake/ports/cpr/vcpkg.json @@ -39,4 +39,4 @@ ] } } - } \ No newline at end of file + } diff --git a/cmake/ports/g2o/csparse.diff b/cmake/ports/g2o/csparse.diff new file mode 100644 index 0000000000..c939deef0c --- /dev/null +++ b/cmake/ports/g2o/csparse.diff @@ -0,0 +1,32 @@ +diff --git a/cmake_modules/FindCSparse.cmake b/cmake_modules/FindCSparse.cmake +index 5af693d..8be574f 100644 +--- a/cmake_modules/FindCSparse.cmake ++++ b/cmake_modules/FindCSparse.cmake +@@ -15,6 +15,8 @@ find_path(CSPARSE_INCLUDE_DIR NAMES cs.h + ) + + find_library(CSPARSE_LIBRARY NAMES cxsparse libcxsparse ++ cxsparsed libcxsparsed ++ NAMES_PER_DIR + PATHS + /usr/lib + /usr/local/lib +diff --git a/g2o/solvers/csparse/CMakeLists.txt b/g2o/solvers/csparse/CMakeLists.txt +index 60d1269..e6b80fc 100644 +--- a/g2o/solvers/csparse/CMakeLists.txt ++++ b/g2o/solvers/csparse/CMakeLists.txt +@@ -2,13 +2,13 @@ if(NOT G2O_USE_CSPARSE) + return() + endif() + +-include_directories(${CSPARSE_INCLUDE_DIR}) + + add_library(csparse_extension ${G2O_LGPL_LIB_TYPE} + csparse_helper.cpp csparse_helper.h + csparse_extension.cpp csparse_extension.h + g2o_csparse_extension_api.h + ) ++target_include_directories(csparse_extension PUBLIC ${CSPARSE_INCLUDE_DIR}) + set_target_properties(csparse_extension PROPERTIES OUTPUT_NAME ${LIB_PREFIX}csparse_extension) + if (APPLE) + set_target_properties(csparse_extension PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib") diff --git a/cmake/ports/g2o/opengl.patch b/cmake/ports/g2o/opengl.patch new file mode 100644 index 0000000000..fcac189d8c --- /dev/null +++ b/cmake/ports/g2o/opengl.patch @@ -0,0 +1,36 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index a3f66dd..1870723 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -158,6 +158,7 @@ find_package(OpenGL) + + # If OpenGL was found, use the import target if available. If not, use old-style includes + set(G2O_USE_OPENGL ON CACHE BOOL "Build g2o with OpenGL support for visualization") ++set(G2O_HAVE_OPENGL 0) + if (OPENGL_FOUND AND G2O_USE_OPENGL) + if (TARGET OpenGL::GL) + set(G2O_OPENGL_TARGET "OpenGL::GL;OpenGL::GLU") +@@ -165,7 +166,7 @@ if (OPENGL_FOUND AND G2O_USE_OPENGL) + set(G2O_OPENGL_TARGET "${OPENGL_LIBRARIES}") + include_directories(${OPENGL_INCLUDE_DIR}) + endif() +- set (G2O_HAVE_OPENGL 1) ++ set(G2O_HAVE_OPENGL 1) + message(STATUS "Compiling with OpenGL support") + #message(WARNING G2O_OPENGL_TARGET=${G2O_OPENGL_TARGET}) + endif() +diff --git a/cmake_modules/Config.cmake.in b/cmake_modules/Config.cmake.in +index d2913a1..ba57e32 100644 +--- a/cmake_modules/Config.cmake.in ++++ b/cmake_modules/Config.cmake.in +@@ -1,7 +1,9 @@ + include(CMakeFindDependencyMacro) + + find_dependency(Eigen3) +-find_dependency(OpenGL) ++if (@G2O_HAVE_OPENGL@) ++ find_dependency(OpenGL) ++endif() + + include("${CMAKE_CURRENT_LIST_DIR}/@G2O_TARGETS_EXPORT_NAME@.cmake") + diff --git a/cmake/ports/g2o/portfile.cmake b/cmake/ports/g2o/portfile.cmake new file mode 100644 index 0000000000..c4d4ec76a7 --- /dev/null +++ b/cmake/ports/g2o/portfile.cmake @@ -0,0 +1,47 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO RainerKuemmerle/g2o + REF fcba4eaca6f20d9a5792404cc8ef303aeb8ba5d2 + SHA512 41e5a6d40db10d66182653d56f937f29264bf4f9412dfa651be949caeb055741c9d9ba75a122180892aafe7d45b334d50470284121148c0561e1d49f6ba5e20a + HEAD_REF master + PATCHES + opengl.patch +) + +string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" BUILD_LGPL_SHARED_LIBS) +file(REMOVE "${SOURCE_PATH}/cmake_modules/FindBLAS.cmake") + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DBUILD_LGPL_SHARED_LIBS=OFF + -DG2O_BUILD_EXAMPLES=OFF + -DG2O_BUILD_APPS=OFF + -DG2O_USE_OPENGL=OFF + -DG2O_USE_CSPARSE=OFF +) + +vcpkg_cmake_install() + +vcpkg_copy_pdbs() + +vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/g2o) + +if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) + file(GLOB_RECURSE HEADERS "${CURRENT_PACKAGES_DIR}/include/*") + foreach(HEADER ${HEADERS}) + file(READ ${HEADER} HEADER_CONTENTS) + string(REPLACE "#ifdef G2O_SHARED_LIBS" "#if 1" HEADER_CONTENTS "${HEADER_CONTENTS}") + file(WRITE ${HEADER} "${HEADER_CONTENTS}") + endforeach() +endif() + +file(GLOB EXE "${CURRENT_PACKAGES_DIR}/bin/*.exe") +file(GLOB DEBUG_EXE "${CURRENT_PACKAGES_DIR}/debug/bin/*.exe") +if(EXE OR DEBUG_EXE) + file(REMOVE ${EXE} ${DEBUG_EXE}) +endif() +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") + +file(INSTALL "${SOURCE_PATH}/doc/license-bsd.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) diff --git a/cmake/ports/g2o/vcpkg.json b/cmake/ports/g2o/vcpkg.json new file mode 100644 index 0000000000..5483be881b --- /dev/null +++ b/cmake/ports/g2o/vcpkg.json @@ -0,0 +1,20 @@ +{ + "name": "g2o", + "version-date": "2020-02-07", + "port-version": 6, + "description": "g2o: A General Framework for Graph Optimization", + "homepage": "https://openslam.org/g2o.html", + "dependencies": [ + "ceres", + "eigen3", + "lapack", + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ] +} diff --git a/cmake/ports/libarchive/disable-warnings.patch b/cmake/ports/libarchive/disable-warnings.patch new file mode 100644 index 0000000000..38af15b60b --- /dev/null +++ b/cmake/ports/libarchive/disable-warnings.patch @@ -0,0 +1,14 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index b2634da..d037071 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -155,9 +155,6 @@ IF (MSVC) + ################################################################# + # Set compile flags for debug build. + # This is added into CMAKE_C_FLAGS when CMAKE_BUILD_TYPE is "Debug" +- # Enable level 4 C4062: The enumerate has no associated handler in a switch +- # statement and there is no default that can catch it. +- SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /w14062") + # Enable level 4 C4254: A larger bit field was assigned to a smaller bit + # field. + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /w14254") diff --git a/cmake/ports/libarchive/fix-buildsystem.patch b/cmake/ports/libarchive/fix-buildsystem.patch new file mode 100644 index 0000000000..75f8905aa5 --- /dev/null +++ b/cmake/ports/libarchive/fix-buildsystem.patch @@ -0,0 +1,110 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index b2634da6..0d846877 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -148,10 +148,6 @@ IF (CMAKE_C_COMPILER_ID MATCHES "^XL$") + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -qinfo=pro:use") + ENDIF(CMAKE_C_COMPILER_ID MATCHES "^XL$") + IF (MSVC) +- if (ENABLE_WERROR) +- # /WX option is the same as gcc's -Werror option. +- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX") +- endif () + ################################################################# + # Set compile flags for debug build. + # This is added into CMAKE_C_FLAGS when CMAKE_BUILD_TYPE is "Debug" +@@ -382,8 +378,6 @@ IF(DEFINED __GNUWIN32PATH AND EXISTS "${__GNUWIN32PATH}") + # Maybe DLL path is "C:/Program Files/GnuWin32/bin". + # The zlib and the bzip2 Setup program have installed programs and DLLs into + # "C:/Program Files/GnuWin32" by default. +- # This is convenience setting for Windows. +- SET(CMAKE_PREFIX_PATH ${__GNUWIN32PATH} $(CMAKE_PREFIX_PATH)) + # + # If you didn't use Setup program or installed into nonstandard path, + # cmake cannot find out your zlib or bzip2 libraries and include files, +@@ -420,14 +414,7 @@ IF(ZLIB_FOUND) + INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) + LIST(APPEND ADDITIONAL_LIBS ${ZLIB_LIBRARIES}) + IF(WIN32 AND NOT CYGWIN) +- # +- # Test if ZLIB_WINAPI macro is needed to use. +- # +- TRY_MACRO_FOR_LIBRARY( +- "${ZLIB_INCLUDE_DIR}" "${ZLIB_LIBRARIES}" +- RUNS +- "#include \nint main() {uLong f = zlibCompileFlags(); return (f&(1U<<10))?0:-1; }" +- ZLIB_WINAPI) ++ SET(ZLIB_WINAPI OFF) # skip following test, it crashes with weird message box + IF(ZLIB_WINAPI) + ADD_DEFINITIONS(-DZLIB_WINAPI) + ELSE(ZLIB_WINAPI) +@@ -1356,7 +1341,7 @@ CHECK_FUNCTION_EXISTS_GLIBC(localtime_r HAVE_LOCALTIME_R) + CHECK_FUNCTION_EXISTS_GLIBC(lstat HAVE_LSTAT) + CHECK_FUNCTION_EXISTS_GLIBC(lutimes HAVE_LUTIMES) + CHECK_FUNCTION_EXISTS_GLIBC(mbrtowc HAVE_MBRTOWC) +-CHECK_FUNCTION_EXISTS_GLIBC(memmove HAVE_MEMMOVE) ++set(HAVE_MEMMOVE 1) + CHECK_FUNCTION_EXISTS_GLIBC(mkdir HAVE_MKDIR) + CHECK_FUNCTION_EXISTS_GLIBC(mkfifo HAVE_MKFIFO) + CHECK_FUNCTION_EXISTS_GLIBC(mknod HAVE_MKNOD) +@@ -1388,10 +1373,10 @@ CHECK_FUNCTION_EXISTS_GLIBC(utime HAVE_UTIME) + CHECK_FUNCTION_EXISTS_GLIBC(utimes HAVE_UTIMES) + CHECK_FUNCTION_EXISTS_GLIBC(utimensat HAVE_UTIMENSAT) + CHECK_FUNCTION_EXISTS_GLIBC(vfork HAVE_VFORK) +-CHECK_FUNCTION_EXISTS_GLIBC(wcrtomb HAVE_WCRTOMB) +-CHECK_FUNCTION_EXISTS_GLIBC(wcscmp HAVE_WCSCMP) +-CHECK_FUNCTION_EXISTS_GLIBC(wcscpy HAVE_WCSCPY) +-CHECK_FUNCTION_EXISTS_GLIBC(wcslen HAVE_WCSLEN) +-CHECK_FUNCTION_EXISTS_GLIBC(wctomb HAVE_WCTOMB) ++set(HAVE_WCRTOMB 1) ++set(HAVE_WCSCMP 1) ++set(HAVE_WCSCPY 1) ++set(HAVE_WCSLEN 1) ++set(HAVE_WCTOMB 1) + CHECK_FUNCTION_EXISTS_GLIBC(_fseeki64 HAVE__FSEEKI64) + CHECK_FUNCTION_EXISTS_GLIBC(_get_timezone HAVE__GET_TIMEZONE) +@@ -1405,10 +1390,10 @@ CHECK_FUNCTION_EXISTS(cygwin_conv_path HAVE_CYGWIN_CONV_PATH) + CHECK_FUNCTION_EXISTS(fseeko HAVE_FSEEKO) + CHECK_FUNCTION_EXISTS(strerror_r HAVE_STRERROR_R) + CHECK_FUNCTION_EXISTS(strftime HAVE_STRFTIME) +-CHECK_FUNCTION_EXISTS(vprintf HAVE_VPRINTF) +-CHECK_FUNCTION_EXISTS(wmemcmp HAVE_WMEMCMP) +-CHECK_FUNCTION_EXISTS(wmemcpy HAVE_WMEMCPY) +-CHECK_FUNCTION_EXISTS(wmemmove HAVE_WMEMMOVE) ++set(HAVE_VPRINTF 1) ++set(HAVE_WMEMCMP 1) ++set(HAVE_WMEMCPY 1) ++set(HAVE_WMEMMOVE 1) + + CMAKE_POP_CHECK_STATE() # Restore the state of the variables + +@@ -2018,7 +2007,7 @@ INCLUDE(CreatePkgConfigFile) + # + # Register installation of PDF documents. + # +-IF(WIN32 AND NOT CYGWIN) ++IF(0) + # + # On Windows platform, It's better that we install PDF documents + # on one's computer. +diff --git a/libarchive/CMakeLists.txt b/libarchive/CMakeLists.txt +index f7fdfb68a..98d287e8c 100644 +--- a/libarchive/CMakeLists.txt ++++ b/libarchive/CMakeLists.txt +@@ -267,11 +267,12 @@ IF(ENABLE_INSTALL) + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) ++ ELSE() ++ INSTALL(TARGETS archive_static ++ RUNTIME DESTINATION bin ++ LIBRARY DESTINATION lib ++ ARCHIVE DESTINATION lib) + ENDIF(BUILD_SHARED_LIBS) +- INSTALL(TARGETS archive_static +- RUNTIME DESTINATION bin +- LIBRARY DESTINATION lib +- ARCHIVE DESTINATION lib) + INSTALL_MAN(${libarchive_MANS}) + INSTALL(FILES ${include_HEADERS} DESTINATION include) + ENDIF() diff --git a/cmake/ports/libarchive/fix-cpu-set.patch b/cmake/ports/libarchive/fix-cpu-set.patch new file mode 100644 index 0000000000..3a957e4cc8 --- /dev/null +++ b/cmake/ports/libarchive/fix-cpu-set.patch @@ -0,0 +1,15 @@ +diff --git a/libarchive/archive_random.c b/libarchive/archive_random.c +index 65ea691..63217ec 100644 +--- a/libarchive/archive_random.c ++++ b/libarchive/archive_random.c +@@ -48,6 +48,10 @@ __FBSDID("$FreeBSD$"); + #include + #endif + #ifdef HAVE_PTHREAD_H ++#ifdef __GNUC__ ++#define _GNU_SOURCE ++#include ++#endif + #include + #endif + diff --git a/cmake/ports/libarchive/fix-deps.patch b/cmake/ports/libarchive/fix-deps.patch new file mode 100644 index 0000000000..bc148475fa --- /dev/null +++ b/cmake/ports/libarchive/fix-deps.patch @@ -0,0 +1,252 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index dc61b28..7dcdefd 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -446,6 +446,8 @@ IF(DEFINED __GNUWIN32PATH AND EXISTS "${__GNUWIN32PATH}") + ENDIF(DEFINED __GNUWIN32PATH AND EXISTS "${__GNUWIN32PATH}") + + SET(ADDITIONAL_LIBS "") ++SET(LIBARCHIVE_LIBS_PRIVATE "") # additional libs for which the pc module is unknown ++SET(LIBSREQUIRED "") # pc modules for additonal libs + # + # Find ZLIB + # +@@ -462,6 +464,7 @@ IF(ZLIB_FOUND) + SET(HAVE_ZLIB_H 1) + INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) + LIST(APPEND ADDITIONAL_LIBS ${ZLIB_LIBRARIES}) ++ STRING(APPEND LIBSREQUIRED " zlib") + IF(WIN32 AND NOT CYGWIN) + SET(ZLIB_WINAPI OFF) # skip following test, it crashes with weird message box + IF(ZLIB_WINAPI) +@@ -494,6 +497,7 @@ IF(BZIP2_FOUND) + SET(HAVE_BZLIB_H 1) + INCLUDE_DIRECTORIES(${BZIP2_INCLUDE_DIR}) + LIST(APPEND ADDITIONAL_LIBS ${BZIP2_LIBRARIES}) ++ STRING(APPEND LIBSREQUIRED " bzip2") + # Test if a macro is needed for the library. + TRY_MACRO_FOR_LIBRARY( + "${BZIP2_INCLUDE_DIR}" "${BZIP2_LIBRARIES}" +@@ -522,6 +526,8 @@ ENDIF() + IF(LIBLZMA_FOUND) + SET(HAVE_LIBLZMA 1) + SET(HAVE_LZMA_H 1) ++ LIST(APPEND ADDITIONAL_LIBS LibLZMA::LibLZMA) ++ STRING(APPEND LIBSREQUIRED " liblzma") + CMAKE_PUSH_CHECK_STATE() + SET(CMAKE_REQUIRED_INCLUDES ${LIBLZMA_INCLUDE_DIR}) + SET(CMAKE_REQUIRED_LIBRARIES ${LIBLZMA_LIBRARIES}) +@@ -569,6 +575,7 @@ IF(LZO2_FOUND) + SET(HAVE_LZO_LZO1X_H 1) + INCLUDE_DIRECTORIES(${LZO2_INCLUDE_DIR}) + LIST(APPEND ADDITIONAL_LIBS ${LZO2_LIBRARY}) ++ STRING(APPEND LIBSREQUIRED " lzo2") + # + # TODO: test for static library. + # +@@ -597,6 +604,7 @@ IF(LIBB2_FOUND) + SET(ARCHIVE_BLAKE2 FALSE) + LIST(APPEND ADDITIONAL_LIBS ${LIBB2_LIBRARY}) + INCLUDE_DIRECTORIES(${LIBB2_INCLUDE_DIR}) ++ LIST(APPEND LIBARCHIVE_LIBS_PRIVATE ${LIBB2_LIBRARY}) + CMAKE_PUSH_CHECK_STATE() + SET(CMAKE_REQUIRED_LIBRARIES ${LIBB2_LIBRARY}) + SET(CMAKE_REQUIRED_INCLUDES ${LIBB2_INCLUDE_DIR}) +@@ -609,6 +617,8 @@ ENDIF(LIBB2_FOUND) + # Find LZ4 + # + IF(ENABLE_LZ4) ++ FIND_PACKAGE(LZ4 NAMES lz4 CONFIG REQUIRED) ++elseif(0) + IF (LZ4_INCLUDE_DIR) + # Already in cache, be silent + SET(LZ4_FIND_QUIETLY TRUE) +@@ -624,6 +634,10 @@ ENDIF(ENABLE_LZ4) + IF(LZ4_FOUND) + SET(HAVE_LIBLZ4 1) + SET(HAVE_LZ4_H 1) ++ SET(HAVE_LZ4HC_H 1) ++ LIST(APPEND ADDITIONAL_LIBS lz4::lz4) ++ STRING(APPEND LIBSREQUIRED " liblz4") ++elseif(0) + CMAKE_PUSH_CHECK_STATE() # Save the state of the variables + SET(CMAKE_REQUIRED_INCLUDES ${LZ4_INCLUDE_DIR}) + CHECK_INCLUDE_FILES("lz4hc.h" HAVE_LZ4HC_H) +@@ -640,6 +654,8 @@ MARK_AS_ADVANCED(CLEAR LZ4_LIBRARY) + # Find Zstd + # + IF(ENABLE_ZSTD) ++ FIND_PACKAGE(ZSTD NAMES zstd CONFIG REQUIRED) ++elseif(0) + IF (ZSTD_INCLUDE_DIR) + # Already in cache, be silent + SET(ZSTD_FIND_QUIETLY TRUE) +@@ -659,6 +675,11 @@ ELSE(ENABLE_ZSTD) + ENDIF(ENABLE_ZSTD) + IF(ZSTD_FOUND) + SET(HAVE_ZSTD_H 1) ++ SET(HAVE_LIBZSTD 1) ++ SET(HAVE_ZSTD_compressStream 1) ++ LIST(APPEND ADDITIONAL_LIBS zstd::libzstd) ++ STRING(APPEND LIBSREQUIRED " libzstd") ++elseif(0) + INCLUDE_DIRECTORIES(${ZSTD_INCLUDE_DIR}) + LIST(APPEND ADDITIONAL_LIBS ${ZSTD_LIBRARY}) + CMAKE_PUSH_CHECK_STATE() +@@ -768,6 +789,7 @@ IF(ENABLE_CNG) + LA_CHECK_INCLUDE_FILE("bcrypt.h" HAVE_BCRYPT_H) + IF(HAVE_BCRYPT_H) + LIST(APPEND ADDITIONAL_LIBS "bcrypt") ++ LIST(APPEND LIBARCHIVE_LIBS_PRIVATE "bcrypt") + ENDIF(HAVE_BCRYPT_H) + ELSE(ENABLE_CNG) + UNSET(HAVE_BCRYPT_H CACHE) +@@ -799,6 +821,7 @@ IF(ENABLE_MBEDTLS) + IF(MBEDTLS_FOUND) + SET(HAVE_LIBMBEDCRYPTO 1) + LIST(APPEND ADDITIONAL_LIBS ${MBEDCRYPTO_LIBRARY}) ++ LIST(APPEND LIBARCHIVE_LIBS_PRIVATE ${MBEDCRYPTO_LIBRARY}) + INCLUDE_DIRECTORIES(${MBEDTLS_INCLUDE_DIRS}) + + LIST(APPEND CMAKE_REQUIRED_INCLUDES ${MBEDTLS_INCLUDE_DIRS}) +@@ -819,6 +842,7 @@ IF(ENABLE_NETTLE) + IF(NETTLE_FOUND) + SET(HAVE_LIBNETTLE 1) + LIST(APPEND ADDITIONAL_LIBS ${NETTLE_LIBRARIES}) ++ STRING(APPEND LIBSREQUIRED " nettle") + INCLUDE_DIRECTORIES(${NETTLE_INCLUDE_DIR}) + + LIST(APPEND CMAKE_REQUIRED_INCLUDES ${NETTLE_INCLUDE_DIR}) +@@ -842,8 +866,8 @@ IF(ENABLE_OPENSSL AND NOT CMAKE_SYSTEM_NAME MATCHES "Darwin") + FIND_PACKAGE(OpenSSL) + IF(OPENSSL_FOUND) + SET(HAVE_LIBCRYPTO 1) +- INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR}) +- LIST(APPEND ADDITIONAL_LIBS ${OPENSSL_CRYPTO_LIBRARY}) ++ LIST(APPEND ADDITIONAL_LIBS OpenSSL::Crypto) ++ STRING(APPEND LIBSREQUIRED " libcrypto") + SET(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY}) + SET(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) + LA_CHECK_INCLUDE_FILE("openssl/evp.h" HAVE_OPENSSL_EVP_H) +@@ -861,6 +885,7 @@ IF(NOT OPENSSL_FOUND) + SET(CMAKE_REQUIRED_LIBRARIES "md") + FIND_LIBRARY(LIBMD_LIBRARY NAMES md) + LIST(APPEND ADDITIONAL_LIBS ${LIBMD_LIBRARY}) ++ LIST(APPEND LIBARCHIVE_LIBS_PRIVATE ${LIBMD_LIBRARY}) + CMAKE_POP_CHECK_STATE() # Restore the state of the variables + ENDIF(LIBMD_FOUND) + ENDIF(NOT OPENSSL_FOUND) +@@ -974,7 +999,8 @@ main(int argc, char **argv) + IF ("${IMPLEMENTATION}" MATCHES "^OPENSSL$" AND OPENSSL_FOUND) + INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR}) + LIST(APPEND ADDITIONAL_LIBS ${OPENSSL_LIBRARIES}) +- LIST(REMOVE_DUPLICATES ADDITIONAL_LIBS) ++ #LIST(REMOVE_DUPLICATES ADDITIONAL_LIBS) ++ STRING(APPEND LIBSREQUIRED " libssl") + ENDIF ("${IMPLEMENTATION}" MATCHES "^OPENSSL$" AND OPENSSL_FOUND) + ENDIF (ARCHIVE_CRYPTO_${ALGORITHM}_${IMPLEMENTATION}) + ENDIF(NOT ARCHIVE_CRYPTO_${ALGORITHM}) +@@ -1148,6 +1174,7 @@ IF(ENABLE_ICONV) + CHECK_ICONV("libiconv" "") + IF (HAVE_ICONV) + LIST(APPEND ADDITIONAL_LIBS ${LIBICONV_PATH}) ++ LIST(APPEND LIBARCHIVE_LIBS_PRIVATE ${LIBICONV_PATH}) + ENDIF(HAVE_ICONV) + ENDIF(NOT HAVE_ICONV AND LIBICONV_PATH) + ENDIF(ICONV_INCLUDE_DIR) +@@ -1181,6 +1208,7 @@ IF(ENABLE_ICONV) + ENDIF(WIN32 AND NOT CYGWIN) + IF(HAVE_LOCALE_CHARSET) + LIST(APPEND ADDITIONAL_LIBS ${LIBCHARSET_PATH}) ++ LIST(APPEND LIBARCHIVE_LIBS_PRIVATE ${LIBCHARSET_PATH}) + ENDIF(HAVE_LOCALE_CHARSET) + ENDIF(LIBCHARSET_PATH) + ENDIF(LIBICONV_PATH) +@@ -1214,6 +1242,7 @@ IF(LIBXML2_FOUND) + CMAKE_PUSH_CHECK_STATE() # Save the state of the variables + INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR}) + LIST(APPEND ADDITIONAL_LIBS ${LIBXML2_LIBRARIES}) ++ STRING(APPEND LIBSREQUIRED " libxml-2.0") + SET(HAVE_LIBXML2 1) + # libxml2's include files use iconv.h + SET(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR}) +@@ -1243,6 +1272,7 @@ ELSE(LIBXML2_FOUND) + CMAKE_PUSH_CHECK_STATE() # Save the state of the variables + INCLUDE_DIRECTORIES(${EXPAT_INCLUDE_DIR}) + LIST(APPEND ADDITIONAL_LIBS ${EXPAT_LIBRARIES}) ++ STRING(APPEND LIBSREQUIRED " expat") + SET(HAVE_LIBEXPAT 1) + LA_CHECK_INCLUDE_FILE("expat.h" HAVE_EXPAT_H) + CMAKE_POP_CHECK_STATE() # Restore the state of the variables +@@ -1273,6 +1303,7 @@ IF(POSIX_REGEX_LIB MATCHES "^(AUTO|LIBC|LIBREGEX)$") + CHECK_FUNCTION_EXISTS_GLIBC(regcomp HAVE_REGCOMP_LIBREGEX) + IF(HAVE_REGCOMP_LIBREGEX) + LIST(APPEND ADDITIONAL_LIBS ${REGEX_LIBRARY}) ++ LIST(APPEND LIBARCHIVE_LIBS_PRIVATE ${REGEX_LIBRARY}) + # + # If regex.h is not found, retry looking for regex.h at + # REGEX_INCLUDE_DIR +@@ -1322,6 +1353,7 @@ IF(NOT FOUND_POSIX_REGEX_LIB AND POSIX_REGEX_LIB MATCHES "^(AUTO|LIBPCREPOSIX)$" + IF(PCREPOSIX_FOUND) + INCLUDE_DIRECTORIES(${PCRE_INCLUDE_DIR}) + LIST(APPEND ADDITIONAL_LIBS ${PCREPOSIX_LIBRARIES}) ++ LIST(APPEND LIBARCHIVE_LIBS_PRIVATE ${PCREPOSIX_LIBRARIES}) + # Test if a macro is needed for the library. + TRY_MACRO_FOR_LIBRARY( + "${PCRE_INCLUDE_DIR}" "${PCREPOSIX_LIBRARIES}" +@@ -1333,6 +1365,7 @@ IF(NOT FOUND_POSIX_REGEX_LIB AND POSIX_REGEX_LIB MATCHES "^(AUTO|LIBPCREPOSIX)$" + ELSEIF(NOT WITHOUT_PCRE_STATIC AND NOT PCRE_STATIC AND PCRE_FOUND) + # Determine if pcre static libraries are to be used. + LIST(APPEND ADDITIONAL_LIBS ${PCRE_LIBRARIES}) ++ LIST(APPEND LIBARCHIVE_LIBS_PRIVATE ${PCRE_LIBRARIES}) + SET(TMP_LIBRARIES ${PCREPOSIX_LIBRARIES} ${PCRE_LIBRARIES}) + MESSAGE(STATUS "trying again with -lpcre included") + TRY_MACRO_FOR_LIBRARY( +@@ -1348,6 +1381,7 @@ IF(NOT FOUND_POSIX_REGEX_LIB AND POSIX_REGEX_LIB MATCHES "^(AUTO|LIBPCREPOSIX)$" + # ___chkstk_ms. + MESSAGE(STATUS "Visual Studio build detected, trying again with -lgcc included") + LIST(APPEND ADDITIONAL_LIBS ${LIBGCC_LIBRARIES}) ++ LIST(APPEND LIBARCHIVE_LIBS_PRIVATE ${LIBGCC_LIBRARIES}) + SET(TMP_LIBRARIES ${PCREPOSIX_LIBRARIES} ${PCRE_LIBRARIES} ${LIBGCC_LIBRARIES}) + TRY_MACRO_FOR_LIBRARY( + "${PCRE_INCLUDE_DIR}" "${TMP_LIBRARIES}" +@@ -1919,6 +1953,7 @@ IF(ENABLE_ACL) + SET(CMAKE_REQUIRED_LIBRARIES "acl") + FIND_LIBRARY(ACL_LIBRARY NAMES acl) + LIST(APPEND ADDITIONAL_LIBS ${ACL_LIBRARY}) ++ LIST(APPEND LIBARCHIVE_LIBS_PRIVATE ${ACL_LIBRARY}) + ENDIF(HAVE_LIBACL) + + CHECK_TYPE_EXISTS(acl_t "sys/types.h;sys/acl.h" HAVE_ACL_T) +@@ -2058,6 +2093,7 @@ int main(void) { return ACL_SYNCHRONIZE; }" HAVE_DECL_ACL_SYNCHRONIZE) + SET(CMAKE_REQUIRED_LIBRARIES "richacl") + FIND_LIBRARY(RICHACL_LIBRARY NAMES richacl) + LIST(APPEND ADDITIONAL_LIBS ${RICHACL_LIBRARY}) ++ LIST(APPEND LIBARCHIVE_LIBS_PRIVATE ${RICHACL_LIBRARY}) + ENDIF(HAVE_LIBRICHACL) + + CHECK_STRUCT_HAS_MEMBER("struct richace" e_type "sys/richacl.h" +diff --git a/build/cmake/CreatePkgConfigFile.cmake b/build/cmake/CreatePkgConfigFile.cmake +index bc5a43f..422b83b 100644 +--- a/build/cmake/CreatePkgConfigFile.cmake ++++ b/build/cmake/CreatePkgConfigFile.cmake +@@ -8,7 +8,7 @@ SET(libdir \${exec_prefix}/lib) + SET(includedir \${prefix}/include) + # Now, this is not particularly pretty, nor is it terribly accurate... + # Loop over all our additional libs +-FOREACH(mylib ${ADDITIONAL_LIBS}) ++FOREACH(mylib ${LIBARCHIVE_LIBS_PRIVATE}) + # Extract the filename from the absolute path + GET_FILENAME_COMPONENT(mylib_name ${mylib} NAME_WE) + # Strip the lib prefix +@@ -16,10 +16,6 @@ FOREACH(mylib ${ADDITIONAL_LIBS}) + # Append it to our LIBS string + SET(LIBS "${LIBS} -l${mylib_name}") + ENDFOREACH() +-# libxml2 is easier, since it's already using pkg-config +-FOREACH(mylib ${PC_LIBXML_STATIC_LDFLAGS}) +- SET(LIBS "${LIBS} ${mylib}") +-ENDFOREACH() + # FIXME: The order of the libraries doesn't take dependencies into account, + # thus there's a good chance it'll make some binutils versions unhappy... + # This only affects Libs.private (looked up for static builds) though. diff --git a/cmake/ports/libarchive/portfile.cmake b/cmake/ports/libarchive/portfile.cmake new file mode 100644 index 0000000000..cd679ae23e --- /dev/null +++ b/cmake/ports/libarchive/portfile.cmake @@ -0,0 +1,100 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO libarchive/libarchive + REF "v${VERSION}" + SHA512 95c6232d178b26daa0eeba43d64ea4235aa96fa279c85fff715ac5e6cc73b2e65f276770f91c3538cb8ca989380555169497628d73e120bfa52e12f657049ff0 + HEAD_REF master + PATCHES + disable-warnings.patch + fix-buildsystem.patch + fix-cpu-set.patch + fix-deps.patch +) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + bzip2 ENABLE_BZip2 + bzip2 CMAKE_REQUIRE_FIND_PACKAGE_BZip2 + libxml2 ENABLE_LIBXML2 + libxml2 CMAKE_REQUIRE_FIND_PACKAGE_LibXml2 + lz4 ENABLE_LZ4 + lz4 CMAKE_REQUIRE_FIND_PACKAGE_lz4 + lzma ENABLE_LZMA + lzma CMAKE_REQUIRE_FIND_PACKAGE_LibLZMA + lzo ENABLE_LZO + zstd ENABLE_ZSTD +) +# Default crypto backend is OpenSSL, but it is ignored for DARWIN +set(WRAPPER_ENABLE_OPENSSL OFF) +if(NOT "crypto" IN_LIST FEATURES) + list(APPEND FEATURE_OPTIONS + -DLIBMD_FOUND=FALSE + -DENABLE_OPENSSL=OFF + ) +elseif(VCPKG_TARGET_IS_OSX) + list(APPEND FEATURE_OPTIONS + -DENABLE_MBEDTLS=ON + -DENABLE_OPENSSL=OFF + -DCMAKE_REQUIRE_FIND_PACKAGE_MbedTLS=ON + ) +else() + set(WRAPPER_ENABLE_OPENSSL ON) + list(APPEND FEATURE_OPTIONS + -DCMAKE_REQUIRE_FIND_PACKAGE_OpenSSL=ON + ) +endif() + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DENABLE_ACL=OFF + -DENABLE_BZip2=OFF + -DENABLE_CAT=OFF + -DENABLE_CAT_SHARED=OFF + -DENABLE_CNG=OFF + -DENABLE_COVERAGE=OFF + -DENABLE_CPIO=OFF + -DENABLE_CPIO_SHARED=OFF + -DENABLE_EXPAT=OFF + -DENABLE_ICONV=OFF + -DENABLE_INSTALL=ON + -DENABLE_LIBB2=OFF + -DENABLE_LIBXML2=OFF + -DENABLE_LZ4=OFF + -DENABLE_LZMA=ON + -DENABLE_LZO=OFF + -DENABLE_LibGCC=OFF + -DENABLE_MBEDTLS=OFF + -DENABLE_NETTLE=OFF + -DENABLE_OPENSSL=OFF + -DENABLE_PCREPOSIX=OFF + -DENABLE_SAFESEH=AUTO + -DENABLE_TAR=OFF + -DENABLE_TAR_SHARED=OFF + -DENABLE_TEST=OFF + -DENABLE_WERROR=OFF + -DENABLE_XATTR=OFF + -DENABLE_ZLIB=OFF + -DENABLE_ZSTD=OFF +) + +vcpkg_cmake_install() + +vcpkg_fixup_pkgconfig() + +vcpkg_copy_pdbs() + +configure_file("${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake.in" "${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-cmake-wrapper.cmake" @ONLY) + +file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/debug/include" + "${CURRENT_PACKAGES_DIR}/debug/share" + "${CURRENT_PACKAGES_DIR}/share/man" +) + +foreach(header "include/archive.h" "include/archive_entry.h") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/${header}" "(!defined LIBARCHIVE_STATIC)" "0") +endforeach() + +file(INSTALL "${CURRENT_PORT_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) diff --git a/cmake/ports/libarchive/usage b/cmake/ports/libarchive/usage new file mode 100644 index 0000000000..213f642d2d --- /dev/null +++ b/cmake/ports/libarchive/usage @@ -0,0 +1,9 @@ +libarchive is compatible with the CMake Find Module: + + find_package(LibArchive REQUIRED) + target_link_libraries(main PRIVATE LibArchive::LibArchive) # since CMake 3.17 + +libarchive provides pkg-config modules: + + # library that can create and read several streaming archive formats + libarchive diff --git a/cmake/ports/libarchive/vcpkg-cmake-wrapper.cmake.in b/cmake/ports/libarchive/vcpkg-cmake-wrapper.cmake.in new file mode 100644 index 0000000000..3eb90e1bc2 --- /dev/null +++ b/cmake/ports/libarchive/vcpkg-cmake-wrapper.cmake.in @@ -0,0 +1,70 @@ +cmake_policy(PUSH) +cmake_policy(SET CMP0012 NEW) +cmake_policy(SET CMP0057 NEW) +set(z_vcpkg_libarchive_args "") +if("REQUIRED" IN_LIST ARGS) + list(APPEND z_vcpkg_libarchive_args "REQUIRED") +endif() +if("QUIET" IN_LIST ARGS) + list(APPEND z_vcpkg_libarchive_args "QUIET") +endif() + +_find_package(${ARGS}) + +if(LibArchive_FOUND AND "@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static") + set(z_vcpkg_libarchive_libs "") + find_package(ZLIB ${z_vcpkg_libarchive_args}) + list(APPEND z_vcpkg_libarchive_libs ZLIB::ZLIB) + if("@ENABLE_BZip2@") + find_package(BZip2 ${z_vcpkg_libarchive_args}) + list(APPEND z_vcpkg_libarchive_libs BZip2::BZip2) + endif() + if("@ENABLE_LIBXML2@") + find_package(LibXml2 ${z_vcpkg_libarchive_args}) + list(APPEND z_vcpkg_libarchive_libs LibXml2::LibXml2) + endif() + if("@ENABLE_LZ4@") + find_package(lz4 CONFIG ${z_vcpkg_libarchive_args}) + list(APPEND z_vcpkg_libarchive_libs lz4::lz4) + endif() + if("@ENABLE_LZMA@") + find_package(LibLZMA ${z_vcpkg_libarchive_args}) + list(APPEND z_vcpkg_libarchive_libs LibLZMA::LibLZMA) + endif() + if("@ENABLE_LZO@") + include(SelectLibraryConfigurations) + find_library(Z_VCPKG_LZO_LIBRARY_DEBUG NAMES lzo2d lzo2 NAMES_PER_DIR PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib" NO_DEFAULT_PATH) + find_library(Z_VCPKG_LZO_LIBRARY_RELEASE NAMES lzo2 NAMES_PER_DIR PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib" NO_DEFAULT_PATH) + select_library_configurations(Z_VCPKG_LZO) + if(Z_VCPKG_LZO_LIBRARY) + list(APPEND z_vcpkg_libarchive_libs ${Z_VCPKG_LZO_LIBRARY}) + else() + set(LibArchive_FOUND FALSE) + endif() + endif() + if("@ENABLE_ZSTD@") + find_package(zstd ${z_vcpkg_libarchive_args}) + list(APPEND z_vcpkg_libarchive_libs zstd::libzstd) + endif() + if("@WRAPPER_ENABLE_OPENSSL@") + find_package(OpenSSL ${z_vcpkg_libarchive_args}) + list(APPEND z_vcpkg_libarchive_libs OpenSSL::Crypto) + endif() + + if(TARGET LibArchive::LibArchive) + set(LibArchive_LIBRARIES LibArchive::LibArchive) + if(Z_VCPKG_LZO_LIBRARY AND Z_VCPKG_LZO_LIBRARY_DEBUG) + list(REMOVE_ITEM z_vcpkg_libarchive_libs ${Z_VCPKG_LZO_LIBRARY}) + list(APPEND z_vcpkg_libarchive_libs + "\$<\$>:${Z_VCPKG_LZO_LIBRARY_RELEASE}>" + "\$<\$:${Z_VCPKG_LZO_LIBRARY_DEBUG}>" + ) + endif() + set_property(TARGET LibArchive::LibArchive APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${z_vcpkg_libarchive_libs}) + else() + list(APPEND LibArchive_LIBRARIES ${z_vcpkg_libarchive_libs}) + endif() + unset(z_vcpkg_libarchive_libs) +endif() +unset(z_vcpkg_libarchive_args) +cmake_policy(POP) diff --git a/cmake/ports/libarchive/vcpkg.json b/cmake/ports/libarchive/vcpkg.json new file mode 100644 index 0000000000..4ca10824c6 --- /dev/null +++ b/cmake/ports/libarchive/vcpkg.json @@ -0,0 +1,76 @@ +{ + "name": "libarchive", + "version": "3.7.7", + "port-version": 1, + "description": "Library for reading and writing streaming archives", + "homepage": "https://www.libarchive.org", + "license": null, + "supports": "!uwp", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + "zlib", + "liblzma" + ], + "default-features": [ + "bzip2", + "crypto", + "libxml2", + "lz4", + "lzma", + "zstd" + ], + "features": { + "bzip2": { + "description": "BZip2 support", + "dependencies": [ + "bzip2" + ] + }, + "crypto": { + "description": "Support for cryptographic features", + "dependencies": [ + { + "name": "mbedtls", + "platform": "osx" + }, + { + "name": "openssl", + "platform": "!osx" + } + ] + }, + "libxml2": { + "description": "Libxml2 support", + "dependencies": [ + "libxml2" + ] + }, + "lz4": { + "description": "Lz4 support", + "dependencies": [ + "lz4" + ] + }, + "lzma": { + "description": "Lzma support", + "dependencies": [ + "liblzma" + ] + }, + "lzo": { + "description": "Lzo support", + "dependencies": [ + "lzo" + ] + }, + "zstd": { + "description": "Zstd support", + "dependencies": [ + "zstd" + ] + } + } +} diff --git a/cmake/ports/libnop/portfile.cmake b/cmake/ports/libnop/portfile.cmake new file mode 100644 index 0000000000..5aadbf4304 --- /dev/null +++ b/cmake/ports/libnop/portfile.cmake @@ -0,0 +1,13 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO luxonis/libnop + REF ab842f51dc2eb13916dc98417c2186b78320ed10 + SHA512 6353765ac8c489e66e0c91dc1da899e5a89200eb3834c95a1697b5e22e4d7186d920c24a67272ff92fdf22a0fac5b6b838345ad077e67693f35815c1cc9dbf17 + HEAD_REF develop +) +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" +) + +vcpkg_cmake_install() + diff --git a/cmake/ports/libnop/vcpkg.json b/cmake/ports/libnop/vcpkg.json new file mode 100644 index 0000000000..40837a65d6 --- /dev/null +++ b/cmake/ports/libnop/vcpkg.json @@ -0,0 +1,15 @@ +{ + "name": "libnop", + "version-string": "1.0-ec8f75a", + "description": "libnop: C++ Native Object Protocols", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } +] +} diff --git a/cmake/ports/libusb/portfile.cmake b/cmake/ports/libusb/portfile.cmake new file mode 100644 index 0000000000..b99523517d --- /dev/null +++ b/cmake/ports/libusb/portfile.cmake @@ -0,0 +1,19 @@ + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO luxonis/libusb + REF b7e4548958325b18feb73977163ad44398099534 + SHA512 b0fd00fe623a6fe527046002d94201cfe2dffe589bd77aa88473f25960e3ce7206a90290ee4fe66fa2e91766c5f6585379ba2b008e9fc7b33da43763127a4ef2 + HEAD_REF main +) +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + WITH_UDEV=OFF + # Build shared libs by default to not cause licensing issues + BUILD_SHARED_LIBS=ON +) + +vcpkg_cmake_install() + +vcpkg_fixup_pkgconfig() diff --git a/cmake/ports/libusb/vcpkg.json b/cmake/ports/libusb/vcpkg.json new file mode 100644 index 0000000000..63ad02d45f --- /dev/null +++ b/cmake/ports/libusb/vcpkg.json @@ -0,0 +1,19 @@ +{ + "name": "libusb", + "version": "1.0.27", + "port-version": 2, + "description": "a cross-platform library to access USB devices", + "homepage": "https://github.com/libusb/libusb", + "license": "LGPL-2.1-or-later", + "supports": "!uwp", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ] +} diff --git a/cmake/ports/mp4v2/portfile.cmake b/cmake/ports/mp4v2/portfile.cmake new file mode 100644 index 0000000000..c9a7134ec1 --- /dev/null +++ b/cmake/ports/mp4v2/portfile.cmake @@ -0,0 +1,24 @@ + + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO luxonis/mp4v2 + REF 1dc9f4d24645ea43405582e5c813dec3eaa8fd3e + SHA512 d1acef4d4fc03154f55dd04f0319c5ade8fa85ffc4d7f8240f68ff9f053079c337945e4c2a860d520b442b05cea8c873aede6ef104957bf64ee548020d7b641c + HEAD_REF master +) +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DBUILD_SHARED=OFF + -DBUILD_UTILS=OFF +) + +vcpkg_cmake_install() + +vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/mp4v2") +vcpkg_fixup_pkgconfig() + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING") diff --git a/cmake/ports/mp4v2/vcpkg.json b/cmake/ports/mp4v2/vcpkg.json new file mode 100644 index 0000000000..1559a9d245 --- /dev/null +++ b/cmake/ports/mp4v2/vcpkg.json @@ -0,0 +1,17 @@ + + +{ + "name": "mp4v2", + "version-string": "2.1.3", + "description": "Fork of the MP4v2 project", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } +] +} diff --git a/cmake/ports/pybind11/portfile.cmake b/cmake/ports/pybind11/portfile.cmake new file mode 100644 index 0000000000..e28582eab7 --- /dev/null +++ b/cmake/ports/pybind11/portfile.cmake @@ -0,0 +1,23 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO luxonis/pybind11 + REF f760e2b984b66be2cfa202c93da9d341a557fb5d + SHA512 8baad5c326553075926901b9e2d5fcb574d298b382f17ba8ae0abf022fe3c92f4704b4a3fdce9b63d12ef31a436afc04d11a2050639f254be886a88d201a8b85 + HEAD_REF luxonis-smart-holder +) +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DPYBIND11_TEST=OFF + # Disable all Python searching, Python required only for tests + -DPYBIND11_NOPYTHON=ON +) + +vcpkg_cmake_install() +vcpkg_cmake_config_fixup(CONFIG_PATH "share/cmake/pybind11") +vcpkg_fixup_pkgconfig() + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/") + +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") diff --git a/cmake/ports/pybind11/usage b/cmake/ports/pybind11/usage new file mode 100644 index 0000000000..1a149fe04d --- /dev/null +++ b/cmake/ports/pybind11/usage @@ -0,0 +1,23 @@ +pybind11 provides CMake targets. There are two modes provided; classic, which is built on the old Python +discovery packages in CMake, or the new FindPython mode, which uses FindPython +from 3.12+ forward (3.15+ _highly_ recommended). + +New FindPython mode: + + find_package(Python COMPONENTS Interpreter Development) + find_package(pybind11 CONFIG) + + # pybind11 method: + pybind11_add_module(MyModule1 src1.cpp) + + # Python method: + Python_add_library(MyModule2 src2.cpp) + target_link_libraries(MyModule2 pybind11::headers) + set_target_properties(MyModule2 PROPERTIES + INTERPROCEDURAL_OPTIMIZATION ON + CXX_VISIBILITY_PRESET ON + VISIBILITY_INLINES_HIDDEN ON + ) + +For more information see here: + https://pybind11.readthedocs.io/en/latest/compiling.html#building-with-cmake diff --git a/cmake/ports/pybind11/vcpkg.json b/cmake/ports/pybind11/vcpkg.json new file mode 100644 index 0000000000..238e4d25d4 --- /dev/null +++ b/cmake/ports/pybind11/vcpkg.json @@ -0,0 +1,16 @@ + +{ + "name": "pybind11", + "version-string": "luxonis-smart-holder", + "description": "Seamless operability between C++11 and Python", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } +] +} diff --git a/cmake/ports/rtabmap/apple.patch b/cmake/ports/rtabmap/apple.patch new file mode 100644 index 0000000000..1af23670de --- /dev/null +++ b/cmake/ports/rtabmap/apple.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 024c729..ddb1cae 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -119,8 +119,6 @@ endif() + #Other paths... + IF(APPLE) + # For Mac ports +- SET(CMAKE_INCLUDE_PATH "/opt/local/include;${CMAKE_INCLUDE_PATH}") +- SET(CMAKE_LIBRARY_PATH "/opt/local/lib;${CMAKE_LIBRARY_PATH}") + ENDIF() + + ####### Build libraries as shared or static ####### diff --git a/cmake/ports/rtabmap/fix_link.patch b/cmake/ports/rtabmap/fix_link.patch new file mode 100644 index 0000000000..77681a0501 --- /dev/null +++ b/cmake/ports/rtabmap/fix_link.patch @@ -0,0 +1,15 @@ +diff --git a/corelib/src/global_map/OctoMap.cpp b/corelib/src/global_map/OctoMap.cpp +index d4c22499..87acefcd 100644 +--- a/corelib/src/global_map/OctoMap.cpp ++++ b/corelib/src/global_map/OctoMap.cpp +@@ -278,10 +278,8 @@ RtabmapColorOcTree::StaticMemberInitializer::StaticMemberInitializer() { + AbstractOcTree::registerTreeType(tree); + } + +-#ifndef _WIN32 + // On Windows, the app freezes on start if the following is defined + RtabmapColorOcTree::StaticMemberInitializer RtabmapColorOcTree::RtabmapColorOcTreeMemberInit; +-#endif + + + ////////////////////////////////////// diff --git a/cmake/ports/rtabmap/gklib.patch b/cmake/ports/rtabmap/gklib.patch new file mode 100644 index 0000000000..2a66fcba18 --- /dev/null +++ b/cmake/ports/rtabmap/gklib.patch @@ -0,0 +1,13 @@ +--- 0.21.4.1-44dcfeb2ff/corelib/src/CMakeLists.txt.old 2024-04-12 09:59:07.656980900 +0200 ++++ 0.21.4.1-44dcfeb2ff/corelib/src/CMakeLists.txt 2024-04-12 09:59:46.701218300 +0200 +@@ -747,8 +747,8 @@ IF(GTSAM_FOUND) + ) + IF(WIN32) + #explicitly add metis target on windows (after gtsam target) +- SET(LIBRARIES +- ${LIBRARIES} ++ SET(PUBLIC_LIBRARIES ++ ${PUBLIC_LIBRARIES} + metis + ) + ENDIF(WIN32) diff --git a/cmake/ports/rtabmap/link-keywords.patch b/cmake/ports/rtabmap/link-keywords.patch new file mode 100644 index 0000000000..891266d274 --- /dev/null +++ b/cmake/ports/rtabmap/link-keywords.patch @@ -0,0 +1,12 @@ +diff --git a/corelib/src/CMakeLists.txt b/corelib/src/CMakeLists.txt +index 6a4a9ab..85ede4e 100644 +--- a/corelib/src/CMakeLists.txt ++++ b/corelib/src/CMakeLists.txt +@@ -167,7 +167,6 @@ SET(LIBRARIES + # Issue that qhull dependency uses optimized and debug keywords, + # which are converted to \$<\$> and \$<\$ + # in RTABMap_coreTargets.cmake (not sure why?!). +-list(REMOVE_ITEM PCL_LIBRARIES "debug" "optimized") + SET(PUBLIC_LIBRARIES + ${OpenCV_LIBS} + ${PCL_LIBRARIES} diff --git a/cmake/ports/rtabmap/lz4.patch b/cmake/ports/rtabmap/lz4.patch new file mode 100644 index 0000000000..346a394ad5 --- /dev/null +++ b/cmake/ports/rtabmap/lz4.patch @@ -0,0 +1,2871 @@ +diff --git a/corelib/src/CMakeLists.txt b/corelib/src/CMakeLists.txt +index b18b3b6..8d5a945 100644 +--- a/corelib/src/CMakeLists.txt ++++ b/corelib/src/CMakeLists.txt +@@ -121,9 +121,6 @@ SET(SRC_FILES + GlobalDescriptorExtractor.cpp + + GainCompensator.cpp +- +- rtflann/ext/lz4.c +- rtflann/ext/lz4hc.c + FlannIndex.cpp + + #clams stuff +@@ -167,11 +164,12 @@ SET(INCLUDE_DIRS + ${ZLIB_INCLUDE_DIRS} + ) + ++find_package(lz4 REQUIRED) + SET(PUBLIC_INCLUDE_DIRS + ${OpenCV_INCLUDE_DIRS} + ${PCL_INCLUDE_DIRS} ++ ${lz4_INCLUDE_DIRS} + ) +- + SET(LIBRARIES + ${ZLIB_LIBRARIES} + ) +@@ -182,6 +180,7 @@ SET(LIBRARIES + SET(PUBLIC_LIBRARIES + ${OpenCV_LIBS} + ${PCL_LIBRARIES} ++ ${lz4_LIBRARIES} + ) + + IF(SQLite3_FOUND) +diff --git a/corelib/src/rtflann/ext/lz4.c b/corelib/src/rtflann/ext/lz4.c +deleted file mode 100644 +index 08cf6b5..0000000 +--- a/corelib/src/rtflann/ext/lz4.c ++++ /dev/null +@@ -1,1516 +0,0 @@ +-/* +- LZ4 - Fast LZ compression algorithm +- Copyright (C) 2011-2015, Yann Collet. +- +- BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) +- +- Redistribution and use in source and binary forms, with or without +- modification, are permitted provided that the following conditions are +- met: +- +- * Redistributions of source code must retain the above copyright +- notice, this list of conditions and the following disclaimer. +- * Redistributions in binary form must reproduce the above +- copyright notice, this list of conditions and the following disclaimer +- in the documentation and/or other materials provided with the +- distribution. +- +- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- +- You can contact the author at : +- - LZ4 source repository : https://github.com/Cyan4973/lz4 +- - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c +-*/ +- +- +-/************************************** +-* Tuning parameters +-**************************************/ +-/* +- * HEAPMODE : +- * Select how default compression functions will allocate memory for their hash table, +- * in memory stack (0:default, fastest), or in memory heap (1:requires malloc()). +- */ +-#define HEAPMODE 0 +- +-/* +- * ACCELERATION_DEFAULT : +- * Select "acceleration" for LZ4_compress_fast() when parameter value <= 0 +- */ +-#define ACCELERATION_DEFAULT 1 +- +- +-/************************************** +-* CPU Feature Detection +-**************************************/ +-/* +- * LZ4_FORCE_SW_BITCOUNT +- * Define this parameter if your target system or compiler does not support hardware bit count +- */ +-#if defined(_MSC_VER) && defined(_WIN32_WCE) /* Visual Studio for Windows CE does not support Hardware bit count */ +-# define LZ4_FORCE_SW_BITCOUNT +-#endif +- +- +-/************************************** +-* Includes +-**************************************/ +-#include "lz4.h" +- +- +-/************************************** +-* Compiler Options +-**************************************/ +-#ifdef _MSC_VER /* Visual Studio */ +-# define FORCE_INLINE static __forceinline +-# include +-# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */ +-# pragma warning(disable : 4293) /* disable: C4293: too large shift (32-bits) */ +-#else +-# if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */ +-# if defined(__GNUC__) || defined(__clang__) +-# define FORCE_INLINE static inline __attribute__((always_inline)) +-# else +-# define FORCE_INLINE static inline +-# endif +-# else +-# define FORCE_INLINE static +-# endif /* __STDC_VERSION__ */ +-#endif /* _MSC_VER */ +- +-/* LZ4_GCC_VERSION is defined into lz4.h */ +-#if (LZ4_GCC_VERSION >= 302) || (__INTEL_COMPILER >= 800) || defined(__clang__) +-# define expect(expr,value) (__builtin_expect ((expr),(value)) ) +-#else +-# define expect(expr,value) (expr) +-#endif +- +-#define likely(expr) expect((expr) != 0, 1) +-#define unlikely(expr) expect((expr) != 0, 0) +- +- +-/************************************** +-* Memory routines +-**************************************/ +-#include /* malloc, calloc, free */ +-#define ALLOCATOR(n,s) calloc(n,s) +-#define FREEMEM free +-#include /* memset, memcpy */ +-#define MEM_INIT memset +- +- +-/************************************** +-* Basic Types +-**************************************/ +-#if defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */ +-# include +- typedef uint8_t BYTE; +- typedef uint16_t U16; +- typedef uint32_t U32; +- typedef int32_t S32; +- typedef uint64_t U64; +-#else +- typedef unsigned char BYTE; +- typedef unsigned short U16; +- typedef unsigned int U32; +- typedef signed int S32; +- typedef unsigned long long U64; +-#endif +- +- +-/************************************** +-* Reading and writing into memory +-**************************************/ +-#define STEPSIZE sizeof(size_t) +- +-static unsigned LZ4_64bits(void) { return sizeof(void*)==8; } +- +-static unsigned LZ4_isLittleEndian(void) +-{ +- const union { U32 i; BYTE c[4]; } one = { 1 }; /* don't use static : performance detrimental */ +- return one.c[0]; +-} +- +- +-static U16 LZ4_read16(const void* memPtr) +-{ +- U16 val16; +- memcpy(&val16, memPtr, 2); +- return val16; +-} +- +-static U16 LZ4_readLE16(const void* memPtr) +-{ +- if (LZ4_isLittleEndian()) +- { +- return LZ4_read16(memPtr); +- } +- else +- { +- const BYTE* p = (const BYTE*)memPtr; +- return (U16)((U16)p[0] + (p[1]<<8)); +- } +-} +- +-static void LZ4_writeLE16(void* memPtr, U16 value) +-{ +- if (LZ4_isLittleEndian()) +- { +- memcpy(memPtr, &value, 2); +- } +- else +- { +- BYTE* p = (BYTE*)memPtr; +- p[0] = (BYTE) value; +- p[1] = (BYTE)(value>>8); +- } +-} +- +-static U32 LZ4_read32(const void* memPtr) +-{ +- U32 val32; +- memcpy(&val32, memPtr, 4); +- return val32; +-} +- +-static U64 LZ4_read64(const void* memPtr) +-{ +- U64 val64; +- memcpy(&val64, memPtr, 8); +- return val64; +-} +- +-static size_t LZ4_read_ARCH(const void* p) +-{ +- if (LZ4_64bits()) +- return (size_t)LZ4_read64(p); +- else +- return (size_t)LZ4_read32(p); +-} +- +- +-static void LZ4_copy4(void* dstPtr, const void* srcPtr) { memcpy(dstPtr, srcPtr, 4); } +- +-static void LZ4_copy8(void* dstPtr, const void* srcPtr) { memcpy(dstPtr, srcPtr, 8); } +- +-/* customized version of memcpy, which may overwrite up to 7 bytes beyond dstEnd */ +-static void LZ4_wildCopy(void* dstPtr, const void* srcPtr, void* dstEnd) +-{ +- BYTE* d = (BYTE*)dstPtr; +- const BYTE* s = (const BYTE*)srcPtr; +- BYTE* e = (BYTE*)dstEnd; +- do { LZ4_copy8(d,s); d+=8; s+=8; } while (d>3); +-# elif (defined(__clang__) || (LZ4_GCC_VERSION >= 304)) && !defined(LZ4_FORCE_SW_BITCOUNT) +- return (__builtin_ctzll((U64)val) >> 3); +-# else +- static const int DeBruijnBytePos[64] = { 0, 0, 0, 0, 0, 1, 1, 2, 0, 3, 1, 3, 1, 4, 2, 7, 0, 2, 3, 6, 1, 5, 3, 5, 1, 3, 4, 4, 2, 5, 6, 7, 7, 0, 1, 2, 3, 3, 4, 6, 2, 6, 5, 5, 3, 4, 5, 6, 7, 1, 2, 4, 6, 4, 4, 5, 7, 2, 6, 5, 7, 6, 7, 7 }; +- return DeBruijnBytePos[((U64)((val & -(long long)val) * 0x0218A392CDABBD3FULL)) >> 58]; +-# endif +- } +- else /* 32 bits */ +- { +-# if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT) +- unsigned long r; +- _BitScanForward( &r, (U32)val ); +- return (int)(r>>3); +-# elif (defined(__clang__) || (LZ4_GCC_VERSION >= 304)) && !defined(LZ4_FORCE_SW_BITCOUNT) +- return (__builtin_ctz((U32)val) >> 3); +-# else +- static const int DeBruijnBytePos[32] = { 0, 0, 3, 0, 3, 1, 3, 0, 3, 2, 2, 1, 3, 2, 0, 1, 3, 3, 1, 2, 2, 2, 2, 0, 3, 1, 2, 0, 1, 0, 1, 1 }; +- return DeBruijnBytePos[((U32)((val & -(S32)val) * 0x077CB531U)) >> 27]; +-# endif +- } +- } +- else /* Big Endian CPU */ +- { +- if (LZ4_64bits()) +- { +-# if defined(_MSC_VER) && defined(_WIN64) && !defined(LZ4_FORCE_SW_BITCOUNT) +- unsigned long r = 0; +- _BitScanReverse64( &r, val ); +- return (unsigned)(r>>3); +-# elif (defined(__clang__) || (LZ4_GCC_VERSION >= 304)) && !defined(LZ4_FORCE_SW_BITCOUNT) +- return (__builtin_clzll((U64)val) >> 3); +-# else +- unsigned r; +- if (!(val>>32)) { r=4; } else { r=0; val>>=32; } +- if (!(val>>16)) { r+=2; val>>=8; } else { val>>=24; } +- r += (!val); +- return r; +-# endif +- } +- else /* 32 bits */ +- { +-# if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT) +- unsigned long r = 0; +- _BitScanReverse( &r, (unsigned long)val ); +- return (unsigned)(r>>3); +-# elif (defined(__clang__) || (LZ4_GCC_VERSION >= 304)) && !defined(LZ4_FORCE_SW_BITCOUNT) +- return (__builtin_clz((U32)val) >> 3); +-# else +- unsigned r; +- if (!(val>>16)) { r=2; val>>=8; } else { r=0; val>>=24; } +- r += (!val); +- return r; +-# endif +- } +- } +-} +- +-static unsigned LZ4_count(const BYTE* pIn, const BYTE* pMatch, const BYTE* pInLimit) +-{ +- const BYTE* const pStart = pIn; +- +- while (likely(pIn compression run slower on incompressible data */ +- +- +-/************************************** +-* Local Structures and types +-**************************************/ +-typedef struct { +- U32 hashTable[HASH_SIZE_U32]; +- U32 currentOffset; +- U32 initCheck; +- const BYTE* dictionary; +- BYTE* bufferStart; /* obsolete, used for slideInputBuffer */ +- U32 dictSize; +-} LZ4_stream_t_internal; +- +-typedef enum { notLimited = 0, limitedOutput = 1 } limitedOutput_directive; +-typedef enum { byPtr, byU32, byU16 } tableType_t; +- +-typedef enum { noDict = 0, withPrefix64k, usingExtDict } dict_directive; +-typedef enum { noDictIssue = 0, dictSmall } dictIssue_directive; +- +-typedef enum { endOnOutputSize = 0, endOnInputSize = 1 } endCondition_directive; +-typedef enum { full = 0, partial = 1 } earlyEnd_directive; +- +- +-/************************************** +-* Local Utils +-**************************************/ +-int LZ4_versionNumber (void) { return LZ4_VERSION_NUMBER; } +-int LZ4_compressBound(int isize) { return LZ4_COMPRESSBOUND(isize); } +-int LZ4_sizeofState() { return LZ4_STREAMSIZE; } +- +- +- +-/******************************** +-* Compression functions +-********************************/ +- +-static U32 LZ4_hashSequence(U32 sequence, tableType_t const tableType) +-{ +- if (tableType == byU16) +- return (((sequence) * 2654435761U) >> ((MINMATCH*8)-(LZ4_HASHLOG+1))); +- else +- return (((sequence) * 2654435761U) >> ((MINMATCH*8)-LZ4_HASHLOG)); +-} +- +-static const U64 prime5bytes = 889523592379ULL; +-static U32 LZ4_hashSequence64(size_t sequence, tableType_t const tableType) +-{ +- const U32 hashLog = (tableType == byU16) ? LZ4_HASHLOG+1 : LZ4_HASHLOG; +- const U32 hashMask = (1<> (40 - hashLog)) & hashMask; +-} +- +-static U32 LZ4_hashSequenceT(size_t sequence, tableType_t const tableType) +-{ +- if (LZ4_64bits()) +- return LZ4_hashSequence64(sequence, tableType); +- return LZ4_hashSequence((U32)sequence, tableType); +-} +- +-static U32 LZ4_hashPosition(const void* p, tableType_t tableType) { return LZ4_hashSequenceT(LZ4_read_ARCH(p), tableType); } +- +-static void LZ4_putPositionOnHash(const BYTE* p, U32 h, void* tableBase, tableType_t const tableType, const BYTE* srcBase) +-{ +- switch (tableType) +- { +- case byPtr: { const BYTE** hashTable = (const BYTE**)tableBase; hashTable[h] = p; return; } +- case byU32: { U32* hashTable = (U32*) tableBase; hashTable[h] = (U32)(p-srcBase); return; } +- case byU16: { U16* hashTable = (U16*) tableBase; hashTable[h] = (U16)(p-srcBase); return; } +- } +-} +- +-static void LZ4_putPosition(const BYTE* p, void* tableBase, tableType_t tableType, const BYTE* srcBase) +-{ +- U32 h = LZ4_hashPosition(p, tableType); +- LZ4_putPositionOnHash(p, h, tableBase, tableType, srcBase); +-} +- +-static const BYTE* LZ4_getPositionOnHash(U32 h, void* tableBase, tableType_t tableType, const BYTE* srcBase) +-{ +- if (tableType == byPtr) { const BYTE** hashTable = (const BYTE**) tableBase; return hashTable[h]; } +- if (tableType == byU32) { U32* hashTable = (U32*) tableBase; return hashTable[h] + srcBase; } +- { U16* hashTable = (U16*) tableBase; return hashTable[h] + srcBase; } /* default, to ensure a return */ +-} +- +-static const BYTE* LZ4_getPosition(const BYTE* p, void* tableBase, tableType_t tableType, const BYTE* srcBase) +-{ +- U32 h = LZ4_hashPosition(p, tableType); +- return LZ4_getPositionOnHash(h, tableBase, tableType, srcBase); +-} +- +-FORCE_INLINE int LZ4_compress_generic( +- void* const ctx, +- const char* const source, +- char* const dest, +- const int inputSize, +- const int maxOutputSize, +- const limitedOutput_directive outputLimited, +- const tableType_t tableType, +- const dict_directive dict, +- const dictIssue_directive dictIssue, +- const U32 acceleration) +-{ +- LZ4_stream_t_internal* const dictPtr = (LZ4_stream_t_internal*)ctx; +- +- const BYTE* ip = (const BYTE*) source; +- const BYTE* base; +- const BYTE* lowLimit; +- const BYTE* const lowRefLimit = ip - dictPtr->dictSize; +- const BYTE* const dictionary = dictPtr->dictionary; +- const BYTE* const dictEnd = dictionary + dictPtr->dictSize; +- const size_t dictDelta = dictEnd - (const BYTE*)source; +- const BYTE* anchor = (const BYTE*) source; +- const BYTE* const iend = ip + inputSize; +- const BYTE* const mflimit = iend - MFLIMIT; +- const BYTE* const matchlimit = iend - LASTLITERALS; +- +- BYTE* op = (BYTE*) dest; +- BYTE* const olimit = op + maxOutputSize; +- +- U32 forwardH; +- size_t refDelta=0; +- +- /* Init conditions */ +- if ((U32)inputSize > (U32)LZ4_MAX_INPUT_SIZE) return 0; /* Unsupported input size, too large (or negative) */ +- switch(dict) +- { +- case noDict: +- default: +- base = (const BYTE*)source; +- lowLimit = (const BYTE*)source; +- break; +- case withPrefix64k: +- base = (const BYTE*)source - dictPtr->currentOffset; +- lowLimit = (const BYTE*)source - dictPtr->dictSize; +- break; +- case usingExtDict: +- base = (const BYTE*)source - dictPtr->currentOffset; +- lowLimit = (const BYTE*)source; +- break; +- } +- if ((tableType == byU16) && (inputSize>=LZ4_64Klimit)) return 0; /* Size too large (not within 64K limit) */ +- if (inputSize> LZ4_skipTrigger); +- +- if (unlikely(forwardIp > mflimit)) goto _last_literals; +- +- match = LZ4_getPositionOnHash(h, ctx, tableType, base); +- if (dict==usingExtDict) +- { +- if (match<(const BYTE*)source) +- { +- refDelta = dictDelta; +- lowLimit = dictionary; +- } +- else +- { +- refDelta = 0; +- lowLimit = (const BYTE*)source; +- } +- } +- forwardH = LZ4_hashPosition(forwardIp, tableType); +- LZ4_putPositionOnHash(ip, h, ctx, tableType, base); +- +- } while ( ((dictIssue==dictSmall) ? (match < lowRefLimit) : 0) +- || ((tableType==byU16) ? 0 : (match + MAX_DISTANCE < ip)) +- || (LZ4_read32(match+refDelta) != LZ4_read32(ip)) ); +- } +- +- /* Catch up */ +- while ((ip>anchor) && (match+refDelta > lowLimit) && (unlikely(ip[-1]==match[refDelta-1]))) { ip--; match--; } +- +- { +- /* Encode Literal length */ +- unsigned litLength = (unsigned)(ip - anchor); +- token = op++; +- if ((outputLimited) && (unlikely(op + litLength + (2 + 1 + LASTLITERALS) + (litLength/255) > olimit))) +- return 0; /* Check output limit */ +- if (litLength>=RUN_MASK) +- { +- int len = (int)litLength-RUN_MASK; +- *token=(RUN_MASK<= 255 ; len-=255) *op++ = 255; +- *op++ = (BYTE)len; +- } +- else *token = (BYTE)(litLength< matchlimit) limit = matchlimit; +- matchLength = LZ4_count(ip+MINMATCH, match+MINMATCH, limit); +- ip += MINMATCH + matchLength; +- if (ip==limit) +- { +- unsigned more = LZ4_count(ip, (const BYTE*)source, matchlimit); +- matchLength += more; +- ip += more; +- } +- } +- else +- { +- matchLength = LZ4_count(ip+MINMATCH, match+MINMATCH, matchlimit); +- ip += MINMATCH + matchLength; +- } +- +- if ((outputLimited) && (unlikely(op + (1 + LASTLITERALS) + (matchLength>>8) > olimit))) +- return 0; /* Check output limit */ +- if (matchLength>=ML_MASK) +- { +- *token += ML_MASK; +- matchLength -= ML_MASK; +- for (; matchLength >= 510 ; matchLength-=510) { *op++ = 255; *op++ = 255; } +- if (matchLength >= 255) { matchLength-=255; *op++ = 255; } +- *op++ = (BYTE)matchLength; +- } +- else *token += (BYTE)(matchLength); +- } +- +- anchor = ip; +- +- /* Test end of chunk */ +- if (ip > mflimit) break; +- +- /* Fill table */ +- LZ4_putPosition(ip-2, ctx, tableType, base); +- +- /* Test next position */ +- match = LZ4_getPosition(ip, ctx, tableType, base); +- if (dict==usingExtDict) +- { +- if (match<(const BYTE*)source) +- { +- refDelta = dictDelta; +- lowLimit = dictionary; +- } +- else +- { +- refDelta = 0; +- lowLimit = (const BYTE*)source; +- } +- } +- LZ4_putPosition(ip, ctx, tableType, base); +- if ( ((dictIssue==dictSmall) ? (match>=lowRefLimit) : 1) +- && (match+MAX_DISTANCE>=ip) +- && (LZ4_read32(match+refDelta)==LZ4_read32(ip)) ) +- { token=op++; *token=0; goto _next_match; } +- +- /* Prepare next loop */ +- forwardH = LZ4_hashPosition(++ip, tableType); +- } +- +-_last_literals: +- /* Encode Last Literals */ +- { +- const size_t lastRun = (size_t)(iend - anchor); +- if ((outputLimited) && ((op - (BYTE*)dest) + lastRun + 1 + ((lastRun+255-RUN_MASK)/255) > (U32)maxOutputSize)) +- return 0; /* Check output limit */ +- if (lastRun >= RUN_MASK) +- { +- size_t accumulator = lastRun - RUN_MASK; +- *op++ = RUN_MASK << ML_BITS; +- for(; accumulator >= 255 ; accumulator-=255) *op++ = 255; +- *op++ = (BYTE) accumulator; +- } +- else +- { +- *op++ = (BYTE)(lastRun<= LZ4_compressBound(inputSize)) +- { +- if (inputSize < LZ4_64Klimit) +- return LZ4_compress_generic(state, source, dest, inputSize, 0, notLimited, byU16, noDict, noDictIssue, acceleration); +- else +- return LZ4_compress_generic(state, source, dest, inputSize, 0, notLimited, LZ4_64bits() ? byU32 : byPtr, noDict, noDictIssue, acceleration); +- } +- else +- { +- if (inputSize < LZ4_64Klimit) +- return LZ4_compress_generic(state, source, dest, inputSize, maxOutputSize, limitedOutput, byU16, noDict, noDictIssue, acceleration); +- else +- return LZ4_compress_generic(state, source, dest, inputSize, maxOutputSize, limitedOutput, LZ4_64bits() ? byU32 : byPtr, noDict, noDictIssue, acceleration); +- } +-} +- +- +-int LZ4_compress_fast(const char* source, char* dest, int inputSize, int maxOutputSize, int acceleration) +-{ +-#if (HEAPMODE) +- void* ctxPtr = ALLOCATOR(1, sizeof(LZ4_stream_t)); /* malloc-calloc always properly aligned */ +-#else +- LZ4_stream_t ctx; +- void* ctxPtr = &ctx; +-#endif +- +- int result = LZ4_compress_fast_extState(ctxPtr, source, dest, inputSize, maxOutputSize, acceleration); +- +-#if (HEAPMODE) +- FREEMEM(ctxPtr); +-#endif +- return result; +-} +- +- +-int LZ4_compress_default(const char* source, char* dest, int inputSize, int maxOutputSize) +-{ +- return LZ4_compress_fast(source, dest, inputSize, maxOutputSize, 1); +-} +- +- +-/* hidden debug function */ +-/* strangely enough, gcc generates faster code when this function is uncommented, even if unused */ +-int LZ4_compress_fast_force(const char* source, char* dest, int inputSize, int maxOutputSize, int acceleration) +-{ +- LZ4_stream_t ctx; +- +- LZ4_resetStream(&ctx); +- +- if (inputSize < LZ4_64Klimit) +- return LZ4_compress_generic(&ctx, source, dest, inputSize, maxOutputSize, limitedOutput, byU16, noDict, noDictIssue, acceleration); +- else +- return LZ4_compress_generic(&ctx, source, dest, inputSize, maxOutputSize, limitedOutput, LZ4_64bits() ? byU32 : byPtr, noDict, noDictIssue, acceleration); +-} +- +- +-/******************************** +-* destSize variant +-********************************/ +- +-static int LZ4_compress_destSize_generic( +- void* const ctx, +- const char* const src, +- char* const dst, +- int* const srcSizePtr, +- const int targetDstSize, +- const tableType_t tableType) +-{ +- const BYTE* ip = (const BYTE*) src; +- const BYTE* base = (const BYTE*) src; +- const BYTE* lowLimit = (const BYTE*) src; +- const BYTE* anchor = ip; +- const BYTE* const iend = ip + *srcSizePtr; +- const BYTE* const mflimit = iend - MFLIMIT; +- const BYTE* const matchlimit = iend - LASTLITERALS; +- +- BYTE* op = (BYTE*) dst; +- BYTE* const oend = op + targetDstSize; +- BYTE* const oMaxLit = op + targetDstSize - 2 /* offset */ - 8 /* because 8+MINMATCH==MFLIMIT */ - 1 /* token */; +- BYTE* const oMaxMatch = op + targetDstSize - (LASTLITERALS + 1 /* token */); +- BYTE* const oMaxSeq = oMaxLit - 1 /* token */; +- +- U32 forwardH; +- +- +- /* Init conditions */ +- if (targetDstSize < 1) return 0; /* Impossible to store anything */ +- if ((U32)*srcSizePtr > (U32)LZ4_MAX_INPUT_SIZE) return 0; /* Unsupported input size, too large (or negative) */ +- if ((tableType == byU16) && (*srcSizePtr>=LZ4_64Klimit)) return 0; /* Size too large (not within 64K limit) */ +- if (*srcSizePtr> LZ4_skipTrigger); +- +- if (unlikely(forwardIp > mflimit)) +- goto _last_literals; +- +- match = LZ4_getPositionOnHash(h, ctx, tableType, base); +- forwardH = LZ4_hashPosition(forwardIp, tableType); +- LZ4_putPositionOnHash(ip, h, ctx, tableType, base); +- +- } while ( ((tableType==byU16) ? 0 : (match + MAX_DISTANCE < ip)) +- || (LZ4_read32(match) != LZ4_read32(ip)) ); +- } +- +- /* Catch up */ +- while ((ip>anchor) && (match > lowLimit) && (unlikely(ip[-1]==match[-1]))) { ip--; match--; } +- +- { +- /* Encode Literal length */ +- unsigned litLength = (unsigned)(ip - anchor); +- token = op++; +- if (op + ((litLength+240)/255) + litLength > oMaxLit) +- { +- /* Not enough space for a last match */ +- op--; +- goto _last_literals; +- } +- if (litLength>=RUN_MASK) +- { +- unsigned len = litLength - RUN_MASK; +- *token=(RUN_MASK<= 255 ; len-=255) *op++ = 255; +- *op++ = (BYTE)len; +- } +- else *token = (BYTE)(litLength< oMaxMatch) +- { +- /* Match description too long : reduce it */ +- matchLength = (15-1) + (oMaxMatch-op) * 255; +- } +- //printf("offset %5i, matchLength%5i \n", (int)(ip-match), matchLength + MINMATCH); +- ip += MINMATCH + matchLength; +- +- if (matchLength>=ML_MASK) +- { +- *token += ML_MASK; +- matchLength -= ML_MASK; +- while (matchLength >= 255) { matchLength-=255; *op++ = 255; } +- *op++ = (BYTE)matchLength; +- } +- else *token += (BYTE)(matchLength); +- } +- +- anchor = ip; +- +- /* Test end of block */ +- if (ip > mflimit) break; +- if (op > oMaxSeq) break; +- +- /* Fill table */ +- LZ4_putPosition(ip-2, ctx, tableType, base); +- +- /* Test next position */ +- match = LZ4_getPosition(ip, ctx, tableType, base); +- LZ4_putPosition(ip, ctx, tableType, base); +- if ( (match+MAX_DISTANCE>=ip) +- && (LZ4_read32(match)==LZ4_read32(ip)) ) +- { token=op++; *token=0; goto _next_match; } +- +- /* Prepare next loop */ +- forwardH = LZ4_hashPosition(++ip, tableType); +- } +- +-_last_literals: +- /* Encode Last Literals */ +- { +- size_t lastRunSize = (size_t)(iend - anchor); +- if (op + 1 /* token */ + ((lastRunSize+240)/255) /* litLength */ + lastRunSize /* literals */ > oend) +- { +- /* adapt lastRunSize to fill 'dst' */ +- lastRunSize = (oend-op) - 1; +- lastRunSize -= (lastRunSize+240)/255; +- } +- ip = anchor + lastRunSize; +- +- if (lastRunSize >= RUN_MASK) +- { +- size_t accumulator = lastRunSize - RUN_MASK; +- *op++ = RUN_MASK << ML_BITS; +- for(; accumulator >= 255 ; accumulator-=255) *op++ = 255; +- *op++ = (BYTE) accumulator; +- } +- else +- { +- *op++ = (BYTE)(lastRunSize<= LZ4_compressBound(*srcSizePtr)) /* compression success is guaranteed */ +- { +- return LZ4_compress_fast_extState(state, src, dst, *srcSizePtr, targetDstSize, 1); +- } +- else +- { +- if (*srcSizePtr < LZ4_64Klimit) +- return LZ4_compress_destSize_generic(state, src, dst, srcSizePtr, targetDstSize, byU16); +- else +- return LZ4_compress_destSize_generic(state, src, dst, srcSizePtr, targetDstSize, LZ4_64bits() ? byU32 : byPtr); +- } +-} +- +- +-int LZ4_compress_destSize(const char* src, char* dst, int* srcSizePtr, int targetDstSize) +-{ +-#if (HEAPMODE) +- void* ctx = ALLOCATOR(1, sizeof(LZ4_stream_t)); /* malloc-calloc always properly aligned */ +-#else +- LZ4_stream_t ctxBody; +- void* ctx = &ctxBody; +-#endif +- +- int result = LZ4_compress_destSize_extState(ctx, src, dst, srcSizePtr, targetDstSize); +- +-#if (HEAPMODE) +- FREEMEM(ctx); +-#endif +- return result; +-} +- +- +- +-/******************************** +-* Streaming functions +-********************************/ +- +-LZ4_stream_t* LZ4_createStream(void) +-{ +- LZ4_stream_t* lz4s = (LZ4_stream_t*)ALLOCATOR(8, LZ4_STREAMSIZE_U64); +- LZ4_STATIC_ASSERT(LZ4_STREAMSIZE >= sizeof(LZ4_stream_t_internal)); /* A compilation error here means LZ4_STREAMSIZE is not large enough */ +- LZ4_resetStream(lz4s); +- return lz4s; +-} +- +-void LZ4_resetStream (LZ4_stream_t* LZ4_stream) +-{ +- MEM_INIT(LZ4_stream, 0, sizeof(LZ4_stream_t)); +-} +- +-int LZ4_freeStream (LZ4_stream_t* LZ4_stream) +-{ +- FREEMEM(LZ4_stream); +- return (0); +-} +- +- +-#define HASH_UNIT sizeof(size_t) +-int LZ4_loadDict (LZ4_stream_t* LZ4_dict, const char* dictionary, int dictSize) +-{ +- LZ4_stream_t_internal* dict = (LZ4_stream_t_internal*) LZ4_dict; +- const BYTE* p = (const BYTE*)dictionary; +- const BYTE* const dictEnd = p + dictSize; +- const BYTE* base; +- +- if ((dict->initCheck) || (dict->currentOffset > 1 GB)) /* Uninitialized structure, or reuse overflow */ +- LZ4_resetStream(LZ4_dict); +- +- if (dictSize < (int)HASH_UNIT) +- { +- dict->dictionary = NULL; +- dict->dictSize = 0; +- return 0; +- } +- +- if ((dictEnd - p) > 64 KB) p = dictEnd - 64 KB; +- dict->currentOffset += 64 KB; +- base = p - dict->currentOffset; +- dict->dictionary = p; +- dict->dictSize = (U32)(dictEnd - p); +- dict->currentOffset += dict->dictSize; +- +- while (p <= dictEnd-HASH_UNIT) +- { +- LZ4_putPosition(p, dict->hashTable, byU32, base); +- p+=3; +- } +- +- return dict->dictSize; +-} +- +- +-static void LZ4_renormDictT(LZ4_stream_t_internal* LZ4_dict, const BYTE* src) +-{ +- if ((LZ4_dict->currentOffset > 0x80000000) || +- ((size_t)LZ4_dict->currentOffset > (size_t)src)) /* address space overflow */ +- { +- /* rescale hash table */ +- U32 delta = LZ4_dict->currentOffset - 64 KB; +- const BYTE* dictEnd = LZ4_dict->dictionary + LZ4_dict->dictSize; +- int i; +- for (i=0; ihashTable[i] < delta) LZ4_dict->hashTable[i]=0; +- else LZ4_dict->hashTable[i] -= delta; +- } +- LZ4_dict->currentOffset = 64 KB; +- if (LZ4_dict->dictSize > 64 KB) LZ4_dict->dictSize = 64 KB; +- LZ4_dict->dictionary = dictEnd - LZ4_dict->dictSize; +- } +-} +- +- +-int LZ4_compress_fast_continue (LZ4_stream_t* LZ4_stream, const char* source, char* dest, int inputSize, int maxOutputSize, int acceleration) +-{ +- LZ4_stream_t_internal* streamPtr = (LZ4_stream_t_internal*)LZ4_stream; +- const BYTE* const dictEnd = streamPtr->dictionary + streamPtr->dictSize; +- +- const BYTE* smallest = (const BYTE*) source; +- if (streamPtr->initCheck) return 0; /* Uninitialized structure detected */ +- if ((streamPtr->dictSize>0) && (smallest>dictEnd)) smallest = dictEnd; +- LZ4_renormDictT(streamPtr, smallest); +- if (acceleration < 1) acceleration = ACCELERATION_DEFAULT; +- +- /* Check overlapping input/dictionary space */ +- { +- const BYTE* sourceEnd = (const BYTE*) source + inputSize; +- if ((sourceEnd > streamPtr->dictionary) && (sourceEnd < dictEnd)) +- { +- streamPtr->dictSize = (U32)(dictEnd - sourceEnd); +- if (streamPtr->dictSize > 64 KB) streamPtr->dictSize = 64 KB; +- if (streamPtr->dictSize < 4) streamPtr->dictSize = 0; +- streamPtr->dictionary = dictEnd - streamPtr->dictSize; +- } +- } +- +- /* prefix mode : source data follows dictionary */ +- if (dictEnd == (const BYTE*)source) +- { +- int result; +- if ((streamPtr->dictSize < 64 KB) && (streamPtr->dictSize < streamPtr->currentOffset)) +- result = LZ4_compress_generic(LZ4_stream, source, dest, inputSize, maxOutputSize, limitedOutput, byU32, withPrefix64k, dictSmall, acceleration); +- else +- result = LZ4_compress_generic(LZ4_stream, source, dest, inputSize, maxOutputSize, limitedOutput, byU32, withPrefix64k, noDictIssue, acceleration); +- streamPtr->dictSize += (U32)inputSize; +- streamPtr->currentOffset += (U32)inputSize; +- return result; +- } +- +- /* external dictionary mode */ +- { +- int result; +- if ((streamPtr->dictSize < 64 KB) && (streamPtr->dictSize < streamPtr->currentOffset)) +- result = LZ4_compress_generic(LZ4_stream, source, dest, inputSize, maxOutputSize, limitedOutput, byU32, usingExtDict, dictSmall, acceleration); +- else +- result = LZ4_compress_generic(LZ4_stream, source, dest, inputSize, maxOutputSize, limitedOutput, byU32, usingExtDict, noDictIssue, acceleration); +- streamPtr->dictionary = (const BYTE*)source; +- streamPtr->dictSize = (U32)inputSize; +- streamPtr->currentOffset += (U32)inputSize; +- return result; +- } +-} +- +- +-/* Hidden debug function, to force external dictionary mode */ +-int LZ4_compress_forceExtDict (LZ4_stream_t* LZ4_dict, const char* source, char* dest, int inputSize) +-{ +- LZ4_stream_t_internal* streamPtr = (LZ4_stream_t_internal*)LZ4_dict; +- int result; +- const BYTE* const dictEnd = streamPtr->dictionary + streamPtr->dictSize; +- +- const BYTE* smallest = dictEnd; +- if (smallest > (const BYTE*) source) smallest = (const BYTE*) source; +- LZ4_renormDictT((LZ4_stream_t_internal*)LZ4_dict, smallest); +- +- result = LZ4_compress_generic(LZ4_dict, source, dest, inputSize, 0, notLimited, byU32, usingExtDict, noDictIssue, 1); +- +- streamPtr->dictionary = (const BYTE*)source; +- streamPtr->dictSize = (U32)inputSize; +- streamPtr->currentOffset += (U32)inputSize; +- +- return result; +-} +- +- +-int LZ4_saveDict (LZ4_stream_t* LZ4_dict, char* safeBuffer, int dictSize) +-{ +- LZ4_stream_t_internal* dict = (LZ4_stream_t_internal*) LZ4_dict; +- const BYTE* previousDictEnd = dict->dictionary + dict->dictSize; +- +- if ((U32)dictSize > 64 KB) dictSize = 64 KB; /* useless to define a dictionary > 64 KB */ +- if ((U32)dictSize > dict->dictSize) dictSize = dict->dictSize; +- +- memmove(safeBuffer, previousDictEnd - dictSize, dictSize); +- +- dict->dictionary = (const BYTE*)safeBuffer; +- dict->dictSize = (U32)dictSize; +- +- return dictSize; +-} +- +- +- +-/******************************* +-* Decompression functions +-*******************************/ +-/* +- * This generic decompression function cover all use cases. +- * It shall be instantiated several times, using different sets of directives +- * Note that it is essential this generic function is really inlined, +- * in order to remove useless branches during compilation optimization. +- */ +-FORCE_INLINE int LZ4_decompress_generic( +- const char* const source, +- char* const dest, +- int inputSize, +- int outputSize, /* If endOnInput==endOnInputSize, this value is the max size of Output Buffer. */ +- +- int endOnInput, /* endOnOutputSize, endOnInputSize */ +- int partialDecoding, /* full, partial */ +- int targetOutputSize, /* only used if partialDecoding==partial */ +- int dict, /* noDict, withPrefix64k, usingExtDict */ +- const BYTE* const lowPrefix, /* == dest if dict == noDict */ +- const BYTE* const dictStart, /* only if dict==usingExtDict */ +- const size_t dictSize /* note : = 0 if noDict */ +- ) +-{ +- /* Local Variables */ +- const BYTE* ip = (const BYTE*) source; +- const BYTE* const iend = ip + inputSize; +- +- BYTE* op = (BYTE*) dest; +- BYTE* const oend = op + outputSize; +- BYTE* cpy; +- BYTE* oexit = op + targetOutputSize; +- const BYTE* const lowLimit = lowPrefix - dictSize; +- +- const BYTE* const dictEnd = (const BYTE*)dictStart + dictSize; +- const size_t dec32table[] = {4, 1, 2, 1, 4, 4, 4, 4}; +- const size_t dec64table[] = {0, 0, 0, (size_t)-1, 0, 1, 2, 3}; +- +- const int safeDecode = (endOnInput==endOnInputSize); +- const int checkOffset = ((safeDecode) && (dictSize < (int)(64 KB))); +- +- +- /* Special cases */ +- if ((partialDecoding) && (oexit> oend-MFLIMIT)) oexit = oend-MFLIMIT; /* targetOutputSize too high => decode everything */ +- if ((endOnInput) && (unlikely(outputSize==0))) return ((inputSize==1) && (*ip==0)) ? 0 : -1; /* Empty output buffer */ +- if ((!endOnInput) && (unlikely(outputSize==0))) return (*ip==0?1:-1); +- +- +- /* Main Loop */ +- while (1) +- { +- unsigned token; +- size_t length; +- const BYTE* match; +- +- /* get literal length */ +- token = *ip++; +- if ((length=(token>>ML_BITS)) == RUN_MASK) +- { +- unsigned s; +- do +- { +- s = *ip++; +- length += s; +- } +- while (likely((endOnInput)?ip(partialDecoding?oexit:oend-MFLIMIT)) || (ip+length>iend-(2+1+LASTLITERALS))) ) +- || ((!endOnInput) && (cpy>oend-COPYLENGTH))) +- { +- if (partialDecoding) +- { +- if (cpy > oend) goto _output_error; /* Error : write attempt beyond end of output buffer */ +- if ((endOnInput) && (ip+length > iend)) goto _output_error; /* Error : read attempt beyond end of input buffer */ +- } +- else +- { +- if ((!endOnInput) && (cpy != oend)) goto _output_error; /* Error : block decoding must stop exactly there */ +- if ((endOnInput) && ((ip+length != iend) || (cpy > oend))) goto _output_error; /* Error : input must be consumed */ +- } +- memcpy(op, ip, length); +- ip += length; +- op += length; +- break; /* Necessarily EOF, due to parsing restrictions */ +- } +- LZ4_wildCopy(op, ip, cpy); +- ip += length; op = cpy; +- +- /* get offset */ +- match = cpy - LZ4_readLE16(ip); ip+=2; +- if ((checkOffset) && (unlikely(match < lowLimit))) goto _output_error; /* Error : offset outside destination buffer */ +- +- /* get matchlength */ +- length = token & ML_MASK; +- if (length == ML_MASK) +- { +- unsigned s; +- do +- { +- if ((endOnInput) && (ip > iend-LASTLITERALS)) goto _output_error; +- s = *ip++; +- length += s; +- } while (s==255); +- if ((safeDecode) && unlikely((size_t)(op+length)<(size_t)op)) goto _output_error; /* overflow detection */ +- } +- length += MINMATCH; +- +- /* check external dictionary */ +- if ((dict==usingExtDict) && (match < lowPrefix)) +- { +- if (unlikely(op+length > oend-LASTLITERALS)) goto _output_error; /* doesn't respect parsing restriction */ +- +- if (length <= (size_t)(lowPrefix-match)) +- { +- /* match can be copied as a single segment from external dictionary */ +- match = dictEnd - (lowPrefix-match); +- memmove(op, match, length); op += length; +- } +- else +- { +- /* match encompass external dictionary and current segment */ +- size_t copySize = (size_t)(lowPrefix-match); +- memcpy(op, dictEnd - copySize, copySize); +- op += copySize; +- copySize = length - copySize; +- if (copySize > (size_t)(op-lowPrefix)) /* overlap within current segment */ +- { +- BYTE* const endOfMatch = op + copySize; +- const BYTE* copyFrom = lowPrefix; +- while (op < endOfMatch) *op++ = *copyFrom++; +- } +- else +- { +- memcpy(op, lowPrefix, copySize); +- op += copySize; +- } +- } +- continue; +- } +- +- /* copy repeated sequence */ +- cpy = op + length; +- if (unlikely((op-match)<8)) +- { +- const size_t dec64 = dec64table[op-match]; +- op[0] = match[0]; +- op[1] = match[1]; +- op[2] = match[2]; +- op[3] = match[3]; +- match += dec32table[op-match]; +- LZ4_copy4(op+4, match); +- op += 8; match -= dec64; +- } else { LZ4_copy8(op, match); op+=8; match+=8; } +- +- if (unlikely(cpy>oend-12)) +- { +- if (cpy > oend-LASTLITERALS) goto _output_error; /* Error : last LASTLITERALS bytes must be literals */ +- if (op < oend-8) +- { +- LZ4_wildCopy(op, match, oend-8); +- match += (oend-8) - op; +- op = oend-8; +- } +- while (opprefixSize = (size_t) dictSize; +- lz4sd->prefixEnd = (const BYTE*) dictionary + dictSize; +- lz4sd->externalDict = NULL; +- lz4sd->extDictSize = 0; +- return 1; +-} +- +-/* +-*_continue() : +- These decoding functions allow decompression of multiple blocks in "streaming" mode. +- Previously decoded blocks must still be available at the memory position where they were decoded. +- If it's not possible, save the relevant part of decoded data into a safe buffer, +- and indicate where it stands using LZ4_setStreamDecode() +-*/ +-int LZ4_decompress_safe_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int compressedSize, int maxOutputSize) +-{ +- LZ4_streamDecode_t_internal* lz4sd = (LZ4_streamDecode_t_internal*) LZ4_streamDecode; +- int result; +- +- if (lz4sd->prefixEnd == (BYTE*)dest) +- { +- result = LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, +- endOnInputSize, full, 0, +- usingExtDict, lz4sd->prefixEnd - lz4sd->prefixSize, lz4sd->externalDict, lz4sd->extDictSize); +- if (result <= 0) return result; +- lz4sd->prefixSize += result; +- lz4sd->prefixEnd += result; +- } +- else +- { +- lz4sd->extDictSize = lz4sd->prefixSize; +- lz4sd->externalDict = lz4sd->prefixEnd - lz4sd->extDictSize; +- result = LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, +- endOnInputSize, full, 0, +- usingExtDict, (BYTE*)dest, lz4sd->externalDict, lz4sd->extDictSize); +- if (result <= 0) return result; +- lz4sd->prefixSize = result; +- lz4sd->prefixEnd = (BYTE*)dest + result; +- } +- +- return result; +-} +- +-int LZ4_decompress_fast_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int originalSize) +-{ +- LZ4_streamDecode_t_internal* lz4sd = (LZ4_streamDecode_t_internal*) LZ4_streamDecode; +- int result; +- +- if (lz4sd->prefixEnd == (BYTE*)dest) +- { +- result = LZ4_decompress_generic(source, dest, 0, originalSize, +- endOnOutputSize, full, 0, +- usingExtDict, lz4sd->prefixEnd - lz4sd->prefixSize, lz4sd->externalDict, lz4sd->extDictSize); +- if (result <= 0) return result; +- lz4sd->prefixSize += originalSize; +- lz4sd->prefixEnd += originalSize; +- } +- else +- { +- lz4sd->extDictSize = lz4sd->prefixSize; +- lz4sd->externalDict = (BYTE*)dest - lz4sd->extDictSize; +- result = LZ4_decompress_generic(source, dest, 0, originalSize, +- endOnOutputSize, full, 0, +- usingExtDict, (BYTE*)dest, lz4sd->externalDict, lz4sd->extDictSize); +- if (result <= 0) return result; +- lz4sd->prefixSize = originalSize; +- lz4sd->prefixEnd = (BYTE*)dest + originalSize; +- } +- +- return result; +-} +- +- +-/* +-Advanced decoding functions : +-*_usingDict() : +- These decoding functions work the same as "_continue" ones, +- the dictionary must be explicitly provided within parameters +-*/ +- +-FORCE_INLINE int LZ4_decompress_usingDict_generic(const char* source, char* dest, int compressedSize, int maxOutputSize, int safe, const char* dictStart, int dictSize) +-{ +- if (dictSize==0) +- return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, safe, full, 0, noDict, (BYTE*)dest, NULL, 0); +- if (dictStart+dictSize == dest) +- { +- if (dictSize >= (int)(64 KB - 1)) +- return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, safe, full, 0, withPrefix64k, (BYTE*)dest-64 KB, NULL, 0); +- return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, safe, full, 0, noDict, (BYTE*)dest-dictSize, NULL, 0); +- } +- return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, safe, full, 0, usingExtDict, (BYTE*)dest, (const BYTE*)dictStart, dictSize); +-} +- +-int LZ4_decompress_safe_usingDict(const char* source, char* dest, int compressedSize, int maxOutputSize, const char* dictStart, int dictSize) +-{ +- return LZ4_decompress_usingDict_generic(source, dest, compressedSize, maxOutputSize, 1, dictStart, dictSize); +-} +- +-int LZ4_decompress_fast_usingDict(const char* source, char* dest, int originalSize, const char* dictStart, int dictSize) +-{ +- return LZ4_decompress_usingDict_generic(source, dest, 0, originalSize, 0, dictStart, dictSize); +-} +- +-/* debug function */ +-int LZ4_decompress_safe_forceExtDict(const char* source, char* dest, int compressedSize, int maxOutputSize, const char* dictStart, int dictSize) +-{ +- return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, endOnInputSize, full, 0, usingExtDict, (BYTE*)dest, (const BYTE*)dictStart, dictSize); +-} +- +- +-/*************************************************** +-* Obsolete Functions +-***************************************************/ +-/* obsolete compression functions */ +-int LZ4_compress_limitedOutput(const char* source, char* dest, int inputSize, int maxOutputSize) { return LZ4_compress_default(source, dest, inputSize, maxOutputSize); } +-int LZ4_compress(const char* source, char* dest, int inputSize) { return LZ4_compress_default(source, dest, inputSize, LZ4_compressBound(inputSize)); } +-int LZ4_compress_limitedOutput_withState (void* state, const char* src, char* dst, int srcSize, int dstSize) { return LZ4_compress_fast_extState(state, src, dst, srcSize, dstSize, 1); } +-int LZ4_compress_withState (void* state, const char* src, char* dst, int srcSize) { return LZ4_compress_fast_extState(state, src, dst, srcSize, LZ4_compressBound(srcSize), 1); } +-int LZ4_compress_limitedOutput_continue (LZ4_stream_t* LZ4_stream, const char* src, char* dst, int srcSize, int maxDstSize) { return LZ4_compress_fast_continue(LZ4_stream, src, dst, srcSize, maxDstSize, 1); } +-int LZ4_compress_continue (LZ4_stream_t* LZ4_stream, const char* source, char* dest, int inputSize) { return LZ4_compress_fast_continue(LZ4_stream, source, dest, inputSize, LZ4_compressBound(inputSize), 1); } +- +-/* +-These function names are deprecated and should no longer be used. +-They are only provided here for compatibility with older user programs. +-- LZ4_uncompress is totally equivalent to LZ4_decompress_fast +-- LZ4_uncompress_unknownOutputSize is totally equivalent to LZ4_decompress_safe +-*/ +-int LZ4_uncompress (const char* source, char* dest, int outputSize) { return LZ4_decompress_fast(source, dest, outputSize); } +-int LZ4_uncompress_unknownOutputSize (const char* source, char* dest, int isize, int maxOutputSize) { return LZ4_decompress_safe(source, dest, isize, maxOutputSize); } +- +- +-/* Obsolete Streaming functions */ +- +-int LZ4_sizeofStreamState() { return LZ4_STREAMSIZE; } +- +-static void LZ4_init(LZ4_stream_t_internal* lz4ds, BYTE* base) +-{ +- MEM_INIT(lz4ds, 0, LZ4_STREAMSIZE); +- lz4ds->bufferStart = base; +-} +- +-int LZ4_resetStreamState(void* state, char* inputBuffer) +-{ +- if ((((size_t)state) & 3) != 0) return 1; /* Error : pointer is not aligned on 4-bytes boundary */ +- LZ4_init((LZ4_stream_t_internal*)state, (BYTE*)inputBuffer); +- return 0; +-} +- +-void* LZ4_create (char* inputBuffer) +-{ +- void* lz4ds = ALLOCATOR(8, LZ4_STREAMSIZE_U64); +- LZ4_init ((LZ4_stream_t_internal*)lz4ds, (BYTE*)inputBuffer); +- return lz4ds; +-} +- +-char* LZ4_slideInputBuffer (void* LZ4_Data) +-{ +- LZ4_stream_t_internal* ctx = (LZ4_stream_t_internal*)LZ4_Data; +- int dictSize = LZ4_saveDict((LZ4_stream_t*)LZ4_Data, (char*)ctx->bufferStart, 64 KB); +- return (char*)(ctx->bufferStart + dictSize); +-} +- +-/* Obsolete streaming decompression functions */ +- +-int LZ4_decompress_safe_withPrefix64k(const char* source, char* dest, int compressedSize, int maxOutputSize) +-{ +- return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, endOnInputSize, full, 0, withPrefix64k, (BYTE*)dest - 64 KB, NULL, 64 KB); +-} +- +-int LZ4_decompress_fast_withPrefix64k(const char* source, char* dest, int originalSize) +-{ +- return LZ4_decompress_generic(source, dest, 0, originalSize, endOnOutputSize, full, 0, withPrefix64k, (BYTE*)dest - 64 KB, NULL, 64 KB); +-} +- +-#endif /* LZ4_COMMONDEFS_ONLY */ +- +diff --git a/corelib/src/rtflann/ext/lz4.h b/corelib/src/rtflann/ext/lz4.h +deleted file mode 100644 +index 3e74002..0000000 +--- a/corelib/src/rtflann/ext/lz4.h ++++ /dev/null +@@ -1,360 +0,0 @@ +-/* +- LZ4 - Fast LZ compression algorithm +- Header File +- Copyright (C) 2011-2015, Yann Collet. +- +- BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) +- +- Redistribution and use in source and binary forms, with or without +- modification, are permitted provided that the following conditions are +- met: +- +- * Redistributions of source code must retain the above copyright +- notice, this list of conditions and the following disclaimer. +- * Redistributions in binary form must reproduce the above +- copyright notice, this list of conditions and the following disclaimer +- in the documentation and/or other materials provided with the +- distribution. +- +- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- +- You can contact the author at : +- - LZ4 source repository : https://github.com/Cyan4973/lz4 +- - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c +-*/ +-#pragma once +- +-#if defined (__cplusplus) +-extern "C" { +-#endif +- +-/* +- * lz4.h provides block compression functions, and gives full buffer control to programmer. +- * If you need to generate inter-operable compressed data (respecting LZ4 frame specification), +- * and can let the library handle its own memory, please use lz4frame.h instead. +-*/ +- +-/************************************** +-* Version +-**************************************/ +-#define LZ4_VERSION_MAJOR 1 /* for breaking interface changes */ +-#define LZ4_VERSION_MINOR 7 /* for new (non-breaking) interface capabilities */ +-#define LZ4_VERSION_RELEASE 1 /* for tweaks, bug-fixes, or development */ +-#define LZ4_VERSION_NUMBER (LZ4_VERSION_MAJOR *100*100 + LZ4_VERSION_MINOR *100 + LZ4_VERSION_RELEASE) +-int LZ4_versionNumber (void); +- +-/************************************** +-* Tuning parameter +-**************************************/ +-/* +- * LZ4_MEMORY_USAGE : +- * Memory usage formula : N->2^N Bytes (examples : 10 -> 1KB; 12 -> 4KB ; 16 -> 64KB; 20 -> 1MB; etc.) +- * Increasing memory usage improves compression ratio +- * Reduced memory usage can improve speed, due to cache effect +- * Default value is 14, for 16KB, which nicely fits into Intel x86 L1 cache +- */ +-#define LZ4_MEMORY_USAGE 14 +- +- +-/************************************** +-* Simple Functions +-**************************************/ +- +-int LZ4_compress_default(const char* source, char* dest, int sourceSize, int maxDestSize); +-int LZ4_decompress_safe (const char* source, char* dest, int compressedSize, int maxDecompressedSize); +- +-/* +-LZ4_compress_default() : +- Compresses 'sourceSize' bytes from buffer 'source' +- into already allocated 'dest' buffer of size 'maxDestSize'. +- Compression is guaranteed to succeed if 'maxDestSize' >= LZ4_compressBound(sourceSize). +- It also runs faster, so it's a recommended setting. +- If the function cannot compress 'source' into a more limited 'dest' budget, +- compression stops *immediately*, and the function result is zero. +- As a consequence, 'dest' content is not valid. +- This function never writes outside 'dest' buffer, nor read outside 'source' buffer. +- sourceSize : Max supported value is LZ4_MAX_INPUT_VALUE +- maxDestSize : full or partial size of buffer 'dest' (which must be already allocated) +- return : the number of bytes written into buffer 'dest' (necessarily <= maxOutputSize) +- or 0 if compression fails +- +-LZ4_decompress_safe() : +- compressedSize : is the precise full size of the compressed block. +- maxDecompressedSize : is the size of destination buffer, which must be already allocated. +- return : the number of bytes decompressed into destination buffer (necessarily <= maxDecompressedSize) +- If destination buffer is not large enough, decoding will stop and output an error code (<0). +- If the source stream is detected malformed, the function will stop decoding and return a negative result. +- This function is protected against buffer overflow exploits, including malicious data packets. +- It never writes outside output buffer, nor reads outside input buffer. +-*/ +- +- +-/************************************** +-* Advanced Functions +-**************************************/ +-#define LZ4_MAX_INPUT_SIZE 0x7E000000 /* 2 113 929 216 bytes */ +-#define LZ4_COMPRESSBOUND(isize) ((unsigned)(isize) > (unsigned)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize)/255) + 16) +- +-/* +-LZ4_compressBound() : +- Provides the maximum size that LZ4 compression may output in a "worst case" scenario (input data not compressible) +- This function is primarily useful for memory allocation purposes (destination buffer size). +- Macro LZ4_COMPRESSBOUND() is also provided for compilation-time evaluation (stack memory allocation for example). +- Note that LZ4_compress_default() compress faster when dest buffer size is >= LZ4_compressBound(srcSize) +- inputSize : max supported value is LZ4_MAX_INPUT_SIZE +- return : maximum output size in a "worst case" scenario +- or 0, if input size is too large ( > LZ4_MAX_INPUT_SIZE) +-*/ +-int LZ4_compressBound(int inputSize); +- +-/* +-LZ4_compress_fast() : +- Same as LZ4_compress_default(), but allows to select an "acceleration" factor. +- The larger the acceleration value, the faster the algorithm, but also the lesser the compression. +- It's a trade-off. It can be fine tuned, with each successive value providing roughly +~3% to speed. +- An acceleration value of "1" is the same as regular LZ4_compress_default() +- Values <= 0 will be replaced by ACCELERATION_DEFAULT (see lz4.c), which is 1. +-*/ +-int LZ4_compress_fast (const char* source, char* dest, int sourceSize, int maxDestSize, int acceleration); +- +- +-/* +-LZ4_compress_fast_extState() : +- Same compression function, just using an externally allocated memory space to store compression state. +- Use LZ4_sizeofState() to know how much memory must be allocated, +- and allocate it on 8-bytes boundaries (using malloc() typically). +- Then, provide it as 'void* state' to compression function. +-*/ +-int LZ4_sizeofState(void); +-int LZ4_compress_fast_extState (void* state, const char* source, char* dest, int inputSize, int maxDestSize, int acceleration); +- +- +-/* +-LZ4_compress_destSize() : +- Reverse the logic, by compressing as much data as possible from 'source' buffer +- into already allocated buffer 'dest' of size 'targetDestSize'. +- This function either compresses the entire 'source' content into 'dest' if it's large enough, +- or fill 'dest' buffer completely with as much data as possible from 'source'. +- *sourceSizePtr : will be modified to indicate how many bytes where read from 'source' to fill 'dest'. +- New value is necessarily <= old value. +- return : Nb bytes written into 'dest' (necessarily <= targetDestSize) +- or 0 if compression fails +-*/ +-int LZ4_compress_destSize (const char* source, char* dest, int* sourceSizePtr, int targetDestSize); +- +- +-/* +-LZ4_decompress_fast() : +- originalSize : is the original and therefore uncompressed size +- return : the number of bytes read from the source buffer (in other words, the compressed size) +- If the source stream is detected malformed, the function will stop decoding and return a negative result. +- Destination buffer must be already allocated. Its size must be a minimum of 'originalSize' bytes. +- note : This function fully respect memory boundaries for properly formed compressed data. +- It is a bit faster than LZ4_decompress_safe(). +- However, it does not provide any protection against intentionally modified data stream (malicious input). +- Use this function in trusted environment only (data to decode comes from a trusted source). +-*/ +-int LZ4_decompress_fast (const char* source, char* dest, int originalSize); +- +-/* +-LZ4_decompress_safe_partial() : +- This function decompress a compressed block of size 'compressedSize' at position 'source' +- into destination buffer 'dest' of size 'maxDecompressedSize'. +- The function tries to stop decompressing operation as soon as 'targetOutputSize' has been reached, +- reducing decompression time. +- return : the number of bytes decoded in the destination buffer (necessarily <= maxDecompressedSize) +- Note : this number can be < 'targetOutputSize' should the compressed block to decode be smaller. +- Always control how many bytes were decoded. +- If the source stream is detected malformed, the function will stop decoding and return a negative result. +- This function never writes outside of output buffer, and never reads outside of input buffer. It is therefore protected against malicious data packets +-*/ +-int LZ4_decompress_safe_partial (const char* source, char* dest, int compressedSize, int targetOutputSize, int maxDecompressedSize); +- +- +-/*********************************************** +-* Streaming Compression Functions +-***********************************************/ +-#define LZ4_STREAMSIZE_U64 ((1 << (LZ4_MEMORY_USAGE-3)) + 4) +-#define LZ4_STREAMSIZE (LZ4_STREAMSIZE_U64 * sizeof(long long)) +-/* +- * LZ4_stream_t +- * information structure to track an LZ4 stream. +- * important : init this structure content before first use ! +- * note : only allocated directly the structure if you are statically linking LZ4 +- * If you are using liblz4 as a DLL, please use below construction methods instead. +- */ +-typedef struct { long long table[LZ4_STREAMSIZE_U64]; } LZ4_stream_t; +- +-/* +- * LZ4_resetStream +- * Use this function to init an allocated LZ4_stream_t structure +- */ +-void LZ4_resetStream (LZ4_stream_t* streamPtr); +- +-/* +- * LZ4_createStream will allocate and initialize an LZ4_stream_t structure +- * LZ4_freeStream releases its memory. +- * In the context of a DLL (liblz4), please use these methods rather than the static struct. +- * They are more future proof, in case of a change of LZ4_stream_t size. +- */ +-LZ4_stream_t* LZ4_createStream(void); +-int LZ4_freeStream (LZ4_stream_t* streamPtr); +- +-/* +- * LZ4_loadDict +- * Use this function to load a static dictionary into LZ4_stream. +- * Any previous data will be forgotten, only 'dictionary' will remain in memory. +- * Loading a size of 0 is allowed. +- * Return : dictionary size, in bytes (necessarily <= 64 KB) +- */ +-int LZ4_loadDict (LZ4_stream_t* streamPtr, const char* dictionary, int dictSize); +- +-/* +- * LZ4_compress_fast_continue +- * Compress buffer content 'src', using data from previously compressed blocks as dictionary to improve compression ratio. +- * Important : Previous data blocks are assumed to still be present and unmodified ! +- * 'dst' buffer must be already allocated. +- * If maxDstSize >= LZ4_compressBound(srcSize), compression is guaranteed to succeed, and runs faster. +- * If not, and if compressed data cannot fit into 'dst' buffer size, compression stops, and function returns a zero. +- */ +-int LZ4_compress_fast_continue (LZ4_stream_t* streamPtr, const char* src, char* dst, int srcSize, int maxDstSize, int acceleration); +- +-/* +- * LZ4_saveDict +- * If previously compressed data block is not guaranteed to remain available at its memory location +- * save it into a safer place (char* safeBuffer) +- * Note : you don't need to call LZ4_loadDict() afterwards, +- * dictionary is immediately usable, you can therefore call LZ4_compress_fast_continue() +- * Return : saved dictionary size in bytes (necessarily <= dictSize), or 0 if error +- */ +-int LZ4_saveDict (LZ4_stream_t* streamPtr, char* safeBuffer, int dictSize); +- +- +-/************************************************ +-* Streaming Decompression Functions +-************************************************/ +- +-#define LZ4_STREAMDECODESIZE_U64 4 +-#define LZ4_STREAMDECODESIZE (LZ4_STREAMDECODESIZE_U64 * sizeof(unsigned long long)) +-typedef struct { unsigned long long table[LZ4_STREAMDECODESIZE_U64]; } LZ4_streamDecode_t; +-/* +- * LZ4_streamDecode_t +- * information structure to track an LZ4 stream. +- * init this structure content using LZ4_setStreamDecode or memset() before first use ! +- * +- * In the context of a DLL (liblz4) please prefer usage of construction methods below. +- * They are more future proof, in case of a change of LZ4_streamDecode_t size in the future. +- * LZ4_createStreamDecode will allocate and initialize an LZ4_streamDecode_t structure +- * LZ4_freeStreamDecode releases its memory. +- */ +-LZ4_streamDecode_t* LZ4_createStreamDecode(void); +-int LZ4_freeStreamDecode (LZ4_streamDecode_t* LZ4_stream); +- +-/* +- * LZ4_setStreamDecode +- * Use this function to instruct where to find the dictionary. +- * Setting a size of 0 is allowed (same effect as reset). +- * Return : 1 if OK, 0 if error +- */ +-int LZ4_setStreamDecode (LZ4_streamDecode_t* LZ4_streamDecode, const char* dictionary, int dictSize); +- +-/* +-*_continue() : +- These decoding functions allow decompression of multiple blocks in "streaming" mode. +- Previously decoded blocks *must* remain available at the memory position where they were decoded (up to 64 KB) +- In the case of a ring buffers, decoding buffer must be either : +- - Exactly same size as encoding buffer, with same update rule (block boundaries at same positions) +- In which case, the decoding & encoding ring buffer can have any size, including very small ones ( < 64 KB). +- - Larger than encoding buffer, by a minimum of maxBlockSize more bytes. +- maxBlockSize is implementation dependent. It's the maximum size you intend to compress into a single block. +- In which case, encoding and decoding buffers do not need to be synchronized, +- and encoding ring buffer can have any size, including small ones ( < 64 KB). +- - _At least_ 64 KB + 8 bytes + maxBlockSize. +- In which case, encoding and decoding buffers do not need to be synchronized, +- and encoding ring buffer can have any size, including larger than decoding buffer. +- Whenever these conditions are not possible, save the last 64KB of decoded data into a safe buffer, +- and indicate where it is saved using LZ4_setStreamDecode() +-*/ +-int LZ4_decompress_safe_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int compressedSize, int maxDecompressedSize); +-int LZ4_decompress_fast_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int originalSize); +- +- +-/* +-Advanced decoding functions : +-*_usingDict() : +- These decoding functions work the same as +- a combination of LZ4_setStreamDecode() followed by LZ4_decompress_x_continue() +- They are stand-alone. They don't need nor update an LZ4_streamDecode_t structure. +-*/ +-int LZ4_decompress_safe_usingDict (const char* source, char* dest, int compressedSize, int maxDecompressedSize, const char* dictStart, int dictSize); +-int LZ4_decompress_fast_usingDict (const char* source, char* dest, int originalSize, const char* dictStart, int dictSize); +- +- +- +-/************************************** +-* Obsolete Functions +-**************************************/ +-/* Deprecate Warnings */ +-/* Should these warnings messages be a problem, +- it is generally possible to disable them, +- with -Wno-deprecated-declarations for gcc +- or _CRT_SECURE_NO_WARNINGS in Visual for example. +- You can also define LZ4_DEPRECATE_WARNING_DEFBLOCK. */ +-#ifndef LZ4_DEPRECATE_WARNING_DEFBLOCK +-# define LZ4_DEPRECATE_WARNING_DEFBLOCK +-# define LZ4_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) +-# if (LZ4_GCC_VERSION >= 405) || defined(__clang__) +-# define LZ4_DEPRECATED(message) __attribute__((deprecated(message))) +-# elif (LZ4_GCC_VERSION >= 301) +-# define LZ4_DEPRECATED(message) __attribute__((deprecated)) +-# elif defined(_MSC_VER) +-# define LZ4_DEPRECATED(message) __declspec(deprecated(message)) +-# else +-# pragma message("WARNING: You need to implement LZ4_DEPRECATED for this compiler") +-# define LZ4_DEPRECATED(message) +-# endif +-#endif /* LZ4_DEPRECATE_WARNING_DEFBLOCK */ +- +-/* Obsolete compression functions */ +-/* These functions are planned to start generate warnings by r131 approximately */ +-int LZ4_compress (const char* source, char* dest, int sourceSize); +-int LZ4_compress_limitedOutput (const char* source, char* dest, int sourceSize, int maxOutputSize); +-int LZ4_compress_withState (void* state, const char* source, char* dest, int inputSize); +-int LZ4_compress_limitedOutput_withState (void* state, const char* source, char* dest, int inputSize, int maxOutputSize); +-int LZ4_compress_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize); +-int LZ4_compress_limitedOutput_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize, int maxOutputSize); +- +-/* Obsolete decompression functions */ +-/* These function names are completely deprecated and must no longer be used. +- They are only provided here for compatibility with older programs. +- - LZ4_uncompress is the same as LZ4_decompress_fast +- - LZ4_uncompress_unknownOutputSize is the same as LZ4_decompress_safe +- These function prototypes are now disabled; uncomment them only if you really need them. +- It is highly recommended to stop using these prototypes and migrate to maintained ones */ +-/* int LZ4_uncompress (const char* source, char* dest, int outputSize); */ +-/* int LZ4_uncompress_unknownOutputSize (const char* source, char* dest, int isize, int maxOutputSize); */ +- +-/* Obsolete streaming functions; use new streaming interface whenever possible */ +-LZ4_DEPRECATED("use LZ4_createStream() instead") void* LZ4_create (char* inputBuffer); +-LZ4_DEPRECATED("use LZ4_createStream() instead") int LZ4_sizeofStreamState(void); +-LZ4_DEPRECATED("use LZ4_resetStream() instead") int LZ4_resetStreamState(void* state, char* inputBuffer); +-LZ4_DEPRECATED("use LZ4_saveDict() instead") char* LZ4_slideInputBuffer (void* state); +- +-/* Obsolete streaming decoding functions */ +-LZ4_DEPRECATED("use LZ4_decompress_safe_usingDict() instead") int LZ4_decompress_safe_withPrefix64k (const char* src, char* dst, int compressedSize, int maxDstSize); +-LZ4_DEPRECATED("use LZ4_decompress_fast_usingDict() instead") int LZ4_decompress_fast_withPrefix64k (const char* src, char* dst, int originalSize); +- +- +-#if defined (__cplusplus) +-} +-#endif +diff --git a/corelib/src/rtflann/ext/lz4hc.c b/corelib/src/rtflann/ext/lz4hc.c +deleted file mode 100644 +index bbe7a9d..0000000 +--- a/corelib/src/rtflann/ext/lz4hc.c ++++ /dev/null +@@ -1,731 +0,0 @@ +-/* +- LZ4 HC - High Compression Mode of LZ4 +- Copyright (C) 2011-2015, Yann Collet. +- +- BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) +- +- Redistribution and use in source and binary forms, with or without +- modification, are permitted provided that the following conditions are +- met: +- +- * Redistributions of source code must retain the above copyright +- notice, this list of conditions and the following disclaimer. +- * Redistributions in binary form must reproduce the above +- copyright notice, this list of conditions and the following disclaimer +- in the documentation and/or other materials provided with the +- distribution. +- +- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- +- You can contact the author at : +- - LZ4 source repository : https://github.com/Cyan4973/lz4 +- - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c +-*/ +- +- +- +-/************************************** +-* Tuning Parameter +-**************************************/ +-static const int LZ4HC_compressionLevel_default = 9; +- +- +-/************************************** +-* Includes +-**************************************/ +-#include "lz4hc.h" +- +- +-/************************************** +-* Local Compiler Options +-**************************************/ +-#if defined(__GNUC__) +-# pragma GCC diagnostic ignored "-Wunused-function" +-#endif +- +-#if defined (__clang__) +-# pragma clang diagnostic ignored "-Wunused-function" +-#endif +- +- +-/************************************** +-* Common LZ4 definition +-**************************************/ +-#define LZ4_COMMONDEFS_ONLY +-#include "lz4.c" +- +- +-/************************************** +-* Local Constants +-**************************************/ +-#define DICTIONARY_LOGSIZE 16 +-#define MAXD (1<> ((MINMATCH*8)-HASH_LOG)) +-//#define DELTANEXTU16(p) chainTable[(p) & MAXD_MASK] /* flexible, MAXD dependent */ +-#define DELTANEXTU16(p) chainTable[(U16)(p)] /* faster */ +- +-static U32 LZ4HC_hashPtr(const void* ptr) { return HASH_FUNCTION(LZ4_read32(ptr)); } +- +- +- +-/************************************** +-* HC Compression +-**************************************/ +-static void LZ4HC_init (LZ4HC_Data_Structure* hc4, const BYTE* start) +-{ +- MEM_INIT((void*)hc4->hashTable, 0, sizeof(hc4->hashTable)); +- MEM_INIT(hc4->chainTable, 0xFF, sizeof(hc4->chainTable)); +- hc4->nextToUpdate = 64 KB; +- hc4->base = start - 64 KB; +- hc4->end = start; +- hc4->dictBase = start - 64 KB; +- hc4->dictLimit = 64 KB; +- hc4->lowLimit = 64 KB; +-} +- +- +-/* Update chains up to ip (excluded) */ +-FORCE_INLINE void LZ4HC_Insert (LZ4HC_Data_Structure* hc4, const BYTE* ip) +-{ +- U16* chainTable = hc4->chainTable; +- U32* HashTable = hc4->hashTable; +- const BYTE* const base = hc4->base; +- const U32 target = (U32)(ip - base); +- U32 idx = hc4->nextToUpdate; +- +- while(idx < target) +- { +- U32 h = LZ4HC_hashPtr(base+idx); +- size_t delta = idx - HashTable[h]; +- if (delta>MAX_DISTANCE) delta = MAX_DISTANCE; +- DELTANEXTU16(idx) = (U16)delta; +- HashTable[h] = idx; +- idx++; +- } +- +- hc4->nextToUpdate = target; +-} +- +- +-FORCE_INLINE int LZ4HC_InsertAndFindBestMatch (LZ4HC_Data_Structure* hc4, /* Index table will be updated */ +- const BYTE* ip, const BYTE* const iLimit, +- const BYTE** matchpos, +- const int maxNbAttempts) +-{ +- U16* const chainTable = hc4->chainTable; +- U32* const HashTable = hc4->hashTable; +- const BYTE* const base = hc4->base; +- const BYTE* const dictBase = hc4->dictBase; +- const U32 dictLimit = hc4->dictLimit; +- const U32 lowLimit = (hc4->lowLimit + 64 KB > (U32)(ip-base)) ? hc4->lowLimit : (U32)(ip - base) - (64 KB - 1); +- U32 matchIndex; +- const BYTE* match; +- int nbAttempts=maxNbAttempts; +- size_t ml=0; +- +- /* HC4 match finder */ +- LZ4HC_Insert(hc4, ip); +- matchIndex = HashTable[LZ4HC_hashPtr(ip)]; +- +- while ((matchIndex>=lowLimit) && (nbAttempts)) +- { +- nbAttempts--; +- if (matchIndex >= dictLimit) +- { +- match = base + matchIndex; +- if (*(match+ml) == *(ip+ml) +- && (LZ4_read32(match) == LZ4_read32(ip))) +- { +- size_t mlt = LZ4_count(ip+MINMATCH, match+MINMATCH, iLimit) + MINMATCH; +- if (mlt > ml) { ml = mlt; *matchpos = match; } +- } +- } +- else +- { +- match = dictBase + matchIndex; +- if (LZ4_read32(match) == LZ4_read32(ip)) +- { +- size_t mlt; +- const BYTE* vLimit = ip + (dictLimit - matchIndex); +- if (vLimit > iLimit) vLimit = iLimit; +- mlt = LZ4_count(ip+MINMATCH, match+MINMATCH, vLimit) + MINMATCH; +- if ((ip+mlt == vLimit) && (vLimit < iLimit)) +- mlt += LZ4_count(ip+mlt, base+dictLimit, iLimit); +- if (mlt > ml) { ml = mlt; *matchpos = base + matchIndex; } /* virtual matchpos */ +- } +- } +- matchIndex -= DELTANEXTU16(matchIndex); +- } +- +- return (int)ml; +-} +- +- +-FORCE_INLINE int LZ4HC_InsertAndGetWiderMatch ( +- LZ4HC_Data_Structure* hc4, +- const BYTE* const ip, +- const BYTE* const iLowLimit, +- const BYTE* const iHighLimit, +- int longest, +- const BYTE** matchpos, +- const BYTE** startpos, +- const int maxNbAttempts) +-{ +- U16* const chainTable = hc4->chainTable; +- U32* const HashTable = hc4->hashTable; +- const BYTE* const base = hc4->base; +- const U32 dictLimit = hc4->dictLimit; +- const BYTE* const lowPrefixPtr = base + dictLimit; +- const U32 lowLimit = (hc4->lowLimit + 64 KB > (U32)(ip-base)) ? hc4->lowLimit : (U32)(ip - base) - (64 KB - 1); +- const BYTE* const dictBase = hc4->dictBase; +- U32 matchIndex; +- int nbAttempts = maxNbAttempts; +- int delta = (int)(ip-iLowLimit); +- +- +- /* First Match */ +- LZ4HC_Insert(hc4, ip); +- matchIndex = HashTable[LZ4HC_hashPtr(ip)]; +- +- while ((matchIndex>=lowLimit) && (nbAttempts)) +- { +- nbAttempts--; +- if (matchIndex >= dictLimit) +- { +- const BYTE* matchPtr = base + matchIndex; +- if (*(iLowLimit + longest) == *(matchPtr - delta + longest)) +- if (LZ4_read32(matchPtr) == LZ4_read32(ip)) +- { +- int mlt = MINMATCH + LZ4_count(ip+MINMATCH, matchPtr+MINMATCH, iHighLimit); +- int back = 0; +- +- while ((ip+back>iLowLimit) +- && (matchPtr+back > lowPrefixPtr) +- && (ip[back-1] == matchPtr[back-1])) +- back--; +- +- mlt -= back; +- +- if (mlt > longest) +- { +- longest = (int)mlt; +- *matchpos = matchPtr+back; +- *startpos = ip+back; +- } +- } +- } +- else +- { +- const BYTE* matchPtr = dictBase + matchIndex; +- if (LZ4_read32(matchPtr) == LZ4_read32(ip)) +- { +- size_t mlt; +- int back=0; +- const BYTE* vLimit = ip + (dictLimit - matchIndex); +- if (vLimit > iHighLimit) vLimit = iHighLimit; +- mlt = LZ4_count(ip+MINMATCH, matchPtr+MINMATCH, vLimit) + MINMATCH; +- if ((ip+mlt == vLimit) && (vLimit < iHighLimit)) +- mlt += LZ4_count(ip+mlt, base+dictLimit, iHighLimit); +- while ((ip+back > iLowLimit) && (matchIndex+back > lowLimit) && (ip[back-1] == matchPtr[back-1])) back--; +- mlt -= back; +- if ((int)mlt > longest) { longest = (int)mlt; *matchpos = base + matchIndex + back; *startpos = ip+back; } +- } +- } +- matchIndex -= DELTANEXTU16(matchIndex); +- } +- +- return longest; +-} +- +- +-typedef enum { noLimit = 0, limitedOutput = 1 } limitedOutput_directive; +- +-#define LZ4HC_DEBUG 0 +-#if LZ4HC_DEBUG +-static unsigned debug = 0; +-#endif +- +-FORCE_INLINE int LZ4HC_encodeSequence ( +- const BYTE** ip, +- BYTE** op, +- const BYTE** anchor, +- int matchLength, +- const BYTE* const match, +- limitedOutput_directive limitedOutputBuffer, +- BYTE* oend) +-{ +- int length; +- BYTE* token; +- +-#if LZ4HC_DEBUG +- if (debug) printf("literal : %u -- match : %u -- offset : %u\n", (U32)(*ip - *anchor), (U32)matchLength, (U32)(*ip-match)); +-#endif +- +- /* Encode Literal length */ +- length = (int)(*ip - *anchor); +- token = (*op)++; +- if ((limitedOutputBuffer) && ((*op + (length>>8) + length + (2 + 1 + LASTLITERALS)) > oend)) return 1; /* Check output limit */ +- if (length>=(int)RUN_MASK) { int len; *token=(RUN_MASK< 254 ; len-=255) *(*op)++ = 255; *(*op)++ = (BYTE)len; } +- else *token = (BYTE)(length<>8) + (1 + LASTLITERALS) > oend)) return 1; /* Check output limit */ +- if (length>=(int)ML_MASK) { *token+=ML_MASK; length-=ML_MASK; for(; length > 509 ; length-=510) { *(*op)++ = 255; *(*op)++ = 255; } if (length > 254) { length-=255; *(*op)++ = 255; } *(*op)++ = (BYTE)length; } +- else *token += (BYTE)(length); +- +- /* Prepare next loop */ +- *ip += matchLength; +- *anchor = *ip; +- +- return 0; +-} +- +- +-static int LZ4HC_compress_generic ( +- void* ctxvoid, +- const char* source, +- char* dest, +- int inputSize, +- int maxOutputSize, +- int compressionLevel, +- limitedOutput_directive limit +- ) +-{ +- LZ4HC_Data_Structure* ctx = (LZ4HC_Data_Structure*) ctxvoid; +- const BYTE* ip = (const BYTE*) source; +- const BYTE* anchor = ip; +- const BYTE* const iend = ip + inputSize; +- const BYTE* const mflimit = iend - MFLIMIT; +- const BYTE* const matchlimit = (iend - LASTLITERALS); +- +- BYTE* op = (BYTE*) dest; +- BYTE* const oend = op + maxOutputSize; +- +- unsigned maxNbAttempts; +- int ml, ml2, ml3, ml0; +- const BYTE* ref=NULL; +- const BYTE* start2=NULL; +- const BYTE* ref2=NULL; +- const BYTE* start3=NULL; +- const BYTE* ref3=NULL; +- const BYTE* start0; +- const BYTE* ref0; +- +- +- /* init */ +- if (compressionLevel > g_maxCompressionLevel) compressionLevel = g_maxCompressionLevel; +- if (compressionLevel < 1) compressionLevel = LZ4HC_compressionLevel_default; +- maxNbAttempts = 1 << (compressionLevel-1); +- ctx->end += inputSize; +- +- ip++; +- +- /* Main Loop */ +- while (ip < mflimit) +- { +- ml = LZ4HC_InsertAndFindBestMatch (ctx, ip, matchlimit, (&ref), maxNbAttempts); +- if (!ml) { ip++; continue; } +- +- /* saved, in case we would skip too much */ +- start0 = ip; +- ref0 = ref; +- ml0 = ml; +- +-_Search2: +- if (ip+ml < mflimit) +- ml2 = LZ4HC_InsertAndGetWiderMatch(ctx, ip + ml - 2, ip + 1, matchlimit, ml, &ref2, &start2, maxNbAttempts); +- else ml2 = ml; +- +- if (ml2 == ml) /* No better match */ +- { +- if (LZ4HC_encodeSequence(&ip, &op, &anchor, ml, ref, limit, oend)) return 0; +- continue; +- } +- +- if (start0 < ip) +- { +- if (start2 < ip + ml0) /* empirical */ +- { +- ip = start0; +- ref = ref0; +- ml = ml0; +- } +- } +- +- /* Here, start0==ip */ +- if ((start2 - ip) < 3) /* First Match too small : removed */ +- { +- ml = ml2; +- ip = start2; +- ref =ref2; +- goto _Search2; +- } +- +-_Search3: +- /* +- * Currently we have : +- * ml2 > ml1, and +- * ip1+3 <= ip2 (usually < ip1+ml1) +- */ +- if ((start2 - ip) < OPTIMAL_ML) +- { +- int correction; +- int new_ml = ml; +- if (new_ml > OPTIMAL_ML) new_ml = OPTIMAL_ML; +- if (ip+new_ml > start2 + ml2 - MINMATCH) new_ml = (int)(start2 - ip) + ml2 - MINMATCH; +- correction = new_ml - (int)(start2 - ip); +- if (correction > 0) +- { +- start2 += correction; +- ref2 += correction; +- ml2 -= correction; +- } +- } +- /* Now, we have start2 = ip+new_ml, with new_ml = min(ml, OPTIMAL_ML=18) */ +- +- if (start2 + ml2 < mflimit) +- ml3 = LZ4HC_InsertAndGetWiderMatch(ctx, start2 + ml2 - 3, start2, matchlimit, ml2, &ref3, &start3, maxNbAttempts); +- else ml3 = ml2; +- +- if (ml3 == ml2) /* No better match : 2 sequences to encode */ +- { +- /* ip & ref are known; Now for ml */ +- if (start2 < ip+ml) ml = (int)(start2 - ip); +- /* Now, encode 2 sequences */ +- if (LZ4HC_encodeSequence(&ip, &op, &anchor, ml, ref, limit, oend)) return 0; +- ip = start2; +- if (LZ4HC_encodeSequence(&ip, &op, &anchor, ml2, ref2, limit, oend)) return 0; +- continue; +- } +- +- if (start3 < ip+ml+3) /* Not enough space for match 2 : remove it */ +- { +- if (start3 >= (ip+ml)) /* can write Seq1 immediately ==> Seq2 is removed, so Seq3 becomes Seq1 */ +- { +- if (start2 < ip+ml) +- { +- int correction = (int)(ip+ml - start2); +- start2 += correction; +- ref2 += correction; +- ml2 -= correction; +- if (ml2 < MINMATCH) +- { +- start2 = start3; +- ref2 = ref3; +- ml2 = ml3; +- } +- } +- +- if (LZ4HC_encodeSequence(&ip, &op, &anchor, ml, ref, limit, oend)) return 0; +- ip = start3; +- ref = ref3; +- ml = ml3; +- +- start0 = start2; +- ref0 = ref2; +- ml0 = ml2; +- goto _Search2; +- } +- +- start2 = start3; +- ref2 = ref3; +- ml2 = ml3; +- goto _Search3; +- } +- +- /* +- * OK, now we have 3 ascending matches; let's write at least the first one +- * ip & ref are known; Now for ml +- */ +- if (start2 < ip+ml) +- { +- if ((start2 - ip) < (int)ML_MASK) +- { +- int correction; +- if (ml > OPTIMAL_ML) ml = OPTIMAL_ML; +- if (ip + ml > start2 + ml2 - MINMATCH) ml = (int)(start2 - ip) + ml2 - MINMATCH; +- correction = ml - (int)(start2 - ip); +- if (correction > 0) +- { +- start2 += correction; +- ref2 += correction; +- ml2 -= correction; +- } +- } +- else +- { +- ml = (int)(start2 - ip); +- } +- } +- if (LZ4HC_encodeSequence(&ip, &op, &anchor, ml, ref, limit, oend)) return 0; +- +- ip = start2; +- ref = ref2; +- ml = ml2; +- +- start2 = start3; +- ref2 = ref3; +- ml2 = ml3; +- +- goto _Search3; +- } +- +- /* Encode Last Literals */ +- { +- int lastRun = (int)(iend - anchor); +- if ((limit) && (((char*)op - dest) + lastRun + 1 + ((lastRun+255-RUN_MASK)/255) > (U32)maxOutputSize)) return 0; /* Check output limit */ +- if (lastRun>=(int)RUN_MASK) { *op++=(RUN_MASK< 254 ; lastRun-=255) *op++ = 255; *op++ = (BYTE) lastRun; } +- else *op++ = (BYTE)(lastRun<base = NULL; +- ((LZ4HC_Data_Structure*)LZ4_streamHCPtr)->compressionLevel = (unsigned)compressionLevel; +-} +- +-int LZ4_loadDictHC (LZ4_streamHC_t* LZ4_streamHCPtr, const char* dictionary, int dictSize) +-{ +- LZ4HC_Data_Structure* ctxPtr = (LZ4HC_Data_Structure*) LZ4_streamHCPtr; +- if (dictSize > 64 KB) +- { +- dictionary += dictSize - 64 KB; +- dictSize = 64 KB; +- } +- LZ4HC_init (ctxPtr, (const BYTE*)dictionary); +- if (dictSize >= 4) LZ4HC_Insert (ctxPtr, (const BYTE*)dictionary +(dictSize-3)); +- ctxPtr->end = (const BYTE*)dictionary + dictSize; +- return dictSize; +-} +- +- +-/* compression */ +- +-static void LZ4HC_setExternalDict(LZ4HC_Data_Structure* ctxPtr, const BYTE* newBlock) +-{ +- if (ctxPtr->end >= ctxPtr->base + 4) +- LZ4HC_Insert (ctxPtr, ctxPtr->end-3); /* Referencing remaining dictionary content */ +- /* Only one memory segment for extDict, so any previous extDict is lost at this stage */ +- ctxPtr->lowLimit = ctxPtr->dictLimit; +- ctxPtr->dictLimit = (U32)(ctxPtr->end - ctxPtr->base); +- ctxPtr->dictBase = ctxPtr->base; +- ctxPtr->base = newBlock - ctxPtr->dictLimit; +- ctxPtr->end = newBlock; +- ctxPtr->nextToUpdate = ctxPtr->dictLimit; /* match referencing will resume from there */ +-} +- +-static int LZ4_compressHC_continue_generic (LZ4HC_Data_Structure* ctxPtr, +- const char* source, char* dest, +- int inputSize, int maxOutputSize, limitedOutput_directive limit) +-{ +- /* auto-init if forgotten */ +- if (ctxPtr->base == NULL) +- LZ4HC_init (ctxPtr, (const BYTE*) source); +- +- /* Check overflow */ +- if ((size_t)(ctxPtr->end - ctxPtr->base) > 2 GB) +- { +- size_t dictSize = (size_t)(ctxPtr->end - ctxPtr->base) - ctxPtr->dictLimit; +- if (dictSize > 64 KB) dictSize = 64 KB; +- +- LZ4_loadDictHC((LZ4_streamHC_t*)ctxPtr, (const char*)(ctxPtr->end) - dictSize, (int)dictSize); +- } +- +- /* Check if blocks follow each other */ +- if ((const BYTE*)source != ctxPtr->end) +- LZ4HC_setExternalDict(ctxPtr, (const BYTE*)source); +- +- /* Check overlapping input/dictionary space */ +- { +- const BYTE* sourceEnd = (const BYTE*) source + inputSize; +- const BYTE* dictBegin = ctxPtr->dictBase + ctxPtr->lowLimit; +- const BYTE* dictEnd = ctxPtr->dictBase + ctxPtr->dictLimit; +- if ((sourceEnd > dictBegin) && ((const BYTE*)source < dictEnd)) +- { +- if (sourceEnd > dictEnd) sourceEnd = dictEnd; +- ctxPtr->lowLimit = (U32)(sourceEnd - ctxPtr->dictBase); +- if (ctxPtr->dictLimit - ctxPtr->lowLimit < 4) ctxPtr->lowLimit = ctxPtr->dictLimit; +- } +- } +- +- return LZ4HC_compress_generic (ctxPtr, source, dest, inputSize, maxOutputSize, ctxPtr->compressionLevel, limit); +-} +- +-int LZ4_compress_HC_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize, int maxOutputSize) +-{ +- if (maxOutputSize < LZ4_compressBound(inputSize)) +- return LZ4_compressHC_continue_generic ((LZ4HC_Data_Structure*)LZ4_streamHCPtr, source, dest, inputSize, maxOutputSize, limitedOutput); +- else +- return LZ4_compressHC_continue_generic ((LZ4HC_Data_Structure*)LZ4_streamHCPtr, source, dest, inputSize, maxOutputSize, noLimit); +-} +- +- +-/* dictionary saving */ +- +-int LZ4_saveDictHC (LZ4_streamHC_t* LZ4_streamHCPtr, char* safeBuffer, int dictSize) +-{ +- LZ4HC_Data_Structure* streamPtr = (LZ4HC_Data_Structure*)LZ4_streamHCPtr; +- int prefixSize = (int)(streamPtr->end - (streamPtr->base + streamPtr->dictLimit)); +- if (dictSize > 64 KB) dictSize = 64 KB; +- if (dictSize < 4) dictSize = 0; +- if (dictSize > prefixSize) dictSize = prefixSize; +- memmove(safeBuffer, streamPtr->end - dictSize, dictSize); +- { +- U32 endIndex = (U32)(streamPtr->end - streamPtr->base); +- streamPtr->end = (const BYTE*)safeBuffer + dictSize; +- streamPtr->base = streamPtr->end - endIndex; +- streamPtr->dictLimit = endIndex - dictSize; +- streamPtr->lowLimit = endIndex - dictSize; +- if (streamPtr->nextToUpdate < streamPtr->dictLimit) streamPtr->nextToUpdate = streamPtr->dictLimit; +- } +- return dictSize; +-} +- +- +-/*********************************** +-* Deprecated Functions +-***********************************/ +-/* Deprecated compression functions */ +-/* These functions are planned to start generate warnings by r131 approximately */ +-int LZ4_compressHC(const char* src, char* dst, int srcSize) { return LZ4_compress_HC (src, dst, srcSize, LZ4_compressBound(srcSize), 0); } +-int LZ4_compressHC_limitedOutput(const char* src, char* dst, int srcSize, int maxDstSize) { return LZ4_compress_HC(src, dst, srcSize, maxDstSize, 0); } +-int LZ4_compressHC2(const char* src, char* dst, int srcSize, int cLevel) { return LZ4_compress_HC (src, dst, srcSize, LZ4_compressBound(srcSize), cLevel); } +-int LZ4_compressHC2_limitedOutput(const char* src, char* dst, int srcSize, int maxDstSize, int cLevel) { return LZ4_compress_HC(src, dst, srcSize, maxDstSize, cLevel); } +-int LZ4_compressHC_withStateHC (void* state, const char* src, char* dst, int srcSize) { return LZ4_compress_HC_extStateHC (state, src, dst, srcSize, LZ4_compressBound(srcSize), 0); } +-int LZ4_compressHC_limitedOutput_withStateHC (void* state, const char* src, char* dst, int srcSize, int maxDstSize) { return LZ4_compress_HC_extStateHC (state, src, dst, srcSize, maxDstSize, 0); } +-int LZ4_compressHC2_withStateHC (void* state, const char* src, char* dst, int srcSize, int cLevel) { return LZ4_compress_HC_extStateHC(state, src, dst, srcSize, LZ4_compressBound(srcSize), cLevel); } +-int LZ4_compressHC2_limitedOutput_withStateHC (void* state, const char* src, char* dst, int srcSize, int maxDstSize, int cLevel) { return LZ4_compress_HC_extStateHC(state, src, dst, srcSize, maxDstSize, cLevel); } +-int LZ4_compressHC_continue (LZ4_streamHC_t* ctx, const char* src, char* dst, int srcSize) { return LZ4_compress_HC_continue (ctx, src, dst, srcSize, LZ4_compressBound(srcSize)); } +-int LZ4_compressHC_limitedOutput_continue (LZ4_streamHC_t* ctx, const char* src, char* dst, int srcSize, int maxDstSize) { return LZ4_compress_HC_continue (ctx, src, dst, srcSize, maxDstSize); } +- +- +-/* Deprecated streaming functions */ +-/* These functions currently generate deprecation warnings */ +-int LZ4_sizeofStreamStateHC(void) { return LZ4_STREAMHCSIZE; } +- +-int LZ4_resetStreamStateHC(void* state, char* inputBuffer) +-{ +- if ((((size_t)state) & (sizeof(void*)-1)) != 0) return 1; /* Error : pointer is not aligned for pointer (32 or 64 bits) */ +- LZ4HC_init((LZ4HC_Data_Structure*)state, (const BYTE*)inputBuffer); +- ((LZ4HC_Data_Structure*)state)->inputBuffer = (BYTE*)inputBuffer; +- return 0; +-} +- +-void* LZ4_createHC (char* inputBuffer) +-{ +- void* hc4 = ALLOCATOR(1, sizeof(LZ4HC_Data_Structure)); +- if (hc4 == NULL) return NULL; /* not enough memory */ +- LZ4HC_init ((LZ4HC_Data_Structure*)hc4, (const BYTE*)inputBuffer); +- ((LZ4HC_Data_Structure*)hc4)->inputBuffer = (BYTE*)inputBuffer; +- return hc4; +-} +- +-int LZ4_freeHC (void* LZ4HC_Data) +-{ +- FREEMEM(LZ4HC_Data); +- return (0); +-} +- +-int LZ4_compressHC2_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int compressionLevel) +-{ +- return LZ4HC_compress_generic (LZ4HC_Data, source, dest, inputSize, 0, compressionLevel, noLimit); +-} +- +-int LZ4_compressHC2_limitedOutput_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel) +-{ +- return LZ4HC_compress_generic (LZ4HC_Data, source, dest, inputSize, maxOutputSize, compressionLevel, limitedOutput); +-} +- +-char* LZ4_slideInputBufferHC(void* LZ4HC_Data) +-{ +- LZ4HC_Data_Structure* hc4 = (LZ4HC_Data_Structure*)LZ4HC_Data; +- int dictSize = LZ4_saveDictHC((LZ4_streamHC_t*)LZ4HC_Data, (char*)(hc4->inputBuffer), 64 KB); +- return (char*)(hc4->inputBuffer + dictSize); +-} +diff --git a/corelib/src/rtflann/ext/lz4hc.h b/corelib/src/rtflann/ext/lz4hc.h +deleted file mode 100644 +index 431f7c8..0000000 +--- a/corelib/src/rtflann/ext/lz4hc.h ++++ /dev/null +@@ -1,189 +0,0 @@ +-/* +- LZ4 HC - High Compression Mode of LZ4 +- Header File +- Copyright (C) 2011-2015, Yann Collet. +- BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) +- +- Redistribution and use in source and binary forms, with or without +- modification, are permitted provided that the following conditions are +- met: +- +- * Redistributions of source code must retain the above copyright +- notice, this list of conditions and the following disclaimer. +- * Redistributions in binary form must reproduce the above +- copyright notice, this list of conditions and the following disclaimer +- in the documentation and/or other materials provided with the +- distribution. +- +- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- +- You can contact the author at : +- - LZ4 source repository : https://github.com/Cyan4973/lz4 +- - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c +-*/ +-#pragma once +- +- +-#if defined (__cplusplus) +-extern "C" { +-#endif +- +-/***************************** +-* Includes +-*****************************/ +-#include /* size_t */ +- +- +-/************************************** +-* Block Compression +-**************************************/ +-int LZ4_compress_HC (const char* src, char* dst, int srcSize, int maxDstSize, int compressionLevel); +-/* +-LZ4_compress_HC : +- Destination buffer 'dst' must be already allocated. +- Compression completion is guaranteed if 'dst' buffer is sized to handle worst circumstances (data not compressible) +- Worst size evaluation is provided by function LZ4_compressBound() (see "lz4.h") +- srcSize : Max supported value is LZ4_MAX_INPUT_SIZE (see "lz4.h") +- compressionLevel : Recommended values are between 4 and 9, although any value between 0 and 16 will work. +- 0 means "use default value" (see lz4hc.c). +- Values >16 behave the same as 16. +- return : the number of bytes written into buffer 'dst' +- or 0 if compression fails. +-*/ +- +- +-/* Note : +- Decompression functions are provided within LZ4 source code (see "lz4.h") (BSD license) +-*/ +- +- +-int LZ4_sizeofStateHC(void); +-int LZ4_compress_HC_extStateHC(void* state, const char* src, char* dst, int srcSize, int maxDstSize, int compressionLevel); +-/* +-LZ4_compress_HC_extStateHC() : +- Use this function if you prefer to manually allocate memory for compression tables. +- To know how much memory must be allocated for the compression tables, use : +- int LZ4_sizeofStateHC(); +- +- Allocated memory must be aligned on 8-bytes boundaries (which a normal malloc() will do properly). +- +- The allocated memory can then be provided to the compression functions using 'void* state' parameter. +- LZ4_compress_HC_extStateHC() is equivalent to previously described function. +- It just uses externally allocated memory for stateHC. +-*/ +- +- +-/************************************** +-* Streaming Compression +-**************************************/ +-#define LZ4_STREAMHCSIZE 262192 +-#define LZ4_STREAMHCSIZE_SIZET (LZ4_STREAMHCSIZE / sizeof(size_t)) +-typedef struct { size_t table[LZ4_STREAMHCSIZE_SIZET]; } LZ4_streamHC_t; +-/* +- LZ4_streamHC_t +- This structure allows static allocation of LZ4 HC streaming state. +- State must then be initialized using LZ4_resetStreamHC() before first use. +- +- Static allocation should only be used in combination with static linking. +- If you want to use LZ4 as a DLL, please use construction functions below, which are future-proof. +-*/ +- +- +-LZ4_streamHC_t* LZ4_createStreamHC(void); +-int LZ4_freeStreamHC (LZ4_streamHC_t* streamHCPtr); +-/* +- These functions create and release memory for LZ4 HC streaming state. +- Newly created states are already initialized. +- Existing state space can be re-used anytime using LZ4_resetStreamHC(). +- If you use LZ4 as a DLL, use these functions instead of static structure allocation, +- to avoid size mismatch between different versions. +-*/ +- +-void LZ4_resetStreamHC (LZ4_streamHC_t* streamHCPtr, int compressionLevel); +-int LZ4_loadDictHC (LZ4_streamHC_t* streamHCPtr, const char* dictionary, int dictSize); +- +-int LZ4_compress_HC_continue (LZ4_streamHC_t* streamHCPtr, const char* src, char* dst, int srcSize, int maxDstSize); +- +-int LZ4_saveDictHC (LZ4_streamHC_t* streamHCPtr, char* safeBuffer, int maxDictSize); +- +-/* +- These functions compress data in successive blocks of any size, using previous blocks as dictionary. +- One key assumption is that previous blocks (up to 64 KB) remain read-accessible while compressing next blocks. +- There is an exception for ring buffers, which can be smaller 64 KB. +- Such case is automatically detected and correctly handled by LZ4_compress_HC_continue(). +- +- Before starting compression, state must be properly initialized, using LZ4_resetStreamHC(). +- A first "fictional block" can then be designated as initial dictionary, using LZ4_loadDictHC() (Optional). +- +- Then, use LZ4_compress_HC_continue() to compress each successive block. +- It works like LZ4_compress_HC(), but use previous memory blocks as dictionary to improve compression. +- Previous memory blocks (including initial dictionary when present) must remain accessible and unmodified during compression. +- As a reminder, size 'dst' buffer to handle worst cases, using LZ4_compressBound(), to ensure success of compression operation. +- +- If, for any reason, previous data blocks can't be preserved unmodified in memory during next compression block, +- you must save it to a safer memory space, using LZ4_saveDictHC(). +- Return value of LZ4_saveDictHC() is the size of dictionary effectively saved into 'safeBuffer'. +-*/ +- +- +- +-/************************************** +-* Deprecated Functions +-**************************************/ +-/* Deprecate Warnings */ +-/* Should these warnings messages be a problem, +- it is generally possible to disable them, +- with -Wno-deprecated-declarations for gcc +- or _CRT_SECURE_NO_WARNINGS in Visual for example. +- You can also define LZ4_DEPRECATE_WARNING_DEFBLOCK. */ +-#ifndef LZ4_DEPRECATE_WARNING_DEFBLOCK +-# define LZ4_DEPRECATE_WARNING_DEFBLOCK +-# define LZ4_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) +-# if (LZ4_GCC_VERSION >= 405) || defined(__clang__) +-# define LZ4_DEPRECATED(message) __attribute__((deprecated(message))) +-# elif (LZ4_GCC_VERSION >= 301) +-# define LZ4_DEPRECATED(message) __attribute__((deprecated)) +-# elif defined(_MSC_VER) +-# define LZ4_DEPRECATED(message) __declspec(deprecated(message)) +-# else +-# pragma message("WARNING: You need to implement LZ4_DEPRECATED for this compiler") +-# define LZ4_DEPRECATED(message) +-# endif +-#endif // LZ4_DEPRECATE_WARNING_DEFBLOCK +- +-/* compression functions */ +-/* these functions are planned to trigger warning messages by r131 approximately */ +-int LZ4_compressHC (const char* source, char* dest, int inputSize); +-int LZ4_compressHC_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize); +-int LZ4_compressHC2 (const char* source, char* dest, int inputSize, int compressionLevel); +-int LZ4_compressHC2_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel); +-int LZ4_compressHC_withStateHC (void* state, const char* source, char* dest, int inputSize); +-int LZ4_compressHC_limitedOutput_withStateHC (void* state, const char* source, char* dest, int inputSize, int maxOutputSize); +-int LZ4_compressHC2_withStateHC (void* state, const char* source, char* dest, int inputSize, int compressionLevel); +-int LZ4_compressHC2_limitedOutput_withStateHC(void* state, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel); +-int LZ4_compressHC_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize); +-int LZ4_compressHC_limitedOutput_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize, int maxOutputSize); +- +-/* Streaming functions following the older model; should no longer be used */ +-LZ4_DEPRECATED("use LZ4_createStreamHC() instead") void* LZ4_createHC (char* inputBuffer); +-LZ4_DEPRECATED("use LZ4_saveDictHC() instead") char* LZ4_slideInputBufferHC (void* LZ4HC_Data); +-LZ4_DEPRECATED("use LZ4_freeStreamHC() instead") int LZ4_freeHC (void* LZ4HC_Data); +-LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") int LZ4_compressHC2_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int compressionLevel); +-LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") int LZ4_compressHC2_limitedOutput_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel); +-LZ4_DEPRECATED("use LZ4_createStreamHC() instead") int LZ4_sizeofStreamStateHC(void); +-LZ4_DEPRECATED("use LZ4_resetStreamHC() instead") int LZ4_resetStreamStateHC(void* state, char* inputBuffer); +- +- +-#if defined (__cplusplus) +-} +-#endif +diff --git a/corelib/src/rtflann/util/serialization.h b/corelib/src/rtflann/util/serialization.h +index 8c25166..dabe3e8 100644 +--- a/corelib/src/rtflann/util/serialization.h ++++ b/corelib/src/rtflann/util/serialization.h +@@ -6,8 +6,8 @@ + #include + #include + #include +-#include "rtflann/ext/lz4.h" +-#include "rtflann/ext/lz4hc.h" ++#include "lz4.h" ++#include "lz4hc.h" + + + namespace rtflann diff --git a/cmake/ports/rtabmap/multi-definition.patch b/cmake/ports/rtabmap/multi-definition.patch new file mode 100644 index 0000000000..060396bba5 --- /dev/null +++ b/cmake/ports/rtabmap/multi-definition.patch @@ -0,0 +1,96 @@ +diff --git a/corelib/include/rtabmap/core/stereo/stereoRectifyFisheye.h b/corelib/include/rtabmap/core/stereo/stereoRectifyFisheye.h +index 2fc12a2..5219a38 100644 +--- a/corelib/include/rtabmap/core/stereo/stereoRectifyFisheye.h ++++ b/corelib/include/rtabmap/core/stereo/stereoRectifyFisheye.h +@@ -39,6 +39,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + #if CV_MAJOR_VERSION >= 4 + #include + ++#include ++ ++namespace { ++ + // Opencv4 doesn't expose those functions below anymore, we should recopy all of them! + int cvRodrigues2( const CvMat* src, CvMat* dst, CvMat* jacobian CV_DEFAULT(0)) + { +@@ -919,13 +923,17 @@ void cvConvertPointsHomogeneous( const CvMat* _src, CvMat* _dst ) + + #endif // OpenCV3 + ++} // namespace ++ + namespace rtabmap + { + + void ++RTABMAP_CORE_EXPORT + icvGetRectanglesFisheye( const CvMat* cameraMatrix, const CvMat* distCoeffs, + const CvMat* R, const CvMat* newCameraMatrix, CvSize imgSize, + cv::Rect_& inner, cv::Rect_& outer ) ++#ifdef RTABMAP_STEREORECTIFIYFISHEYE_IMPLEMENTATION + { + const int N = 9; + int x, y, k; +@@ -967,12 +975,17 @@ icvGetRectanglesFisheye( const CvMat* cameraMatrix, const CvMat* distCoeffs, + inner = cv::Rect_(iX0, iY0, iX1-iX0, iY1-iY0); + outer = cv::Rect_(oX0, oY0, oX1-oX0, oY1-oY0); + } ++#else ++; ++#endif + +-void cvStereoRectifyFisheye( const CvMat* _cameraMatrix1, const CvMat* _cameraMatrix2, ++void RTABMAP_CORE_EXPORT ++ cvStereoRectifyFisheye( const CvMat* _cameraMatrix1, const CvMat* _cameraMatrix2, + const CvMat* _distCoeffs1, const CvMat* _distCoeffs2, + CvSize imageSize, const CvMat* matR, const CvMat* matT, + CvMat* _R1, CvMat* _R2, CvMat* _P1, CvMat* _P2, + CvMat* matQ, int flags, double alpha, CvSize newImgSize ) ++#ifdef RTABMAP_STEREORECTIFIYFISHEYE_IMPLEMENTATION + { + double _om[3], _t[3] = {0}, _uu[3]={0,0,0}, _r_r[3][3], _pp[3][4]; + double _ww[3], _wr[3][3], _z[3] = {0,0,0}, _ri[3][3], _w3[3]; +@@ -1177,14 +1190,20 @@ void cvStereoRectifyFisheye( const CvMat* _cameraMatrix1, const CvMat* _cameraMa + cvConvert( &Q, matQ ); + } + } ++#else ++; ++#endif ++ + +-void stereoRectifyFisheye( cv::InputArray _cameraMatrix1, cv::InputArray _distCoeffs1, ++void RTABMAP_CORE_EXPORT ++ stereoRectifyFisheye( cv::InputArray _cameraMatrix1, cv::InputArray _distCoeffs1, + cv::InputArray _cameraMatrix2, cv::InputArray _distCoeffs2, + cv::Size imageSize, cv::InputArray _Rmat, cv::InputArray _Tmat, + cv::OutputArray _Rmat1, cv::OutputArray _Rmat2, + cv::OutputArray _Pmat1, cv::OutputArray _Pmat2, + cv::OutputArray _Qmat, int flags, + double alpha, cv::Size newImageSize) ++#ifdef RTABMAP_STEREORECTIFIYFISHEYE_IMPLEMENTATION + { + cv::Mat cameraMatrix1 = _cameraMatrix1.getMat(), cameraMatrix2 = _cameraMatrix2.getMat(); + cv::Mat distCoeffs1 = _distCoeffs1.getMat(), distCoeffs2 = _distCoeffs2.getMat(); +@@ -1238,6 +1257,9 @@ void stereoRectifyFisheye( cv::InputArray _cameraMatrix1, cv::InputArray _distCo + CvSize(newImageSize)); + #endif + } ++#else ++; ++#endif + + } + +diff --git a/corelib/src/StereoCameraModel.cpp b/corelib/src/StereoCameraModel.cpp +index 421d3f4..e7c166c 100644 +--- a/corelib/src/StereoCameraModel.cpp ++++ b/corelib/src/StereoCameraModel.cpp +@@ -34,6 +34,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + #include + + #if CV_MAJOR_VERSION > 2 or (CV_MAJOR_VERSION == 2 and (CV_MINOR_VERSION >4 or (CV_MINOR_VERSION == 4 and CV_SUBMINOR_VERSION >=10))) ++#define RTABMAP_STEREORECTIFIYFISHEYE_IMPLEMENTATION + #include + #endif + diff --git a/cmake/ports/rtabmap/portfile.cmake b/cmake/ports/rtabmap/portfile.cmake new file mode 100644 index 0000000000..cee1f8f3b5 --- /dev/null +++ b/cmake/ports/rtabmap/portfile.cmake @@ -0,0 +1,130 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO introlab/rtabmap + REF 623d056436946c35beb12199831f178a84eaad73 + SHA512 e06bf06066f9f567fa5d1c7d09765e0e76c1f920a1087bda32589260e4406042554347f6eb09abb2b225f57ae85ed645d7645f0974dcee06871040d61eb05ac4 + HEAD_REF master + PATCHES + apple.patch + fix_link.patch + link-keywords.patch + multi-definition.patch + rtabmap-res-tool.patch + gklib.patch + lz4.patch +) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + gui WITH_QT + k4w2 WITH_K4W2 + octomap WITH_OCTOMAP + openni2 WITH_OPENNI2 + realsense2 WITH_REALSENSE2 + tools BUILD_APP + tools BUILD_TOOLS +) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + DISABLE_PARALLEL_CONFIGURE + OPTIONS + ${FEATURE_OPTIONS} + -DBUILD_TOOLS=OFF + -DBUILD_APP=OFF + -DBUILD_AS_BUNDLE=OFF + -DBUILD_EXAMPLES=OFF + -DRTABMAP_QT_VERSION=6 + "-DRTABMAP_RES_TOOL=${CURRENT_HOST_INSTALLED_DIR}/tools/rtabmap-res-tool/rtabmap-res_tool${VCPKG_TARGET_EXECUTABLE_SUFFIX}" + -DWITH_ALICE_VISION=OFF + -DWITH_CCCORELIB=OFF + -DWITH_CERES=ON + -DWITH_CPUTSDF=OFF + -DWITH_CVSBA=OFF + -DWITH_DC1394=OFF + -DWITH_DEPTHAI=OFF + -DWITH_DVO=OFF + -DWITH_FASTCV=OFF + -DWITH_FLYCAPTURE2=OFF + -DWITH_FOVIS=OFF + -DWITH_FREENECT=OFF + -DWITH_FREENECT2=OFF + -DWITH_G2O=ON + -DWITH_GTSAM=OFF + -DWITH_K4A=OFF + -DWITH_LOAM=OFF + -DWITH_MADGWICK=OFF + -DWITH_MSCKF_VIO=OFF + -DWITH_MYNTEYE=OFF + -DWITH_OKVIS=OFF + -DWITH_OPENCHISEL=OFF + -DWITH_OPENVINS=OFF + -DWITH_ORB_OCTREE=ON # GPLv3 + -DWITH_ORB_SLAM=OFF + -DWITH_PDAL=OFF + -DWITH_POINTMATCHER=OFF + -DWITH_PYTHON_THREADING=OFF + -DWITH_PYTHON=OFF + -DWITH_REALSENSE_SLAM=OFF + -DWITH_REALSENSE=OFF + -DWITH_TORCH=OFF + -DWITH_VERTIGO=OFF + -DWITH_VINS=OFF + -DWITH_VISO2=OFF + -DWITH_ZED=OFF + -DWITH_ZEDOC=OFF +) + +vcpkg_cmake_install() + +if(VCPKG_TARGET_IS_WINDOWS) + vcpkg_cmake_config_fixup(CONFIG_PATH CMake) +else() + vcpkg_cmake_config_fixup(CONFIG_PATH lib/rtabmap-0.21) +endif() + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") + +if("tools" IN_LIST FEATURES) + vcpkg_copy_tools( + TOOL_NAMES + rtabmap-camera + rtabmap-console + rtabmap-detectMoreLoopClosures + rtabmap-export + rtabmap-extractObject + rtabmap-info + rtabmap-kitti_dataset + rtabmap-recovery + rtabmap-report + rtabmap-reprocess + rtabmap-rgbd_dataset + rtabmap-euroc_dataset + rtabmap-cleanupLocalGrids + rtabmap-globalBundleAdjustment + AUTO_CLEAN + ) + if("gui" IN_LIST FEATURES) + vcpkg_copy_tools( + TOOL_NAMES + rtabmap + rtabmap-calibration + rtabmap-databaseViewer + rtabmap-dataRecorder + rtabmap-odometryViewer + rtabmap-rgbd_camera + AUTO_CLEAN + ) + file(COPY "${CURRENT_INSTALLED_DIR}/tools/Qt6/bin/qt.conf" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/tools/${PORT}/qt.conf" "./../../../" "./../../") + endif() +endif() + +vcpkg_install_copyright( + COMMENT [[ +The RTAB-Map main license is BSD-3-Clause, but some parts of the +source code are under other licenses possibly including GPL-3.0-only. +]] + FILE_LIST "${SOURCE_PATH}/LICENSE" +) diff --git a/cmake/ports/rtabmap/rtabmap-res-tool.patch b/cmake/ports/rtabmap/rtabmap-res-tool.patch new file mode 100644 index 0000000000..6d72bcaaf8 --- /dev/null +++ b/cmake/ports/rtabmap/rtabmap-res-tool.patch @@ -0,0 +1,11 @@ +diff --git a/utilite/resource_generator/CMakeLists.txt b/utilite/resource_generator/CMakeLists.txt +index 82f1253..eedab31 100644 +--- a/utilite/resource_generator/CMakeLists.txt ++++ b/utilite/resource_generator/CMakeLists.txt +@@ -1,5 +1,5 @@ + +-if (CMAKE_CROSSCOMPILING OR ANDROID OR IOS) ++if (RTABMAP_RES_TOOL) + # See this page about tools being required in the build: + # https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/CrossCompiling#using-executables-in-the-build-created-during-the-build + diff --git a/cmake/ports/rtabmap/sqlite3.patch b/cmake/ports/rtabmap/sqlite3.patch new file mode 100644 index 0000000000..5dcf2f6461 --- /dev/null +++ b/cmake/ports/rtabmap/sqlite3.patch @@ -0,0 +1,48 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 1ecd3ae..024c729 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -252,10 +252,10 @@ endif() + + FIND_PACKAGE(ZLIB REQUIRED QUIET) + +-FIND_PACKAGE(Sqlite3 QUIET) +-IF(Sqlite3_FOUND) +- MESSAGE(STATUS "Found Sqlite3: ${Sqlite3_INCLUDE_DIRS} ${Sqlite3_LIBRARIES}") +-ENDIF(Sqlite3_FOUND) ++FIND_PACKAGE(SQLite3 QUIET) ++IF(SQLite3_FOUND) ++ MESSAGE(STATUS "Found Sqlite3: ${SQLite3_INCLUDE_DIRS} ${SQLite3_LIBRARIES}") ++ENDIF(SQLite3_FOUND) + + if(NOT "${PCL_LIBRARIES}" STREQUAL "") + # fix libproj.so not found on Xenial +@@ -1332,7 +1332,7 @@ ELSE() + MESSAGE(STATUS " With Qt = NO (Qt not found)") + ENDIF() + +-IF(Sqlite3_FOUND) ++IF(SQLite3_FOUND) + MESSAGE(STATUS " With external SQLite3 = YES (License: Public Domain)") + ELSE() + MESSAGE(STATUS " With external SQLite3 = NO (sqlite3 not found, internal version is used for convenience)") +--- a/corelib/src/CMakeLists.txt ++++ b/corelib/src/CMakeLists.txt +@@ -173,14 +173,14 @@ SET(PUBLIC_LIBRARIES + ${PCL_LIBRARIES} + ) + +-IF(Sqlite3_FOUND) ++IF(SQLite3_FOUND) + SET(INCLUDE_DIRS + ${INCLUDE_DIRS} +- ${Sqlite3_INCLUDE_DIRS} ++ ${SQLite3_INCLUDE_DIRS} + ) + SET(LIBRARIES + ${LIBRARIES} +- ${Sqlite3_LIBRARIES} ++ ${SQLite3_LIBRARIES} + ) + ELSE() + SET(SRC_FILES diff --git a/cmake/ports/rtabmap/vcpkg.json b/cmake/ports/rtabmap/vcpkg.json new file mode 100644 index 0000000000..b1ff61f422 --- /dev/null +++ b/cmake/ports/rtabmap/vcpkg.json @@ -0,0 +1,138 @@ +{ + "name": "rtabmap", + "version": "0.21.4.1", + "port-version": 1, + "description": "Real-Time Appearance-Based Mapping", + "homepage": "https://introlab.github.io/rtabmap/", + "license": null, + "dependencies": [ + "ceres", + "g2o", + { + "name": "opencv", + "default-features": false + }, + { + "name": "pcl", + "default-features": false + }, + { + "name": "rtabmap-res-tool", + "host": true + }, + "sqlite3", + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + }, + "zlib" + ], + "default-features": [ + "gui", + "opencv-contrib", + "opencv-nonfree", + "tools" + ], + "features": { + "gui": { + "description": "Build RTAB-Map with GUI support (Qt)", + "dependencies": [ + { + "name": "pcl", + "default-features": false, + "features": [ + "qt", + "visualization" + ] + }, + { + "name": "qtbase", + "default-features": false, + "features": [ + "gui", + "opengl", + "widgets" + ] + }, + { + "name": "vtk", + "default-features": false + } + ] + }, + "k4w2": { + "description": "Build RTAB-Map with Kinect For Windows SDK 2.0 camera driver", + "dependencies": [ + "kinectsdk2" + ] + }, + "octomap": { + "description": "Build RTAB-Map with OctoMap support", + "dependencies": [ + "octomap" + ] + }, + "opencv-contrib": { + "description": "Use OpenCV with contrib modules (e.g., xfeatures2d, aruco)", + "dependencies": [ + { + "name": "opencv", + "default-features": false, + "features": [ + "contrib" + ] + } + ] + }, + "opencv-cuda": { + "description": "Use OpenCV with CUDA (accelerated SIFT ad SURF GPU options)", + "dependencies": [ + { + "name": "opencv", + "default-features": false, + "features": [ + "cuda" + ] + } + ] + }, + "opencv-nonfree": { + "description": "Use OpenCV with nonfree module (surf feature)", + "dependencies": [ + { + "name": "opencv", + "default-features": false, + "features": [ + "nonfree" + ] + } + ] + }, + "openni2": { + "description": "Build RTAB-Map with OpenNI2 camera driver", + "dependencies": [ + "kinectsdk1", + "openni2" + ] + }, + "realsense2": { + "description": "Build RTAB-Map with RealSense2 camera driver", + "dependencies": [ + { + "name": "realsense2", + "default-features": false + } + ] + }, + "tools": { + "description": "Build RTAB-Map's tools", + "dependencies": [ + "yaml-cpp" + ] + } + } +} diff --git a/cmake/ports/tbb/overflow-warning.patch b/cmake/ports/tbb/overflow-warning.patch new file mode 100644 index 0000000000..941b85b664 --- /dev/null +++ b/cmake/ports/tbb/overflow-warning.patch @@ -0,0 +1,14 @@ +diff --git a/cmake/compilers/GNU.cmake b/cmake/compilers/GNU.cmake +index 871b72a..76e1900 100644 +--- a/cmake/compilers/GNU.cmake ++++ b/cmake/compilers/GNU.cmake +@@ -26,7 +26,7 @@ else() + set(TBB_DEF_FILE_PREFIX lin${TBB_ARCH}) + endif() + +-set(TBB_WARNING_LEVEL -Wall -Wextra $<$:-Werror> -Wfatal-errors) ++set(TBB_WARNING_LEVEL -Wall -Wextra $<$:-Werror> -Wfatal-errors -Wno-error=stringop-overflow) + set(TBB_TEST_WARNING_FLAGS -Wshadow -Wcast-qual -Woverloaded-virtual -Wnon-virtual-dtor) + + # Depfile options (e.g. -MD) are inserted automatically in some cases. + diff --git a/cmake/ports/tbb/portfile.cmake b/cmake/ports/tbb/portfile.cmake new file mode 100644 index 0000000000..e11cdd844a --- /dev/null +++ b/cmake/ports/tbb/portfile.cmake @@ -0,0 +1,23 @@ + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO oneapi-src/oneTBB + REF v2021.12.0 + SHA512 64022bcb61cf7b2030a1bcc11168445ef9f0d69b70290233a7febb71cc7a12cc2282dddc045f84e30893efe276342f02fd78d176706268eeaefe9aac7446d4e9 + HEAD_REF master + PATCHES + overflow-warning.patch +) +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DTBB_TEST=OFF + -DCMAKE_CXX_VISIBILITY_PRESET=hidden + -DCMAKE_C_VISIBILITY_PRESET=hidden + -DCMAKE_CXX_STANDARD=17 + -DCMAKE_C_STANDARD=11 +) + +vcpkg_cmake_install() + + diff --git a/cmake/ports/tbb/vcpkg.json b/cmake/ports/tbb/vcpkg.json new file mode 100644 index 0000000000..eec1ba823e --- /dev/null +++ b/cmake/ports/tbb/vcpkg.json @@ -0,0 +1,15 @@ +{ + "name": "tbb", + "version-string": "2021.12.0", + "description": "oneAPI Threading Building Blocks (oneTBB)", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } +] +} diff --git a/cmake/ports/xlink/no-hunter.patch b/cmake/ports/xlink/no-hunter.patch new file mode 100644 index 0000000000..51b62bcef0 --- /dev/null +++ b/cmake/ports/xlink/no-hunter.patch @@ -0,0 +1,704 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 3161667..7deaad5 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -4,12 +4,6 @@ + + cmake_minimum_required(VERSION 3.2) + +-include("cmake/HunterGate.cmake") +-HunterGate( +- URL "https://github.com/cpp-pm/hunter/archive/v0.23.320.tar.gz" +- SHA1 "9b4e732afd22f40482c11ad6342f7d336634226f" +- LOCAL # Local config for dependencies +-) + + ### Constants + set(TARGET_NAME "XLink") +@@ -31,10 +25,6 @@ option(XLINK_ENABLE_LIBUSB "Enable USB protocol which requires libusb library" O + option(XLINK_BUILD_EXAMPLES "Build XLink examples" OFF) + # Build tests + option(XLINK_BUILD_TESTS "Build XLink tests" OFF) +-# Debug option +-set(XLINK_LIBUSB_LOCAL "" CACHE STRING "Path to local libub source to use instead of Hunter") +-# Debug option +-option(XLINK_LIBUSB_SYSTEM "Use system libusb library instead of Hunter" OFF) + + # Specify exporting all symbols on Windows (WIP: shared library on windows doesn't yet work fully (eg logging)) + if(WIN32 AND BUILD_SHARED_LIBS) +@@ -66,13 +56,17 @@ if(is_multi_config) + set_target_properties(${TARGET_NAME} PROPERTIES DEBUG_POSTFIX "d") + endif() + ++# Define export header to support shared library on Windows ++include(GenerateExportHeader) ++generate_export_header(${TARGET_NAME} ++ EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}Export.h) + # Add dependencies + include(cmake/XLinkDependencies.cmake) + + if(XLINK_ENABLE_LIBUSB) + if(XLINK_LIBUSB_SYSTEM) + # Find system libusb +- find_path(LIBUSB_INCLUDE_DIR NAMES libusb.h PATH_SUFFIXES "include" "libusb" "libusb-1.0") ++ find_path(LIBUSB_INCLUDE_DIR NAMES "libusb-1.0/libusb.h") + find_library(LIBUSB_LIBRARY NAMES usb-1.0 PATH_SUFFIXES "lib") + if(NOT LIBUSB_INCLUDE_DIR OR NOT LIBUSB_LIBRARY) + message(FATAL_ERROR "libusb is required") +@@ -87,11 +81,14 @@ if(XLINK_ENABLE_LIBUSB) + # Link to CMake libusb + target_link_libraries(${TARGET_NAME} PRIVATE usb-1.0) + if(WIN32 AND NOT MINGW) +- target_link_libraries(${TARGET_NAME} PRIVATE delayimp.lib Pathcch.lib) ++ target_link_libraries(${TARGET_NAME} PRIVATE delayimp.lib) + # workaround https://gitlab.kitware.com/cmake/cmake/-/issues/20022 + target_link_options(${TARGET_NAME} PUBLIC "$:d>.dll>") + endif() + endif() ++ if(WIN32 AND NOT MINGW) ++ target_link_libraries(${TARGET_NAME} PRIVATE Pathcch.lib) ++ endif() + + # Add compile define stating a local libusb usage + if(XLINK_LIBUSB_LOCAL) +@@ -129,6 +126,7 @@ add_library(${TARGET_PUBLIC_NAME} INTERFACE) + target_include_directories(${TARGET_PUBLIC_NAME} INTERFACE + "$" + "$" ++ "$" + ) + + # Link to headers (public, as itself also needs the headers) +@@ -212,11 +210,6 @@ export(TARGETS ${TARGET_NAME} ${TARGET_PUBLIC_NAME} FILE "${PROJECT_NAME}Targets + # Dependencies file + configure_file("cmake/${PROJECT_NAME}Dependencies.cmake" ${PROJECT_NAME}Dependencies.cmake COPYONLY) + +-# Configure config file (one for exporting build directory, one for installation) +-if(${HUNTER_INSTALL_PREFIX}) +- file(RELATIVE_PATH XLINK_DEPENDENCIES_INSTALLATION_PATH_REL "${CMAKE_CURRENT_BINARY_DIR}" "${HUNTER_INSTALL_PREFIX}") +-endif() +- + configure_file(cmake/${PROJECT_NAME}Config.cmake.in ${PROJECT_NAME}Config.cmake @ONLY) + + # Config for installation +@@ -233,12 +226,11 @@ install( + ) + #Install include folder + install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +-# Install Hunter dependencies +-if(XLINK_ENABLE_LIBUSB) +- if(NOT XLINK_LIBUSB_LOCAL AND NOT XLINK_LIBUSB_SYSTEM) +- install(DIRECTORY "${HUNTER_INSTALL_PREFIX}/" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/dependencies") +- endif() +-endif() ++# Install generated export header ++install( ++ FILES ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}Export.h ++ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/XLink ++) + # Install export group (information about targets) + install(EXPORT ${PROJECT_EXPORT_GROUP} + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" +diff --git a/cmake/Hunter/config.cmake b/cmake/Hunter/config.cmake +deleted file mode 100644 +index 8bb4c5e..0000000 +--- a/cmake/Hunter/config.cmake ++++ /dev/null +@@ -1,11 +0,0 @@ +-# libusb without udev +-hunter_config( +- libusb-luxonis +- VERSION "1.0.24-cmake" +- URL "https://github.com/luxonis/libusb/archive/b7e4548958325b18feb73977163ad44398099534.tar.gz" +- SHA1 "2d79573d57628fe56d2868d2f6ce756d40906cf4" +- CMAKE_ARGS +- WITH_UDEV=OFF +- # Build shared libs by default to not cause licensing issues +- BUILD_SHARED_LIBS=ON +-) +diff --git a/cmake/HunterGate.cmake b/cmake/HunterGate.cmake +deleted file mode 100644 +index 6d9cc24..0000000 +--- a/cmake/HunterGate.cmake ++++ /dev/null +@@ -1,539 +0,0 @@ +-# Copyright (c) 2013-2019, Ruslan Baratov +-# All rights reserved. +-# +-# Redistribution and use in source and binary forms, with or without +-# modification, are permitted provided that the following conditions are met: +-# +-# * Redistributions of source code must retain the above copyright notice, this +-# list of conditions and the following disclaimer. +-# +-# * Redistributions in binary form must reproduce the above copyright notice, +-# this list of conditions and the following disclaimer in the documentation +-# and/or other materials provided with the distribution. +-# +-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +-# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +-# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +-# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- +-# This is a gate file to Hunter package manager. +-# Include this file using `include` command and add package you need, example: +-# +-# cmake_minimum_required(VERSION 3.2) +-# +-# include("cmake/HunterGate.cmake") +-# HunterGate( +-# URL "https://github.com/path/to/hunter/archive.tar.gz" +-# SHA1 "798501e983f14b28b10cda16afa4de69eee1da1d" +-# ) +-# +-# project(MyProject) +-# +-# hunter_add_package(Foo) +-# hunter_add_package(Boo COMPONENTS Bar Baz) +-# +-# Projects: +-# * https://github.com/hunter-packages/gate/ +-# * https://github.com/ruslo/hunter +- +-option(HUNTER_ENABLED "Enable Hunter package manager support" ON) +- +-if(HUNTER_ENABLED) +- if(CMAKE_VERSION VERSION_LESS "3.2") +- message( +- FATAL_ERROR +- "At least CMake version 3.2 required for Hunter dependency management." +- " Update CMake or set HUNTER_ENABLED to OFF." +- ) +- endif() +-endif() +- +-include(CMakeParseArguments) # cmake_parse_arguments +- +-option(HUNTER_STATUS_PRINT "Print working status" ON) +-option(HUNTER_STATUS_DEBUG "Print a lot info" OFF) +-option(HUNTER_TLS_VERIFY "Enable/disable TLS certificate checking on downloads" ON) +- +-set(HUNTER_ERROR_PAGE "https://docs.hunter.sh/en/latest/reference/errors") +- +-function(hunter_gate_status_print) +- if(HUNTER_STATUS_PRINT OR HUNTER_STATUS_DEBUG) +- foreach(print_message ${ARGV}) +- message(STATUS "[hunter] ${print_message}") +- endforeach() +- endif() +-endfunction() +- +-function(hunter_gate_status_debug) +- if(HUNTER_STATUS_DEBUG) +- foreach(print_message ${ARGV}) +- string(TIMESTAMP timestamp) +- message(STATUS "[hunter *** DEBUG *** ${timestamp}] ${print_message}") +- endforeach() +- endif() +-endfunction() +- +-function(hunter_gate_error_page error_page) +- message("------------------------------ ERROR ------------------------------") +- message(" ${HUNTER_ERROR_PAGE}/${error_page}.html") +- message("-------------------------------------------------------------------") +- message("") +- message(FATAL_ERROR "") +-endfunction() +- +-function(hunter_gate_internal_error) +- message("") +- foreach(print_message ${ARGV}) +- message("[hunter ** INTERNAL **] ${print_message}") +- endforeach() +- message("[hunter ** INTERNAL **] [Directory:${CMAKE_CURRENT_LIST_DIR}]") +- message("") +- hunter_gate_error_page("error.internal") +-endfunction() +- +-function(hunter_gate_fatal_error) +- cmake_parse_arguments(hunter "" "ERROR_PAGE" "" "${ARGV}") +- if("${hunter_ERROR_PAGE}" STREQUAL "") +- hunter_gate_internal_error("Expected ERROR_PAGE") +- endif() +- message("") +- foreach(x ${hunter_UNPARSED_ARGUMENTS}) +- message("[hunter ** FATAL ERROR **] ${x}") +- endforeach() +- message("[hunter ** FATAL ERROR **] [Directory:${CMAKE_CURRENT_LIST_DIR}]") +- message("") +- hunter_gate_error_page("${hunter_ERROR_PAGE}") +-endfunction() +- +-function(hunter_gate_user_error) +- hunter_gate_fatal_error(${ARGV} ERROR_PAGE "error.incorrect.input.data") +-endfunction() +- +-function(hunter_gate_self root version sha1 result) +- string(COMPARE EQUAL "${root}" "" is_bad) +- if(is_bad) +- hunter_gate_internal_error("root is empty") +- endif() +- +- string(COMPARE EQUAL "${version}" "" is_bad) +- if(is_bad) +- hunter_gate_internal_error("version is empty") +- endif() +- +- string(COMPARE EQUAL "${sha1}" "" is_bad) +- if(is_bad) +- hunter_gate_internal_error("sha1 is empty") +- endif() +- +- string(SUBSTRING "${sha1}" 0 7 archive_id) +- +- if(EXISTS "${root}/cmake/Hunter") +- set(hunter_self "${root}") +- else() +- set( +- hunter_self +- "${root}/_Base/Download/Hunter/${version}/${archive_id}/Unpacked" +- ) +- endif() +- +- set("${result}" "${hunter_self}" PARENT_SCOPE) +-endfunction() +- +-# Set HUNTER_GATE_ROOT cmake variable to suitable value. +-function(hunter_gate_detect_root) +- # Check CMake variable +- string(COMPARE NOTEQUAL "${HUNTER_ROOT}" "" not_empty) +- if(not_empty) +- set(HUNTER_GATE_ROOT "${HUNTER_ROOT}" PARENT_SCOPE) +- hunter_gate_status_debug("HUNTER_ROOT detected by cmake variable") +- return() +- endif() +- +- # Check environment variable +- string(COMPARE NOTEQUAL "$ENV{HUNTER_ROOT}" "" not_empty) +- if(not_empty) +- set(HUNTER_GATE_ROOT "$ENV{HUNTER_ROOT}" PARENT_SCOPE) +- hunter_gate_status_debug("HUNTER_ROOT detected by environment variable") +- return() +- endif() +- +- # Check HOME environment variable +- string(COMPARE NOTEQUAL "$ENV{HOME}" "" result) +- if(result) +- set(HUNTER_GATE_ROOT "$ENV{HOME}/.hunter" PARENT_SCOPE) +- hunter_gate_status_debug("HUNTER_ROOT set using HOME environment variable") +- return() +- endif() +- +- # Check SYSTEMDRIVE and USERPROFILE environment variable (windows only) +- if(WIN32) +- string(COMPARE NOTEQUAL "$ENV{SYSTEMDRIVE}" "" result) +- if(result) +- set(HUNTER_GATE_ROOT "$ENV{SYSTEMDRIVE}/.hunter" PARENT_SCOPE) +- hunter_gate_status_debug( +- "HUNTER_ROOT set using SYSTEMDRIVE environment variable" +- ) +- return() +- endif() +- +- string(COMPARE NOTEQUAL "$ENV{USERPROFILE}" "" result) +- if(result) +- set(HUNTER_GATE_ROOT "$ENV{USERPROFILE}/.hunter" PARENT_SCOPE) +- hunter_gate_status_debug( +- "HUNTER_ROOT set using USERPROFILE environment variable" +- ) +- return() +- endif() +- endif() +- +- hunter_gate_fatal_error( +- "Can't detect HUNTER_ROOT" +- ERROR_PAGE "error.detect.hunter.root" +- ) +-endfunction() +- +-function(hunter_gate_download dir) +- string( +- COMPARE +- NOTEQUAL +- "$ENV{HUNTER_DISABLE_AUTOINSTALL}" +- "" +- disable_autoinstall +- ) +- if(disable_autoinstall AND NOT HUNTER_RUN_INSTALL) +- hunter_gate_fatal_error( +- "Hunter not found in '${dir}'" +- "Set HUNTER_RUN_INSTALL=ON to auto-install it from '${HUNTER_GATE_URL}'" +- "Settings:" +- " HUNTER_ROOT: ${HUNTER_GATE_ROOT}" +- " HUNTER_SHA1: ${HUNTER_GATE_SHA1}" +- ERROR_PAGE "error.run.install" +- ) +- endif() +- string(COMPARE EQUAL "${dir}" "" is_bad) +- if(is_bad) +- hunter_gate_internal_error("Empty 'dir' argument") +- endif() +- +- string(COMPARE EQUAL "${HUNTER_GATE_SHA1}" "" is_bad) +- if(is_bad) +- hunter_gate_internal_error("HUNTER_GATE_SHA1 empty") +- endif() +- +- string(COMPARE EQUAL "${HUNTER_GATE_URL}" "" is_bad) +- if(is_bad) +- hunter_gate_internal_error("HUNTER_GATE_URL empty") +- endif() +- +- set(done_location "${dir}/DONE") +- set(sha1_location "${dir}/SHA1") +- +- set(build_dir "${dir}/Build") +- set(cmakelists "${dir}/CMakeLists.txt") +- +- hunter_gate_status_debug("Locking directory: ${dir}") +- file(LOCK "${dir}" DIRECTORY GUARD FUNCTION) +- hunter_gate_status_debug("Lock done") +- +- if(EXISTS "${done_location}") +- # while waiting for lock other instance can do all the job +- hunter_gate_status_debug("File '${done_location}' found, skip install") +- return() +- endif() +- +- file(REMOVE_RECURSE "${build_dir}") +- file(REMOVE_RECURSE "${cmakelists}") +- +- file(MAKE_DIRECTORY "${build_dir}") # check directory permissions +- +- # Disabling languages speeds up a little bit, reduces noise in the output +- # and avoids path too long windows error +- file( +- WRITE +- "${cmakelists}" +- "cmake_minimum_required(VERSION 3.2)\n" +- "project(HunterDownload LANGUAGES NONE)\n" +- "include(ExternalProject)\n" +- "ExternalProject_Add(\n" +- " Hunter\n" +- " URL\n" +- " \"${HUNTER_GATE_URL}\"\n" +- " URL_HASH\n" +- " SHA1=${HUNTER_GATE_SHA1}\n" +- " DOWNLOAD_DIR\n" +- " \"${dir}\"\n" +- " TLS_VERIFY\n" +- " ${HUNTER_TLS_VERIFY}\n" +- " SOURCE_DIR\n" +- " \"${dir}/Unpacked\"\n" +- " CONFIGURE_COMMAND\n" +- " \"\"\n" +- " BUILD_COMMAND\n" +- " \"\"\n" +- " INSTALL_COMMAND\n" +- " \"\"\n" +- ")\n" +- ) +- +- if(HUNTER_STATUS_DEBUG) +- set(logging_params "") +- else() +- set(logging_params OUTPUT_QUIET) +- endif() +- +- hunter_gate_status_debug("Run generate") +- +- # Need to add toolchain file too. +- # Otherwise on Visual Studio + MDD this will fail with error: +- # "Could not find an appropriate version of the Windows 10 SDK installed on this machine" +- if(EXISTS "${CMAKE_TOOLCHAIN_FILE}") +- get_filename_component(absolute_CMAKE_TOOLCHAIN_FILE "${CMAKE_TOOLCHAIN_FILE}" ABSOLUTE) +- set(toolchain_arg "-DCMAKE_TOOLCHAIN_FILE=${absolute_CMAKE_TOOLCHAIN_FILE}") +- else() +- # 'toolchain_arg' can't be empty +- set(toolchain_arg "-DCMAKE_TOOLCHAIN_FILE=") +- endif() +- +- string(COMPARE EQUAL "${CMAKE_MAKE_PROGRAM}" "" no_make) +- if(no_make) +- set(make_arg "") +- else() +- # Test case: remove Ninja from PATH but set it via CMAKE_MAKE_PROGRAM +- set(make_arg "-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}") +- endif() +- +- execute_process( +- COMMAND +- "${CMAKE_COMMAND}" +- "-H${dir}" +- "-B${build_dir}" +- "-G${CMAKE_GENERATOR}" +- "${toolchain_arg}" +- ${make_arg} +- WORKING_DIRECTORY "${dir}" +- RESULT_VARIABLE download_result +- ${logging_params} +- ) +- +- if(NOT download_result EQUAL 0) +- hunter_gate_internal_error( +- "Configure project failed." +- "To reproduce the error run: ${CMAKE_COMMAND} -H${dir} -B${build_dir} -G${CMAKE_GENERATOR} ${toolchain_arg} ${make_arg}" +- "In directory ${dir}" +- ) +- endif() +- +- hunter_gate_status_print( +- "Initializing Hunter workspace (${HUNTER_GATE_SHA1})" +- " ${HUNTER_GATE_URL}" +- " -> ${dir}" +- ) +- execute_process( +- COMMAND "${CMAKE_COMMAND}" --build "${build_dir}" +- WORKING_DIRECTORY "${dir}" +- RESULT_VARIABLE download_result +- ${logging_params} +- ) +- +- if(NOT download_result EQUAL 0) +- hunter_gate_internal_error("Build project failed") +- endif() +- +- file(REMOVE_RECURSE "${build_dir}") +- file(REMOVE_RECURSE "${cmakelists}") +- +- file(WRITE "${sha1_location}" "${HUNTER_GATE_SHA1}") +- file(WRITE "${done_location}" "DONE") +- +- hunter_gate_status_debug("Finished") +-endfunction() +- +-# Must be a macro so master file 'cmake/Hunter' can +-# apply all variables easily just by 'include' command +-# (otherwise PARENT_SCOPE magic needed) +-macro(HunterGate) +- if(HUNTER_GATE_DONE) +- # variable HUNTER_GATE_DONE set explicitly for external project +- # (see `hunter_download`) +- set_property(GLOBAL PROPERTY HUNTER_GATE_DONE YES) +- endif() +- +- # First HunterGate command will init Hunter, others will be ignored +- get_property(_hunter_gate_done GLOBAL PROPERTY HUNTER_GATE_DONE SET) +- +- if(NOT HUNTER_ENABLED) +- # Empty function to avoid error "unknown function" +- function(hunter_add_package) +- endfunction() +- +- set( +- _hunter_gate_disabled_mode_dir +- "${CMAKE_CURRENT_LIST_DIR}/cmake/Hunter/disabled-mode" +- ) +- if(EXISTS "${_hunter_gate_disabled_mode_dir}") +- hunter_gate_status_debug( +- "Adding \"disabled-mode\" modules: ${_hunter_gate_disabled_mode_dir}" +- ) +- list(APPEND CMAKE_PREFIX_PATH "${_hunter_gate_disabled_mode_dir}") +- endif() +- elseif(_hunter_gate_done) +- hunter_gate_status_debug("Secondary HunterGate (use old settings)") +- hunter_gate_self( +- "${HUNTER_CACHED_ROOT}" +- "${HUNTER_VERSION}" +- "${HUNTER_SHA1}" +- _hunter_self +- ) +- include("${_hunter_self}/cmake/Hunter") +- else() +- set(HUNTER_GATE_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}") +- +- string(COMPARE NOTEQUAL "${PROJECT_NAME}" "" _have_project_name) +- if(_have_project_name) +- hunter_gate_fatal_error( +- "Please set HunterGate *before* 'project' command. " +- "Detected project: ${PROJECT_NAME}" +- ERROR_PAGE "error.huntergate.before.project" +- ) +- endif() +- +- cmake_parse_arguments( +- HUNTER_GATE "LOCAL" "URL;SHA1;GLOBAL;FILEPATH" "" ${ARGV} +- ) +- +- string(COMPARE EQUAL "${HUNTER_GATE_SHA1}" "" _empty_sha1) +- string(COMPARE EQUAL "${HUNTER_GATE_URL}" "" _empty_url) +- string( +- COMPARE +- NOTEQUAL +- "${HUNTER_GATE_UNPARSED_ARGUMENTS}" +- "" +- _have_unparsed +- ) +- string(COMPARE NOTEQUAL "${HUNTER_GATE_GLOBAL}" "" _have_global) +- string(COMPARE NOTEQUAL "${HUNTER_GATE_FILEPATH}" "" _have_filepath) +- +- if(_have_unparsed) +- hunter_gate_user_error( +- "HunterGate unparsed arguments: ${HUNTER_GATE_UNPARSED_ARGUMENTS}" +- ) +- endif() +- if(_empty_sha1) +- hunter_gate_user_error("SHA1 suboption of HunterGate is mandatory") +- endif() +- if(_empty_url) +- hunter_gate_user_error("URL suboption of HunterGate is mandatory") +- endif() +- if(_have_global) +- if(HUNTER_GATE_LOCAL) +- hunter_gate_user_error("Unexpected LOCAL (already has GLOBAL)") +- endif() +- if(_have_filepath) +- hunter_gate_user_error("Unexpected FILEPATH (already has GLOBAL)") +- endif() +- endif() +- if(HUNTER_GATE_LOCAL) +- if(_have_global) +- hunter_gate_user_error("Unexpected GLOBAL (already has LOCAL)") +- endif() +- if(_have_filepath) +- hunter_gate_user_error("Unexpected FILEPATH (already has LOCAL)") +- endif() +- endif() +- if(_have_filepath) +- if(_have_global) +- hunter_gate_user_error("Unexpected GLOBAL (already has FILEPATH)") +- endif() +- if(HUNTER_GATE_LOCAL) +- hunter_gate_user_error("Unexpected LOCAL (already has FILEPATH)") +- endif() +- endif() +- +- hunter_gate_detect_root() # set HUNTER_GATE_ROOT +- +- # Beautify path, fix probable problems with windows path slashes +- get_filename_component( +- HUNTER_GATE_ROOT "${HUNTER_GATE_ROOT}" ABSOLUTE +- ) +- hunter_gate_status_debug("HUNTER_ROOT: ${HUNTER_GATE_ROOT}") +- if(NOT HUNTER_ALLOW_SPACES_IN_PATH) +- string(FIND "${HUNTER_GATE_ROOT}" " " _contain_spaces) +- if(NOT _contain_spaces EQUAL -1) +- hunter_gate_fatal_error( +- "HUNTER_ROOT (${HUNTER_GATE_ROOT}) contains spaces." +- "Set HUNTER_ALLOW_SPACES_IN_PATH=ON to skip this error" +- "(Use at your own risk!)" +- ERROR_PAGE "error.spaces.in.hunter.root" +- ) +- endif() +- endif() +- +- string( +- REGEX +- MATCH +- "[0-9]+\\.[0-9]+\\.[0-9]+[-_a-z0-9]*" +- HUNTER_GATE_VERSION +- "${HUNTER_GATE_URL}" +- ) +- string(COMPARE EQUAL "${HUNTER_GATE_VERSION}" "" _is_empty) +- if(_is_empty) +- set(HUNTER_GATE_VERSION "unknown") +- endif() +- +- hunter_gate_self( +- "${HUNTER_GATE_ROOT}" +- "${HUNTER_GATE_VERSION}" +- "${HUNTER_GATE_SHA1}" +- _hunter_self +- ) +- +- set(_master_location "${_hunter_self}/cmake/Hunter") +- if(EXISTS "${HUNTER_GATE_ROOT}/cmake/Hunter") +- # Hunter downloaded manually (e.g. by 'git clone') +- set(_unused "xxxxxxxxxx") +- set(HUNTER_GATE_SHA1 "${_unused}") +- set(HUNTER_GATE_VERSION "${_unused}") +- else() +- get_filename_component(_archive_id_location "${_hunter_self}/.." ABSOLUTE) +- set(_done_location "${_archive_id_location}/DONE") +- set(_sha1_location "${_archive_id_location}/SHA1") +- +- # Check Hunter already downloaded by HunterGate +- if(NOT EXISTS "${_done_location}") +- hunter_gate_download("${_archive_id_location}") +- endif() +- +- if(NOT EXISTS "${_done_location}") +- hunter_gate_internal_error("hunter_gate_download failed") +- endif() +- +- if(NOT EXISTS "${_sha1_location}") +- hunter_gate_internal_error("${_sha1_location} not found") +- endif() +- file(READ "${_sha1_location}" _sha1_value) +- string(COMPARE EQUAL "${_sha1_value}" "${HUNTER_GATE_SHA1}" _is_equal) +- if(NOT _is_equal) +- hunter_gate_internal_error( +- "Short SHA1 collision:" +- " ${_sha1_value} (from ${_sha1_location})" +- " ${HUNTER_GATE_SHA1} (HunterGate)" +- ) +- endif() +- if(NOT EXISTS "${_master_location}") +- hunter_gate_user_error( +- "Master file not found:" +- " ${_master_location}" +- "try to update Hunter/HunterGate" +- ) +- endif() +- endif() +- include("${_master_location}") +- set_property(GLOBAL PROPERTY HUNTER_GATE_DONE YES) +- endif() +-endmacro() +diff --git a/cmake/XLinkDependencies.cmake b/cmake/XLinkDependencies.cmake +index 1072d1d..7bc47e6 100644 +--- a/cmake/XLinkDependencies.cmake ++++ b/cmake/XLinkDependencies.cmake +@@ -5,13 +5,6 @@ if(CONFIG_MODE) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE "BOTH") + set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_LIST_DIR}/${_IMPORT_PREFIX}" ${CMAKE_PREFIX_PATH}) + set(_QUIET "QUIET") +-else() +- # set(XLINK_SHARED_LIBS ${BUILD_SHARED_LIBS}) +- if(XLINK_ENABLE_LIBUSB) +- if(NOT XLINK_LIBUSB_LOCAL AND NOT XLINK_LIBUSB_SYSTEM) +- hunter_add_package(libusb-luxonis) +- endif() +- endif() + endif() + + # libusb +diff --git a/include/XLink/XLinkLog.h b/include/XLink/XLinkLog.h +index e487c71..7e1ccb3 100644 +--- a/include/XLink/XLinkLog.h ++++ b/include/XLink/XLinkLog.h +@@ -29,6 +29,7 @@ extern "C" { + #include + #include + #include ++#include "XLinkExport.h" + + #ifndef _GNU_SOURCE + #define _GNU_SOURCE +@@ -72,8 +73,8 @@ FUNCATTR_WEAK mvLog_t __attribute__ ((weak)) MVLOGLEVEL(MVLOG_UNIT_NAME) = MVLOG + #define UNIT_NAME_STR MVLOG_STR(MVLOG_UNIT_NAME) + + +-extern mvLog_t MVLOGLEVEL(global); +-extern mvLog_t MVLOGLEVEL(default); ++extern XLINK_EXPORT mvLog_t MVLOGLEVEL(global); ++extern XLINK_EXPORT mvLog_t MVLOGLEVEL(default); + + int __attribute__ ((unused)) logprintf(mvLog_t curLogLvl, mvLog_t lvl, const char * func, const int line, const char * format, ...); + diff --git a/cmake/ports/xlink/portfile.cmake b/cmake/ports/xlink/portfile.cmake new file mode 100644 index 0000000000..fbe103b87b --- /dev/null +++ b/cmake/ports/xlink/portfile.cmake @@ -0,0 +1,29 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO luxonis/XLink + REF 6615e0721021c136dc50a3af5a5bf16919ffef87 + SHA512 35fb1c1ee8dea69a6bf577fb374fe6dd3cf815e7baef70671732fa8062d81fc34c17439fbe95f3bfe1a4266e0bc4e47b0d033c8abf586bbd7e0713891ffe6c28 + HEAD_REF develop_server + PATCHES + no-hunter.patch +) +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + libusb XLINK_ENABLE_LIBUSB +) +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + # temporary + ${FEATURE_OPTIONS} + -DCMAKE_CXX_STANDARD=17 + -DCMAKE_C_STANDARD=11 +) + +vcpkg_cmake_install() + +vcpkg_fixup_pkgconfig() +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") +vcpkg_cmake_config_fixup(PACKAGE_NAME xlink CONFIG_PATH "lib/cmake/XLink") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") diff --git a/cmake/ports/xlink/vcpkg.json b/cmake/ports/xlink/vcpkg.json new file mode 100644 index 0000000000..b5075130fb --- /dev/null +++ b/cmake/ports/xlink/vcpkg.json @@ -0,0 +1,26 @@ +{ + "name": "xlink", + "version-string": "luxonis-develop-server", + "description": "A cross-platform library for communicating with devices over various physical links.", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } +], + "features": { + "libusb": { + "description": "Build with libusb support", + "dependencies": [ + { + "name": "libusb" + } + ] + + } + } +} diff --git a/cmake/triplets/arm64-linux.cmake b/cmake/triplets/arm64-linux.cmake new file mode 100644 index 0000000000..5683acaaa6 --- /dev/null +++ b/cmake/triplets/arm64-linux.cmake @@ -0,0 +1,10 @@ +set(VCPKG_TARGET_ARCHITECTURE arm64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) + +set(VCPKG_CMAKE_SYSTEM_NAME Linux) + +if(PORT MATCHES "libusb") + set(VCPKG_LIBRARY_LINKAGE dynamic) +endif() + diff --git a/cmake/triplets/arm64-osx.cmake b/cmake/triplets/arm64-osx.cmake new file mode 100644 index 0000000000..1d8c1a5bd6 --- /dev/null +++ b/cmake/triplets/arm64-osx.cmake @@ -0,0 +1,9 @@ +set(VCPKG_TARGET_ARCHITECTURE arm64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) + +set(VCPKG_CMAKE_SYSTEM_NAME Darwin) +set(VCPKG_OSX_ARCHITECTURES arm64) +if(PORT MATCHES "libusb") + set(VCPKG_LIBRARY_LINKAGE dynamic) +endif() diff --git a/cmake/triplets/x64-linux.cmake b/cmake/triplets/x64-linux.cmake new file mode 100644 index 0000000000..39f17c4e01 --- /dev/null +++ b/cmake/triplets/x64-linux.cmake @@ -0,0 +1,8 @@ +set(VCPKG_TARGET_ARCHITECTURE x64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) +if(PORT MATCHES "libusb") + set(VCPKG_LIBRARY_LINKAGE dynamic) +endif() + +set(VCPKG_CMAKE_SYSTEM_NAME Linux) diff --git a/cmake/triplets/x64-osx.cmake b/cmake/triplets/x64-osx.cmake new file mode 100644 index 0000000000..fb35456978 --- /dev/null +++ b/cmake/triplets/x64-osx.cmake @@ -0,0 +1,11 @@ +set(VCPKG_TARGET_ARCHITECTURE x64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) + +set(VCPKG_CMAKE_SYSTEM_NAME Darwin) +set(VCPKG_OSX_ARCHITECTURES x86_64) + +if(PORT MATCHES "libusb") + set(VCPKG_LIBRARY_LINKAGE dynamic) +endif() + diff --git a/cmake/triplets/x64-windows.cmake b/cmake/triplets/x64-windows.cmake new file mode 100644 index 0000000000..4615a4ae9a --- /dev/null +++ b/cmake/triplets/x64-windows.cmake @@ -0,0 +1,8 @@ +set(VCPKG_TARGET_ARCHITECTURE x64) +set(VCPKG_CRT_LINKAGE static) +set(VCPKG_LIBRARY_LINKAGE static) + +if(PORT MATCHES "libusb") + set(VCPKG_LIBRARY_LINKAGE dynamic) +endif() + diff --git a/examples/cpp/CMakeLists.txt b/examples/cpp/CMakeLists.txt index e94b710960..46ad027ffd 100644 --- a/examples/cpp/CMakeLists.txt +++ b/examples/cpp/CMakeLists.txt @@ -9,7 +9,7 @@ find_package(Sanitizers) add_library(utility utility/utility.cpp) target_include_directories(utility PUBLIC "utility") add_default_flags(utility LEAN) -target_link_libraries(utility FP16::fp16 ${OpenCV_LIBS}) +target_link_libraries(utility ${OpenCV_LIBS}) set(test_env # Misc @@ -105,7 +105,7 @@ endfunction() # Add any custom binary data using the following snippet ## # Hunter test data download -## hunter_private_data( +## private_data( ## URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/mobilenet.blob" ## SHA1 "e89d3ee9f26d80397e44f89c6b375990064a4a42" ## FILE "mobilenet.blob" @@ -116,7 +116,7 @@ endfunction() # Hunter test data download # NeuralNetwork node, mobilenet example -hunter_private_data( +private_data( URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/mobilenet-ssd_openvino_2021.4_6shave.blob" SHA1 "4f4506726e3083981064938a0faaf9af6180d2c6" FILE "mobilenet-ssd_openvino_2021.4_6shave.blob" @@ -124,7 +124,7 @@ hunter_private_data( ) # YoloV3 resource -hunter_private_data( +private_data( URL "http://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/yolo-v3-tiny-tf_openvino_2021.4_6shave.blob" SHA1 "dedb2d4d96b23e42d15c15e454b8f02eca2713de" FILE "yolo-v3-tiny-tf_openvino_2021.4_6shave.blob" @@ -132,7 +132,7 @@ hunter_private_data( ) # YoloV4 resource -hunter_private_data( +private_data( URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/yolo-v4-tiny-tf_openvino_2021.4_6shave.blob" SHA1 "d8d09b697dac298fe83cf8856740a21b1a61ab89" FILE "yolo-v4-tiny-tf_openvino_2021.4_6shave.blob" @@ -140,7 +140,7 @@ hunter_private_data( ) # NeuralNetwork node, mobilenet example, 5 shaves -hunter_private_data( +private_data( URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/mobilenet-ssd_openvino_2021.4_5shave.blob" SHA1 "14ab3ef446b8a649d6694d94c2fc8b798efd74a3" FILE "mobilenet-ssd_openvino_2021.4_5shave.blob" @@ -148,7 +148,7 @@ hunter_private_data( ) # NeuralNetwork node, mobilenet example, 8 shaves -hunter_private_data( +private_data( URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/mobilenet-ssd_openvino_2021.4_8shave.blob" SHA1 "7e7ea9a680668f3ca9e8f1d22cc8f3f1a02ac018" FILE "mobilenet-ssd_openvino_2021.4_8shave.blob" @@ -156,7 +156,7 @@ hunter_private_data( ) # Video file with objects to detect -hunter_private_data( +private_data( URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/construction_vest.mp4" SHA1 "271d8d0b702e683ce02957db7c100843de5ceaec" FILE "construction_vest.mp4" @@ -164,21 +164,21 @@ hunter_private_data( ) # Calibration Sample files -hunter_private_data( +private_data( URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/misc/depthai_calib.json" SHA1 "ec50a47496473116c51cec1c8249bff2679383c3" FILE "depthai_calib.json" LOCATION calib_v6 ) -hunter_private_data( +private_data( URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/misc/depthai_v5.calib" SHA1 "adfe9976b9aacfdaa76ac7138810999988177e71" FILE "depthai_v5.calib" LOCATION calib_v5 ) -hunter_private_data( +private_data( URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/misc/BW1098OBC.json" SHA1 "1e84b6c339ac51e3b254775090b91235a40fac71" FILE "BW1098OBC.json" @@ -186,7 +186,7 @@ hunter_private_data( ) # person-detection -hunter_private_data( +private_data( URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/person-detection-retail-0013_openvino_2021.4_7shave.blob" SHA1 "946d102874b287292cdb5952fa66356c8d36025f" FILE "person-detection-retail-0013_openvino_2021.4_7shave.blob" @@ -194,7 +194,7 @@ hunter_private_data( ) # concat model -hunter_private_data( +private_data( URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/concat_openvino_2021.4_6shave.blob" SHA1 "e4af6fb2bed39648a2a4424d8bdc5bac56d616df" FILE "concat_openvino_2021.4_6shave.blob" @@ -202,7 +202,7 @@ hunter_private_data( ) # normalization model -hunter_private_data( +private_data( URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/normalize_openvino_2021.4_4shave.blob" SHA1 "1435f6d11e0dfdbc60f2dfa45aecd3d530b6153b" FILE "normalize_openvino_2021.4_4shave.blob" @@ -210,7 +210,7 @@ hunter_private_data( ) # mobilnet xml model for S3 example -hunter_private_data( +private_data( URL "https://download.01.org/opencv/2021/openvinotoolkit/2021.1/open_model_zoo/models_bin/1/person-detection-0202/FP32/person-detection-0202.xml" SHA1 "87f9cf8833043162f1b728e9afa6f38ba177d9db" FILE "person-detection-0202.xml" @@ -218,7 +218,7 @@ hunter_private_data( ) # mobilnet xml model for S3 example -hunter_private_data( +private_data( URL "https://download.01.org/opencv/2021/openvinotoolkit/2021.1/open_model_zoo/models_bin/1/person-detection-0202/FP32/person-detection-0202.bin" SHA1 "1560bf2ee372a0640539780ea8bd061278a6cc20" FILE "person-detection-0202.bin" @@ -226,7 +226,7 @@ hunter_private_data( ) # yolo xml model for S3 example -hunter_private_data( +private_data( URL "https://github.com/luxonis/depthai-model-zoo/raw/main/models/yolov4_tiny_coco_416x416/yolov4_tiny_coco_416x416.xml" SHA1 "423069bdff250643cf080c76e15594cfd72cb816" FILE "yolov4_tiny_coco_416x416.xml" @@ -234,7 +234,7 @@ hunter_private_data( ) # yolo bin model for S3 example -hunter_private_data( +private_data( URL "https://robothub.fra1.cdn.digitaloceanspaces.com/models/yolov4_tiny_coco_416x416/yolov4_tiny_coco_416x416.bin" SHA1 "a7627c074ee76ceb9ff9bb8529b67867e3e440bc" FILE "yolov4_tiny_coco_416x416.bin" @@ -242,7 +242,7 @@ hunter_private_data( ) # yolo v5 nn archive -hunter_private_data( +private_data( URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/nnarchive/yolo-v6-openvino_2022.1_6shave-rvc2.tar.xz" SHA1 "63a5bb29d1ca0d3b019f13d66401e634539aac82" FILE "yolo-v6-openvino_2022.1_6shave-rvc2.tar.xz" diff --git a/include/depthai/rtabmap/RTABMapSLAM.hpp b/include/depthai/rtabmap/RTABMapSLAM.hpp index 18bf333c54..50319ca025 100644 --- a/include/depthai/rtabmap/RTABMapSLAM.hpp +++ b/include/depthai/rtabmap/RTABMapSLAM.hpp @@ -49,49 +49,49 @@ class RTABMapSLAM : public dai::NodeCRTP data); void odomPoseCB(std::shared_ptr data); void imuCB(std::shared_ptr msg); @@ -215,4 +215,4 @@ class RTABMapSLAM : public dai::NodeCRTP { /** * Input tracked features on which VIO is performed (optional). */ - Input features{*this, {.name = featuresInputName, .types = {{DatatypeEnum::TrackedFeatures, true}}}}; + Input features{*this, {featuresInputName, DEFAULT_GROUP, DEFAULT_BLOCKING, 15, {{{DatatypeEnum::TrackedFeatures, true}}}}}; /** * Input IMU data. */ - Input imu{*this, {.name = "imu", .types = {{DatatypeEnum::IMUData, true}}}}; + Input imu{*this, {"imu", DEFAULT_GROUP, DEFAULT_BLOCKING, 15, {{{DatatypeEnum::IMUData, true}}}}}; /** * Output transform. */ - Output transform{*this, {.name = "transform", .types = {{DatatypeEnum::TransformData, true}}}}; + Output transform{*this, {"transform", DEFAULT_GROUP, {{{DatatypeEnum::TransformData, true}}}}}; /** * Passthrough rectified frame. */ - Output passthroughRect{*this, {.name = "passthroughRect", .types = {{DatatypeEnum::ImgFrame, true}}}}; + Output passthroughRect{*this, {"passthroughRect", DEFAULT_GROUP, {{{DatatypeEnum::ImgFrame, true}}}}}; /** * Passthrough depth frame. */ - Output passthroughDepth{*this, {.name = "passthroughDepth", .types = {{DatatypeEnum::ImgFrame, true}}}}; + Output passthroughDepth{*this, {"passthroughDepth", DEFAULT_GROUP, {{{DatatypeEnum::ImgFrame, true}}}}}; /** * Passthrough features. */ - Output passthroughFeatures{*this, {.name = "passthroughFeatures", .types = {{DatatypeEnum::TrackedFeatures, true}}}}; + Output passthroughFeatures{*this, {"passthroughFeatures", DEFAULT_GROUP, {{{DatatypeEnum::TrackedFeatures, true}}}}}; /** * Set RTABMap parameters. @@ -91,20 +91,21 @@ class RTABMapVIO : public NodeCRTP { private: void run() override; void syncCB(std::shared_ptr data); - Input inSync{*this, {.name = "inSync", .types = {{DatatypeEnum::MessageGroup, true}}}}; - void imuCB(std::shared_ptr msg); - void initialize(Pipeline& pipeline, int instanceNum, int width, int height); - rtabmap::StereoCameraModel model; - std::unique_ptr odom; - rtabmap::Transform localTransform; - rtabmap::Transform imuLocalTransform; - std::map rtabParams; - std::map accBuffer; - std::map gyroBuffer; - std::mutex imuMtx; - float alphaScaling = -1.0; - bool initialized = false; - bool useFeatures = true; -}; + Input inSync { + *this, {"inSync", DEFAULT_GROUP, DEFAULT_BLOCKING, 15, {{{DatatypeEnum::MessageGroup, true}}}}}; + void imuCB(std::shared_ptr msg); + void initialize(Pipeline & pipeline, int instanceNum, int width, int height); + rtabmap::StereoCameraModel model; + std::unique_ptr odom; + rtabmap::Transform localTransform; + rtabmap::Transform imuLocalTransform; + std::map rtabParams; + std::map accBuffer; + std::map gyroBuffer; + std::mutex imuMtx; + float alphaScaling = -1.0; + bool initialized = false; + bool useFeatures = true; + }; } // namespace node -} // namespace dai \ No newline at end of file +} // namespace dai diff --git a/src/device/DeviceBase.cpp b/src/device/DeviceBase.cpp index ee82e24ec6..7594541226 100644 --- a/src/device/DeviceBase.cpp +++ b/src/device/DeviceBase.cpp @@ -45,6 +45,7 @@ #include "spdlog/spdlog.h" #include "utility/LogCollection.hpp" #include "utility/Logging.hpp" +#include "utility/spdlog-fmt.hpp" namespace dai { diff --git a/src/utility/Resources.cpp b/src/utility/Resources.cpp index 303de2797a..574b77ee8a 100644 --- a/src/utility/Resources.cpp +++ b/src/utility/Resources.cpp @@ -463,8 +463,12 @@ Resources::Resources() { Resources::~Resources() { // join the lazy threads +#ifdef DEPTHAI_ENABLE_DEVICE_FW if(lazyThreadDevice.joinable()) lazyThreadDevice.join(); +#endif +#ifdef DEPTHAI_ENABLE_DEVICE_BOOTLOADER_FW if(lazyThreadBootloader.joinable()) lazyThreadBootloader.join(); +#endif } // Get device firmware diff --git a/src/utility/spdlog-fmt.hpp b/src/utility/spdlog-fmt.hpp index f1d5cf2c6e..a42de2fc65 100755 --- a/src/utility/spdlog-fmt.hpp +++ b/src/utility/spdlog-fmt.hpp @@ -4,6 +4,13 @@ #include "depthai/utility/Path.hpp" +#if FMT_VERSION >= 100000 +#include + +#include "depthai/common/CameraBoardSocket.hpp" +#include "pipeline/datatype/DatatypeEnum.hpp" +#endif + namespace dai { namespace utility { static constexpr char path_convert_err[] = ""; @@ -15,7 +22,11 @@ struct fmt::formatter : formatter { // https://fmt.dev/latest/api.html#formatting-user-defined-types // https://fmt.dev/latest/syntax.html#format-specification-mini-language template - auto format(const dai::Path& p, FormatContext& ctx) { +#if FMT_VERSION >= 100000 + auto format(const dai::Path& p, FormatContext& ctx) const { +#else + auto format(const dai::Path& p, FormatContext& ctx) -> decltype(ctx.out()) { +#endif std::string output; try { output = p.string(); @@ -25,3 +36,16 @@ struct fmt::formatter : formatter { return formatter::format(output, ctx); } }; + + +#if FMT_VERSION >= 100000 +template <> +struct fmt::formatter : ostream_formatter {}; + +template <> +struct fmt::formatter : fmt::formatter { + auto format(dai::DatatypeEnum my, format_context& ctx) const -> decltype(ctx.out()) { + return fmt::format_to(ctx.out(), "{}", static_cast(my)); + } +}; +#endif diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 60269fd3d4..5cb1782ede 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -3,7 +3,6 @@ include(CTest) enable_testing() # Add Catch2 for writing tests -hunter_add_package(Catch2) find_package(Catch2 CONFIG REQUIRED) # Print details of the Catch2 package @@ -111,7 +110,7 @@ function(dai_test_compile_definitions) endfunction() # Mobilenet network -hunter_private_data( +private_data( URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/mobilenet-ssd_openvino_2021.2_8shave.blob" SHA1 "3329bb8f3a9c881ef9756d232055f9d6f38aa07b" FILE "mobilenet-ssd_openvino_2021.2_8shave.blob" @@ -119,14 +118,14 @@ hunter_private_data( ) # OpenVINO 2020.3 blob -hunter_private_data( +private_data( URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/text-image-super-resolution-0001_2020.3_4shave.blob" SHA1 "f0134c9b843fe414f6d98b17a70f069d1ab0f3d8" FILE "text-image-super-resolution-0001_2020.3_4shave.blob" LOCATION openvino_2020_3_blob ) # OpenVINO 2020.4 blob -hunter_private_data( +private_data( URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/text-image-super-resolution-0001_2020.4_4shave.blob" SHA1 "25dcf0b146da8c85c9c4cba00ad5fdd4ed02a1b6" FILE "text-image-super-resolution-0001_2020.4_4shave.blob" @@ -134,42 +133,42 @@ hunter_private_data( ) # OpenVINO 2021.1 blob -hunter_private_data( +private_data( URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/text-image-super-resolution-0001_2021.1_4shave.blob" SHA1 "39c4f47f2a75627b7561e97dd7cdfcd0b1925a1e" FILE "text-image-super-resolution-0001_2021.1_4shave.blob" LOCATION openvino_2021_1_blob ) # OpenVINO 2021.2 blob -hunter_private_data( +private_data( URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/text-image-super-resolution-0001_2021.2_4shave.blob" SHA1 "a204467f86aa4ad63d31782ada271bea6f57f789" FILE "text-image-super-resolution-0001_2021.2_4shave.blob" LOCATION openvino_2021_2_blob ) # OpenVINO 2021.3 blob -hunter_private_data( +private_data( URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/text-image-super-resolution-0001_2021.3_4shave.blob" SHA1 "af19470feb59317e74d045bc31d93ca129c46674" FILE "text-image-super-resolution-0001_2021.3_4shave.blob" LOCATION openvino_2021_3_blob ) # OpenVINO 2021.4.2 blob -hunter_private_data( +private_data( URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/text-image-super-resolution-0001_2021.4.2_4shave.blob" SHA1 "164b6b2ae48d38bc4f07cc8296b8bcb7644a1578" FILE "text-image-super-resolution-0001_2021.4.2_4shave.blob" LOCATION openvino_2021_4_2_blob ) # OpenVINO 2022.1.0 blob -hunter_private_data( +private_data( URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/text-image-super-resolution-0001_2022.1.0_4shave.blob" SHA1 "98e94b865b9c48a92eaebd1ddc883712dfe7cfcb" FILE "text-image-super-resolution-0001_2022.1.0_4shave.blob" LOCATION openvino_2022_1_blob ) # YoloV4 resource -hunter_private_data( +private_data( URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/yolo-v4-tiny-tf_openvino_2021.4_4shave.blob" SHA1 "7da2f96f7300e3828940557e6a86ac6f243eef7e" FILE "yolo-v4-tiny-tf_openvino_2021.4_4shave.blob" @@ -177,7 +176,7 @@ hunter_private_data( ) # Superblob -hunter_private_data( +private_data( URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/person-reidentification-retail-0277_openvino_2022.1_8shave.superblob" SHA1 "6f14e3a5388946d6de849ff4f6432702601b1003" FILE "person-reidentification-retail-0277_openvino_2022.1_8shave.superblob" @@ -185,28 +184,28 @@ hunter_private_data( ) # NNarchives of different types -hunter_private_data( +private_data( URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/nnarchive/yolo_blob_nnarchive.tar.xz" SHA1 "6b9697e5aaf1560efbdea7f8d7487bae51def619" FILE "yolo_blob_nnarchive.tar.xz" LOCATION yolo_blob_nnarchive_path ) -hunter_private_data( +private_data( URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/nnarchive/yolo_superblob_nnarchive.tar.xz" SHA1 "2356fd7e5a203446211a891a74f0b23e0912eaf6" FILE "yolo_superblob_nnarchive.tar.xz" LOCATION yolo_superblob_nnarchive_path ) -hunter_private_data( +private_data( URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/nnarchive/yolo_onnx_nnarchive.tar.xz" SHA1 "7abb6a8c05c5f66897cd2c5c6b4f0170620dff8b" FILE "yolo_onnx_nnarchive.tar.xz" LOCATION yolo_onnx_nnarchive_path ) -hunter_private_data( +private_data( URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/images/lenna.png" SHA1 "3ee0d360dc12003c0d43e3579295b52b64906e85" FILE "lenna.png" diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json index a27db75cf2..5505bbd5d4 100644 --- a/vcpkg-configuration.json +++ b/vcpkg-configuration.json @@ -1,7 +1,7 @@ { "default-registry": { "kind": "git", - "baseline": "509f71e53f45e46c13fa7935d2f6a45803580c07", + "baseline": "f56b56e01683ba9fde12b64de246ec0b3eb69b18", "repository": "https://github.com/microsoft/vcpkg" }, "registries": [ @@ -13,5 +13,8 @@ ], "overlay-ports": [ "./cmake/ports" - ] + ], + "overlay-triplets": [ + "./cmake/triplets" + ] } diff --git a/vcpkg.json b/vcpkg.json index 8e50bfa309..eec5132136 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,44 +1,155 @@ { - "dependencies": [ - "zlib" - ], - "features": { - "curl-support": { - "description": "Enable CURL support", - "dependencies": [ - "cpr" - ] + "name": "depthai", + "dependencies": [ + "cpp-httplib", + "libpng", + "tiff", + "yaml-cpp", + "nlohmann-json", + "spdlog", + "zlib", + "bzip2", + "lz4", + "liblzma", + "fp16", + "mp4v2", + "libnop", + "neargye-semver", + { + "name": "ffmpeg", + "features": [ + "openh264" + ] + }, + { + "name": "libarchive", + "default-features": false + }, + { + "name": "opencv4", + "default-features": false, + "features": [ + "jpeg", + "png", + "quirc", + "tiff", + "webp", + "ffmpeg" + ] + }, + { + "name": "opencv4", + "default-features": false, + "features": [ + "gtk" + ], + "platform": "linux" + } + ], + "features": { + "curl-support": { + "description": "Enable CURL support", + "dependencies": [ + "cpr" + ] + }, + "protobuf-support": { + "description": "Enable Protobuf support", + "dependencies": [ + "protobuf" + ] + }, + "python-bindings": { + "description": "Enable Python bindings", + "dependencies": [ + "pybind11" + ] + }, + "remote-connection-support": { + "description": "Enable remote connection support", + "dependencies": [ + "websocketpp" + ] + }, + "rtabmap": { + "description": "Enable RTAB-Map support", + "dependencies": [ + { + "name": "pcl", + "default-features": false + }, + { + "name": "opencv4", + "default-features": false + }, + { + "name": "opencv", + "default-features": false + }, + { + "name": "rtabmap", + "default-features": false + } + ] + }, + "apriltag": { + "description": "Enable AprilTag support", + "dependencies": [ + { + "name": "apriltag" + } + ] + }, + "backward": { + "description": "Enable backward-cpp support", + "dependencies": [ + { + "name": "backward-cpp" + } + ] + }, + "basalt": { + "description": "Enable Basalt support", + "dependencies": [ + { + "name": "opencv4", + "default-features": false + }, + { + "name": "basalt" + } + ] + }, + "xlink": { + "description": "Enable XLink support", + "dependencies": [ + { + "name": "xlink" + } + ] + }, + "xlink-usb": { + "description": "Enable XLink support", + "dependencies": [ + { + "name": "xlink", + "features": [ + "libusb" + ] + }, + { + "name": "libusb" + } + ] + }, + "tests": { + "description": "Enable tests", + "dependencies": [ + { + "name": "catch2" + } + ] + } }, - "protobuf-support": { - "description": "Enable Protobuf support", - "dependencies": [ - "protobuf" - ] - }, - "remote-connection-support": { - "description": "Enable remote connection support", - "dependencies": [ - "websocketpp" - ] - } - }, - "overrides": [ - { - "name": "websocketpp", - "version": "0.8.2" - }, - { - "name": "protobuf", - "version": "3.21.12" - }, - { - "name": "cpr", - "version": "1.11.0" - }, - { - "name": "zlib", - "version": "1.3.1" - } - ], - "builtin-baseline": "f5ec6f30ff70f04f841436a0f36600bdbabfcfbf" -} \ No newline at end of file + "builtin-baseline": "f5ec6f30ff70f04f841436a0f36600bdbabfcfbf" +}