diff --git a/.github/workflows/build-variants.yml b/.github/workflows/build-variants.yml new file mode 100644 index 000000000..5b5f22880 --- /dev/null +++ b/.github/workflows/build-variants.yml @@ -0,0 +1,115 @@ +name: Build Variants + +on: + push: + +jobs: + # This job should mimic conda-feedstock build + libtiledbvcf: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Mamba environment + uses: mamba-org/setup-micromamba@v2 + with: + environment-name: ci + create-args: -c tiledb tiledb=2.26 spdlog fmt cli11 htslib catch2=2.13.8 + init-shell: >- + bash + - name: Configure CMake + shell: micromamba-shell {0} + run: | + cmake -S libtiledbvcf -B build \ + -D CMAKE_BUILD_TYPE=Release \ + -D BUILD_SHARED_LIBS=ON \ + -D CMAKE_INSTALL_PREFIX=install \ + -D TILEDBVCF_ENABLE_TESTS=OFF \ + -D TILEDBVCF_FORCE_EXTERNAL_DEPENDENCIES=ON \ + -D TILEDBVCF_INSTALL_TILEDB=OFF \ + -D TILEDBVCF_SET_INSTALL_SUBPATH=OFF \ + -D CMAKE_PREFIX_PATH=$CONDA_PREFIX + - name: Build using CMake + shell: micromamba-shell {0} + run: | + cmake --build build --config Release + - name: Install using CMake + shell: micromamba-shell {0} + run: | + cmake --install build --config Release + + - name: Upload install folder + uses: actions/upload-artifact@v4 + with: + name: libtiledbvcf + path: install/* + + # Tests + - name: Run unit tests + shell: micromamba-shell {0} + run: | + ctest --test-dir build + - name: Install cli test dependencies + run: | + sudo apt-get install -y bcftools + - name: Run CLI tests + shell: micromamba-shell {0} + run: | + libtiledbvcf/test/run-cli-tests.sh build libtiledbvcf/test/inputs + + + # This job should mimic conda-feedstock build + python-bindings-external-libtiledbvcf: + needs: libtiledbvcf + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Mamba environment + uses: mamba-org/setup-micromamba@v2 + with: + environment-name: ci + create-args: -c tiledb htslib tiledb=2.26 tiledb-py python=3.11 pip pytest numpy pandas pyarrow + init-shell: >- + bash + - name: Download libtiledbvcf artifact + uses: actions/download-artifact@v4 + with: + name: libtiledbvcf + path: install + - name: Build Python bindings + shell: micromamba-shell {0} + env: + tiledbvcf_DIR: "${{ github.workspace }}/install" + run: | + pip install -v --no-deps . \ + --config-settings=cmake.define.TILEDBVCF_ONLY_PYTHON_BINDINGS=ON \ + --config-settings=cmake.define.TILEDBVCF_SET_RPATH=OFF + + - name: Install test dependencies + run: | + sudo apt-get install -y bcftools + + - name: Run tests + shell: micromamba-shell {0} + run: | + export LD_LIBRARY_PATH="$CONDA_PREFIX/lib" + cp ${{ github.workspace }}/install/lib/libtiledbvcf* $LD_LIBRARY_PATH + ldd $CONDA_PREFIX/lib/python3.11/site-packages/tiledbvcf/libtiledbvcf.cpython-311-x86_64-linux-gnu.so + pytest apis/python + + + # This job should mimic wheel build + python-bindings-wheel: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install build dependencies + run: | + sudo apt-get install -y ninja-build bcftools + - name: Build and install using PiP + run: | + pip install -v .[test] + + - name: Run tests + run: | + pytest apis/python + diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml new file mode 100644 index 000000000..42331e572 --- /dev/null +++ b/.github/workflows/build-wheels.yml @@ -0,0 +1,168 @@ +name: Build and test wheels + +on: + workflow_dispatch: + inputs: + version: + description: Version to use are release version + required: true + type: string + test_pypi: + description: Upload packages to test.pypi.org + required: false + type: boolean + default: false + push: + branches: + - "db/vcpkg" + tags: + - "*" + +env: + SETUPTOOLS_SCM_PRETEND_VERSION_FOR_TILEDB: ${{ inputs.version }} + +jobs: + build_wheels: + name: Wheel ${{ matrix.buildplat[0] }}-${{ matrix.buildplat[1] }}-${{ matrix.python }} + runs-on: ${{ matrix.buildplat[0] }} + strategy: + matrix: + buildplat: + - [ubuntu-22.04, manylinux_x86_64] + - [macos-13, macosx_x86_64] + - [macos-14, macosx_arm64] + # - [windows-2022, win_amd64] + python: ["cp39", "cp310", "cp311", "cp312"] + + steps: + - uses: actions/checkout@v4 + + - name: "Brew setup on macOS" # x-ref c8e49ba8f8b9ce + if: ${{ startsWith(matrix.buildplat[0], 'macos-') == true }} + run: | + set -e pipefail + brew update + brew install automake autoconf pkg-config bcftools libtool + + - name: Build wheels + uses: pypa/cibuildwheel@v2.20.0 + env: + CIBW_BUILD_VERBOSITY: 3 + CIBW_ENVIRONMENT_MACOS: > + CC=clang + CXX=clang++ + CIBW_ARCHS: all + CIBW_PRERELEASE_PYTHONS: True + CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }} + CIBW_BEFORE_ALL_LINUX: yum install -y bzip2-devel xz-devel bcftools curl zip unzip tar + CIBW_TEST_COMMAND: pytest {package}/apis/python + CIBW_TEST_EXTRAS: test + MACOSX_DEPLOYMENT_TARGET: "13.0" + with: + output-dir: wheelhouse + + - uses: actions/upload-artifact@v4 + with: + name: cibw-wheels-${{ matrix.buildplat[0] }}-${{ matrix.buildplat[1] }}-${{ matrix.python }} + path: "./wheelhouse/*.whl" + + - name: "Print log files (failed build only)" + run: | + cat /Users/runner/work/TileDB-VCF/TileDB-VCF/build/cp310-cp310-macosx_13_0_arm64/_deps/vcpkg-src/buildtrees/htscodecs/autoconf-arm64-osx-err.log + if: failure() # only run this job if the build step failed + + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + outputs: + sdist_name: ${{ steps.get_sdist_name.outputs.sdist_name }} + steps: + - uses: actions/checkout@v4 + + - name: Build sdist + run: pipx run build --sdist + + - name: Get sdist package name + id: get_sdist_name + run: | + echo "sdist_name=$(ls dist/ | head -n 1)" >> "$GITHUB_OUTPUT" + + - uses: actions/upload-artifact@v4 + with: + name: sdist + path: dist/*.tar.gz + + test_sdist: + name: Test source distribution package + needs: [build_sdist] + strategy: + matrix: + os: + - macos-13 + - macos-14 + # - windows-2022 Currently we do not know how to install bcftools on windows + - ubuntu-22.04 + python: ["3.9", "3.10", "3.11", "3.12"] + runs-on: ${{ matrix.os }} + steps: + - name: Set up Python ${{ matrix.python }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python }} + + - name: Install bcftools MacOS + if: ${{ startsWith(matrix.os, 'macos-') == true }} + run: | + set -e pipefail + brew update + brew install automake pkg-config ninja llvm bzip2 xz autoconf zlib libdeflate bcftools libtool + + - name: Install bcftools Ubuntu + if: ${{ startsWith(matrix.os, 'ubuntu-') == true }} + run: sudo apt install bcftools + + - name: Download sdist artifact + uses: actions/download-artifact@v4 + with: + name: sdist + path: dist + + - name: Install sdist artifact + run: pip install --verbose dist/${{ needs.build_sdist.outputs.sdist_name }}[test] + + - uses: actions/checkout@v4 + + - name: Run tests + shell: bash + run: | + PROJECT_CWD=$PWD + cd .. + pytest -vv --showlocals $PROJECT_CWD/apis/python + + upload_pypi: + needs: [build_wheels, test_sdist] + runs-on: ubuntu-latest + environment: pypi + permissions: + id-token: write + outputs: + package_version: ${{ steps.get_package_version.outputs.package_version }} + steps: + - uses: actions/download-artifact@v4 + with: + path: dist + merge-multiple: true + + - id: get_package_version + run: | + echo "package_version=$(ls dist/ | head -n 1 | cut -d - -f 2)" >> "$GITHUB_OUTPUT" + + - name: Upload to test-pypi + if: inputs.test_pypi + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + + # - name: Upload to pypi + # if: startsWith(github.ref, 'refs/tags/') + # uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 47bfbef11..5b847f95a 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -27,9 +27,12 @@ jobs: run: | cmake -S libtiledbvcf -B $(pwd)/libtiledbvcf/build \ -D CMAKE_BUILD_TYPE=Debug \ + -D BUILD_SHARED_LIBS=ON \ -D CMAKE_INSTALL_PREFIX=$(pwd)/dist \ -D OVERRIDE_INSTALL_PREFIX=OFF \ - -D DOWNLOAD_TILEDB_PREBUILT=ON + -D DOWNLOAD_TILEDB_PREBUILT=ON \ + -D TILEDBVCF_ENABLE_TESTS=ON \ + -D TILEDBVCF_SET_INSTALL_SUBPATH=OFF - name: Build libtiledbvcf run: cmake --build $(pwd)/libtiledbvcf/build -j 2 --config Debug - name: Upload coredump as artifact if build failed @@ -41,7 +44,7 @@ jobs: retention-days: 14 if-no-files-found: error - name: Install libtiledbvcf - run: cmake --build $(pwd)/libtiledbvcf/build --config Debug --target install-libtiledbvcf + run: cmake --install $(pwd)/libtiledbvcf/build --config Debug - name: Upload libtiledbvcf as artifact uses: actions/upload-artifact@v4 with: @@ -57,8 +60,7 @@ jobs: run: brew install bcftools - name: Unit tests run: | - make -j 2 -C libtiledbvcf/build/libtiledbvcf tiledb_vcf_unit - ./libtiledbvcf/build/libtiledbvcf/test/tiledb_vcf_unit + ctest --test-dir libtiledbvcf/build - name: CLI tests (require bcftools) run: | # USAGE: run-cli-tests.sh @@ -67,7 +69,7 @@ jobs: runs-on: macos-13 needs: libtiledbvcf env: - DYLD_LIBRARY_PATH: "${{ github.workspace }}/dist/lib" + DYLD_LIBRARY_PATH: "${{ github.workspace }}/dist/tiledbvcf/lib" steps: - uses: actions/checkout@v4 with: @@ -88,13 +90,10 @@ jobs: create-args: tiledb - name: Build tiledbvcf-py env: - LIBTILEDBVCF_PATH: "${{ github.workspace }}/dist" + tiledbvcf_DIR: "${{ github.workspace }}/dist" TileDB_DIR: "/Users/runner/micromamba/envs/ci/lib/cmake/TileDB" run: | - echo $DYLD_LIBRARY_PATH - echo $TileDB_DIR - cd apis/python - python -m pip install -v .[test] + python -m pip install -v --no-deps --config-settings=cmake.define.TILEDBVCF_ONLY_PYTHON_BINDINGS=ON .[test] - name: Confirm linking run: otool -L /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/tiledbvcf/libtiledbvcf.cpython-*-darwin.so java: @@ -107,6 +106,11 @@ jobs: with: name: libtiledbvcf path: dist + - name: Debug + run: | + ls -R dist + - name: Build dependencies + run: brew install autoconf automake - name: Check format run: cd apis/java && ./gradlew checkFormat - name: Assemble @@ -126,13 +130,11 @@ jobs: with: python-version: "3.11" - name: Build tiledbvcf-py - run: cd apis/python && python -m pip install -v .[test] + run: python -m pip install -v .[test] - name: Confirm linking run: | otool -L /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/tiledbvcf/libtiledbvcf.cpython-*-darwin.so - otool -L /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/tiledbvcf/libtiledbvcf.dylib - otool -L /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/tiledbvcf/libtiledb.dylib - otool -L /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/tiledbvcf/libhts.*.dylib + otool -L /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/tiledbvcf/lib/libtiledb.dylib - name: Version run: python -c "import tiledbvcf; print(tiledbvcf.version)" - name: Install bcftools (for tests) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index fb9b3c52e..4a2d3a038 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -59,13 +59,13 @@ jobs: - name: Confirm linking (Linux) if: runner.os == 'Linux' run: | - ldd install/lib/libtiledb.so - ldd install/lib/libtiledbvcf.so + ldd install/tiledbvcf/lib/libtiledb.so* + ldd install/tiledbvcf/lib/libtiledbvcf.so* - name: Confirm linking (macOS) if: runner.os == 'macOS' run: | - otool -L install/lib/libtiledb.dylib - otool -L install/lib/libtiledbvcf.dylib + otool -L install/tiledbvcf/lib/libtiledb.dylib + otool -L install/tiledbvcf/lib/libtiledbvcf.dylib - name: Install bcftools (for tests) (Linux) if: runner.os == 'Linux' run: sudo apt-get install --yes bcftools diff --git a/.gitignore b/.gitignore index d22c8182d..c0704903f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ .vscode* *.swp dev/* -dist/* +dist +env libtiledbvcf/cmake-build-*/* libtiledbvcf/build/* apis/java/.gradle/* @@ -57,3 +58,6 @@ docs/.quarto # Python venv venv/ + +# CMake user presets +CMakeUserPresets.json diff --git a/Makefile b/Makefile deleted file mode 100644 index 74813dcd1..000000000 --- a/Makefile +++ /dev/null @@ -1,154 +0,0 @@ -# This Makefile captures common developer build and test use cases. - -MAKEFLAGS += --no-print-directory - -# print help by default -help: - -# install -# ------------------------------------------------------------------- - -# set default variable values, if non-null -build ?= Release - -.PHONY: install -install: clean - mkdir -p libtiledbvcf/build && \ - cd libtiledbvcf/build && \ - cmake .. -DCMAKE_BUILD_TYPE=${build} && \ - make -j && make install-libtiledbvcf - pip install -v apis/python[test,dev] - -# incremental compile and update python install -# ------------------------------------------------------------------- -.PHONY: update -update: - cd libtiledbvcf/build && make -j && make -j install-libtiledbvcf - pip install -v apis/python[test,dev] - -# test -# ------------------------------------------------------------------- -.PHONY: test -test: - cd libtiledbvcf/build && make -j check - cd libtiledbvcf/test && ./run-cli-tests.sh ../build/ ./inputs/ - cd apis/java && ./gradlew assemble test - pytest apis/python - python -c "import tiledbvcf; print(tiledbvcf.version)" - -# docs -# ------------------------------------------------------------------- -.PHONY: notebooks -notebooks: - @for f in `find examples -name "*.ipynb"`; do \ - jupyter nbconvert --execute --to=notebook --inplace $$f; \ - done - -.PHONY: docs -docs: - @ln -sf apis/python/src/tiledbvcf - quartodoc build - @rm tiledbvcf - quarto render --fail-if-warnings - -# format -# ------------------------------------------------------------------- -.PHONY: check-format -check-format: - @./ci/run-clang-format.sh . clang-format 0 \ - `find libtiledbvcf/src -name "*.cc" -or -name "*.h"` - @./ci/run-clang-format.sh . clang-format 0 \ - `find libtiledbvcf/test -name "*.cc" -or -name "*.h"` - -.PHONY: format -format: - @./ci/run-clang-format.sh . clang-format 1 \ - `find libtiledbvcf/src -name "*.cc" -or -name "*.h"` - @./ci/run-clang-format.sh . clang-format 1 \ - `find libtiledbvcf/test -name "*.cc" -or -name "*.h"` - -# venv -# ------------------------------------------------------------------- -.PHONY: venv -venv: - @if [ ! -d venv ]; then \ - python3.9 -m venv venv; \ - venv/bin/pip install --upgrade pip; \ - fi - @printf "Run the following command to activate the venv:\nsource venv/bin/activate\n" - -# docker -# ------------------------------------------------------------------- -.PHONY: docker -docker: - docker build -t tiledbvcf-cli:dev -f docker/Dockerfile-cli . && \ - docker run --rm -t tiledbvcf-cli:dev version && \ - docker build -t tiledbvcf-py:dev -f docker/Dockerfile-py . && \ - docker run --rm -t tiledbvcf-py:dev -c "import tiledbvcf; print(tiledbvcf.version)" - -# wheel -# ------------------------------------------------------------------- -.PHONY: wheel -wheel: clean - docker run --rm -v `pwd`:/io quay.io/pypa/manylinux_2_28_x86_64 /io/apis/python/build-wheels.sh - sudo chown -R ${USER}:$(id -gn) . - -# clean -# ------------------------------------------------------------------- -.PHONY: clean -clean: - @rm -rf libtiledbvcf/build dist apis/python/build - -.PHONY: cleaner -cleaner: - @printf "*** dry-run mode: remove -n to actually remove files\n" - git clean -ffdx -e .vscode -e dev -e venv -n - -# help -# ------------------------------------------------------------------- -define HELP -Usage: make rule [options] - -Rules: - install [options] Build C++ library and install python module - update Incrementally build C++ library and update python module - test Run tests - notebooks Execute notebooks and update cell outputs - docs Render the documentation - docker Build and test docker images - check-format Run C++ format check - format Run C++ format - venv Create a virtual environment - wheel Build python wheel - clean Remove build artifacts - -Options: - build=BUILD_TYPE Cmake build type = Release|Debug|RelWithDebInfo|Coverage [Release] - prefix=PREFIX Install location [${PWD}/dist] - tiledb=TILEDB_DIST Absolute path to custom TileDB build - -Examples: - Install Release build - - make install - - Install Debug build of libtiledbvcf and libtiledb - - make install build=Debug - - Install Release build with custom libtiledb - - make install tiledb=$$PWD/../TileDB/dist - - Incrementally build C++ changes and update the python module - - make update - - -endef -export HELP - -.PHONY: help -help: - @printf "$${HELP}" - diff --git a/apis/java/CMakeLists.txt b/apis/java/CMakeLists.txt index 407205f50..e6d4d9ee9 100644 --- a/apis/java/CMakeLists.txt +++ b/apis/java/CMakeLists.txt @@ -61,7 +61,7 @@ find_package(JNI REQUIRED) # You can set CMAKE_PREFIX_PATH manually for a custom TileDB-VCF location. find_library(TILEDBVCF_LIBRARY NAMES - tiledbvcf + tiledbvcf libtiledbvcf PATH_SUFFIXES lib ) find_path(TILEDBVCF_INCLUDE_DIR diff --git a/apis/java/build.gradle b/apis/java/build.gradle index 8a66e723f..d82b0c310 100644 --- a/apis/java/build.gradle +++ b/apis/java/build.gradle @@ -151,16 +151,16 @@ task cmakeNativeLibTask(type: Exec) { task makeNativeLibTask(type: Exec) { dependsOn 'cmakeNativeLibTask' workingDir = "${pathConfig.nativeLibBuildDir}" - executable = 'make' - args '-j8' + executable = 'cmake' + args '--build', '.' } // Installs the native TileDB-VCF library. task installNativeLibTask(type: Exec) { - dependsOn 'makeNativeLibTask' + dependsOn 'cmakeNativeLibTask' workingDir = "${pathConfig.nativeLibBuildDir}" - executable = 'make' - args 'install-libtiledbvcf' + executable = 'cmake' + args '--install', '.' } // Runs CMake for the JNI library @@ -202,6 +202,7 @@ task findNativeLib { println "Found native TileDB-VCF library: ${pathConfig.nativeLibInstallDir}" } else { cmakeJNITask.dependsOn installNativeLibTask + println "Native lib not found in: ${pathConfig.nativeLibInstallDir}" } } diff --git a/apis/python/CMakeLists.txt b/apis/python/CMakeLists.txt index 568170072..5af9070fc 100644 --- a/apis/python/CMakeLists.txt +++ b/apis/python/CMakeLists.txt @@ -30,97 +30,41 @@ project( LANGUAGES CXX ) -# Search for libtilebdvcf in the default install directory and in the directory -# specified by the LIBTILEDBVCF_PATH environment variable. -set(LIBTILEDBVCF_SEARCH_PATHS - "${CMAKE_CURRENT_SOURCE_DIR}/../../dist/lib" - "${CMAKE_CURRENT_SOURCE_DIR}/dist_links/dist/lib" - "$ENV{LIBTILEDBVCF_PATH}" -) - -message(STATUS "Searching for libtiledbvcf in ${LIBTILEDBVCF_SEARCH_PATHS}") - -# TODO: Use find_package() instead of find_library() to find libtiledbvcf. -find_library( - TILEDBVCF_LIB - NAMES tiledbvcf - PATHS ${LIBTILEDBVCF_SEARCH_PATHS} -) - -if(NOT TILEDBVCF_LIB) - message(STATUS "Building libtiledbvcf from source") - - file(MAKE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/dist_links/libtiledbvcf/build") - - execute_process( - COMMAND bash -c "\ - ${CMAKE_COMMAND} .. && \ - ${CMAKE_COMMAND} --build . && \ - ${CMAKE_COMMAND} --build . --target install-libtiledbvcf" - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/dist_links/libtiledbvcf/build" - ) +if (NOT TARGET tiledbvcf) + message(STATUS "DEBUG: tiledbvcf_DIR: ${tiledbvcf_DIR}") + # If tiledbvcf is not present it means that this script was not included as a + # subdirectory of the tiledbvcf library, thus we need to find it find_library( - TILEDBVCF_LIB - NAMES tiledbvcf - PATHS ${LIBTILEDBVCF_SEARCH_PATHS} + TILEDBVCF_LIBRARIES + REQUIRED + NAMES libtiledbvcf tiledbvcf + PATHS ${tiledbvcf_DIR} + PATH_SUFFIXES lib + ) + find_path( + TILEDBVCF_INCLUDE_DIR + REQUIRED + NAMES tiledbvcf.h + PATHS ${tiledbvcf_DIR} + PATH_SUFFIXES include/tiledbvcf + ) + add_library(tiledbvcf SHARED IMPORTED) + set_target_properties(tiledbvcf PROPERTIES + IMPORTED_IMPLIB "${TILEDBVCF_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${TILEDBVCF_INCLUDE_DIR}" ) endif() -if(NOT TILEDBVCF_LIB) - message(FATAL_ERROR "Could not find libtiledbvcf") -else() - message(STATUS "Found libtiledbvcf: ${TILEDBVCF_LIB}") - get_filename_component(TILEDBVCF_LIB_DIR ${TILEDBVCF_LIB} DIRECTORY) - cmake_path(APPEND TILEDBVCF_LIB_DIR "../include/tiledbvcf" OUTPUT_VARIABLE TILEDBVCF_INCLUDE_DIR) - cmake_path(APPEND TILEDBVCF_LIB_DIR "../bin" OUTPUT_VARIABLE TILEDBVCF_BIN_DIR) - - # Find required shared libs for the current platform - if (APPLE) - set(TILEDBVCF_SHARED_LIB_NAMES - "libtiledb.dylib" "libtiledbvcf.dylib" "libhts.*dylib" - ) - elseif(WIN32) - set(TILEDBVCF_SHARED_LIB_NAMES - "tiledb.lib" "tiledbvcf.lib" "hts-3.lib" - ) - else() - set(TILEDBVCF_SHARED_LIB_NAMES - "libtiledb.so*" "libtiledbvcf.so" "libhts.so*" - ) - endif() - - set(TILEDBVCF_SHARED_LIBS "") - foreach(ITEM ${TILEDBVCF_SHARED_LIB_NAMES}) - file(GLOB LIB_FILE "${TILEDBVCF_LIB_DIR}/${ITEM}") - if(LIB_FILE) - list(APPEND TILEDBVCF_SHARED_LIBS "${LIB_FILE}") - endif() - endforeach() - - file(GLOB TILEDBVCF_PROGRAMS "${TILEDBVCF_BIN_DIR}/tiledbvcf*") -endif() - -# Search for TileDB in the EP install directory -list(PREPEND CMAKE_PREFIX_PATH - "${CMAKE_CURRENT_SOURCE_DIR}/dist_links/libtiledbvcf/build/externals/install" -) - -# Search TileDB_DIR first if it is defined -if (DEFINED TileDB_DIR) - list(PREPEND CMAKE_PREFIX_PATH "${TileDB_DIR}") -endif() - -find_package(TileDB REQUIRED) - -if (TILEDB_FOUND) - get_target_property(TILEDB_LIB TileDB::tiledb_shared IMPORTED_LOCATION_RELEASE) - message(STATUS "Found TileDB: ${TILEDB_LIB}") +if (NOT TARGET TileDB::tiledb_shared) + find_package(TileDB REQUIRED) endif() set(VCF_TARGET_NAME libtiledbvcf) -find_package(pybind11 REQUIRED) +# NOTE: If you remove the line below the Windows build will fail +find_package(Python COMPONENTS Interpreter Development.Module REQUIRED) +find_package(pybind11 CONFIG REQUIRED) pybind11_add_module( ${VCF_TARGET_NAME} @@ -136,39 +80,24 @@ if (NOT WIN32) target_compile_options(${VCF_TARGET_NAME} PRIVATE -Wno-deprecated-declarations) endif() -target_include_directories( - ${VCF_TARGET_NAME} PRIVATE - ${TILEDBVCF_INCLUDE_DIR} - "${CMAKE_CURRENT_SOURCE_DIR}/dist_links/libtiledbvcf/src" - $ -) - target_link_libraries( - ${VCF_TARGET_NAME} PRIVATE - ${TILEDBVCF_LIB} + ${VCF_TARGET_NAME} + PRIVATE + tiledbvcf + TileDB::tiledb_shared ) +if (TILEDBVCF_SET_RPATH) # Search for shared libraries in the same directory as the target -if (APPLE) - set_target_properties(${VCF_TARGET_NAME} PROPERTIES INSTALL_RPATH "@loader_path") -else() - set_target_properties(${VCF_TARGET_NAME} PROPERTIES INSTALL_RPATH "$ORIGIN") + if (APPLE) + set_target_properties(${VCF_TARGET_NAME} PROPERTIES INSTALL_RPATH "@loader_path/lib") + else() + set_target_properties(${VCF_TARGET_NAME} PROPERTIES INSTALL_RPATH "$ORIGIN/lib") + endif() endif() # Install the extension module install( - TARGETS ${VCF_TARGET_NAME} - DESTINATION ${SKBUILD_PROJECT_NAME} -) - -# Install required shared libraries -install( - FILES ${TILEDBVCF_SHARED_LIBS} - DESTINATION ${SKBUILD_PROJECT_NAME} -) - -# Install the command line tool -install( - PROGRAMS ${TILEDBVCF_PROGRAMS} - DESTINATION ${SKBUILD_SCRIPTS_DIR} + TARGETS ${VCF_TARGET_NAME} + DESTINATION tiledbvcf ) diff --git a/apis/python/build-wheels.sh b/apis/python/build-wheels.sh index 669029c94..a239a1a95 100755 --- a/apis/python/build-wheels.sh +++ b/apis/python/build-wheels.sh @@ -9,7 +9,7 @@ cd /io/ mkdir -p libtiledbvcf/build cd libtiledbvcf/build cmake -DTILEDBVCF_ENABLE_TESTING=OFF .. -make -j && make install-libtiledbvcf +make -j install cd - # Build Python wheels diff --git a/ci/azure-linux_mac.yml b/ci/azure-linux_mac.yml index ae4b7bc1a..a4fbbeea1 100755 --- a/ci/azure-linux_mac.yml +++ b/ci/azure-linux_mac.yml @@ -85,15 +85,14 @@ steps: cd $BUILD_REPOSITORY_LOCALPATH/libtiledbvcf/build cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$BUILD_REPOSITORY_LOCALPATH/dist -DDOWNLOAD_TILEDB_PREBUILT=${DOWNLOAD_TILEDB_PREBUILT} .. - make -j4 - make -j4 -C libtiledbvcf tiledb_vcf_unit + make -j4 all tiledb_vcf_unit # cmake catches the segfault and blocks the core dump # sudo make check - ./libtiledbvcf/test/tiledb_vcf_unit + ./test/tiledb_vcf_unit ../test/run-cli-tests.sh . ../test/inputs - make install-libtiledbvcf + make install displayName: 'Build and test TileDB-VCF' diff --git a/ci/build-libtiledbvcf.bat b/ci/build-libtiledbvcf.bat index 9c7626997..77a519d42 100644 --- a/ci/build-libtiledbvcf.bat +++ b/ci/build-libtiledbvcf.bat @@ -17,5 +17,5 @@ cmake --build . --config Release --parallel %CPU_COUNT% if %ERRORLEVEL% neq 0 exit 1 rem install -cmake --build . --target install-libtiledbvcf --config Release +cmake --install . if %ERRORLEVEL% neq 0 exit 1 diff --git a/ci/build-tiledbvcf-py.bat b/ci/build-tiledbvcf-py.bat index e899fb470..598005f03 100644 --- a/ci/build-tiledbvcf-py.bat +++ b/ci/build-tiledbvcf-py.bat @@ -1,8 +1,4 @@ @echo on -cd apis\python - -set LIBTILEDBVCF_PATH="%CONDA_PREFIX%\Library" - pip install -v .[test] if %ERRORLEVEL% neq 0 exit 1 diff --git a/ci/native_libs-linux_osx.yml b/ci/native_libs-linux_osx.yml new file mode 100755 index 000000000..e69de29bb diff --git a/ci/nightly/build-libtiledb.sh b/ci/nightly/build-libtiledb.sh index 3d7e598a8..ac622efc3 100644 --- a/ci/nightly/build-libtiledb.sh +++ b/ci/nightly/build-libtiledb.sh @@ -12,4 +12,4 @@ cmake -S TileDB -B build-libtiledb \ cmake --build build-libtiledb -j2 --config Release -cmake --build build-libtiledb --config Release --target install-tiledb +cmake --install build-libtiledb diff --git a/ci/nightly/build-libtiledbvcf.sh b/ci/nightly/build-libtiledbvcf.sh index 806a03e3f..f5fa6673d 100644 --- a/ci/nightly/build-libtiledbvcf.sh +++ b/ci/nightly/build-libtiledbvcf.sh @@ -7,10 +7,11 @@ cmake -S TileDB-VCF/libtiledbvcf -B build-libtiledbvcf \ -D CMAKE_BUILD_TYPE=Release \ -D CMAKE_INSTALL_PREFIX:PATH=$GITHUB_WORKSPACE/install/ \ -D OVERRIDE_INSTALL_PREFIX=OFF \ - -D TILEDB_WERROR=OFF + -D TILEDB_WERROR=OFF \ + -D BUILD_SHARED_LIBS=ON cmake --build build-libtiledbvcf -j2 --config Release -cmake --build build-libtiledbvcf --config Release --target install-libtiledbvcf +cmake --install build-libtiledbvcf -./install/bin/tiledbvcf version +./install/tiledbvcf/bin/tiledbvcf version diff --git a/ci/nightly/build-tiledbvcf-py.sh b/ci/nightly/build-tiledbvcf-py.sh index 54fc1af45..aa75e76af 100644 --- a/ci/nightly/build-tiledbvcf-py.sh +++ b/ci/nightly/build-tiledbvcf-py.sh @@ -17,10 +17,11 @@ then echo "DYLD_LIBRARY_PATH: $DYLD_LIBRARY_PATH" fi -export LIBTILEDBVCF_PATH=$GITHUB_WORKSPACE/install/ +export tiledbvcf_DIR=$GITHUB_WORKSPACE/install/tiledbvcf +export TileDB_DIR=$GITHUB_WORKSPACE/install/ -cd TileDB-VCF/apis/python -python -m pip install .[test] +cd TileDB-VCF +python -m pip install -v --config-settings=cmake.define.TILEDBVCF_ONLY_PYTHON_BINDINGS=ON .[test] python -c "import tiledbvcf; print(tiledbvcf.version)" pytest diff --git a/ci/nightly/test-libtiledbvcf.sh b/ci/nightly/test-libtiledbvcf.sh index 87026ed97..d71301d56 100644 --- a/ci/nightly/test-libtiledbvcf.sh +++ b/ci/nightly/test-libtiledbvcf.sh @@ -4,8 +4,8 @@ set -ex # Test libtiledbvcf assuming source code directory is ./TileDB-VCF/libtiledbvcf # and build directory is build-libtiledbvcf -make -j2 -C build-libtiledbvcf/libtiledbvcf tiledb_vcf_unit -./build-libtiledbvcf/libtiledbvcf/test/tiledb_vcf_unit +make -j2 -C build-libtiledbvcf tiledb_vcf_unit +./build-libtiledbvcf/test/tiledb_vcf_unit # cli tests (require bcftools) # USAGE: run-cli-tests.sh diff --git a/docker/Dockerfile-cli b/docker/Dockerfile-cli index 6046fe0d2..729e187ec 100644 --- a/docker/Dockerfile-cli +++ b/docker/Dockerfile-cli @@ -34,8 +34,7 @@ WORKDIR /tmp/libtiledbvcf/build RUN cmake .. -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr/local \ -DOVERRIDE_INSTALL_PREFIX=OFF \ - && make -j$(nproc) \ - && make install-libtiledbvcf + && make -j$(nproc) install FROM ubuntu:22.04 diff --git a/libtiledbvcf/CMakeLists.txt b/libtiledbvcf/CMakeLists.txt index 691fe52b8..24fefb26d 100644 --- a/libtiledbvcf/CMakeLists.txt +++ b/libtiledbvcf/CMakeLists.txt @@ -25,125 +25,105 @@ # THE SOFTWARE. # -############################################################ -# CMake setup -############################################################ +cmake_minimum_required(VERSION 3.21) -cmake_minimum_required(VERSION 3.5) -if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") - cmake_policy(SET CMP0135 NEW) -endif() -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/") - -# Superbuild option must be on by default. -option(SUPERBUILD "If true, perform a superbuild (builds all missing dependencies)." ON) -option(CMAKE_IDE "(Used for CLion builds). Disables superbuild and sets the EP install dir." OFF) -option(FORCE_EXTERNAL_HTSLIB "Forces a local build of HTSlib instead of searching system paths." ON) -option(FORCE_EXTERNAL_SPDLOG "Forces a local build of spdlog instead of searching system paths." ON) -option(FORCE_EXTERNAL_TILEDB "Forces a local build of TileDB instead of searching system paths." OFF) -option(DOWNLOAD_TILEDB_PREBUILT "If tiledb is being super built, this controls downloading prebuilt artifacts or building from source" ON) -option(TILEDB_S3 "Enables S3/minio support using aws-cpp-sdk" ON) -option(TILEDB_WERROR "Enables warnings as errors (-Werror)" ON) -option(OVERRIDE_INSTALL_PREFIX "Ignores the setting of CMAKE_INSTALL_PREFIX and sets a default prefix" ON) - -# Set C++20 as required standard for all C++ targets. -set(CMAKE_CXX_STANDARD 20) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) # Don't use GNU extensions - -# Release builds by default. -if (NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE RELEASE) -endif() +option(TILEDBVCF_ENABLE_TESTS "TODO" ON) +option(TILEDBVCF_ENABLE_PYTHON "TODO" OFF) -# Root directory default installation prefix -if (OVERRIDE_INSTALL_PREFIX) - set(PREFIX_REL_PATH "${CMAKE_SOURCE_DIR}/../dist") - get_filename_component(DEFAULT_PREFIX "${PREFIX_REL_PATH}" ABSOLUTE) - set(CMAKE_INSTALL_PREFIX "${DEFAULT_PREFIX}" CACHE PATH "Default install prefix" FORCE) - message(STATUS "Using default install prefix ${CMAKE_INSTALL_PREFIX}. To control CMAKE_INSTALL_PREFIX, set OVERRIDE_INSTALL_PREFIX=OFF") -endif() -message(STATUS "Install prefix is ${CMAKE_INSTALL_PREFIX}.") +option(TILEDBVCF_INSTALL_TILEDB "TODO" ON) +option(TILEDBVCF_FORCE_EXTERNAL_DEPENDENCIES "TODO" OFF) +option(TILEDBVCF_ONLY_PYTHON_BINDINGS "TODO" OFF) +option(TILEDBVCF_SET_INSTALL_SUBPATH "TODO" ON) -if (FORCE_EXTERNAL_HTSLIB) - message(STATUS "Skipping search for htslib, building it as an external project. To use system htslib, set FORCE_EXTERNAL_HTSLIB=OFF") -endif() +option(TILEDBVCF_SET_RPATH "TODO" ON) -if (FORCE_EXTERNAL_TILEDB) - message(STATUS "Skipping search for TileDB, building it as an external project. To use system TileDB, set FORCE_EXTERNAL_TILEDB=OFF") +if(TILEDBVCF_SET_INSTALL_SUBPATH) + set(LOCAL_INSTALL_PREFIX "tiledbvcf/") + message(STATUS "Appending \"tiledbvcf\" to install prefix") endif() -# Use @rpath on macOS for building shared libraries. -if (APPLE) - set(CMAKE_MACOSX_RPATH ON) +if (TILEDBVCF_ONLY_PYTHON_BINDINGS) + add_subdirectory(../apis/python apis/python) + return() endif() -# Add some global compiler flags -string( TOUPPER "${CMAKE_BUILD_TYPE}" BUILD_TYPE) -if(WIN32 AND NOT MSYS) - #Note: seems this branch is taken even when -G "MSYS Makefiles" was used to invoke at top-level! - #(cmake --version was 3.24.1 when this apparent failure encountered...) - message(STATUS "configuring for WIN32, MSYS is \"${MSYS}\", MSVC is \"${MSVC}\"") - #Note: also seems MSVC not yet set at this point, so can't check 'if (MSVC)'. - #TBD: figure out approp. compile options to set for WIN32/MSVC if they need to - # be different from cmake defaults - if (BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]") - set(CMAKE_BUILD_TYPE "Debug") - elseif (BUILD_TYPE MATCHES [Rr][Ee][Ll][Ww][Ii][Tt][Hh][Ii][Nn][Ff][Oo]) - set(CMAKE_BUILD_TYPE "RelWithDebInfo") - elseif (BUILD_TYPE MATCHES "[Rr][Ee][Ll][Ee][Aa][Ss][Ee]") - set(CMAKE_BUILD_TYPE "Release") - endif() - # /wd4996 - no deprecated - add_compile_options(/wd4996) -else() - if (BUILD_TYPE STREQUAL "DEBUG") - add_compile_options(-DDEBUG -O0 -g3 -ggdb3 -gdwarf-3 -Wall) - elseif (BUILD_TYPE STREQUAL "RELEASE") - add_compile_options(-DNDEBUG -O3 -Wall) - endif() - if (TILEDB_WERROR) - add_compile_options(-Werror) - endif() - add_compile_options(-Wno-deprecated-declarations) +if (NOT TILEDBVCF_FORCE_EXTERNAL_DEPENDENCIES) + include(cmake/TileDBToolchain.cmake) endif() -add_definitions(-D_FILE_OFFSET_BITS=64) - -############################################################ -# Superbuild setup -############################################################ -# Search the externals install directory for dependencies. -list(APPEND CMAKE_PREFIX_PATH "${EP_INSTALL_PREFIX}") +project(TileDB-VCF) -# If this is an in-IDE build, we need to disable the superbuild and explicitly -# set the EP base dir. The normal 'cmake && make' process won't need this step, -# it is for better CLion support of the superbuild architecture. -if (CMAKE_IDE) - set(SUPERBUILD OFF) - set(EP_BASE "${CMAKE_CURRENT_BINARY_DIR}/externals") -endif() +include(cmake/DownloadTileDB.cmake) -if (SUPERBUILD) - project(TileDB-VCF-Superbuild) - message(STATUS "Starting TileDB-VCF superbuild.") - include("cmake/Superbuild.cmake") - return() +if (NOT TILEDBVCF_FORCE_EXTERNAL_DEPENDENCIES) + fetch_prebuilt_tiledb( + VERSION 2.26.1 + RELLIST_HASH SHA256=256216aa989015397f4efbbd319ebeccfead568baa73611aa0c1c0fcea35f8d5 + ) +else() + add_link_options("-Wl,--allow-shlib-undefined") endif() -project(TileDB-VCF) -message(STATUS "Starting TileDB-VCF regular build.") - -# Paths to locate the installed external projects. -set(EP_SOURCE_DIR "${EP_BASE}/src") -set(EP_INSTALL_PREFIX "${EP_BASE}/install") - ############################################################ -# Regular build +# Find required dependencies ############################################################ -# Enable testing -enable_testing() +find_package(TileDB REQUIRED) +find_package(CLI11 REQUIRED) +find_package(spdlog REQUIRED) + +# TODO: Add simple find_package for Conda builds + +if (WIN32) + FetchContent_Declare( + htslib + URL https://github.com/TileDB-Inc/m2w64-htslib-build/releases/download/1.20-0/m2w64-htslib-1.20-0.tar.gz + # TODO: URL_HASH SHA256= + ) + FetchContent_MakeAvailable(htslib) + find_library( + HTSLIB_LIBRARIES + REQUIRED + NAMES hts hts-3 + PATHS ${htslib_SOURCE_DIR} + PATH_SUFFIXES lib + NO_DEFAULT_PATH + ) + find_path( + HTSLIB_INCLUDE_DIR + REQUIRED + NAMES htslib/hts.h + PATHS ${htslib_SOURCE_DIR} + PATH_SUFFIXES include + NO_DEFAULT_PATH + ) + find_file( + HTSLIB_BINARIES + REQUIRED + NAMES hts-3.dll + PATHS ${htslib_SOURCE_DIR} + PATH_SUFFIXES bin + NO_DEFAULT_PATH + ) + add_library(HTSlib::HTSlib SHARED IMPORTED) + set_target_properties(HTSlib::HTSlib PROPERTIES + IMPORTED_IMPLIB "${HTSLIB_LIBRARIES}" + IMPORTED_LOCATION "${HTSLIB_BINARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${HTSLIB_INCLUDE_DIR}" + ) +else() + find_package(PkgConfig REQUIRED) + pkg_check_modules(HTSlib REQUIRED IMPORTED_TARGET htslib) + add_library(HTSlib::HTSlib ALIAS PkgConfig::HTSlib) +endif() add_subdirectory(src) -add_subdirectory(test) + +if (TILEDBVCF_ENABLE_TESTS) + enable_testing() + add_subdirectory(test) +endif() + +if (TILEDBVCF_ENABLE_PYTHON) + add_subdirectory(../apis/python apis/python) +endif() diff --git a/libtiledbvcf/cmake/DownloadTileDB.cmake b/libtiledbvcf/cmake/DownloadTileDB.cmake new file mode 100644 index 000000000..c0f177cf8 --- /dev/null +++ b/libtiledbvcf/cmake/DownloadTileDB.cmake @@ -0,0 +1,127 @@ +# +# DownloadTileDB.cmake +# +# +# The MIT License +# +# Copyright (c) 2023 TileDB, Inc. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +include(FetchContent) + +function(fetch_tiledb_release_list VERSION) + # Local constants + set(UPSTREAM_URL "https://github.com/TileDB-Inc/TileDB/releases/download") + list(LENGTH ARGV COUNT) + if (${COUNT} GREATER 1) + list(GET ARGV 1 EXPECTED_HASH) + endif() + + if(NOT VERSION) + set(VERSION latest) + endif() + + if(EXPECTED_HASH) + file(DOWNLOAD + ${UPSTREAM_URL}/${VERSION}/releases.csv + ${CMAKE_CURRENT_BINARY_DIR}/releases.csv + SHOW_PROGRESS + EXPECTED_HASH ${EXPECTED_HASH} + ) + else() + message(WARNING "Downloading release list without SHA checksum!") + file(DOWNLOAD + ${UPSTREAM_URL}/${VERSION}/releases.csv + ${CMAKE_CURRENT_BINARY_DIR}/releases.csv + SHOW_PROGRESS + ) + endif() + + file(STRINGS + ${CMAKE_CURRENT_BINARY_DIR}/releases.csv + RELLIST + ) + + # Remove csv table headers + list(POP_FRONT RELLIST) + + foreach(LINE ${RELLIST}) + string(REPLACE "," ";" LINE ${LINE}) + list(LENGTH LINE LENGTH) + + list(GET LINE 0 PLATFORM) + list(GET LINE 1 URL) + list(GET LINE 2 SHA) + + set(RELEASE_VAR TILEDB_${PLATFORM}) + set(URL_${RELEASE_VAR} ${URL} PARENT_SCOPE) + set(HASH_${RELEASE_VAR} ${SHA} PARENT_SCOPE) + endforeach() +endfunction() + +function(detect_artifact_name OUT_VAR) + if (WIN32) # Windows + SET(${OUT_VAR} TILEDB_WINDOWS-X86_64 PARENT_SCOPE) + elseif(APPLE) # OSX + if (CMAKE_OSX_ARCHITECTURES) + set(ACTUAL_TARGET ${CMAKE_OSX_ARCHITECTURES}) + else() + set(ACTUAL_TARGET ${CMAKE_SYSTEM_PROCESSOR}) + endif() + + if (ACTUAL_TARGET MATCHES "(x86_64)|(AMD64|amd64)|(^i.86$)") + SET(${OUT_VAR} TILEDB_MACOS-X86_64 PARENT_SCOPE) + elseif (ACTUAL_TARGET STREQUAL arm64 OR ACTUAL_TARGET MATCHES "^aarch64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") + SET(${OUT_VAR} TILEDB_MACOS-ARM64 PARENT_SCOPE) + endif() + else() # Linux + SET(${OUT_VAR} TILEDB_LINUX-X86_64 PARENT_SCOPE) + endif() +endfunction() + +function(fetch_prebuilt_tiledb) + # Arguments + set(oneValueArgs VERSION ARTIFACT_NAME RELLIST_HASH) + set(multiValueArgs) + cmake_parse_arguments( + FETCH_PREBUILT_TILEDB + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${ARGN} + ) + + fetch_tiledb_release_list(${FETCH_PREBUILT_TILEDB_VERSION} ${FETCH_PREBUILT_TILEDB_RELLIST_HASH}) + + if(NOT FETCH_PREBUILT_TILEDB_ARTIFACT_NAME) + detect_artifact_name(FETCH_PREBUILT_TILEDB_ARTIFACT_NAME) + endif() + + message(STATUS "Downloading TileDB artifact: ${FETCH_PREBUILT_TILEDB_ARTIFACT_NAME}") + + string(STRIP ${HASH_${FETCH_PREBUILT_TILEDB_ARTIFACT_NAME}} HASH_${FETCH_PREBUILT_TILEDB_ARTIFACT_NAME}) + FetchContent_Declare( + tiledb + URL ${URL_${FETCH_PREBUILT_TILEDB_ARTIFACT_NAME}} + URL_HASH SHA256=${HASH_${FETCH_PREBUILT_TILEDB_ARTIFACT_NAME}} + ) + FetchContent_MakeAvailable(tiledb) + set(TileDB_DIR ${tiledb_SOURCE_DIR}/lib/cmake/TileDB PARENT_SCOPE) +endfunction() \ No newline at end of file diff --git a/libtiledbvcf/cmake/Modules/FindCLI11.cmake b/libtiledbvcf/cmake/Modules/FindCLI11.cmake deleted file mode 100644 index 569732147..000000000 --- a/libtiledbvcf/cmake/Modules/FindCLI11.cmake +++ /dev/null @@ -1,92 +0,0 @@ -# -# FindCLI11_EP.cmake -# -# -# The MIT License -# -# Copyright (c) 2021 TileDB, Inc. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# -# Finds the CLI11 library, installing with an ExternalProject as necessary. -# -# This module defines: -# - CLI11_INCLUDE_DIR, directory containing headers -# - CLI11_FOUND, whether CLI11 has been found -# - The CLI11::CLI11 imported target - -# Search the path set during the superbuild for the EP. -set(CLI11_PATHS ${EP_INSTALL_PREFIX}) - -find_path(CLI11_INCLUDE_DIR - NAMES CLI11.hpp - PATHS ${CLI11_PATHS} - PATH_SUFFIXES include -) - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(CLI11 - REQUIRED_VARS CLI11_INCLUDE_DIR -) - -if (NOT CLI11_FOUND) - if (SUPERBUILD) - message(STATUS "Adding CLI11 as an external project") - if (WIN32) - find_package(Git REQUIRED) - set(CONDITIONAL_PATCH cd ${CMAKE_SOURCE_DIR}/.. && ${GIT_EXECUTABLE} apply --ignore-whitespace -p1 --unsafe-paths --verbose --directory=${EP_SOURCE_DIR}/ep_cli11 < ${CMAKE_CURRENT_SOURCE_DIR}/cmake/patches/cli11-2.1.0.patch) - else() - set(CONDITIONAL_PATCH patch -N -p1 < ${CMAKE_CURRENT_SOURCE_DIR}/cmake/patches/cli11-2.1.0.patch) - endif() - ExternalProject_Add(ep_cli11 - PREFIX "externals" - URL "https://github.com/CLIUtils/CLI11/releases/download/v2.1.0/CLI11.hpp" - URL_HASH SHA1=35fd46dfdcee03f13f0cd63d2b6d64c80a2668bb - DOWNLOAD_NO_EXTRACT TRUE - DOWNLOAD_DIR ${EP_BASE}/src/ep_cli11 - UPDATE_COMMAND "" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND - ${CMAKE_COMMAND} -E make_directory ${EP_INSTALL_PREFIX}/include - COMMAND - ${CMAKE_COMMAND} -E copy_if_different - ${EP_BASE}/src/ep_cli11/CLI11.hpp - ${EP_INSTALL_PREFIX}/include/ - PATCH_COMMAND - ${CONDITIONAL_PATCH} - LOG_DOWNLOAD TRUE - LOG_CONFIGURE TRUE - LOG_BUILD TRUE - LOG_INSTALL TRUE - ) - - list(APPEND EXTERNAL_PROJECTS ep_cli11) - else() - message(FATAL_ERROR "Unable to find CLI11") - endif() -endif() - -# Create the imported target for CLI11 -if (CLI11_FOUND AND NOT TARGET CLI11::CLI11) - add_library(CLI11::CLI11 INTERFACE IMPORTED) - set_target_properties(CLI11::CLI11 PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${CLI11_INCLUDE_DIR}" - ) -endif() \ No newline at end of file diff --git a/libtiledbvcf/cmake/Modules/FindCatch2.cmake b/libtiledbvcf/cmake/Modules/FindCatch2.cmake deleted file mode 100644 index 93aa51f0f..000000000 --- a/libtiledbvcf/cmake/Modules/FindCatch2.cmake +++ /dev/null @@ -1,80 +0,0 @@ -# -# FindCatch_EP.cmake -# -# -# The MIT License -# -# Copyright (c) 2018-2021 TileDB, Inc. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# -# Finds the Catch library, installing with an ExternalProject as necessary. -# This module defines: -# - CATCH_INCLUDE_DIR, directory containing headers -# - CATCH2_FOUND, whether Catch has been found -# - The Catch::Catch imported target - -# Include some common helper functions. -include(TileDBCommon) - -# Search the path set during the superbuild for the EP. -set(CATCH_PATHS ${EP_SOURCE_DIR}/ep_catch/single_include) - -if (NOT TILEDB_FORCE_ALL_DEPS OR TILEDB_CATCH_EP_BUILT) - find_path(CATCH_INCLUDE_DIR - NAMES catch.hpp - PATHS ${CATCH_PATHS} - PATH_SUFFIXES "catch2" - ${TILEDB_DEPS_NO_DEFAULT_PATH} - ) -endif() - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Catch2 - REQUIRED_VARS CATCH_INCLUDE_DIR -) - -if (NOT CATCH2_FOUND) - message(STATUS "Adding Catch as an external project") - ExternalProject_Add(ep_catch - PREFIX "externals" - # Set download name to avoid collisions with only the version number in the filename - DOWNLOAD_NAME ep_catch.zip - URL "https://github.com/catchorg/Catch2/archive/v2.13.8.zip" - URL_HASH SHA1=73adf43795abb7f481f07d307d11ac1fbc7a6015 - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - UPDATE_COMMAND "" - LOG_DOWNLOAD TRUE - LOG_OUTPUT_ON_FAILURE ${TILEDB_LOG_OUTPUT_ON_FAILURE} - ) - list(APPEND TILEDB_EXTERNAL_PROJECTS ep_catch) - list(APPEND FORWARD_EP_CMAKE_ARGS - -DTILEDB_CATCH_EP_BUILT=TRUE - -DCATCH_INCLUDE_DIR=${EP_SOURCE_DIR}/ep_catch/single_include/catch2 - ) -endif() - -if (CATCH2_FOUND AND NOT TARGET Catch2::Catch2) - add_library(Catch2::Catch2 INTERFACE IMPORTED) - set_target_properties(Catch2::Catch2 PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${CATCH_INCLUDE_DIR}" - ) -endif() diff --git a/libtiledbvcf/cmake/Modules/FindClangTools.cmake b/libtiledbvcf/cmake/Modules/FindClangTools.cmake deleted file mode 100644 index e0b3dbcfb..000000000 --- a/libtiledbvcf/cmake/Modules/FindClangTools.cmake +++ /dev/null @@ -1,73 +0,0 @@ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Tries to find the clang-tidy and clang-format modules -# -# Usage of this module as follows: -# -# find_package(ClangTools) -# -# Variables used by this module, they can change the default behaviour and need -# to be set before calling find_package: -# -# ClangToolsBin_HOME - -# When set, this path is inspected instead of standard library binary locations -# to find clang-tidy and clang-format -# -# This module defines -# CLANG_TIDY_BIN, The path to the clang tidy binary -# CLANG_TIDY_FOUND, Whether clang tidy was found -# CLANG_FORMAT_BIN, The path to the clang format binary -# CLANG_TIDY_FOUND, Whether clang format was found - -find_program(CLANG_TIDY_BIN - NAMES clang-tidy-5.0 - clang-tidy-4.0 - clang-tidy-3.9 - clang-tidy-3.8 - clang-tidy-3.7 - clang-tidy-3.6 - clang-tidy - PATHS ${ClangTools_PATH} $ENV{CLANG_TOOLS_PATH} /usr/local/bin /usr/bin - NO_DEFAULT_PATH -) - -if ( "${CLANG_TIDY_BIN}" STREQUAL "CLANG_TIDY_BIN-NOTFOUND" ) - set(CLANG_TIDY_FOUND 0) - message(STATUS "Not found clang-tidy") -else() - set(CLANG_TIDY_FOUND 1) - message(STATUS "Found clang-tidy: ${CLANG_TIDY_BIN}") -endif() - -find_program(CLANG_FORMAT_BIN - NAMES - clang-format-15 - clang-format-5.0 - clang-format-4.0 - clang-format-3.9 - clang-format-3.8 - clang-format-3.7 - clang-format-3.6 - clang-format - PATHS ${ClangTools_PATH} $ENV{CLANG_TOOLS_PATH} /usr/local/bin /usr/bin - NO_DEFAULT_PATH -) - -if ( "${CLANG_FORMAT_BIN}" STREQUAL "CLANG_FORMAT_BIN-NOTFOUND" ) - set(CLANG_FORMAT_FOUND 0) - message(STATUS "Not found clang-format") -else() - set(CLANG_FORMAT_FOUND 1) - message(STATUS "Found clang-format: ${CLANG_FORMAT_BIN}") -endif() diff --git a/libtiledbvcf/cmake/Modules/FindHTSlib.cmake b/libtiledbvcf/cmake/Modules/FindHTSlib.cmake deleted file mode 100644 index 9bf26dd08..000000000 --- a/libtiledbvcf/cmake/Modules/FindHTSlib.cmake +++ /dev/null @@ -1,167 +0,0 @@ -# -# FindHTSlib_EP.cmake -# -# -# The MIT License -# -# Copyright (c) 2018 TileDB, Inc. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# -# Finds the HTSlib library, installing with an ExternalProject as necessary. -# -# This module defines: -# - HTSLIB_INCLUDE_DIR, directory containing headers -# - HTSLIB_LIBRARIES, the HTSlib library path -# - HTSLIB_FOUND, whether HTSlib has been found -# - The HTSlib::HTSlib imported target - -# Search the path set during the superbuild for the EP. -set(HTSLIB_PATHS ${EP_INSTALL_PREFIX}) - -if (FORCE_EXTERNAL_HTSLIB) - set(HTSLIB_NO_DEFAULT_PATH NO_DEFAULT_PATH) -else() - set(HTSLIB_NO_DEFAULT_PATH) -endif() - -find_path(HTSLIB_INCLUDE_DIR - NAMES htslib/hts.h - PATHS ${HTSLIB_PATHS} - PATH_SUFFIXES include - ${HTSLIB_NO_DEFAULT_PATH} -) - -find_library(HTSLIB_LIBRARIES - NAMES hts hts-3 - PATHS ${HTSLIB_PATHS} - PATH_SUFFIXES lib - ${HTSLIB_NO_DEFAULT_PATH} -) - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(HTSlib - REQUIRED_VARS HTSLIB_LIBRARIES HTSLIB_INCLUDE_DIR -) - - -if (NOT HTSLIB_FOUND) - if (SUPERBUILD) - message(STATUS "Adding HTSlib as an external project") - # Use explicit soname to avoid having to use library symlinks (easier for embedding). - if (APPLE) - set(EXTRA_LDFLAGS "-Wl,-install_name,@rpath/libhts.1.20.dylib") - else() - set(EXTRA_LDFLAGS "-Wl,-soname,libhts.so.1.20") - endif() - SET(CFLAGS "") - string( TOUPPER "${CMAKE_BUILD_TYPE}" BUILD_TYPE) - if (BUILD_TYPE STREQUAL "DEBUG") - if(NOT WIN32) - SET(CFLAGS "-g") - endif() - endif() - - # required to updated htslib configure.ac with autoconf 2.70 - # - see https://github.com/samtools/htslib/commit/680c0b8ef0ff133d3b572abc80fe66fc2ea965f0 - # - and https://github.com/samtools/htslib/pull/1198/commits/6821fc8ed88706e9282b561e74dfa45dac4d74c8 - - if(WIN32) - # fetch from prebuilt msys2 htslib version - find_program(CMD_EXE_PATH cmd.exe) - if ( "${CMD_EXE_PATH}" STREQUAL "CMD_EXE_PATH-NOTFOUND" ) - message(FATAL_ERROR "Failed to find cmd.exe!") - endif() - message("CMD_EXE_PATH is ${CMD_EXE_PATH}") - string(REPLACE "/" "\\\\" CMD_EXE_PATH_FWD_SLASH "${CMD_EXE_PATH}") - message("CMD_EXE_PATH_FWD_SLASH is ${CMD_EXE_PATH_FWD_SLASH}") - - ExternalProject_Add(ep_htslib - PREFIX "externals" - URL https://github.com/TileDB-Inc/m2w64-htslib-build/releases/download/1.20-0/m2w64-htslib-1.20-0.tar.gz - URL_HASH SHA1=da39a3ee5e6b4b0d3255bfef95601890afd80709 - UPDATE_COMMAND "" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND - ${CMAKE_COMMAND} -E copy_directory ${EP_BASE}/src/ep_htslib/bin ${EP_INSTALL_PREFIX}/bin - COMMAND - ${CMAKE_COMMAND} -E copy_directory ${EP_BASE}/src/ep_htslib/include ${EP_INSTALL_PREFIX}/include - COMMAND - ${CMAKE_COMMAND} -E copy_directory ${EP_BASE}/src/ep_htslib/lib ${EP_INSTALL_PREFIX}/lib - BUILD_IN_SOURCE TRUE - LOG_DOWNLOAD TRUE - LOG_CONFIGURE TRUE - LOG_BUILD TRUE - LOG_INSTALL TRUE - LOG_PATCH TRUE - LOG_OUTPUT_ON_FAILURE TRUE - ) - else() - # required to updated htslib configure.ac with autoconf 2.70 - # - see https://github.com/samtools/htslib/commit/680c0b8ef0ff133d3b572abc80fe66fc2ea965f0 - # - and https://github.com/samtools/htslib/pull/1198/commits/6821fc8ed88706e9282b561e74dfa45dac4d74c8 - find_program(AUTORECONF NAMES autoreconf REQUIRED) - find_program(MAKE NAMES make gmake REQUIRED) - - ExternalProject_Add(ep_htslib - PREFIX "externals" - URL "https://github.com/samtools/htslib/releases/download/1.20/htslib-1.20.tar.bz2" - URL_HASH SHA1=da8bf95e4ae2404d1a48f88ece94ca25d69d6596 - UPDATE_COMMAND "" - CONFIGURE_COMMAND - autoheader - COMMAND - ${AUTORECONF} -i - COMMAND - ./configure --prefix=${EP_INSTALL_PREFIX} LDFLAGS=${EXTRA_LDFLAGS} CFLAGS=${CFLAGS} - BUILD_COMMAND - # Add -j to avoid the following error in some docker builds: - # make[3]: *** read jobs pipe: Bad file descriptor. Stop. - ${MAKE} -j4 - INSTALL_COMMAND - ${MAKE} -j4 install - PATCH_COMMAND - BUILD_IN_SOURCE TRUE - LOG_DOWNLOAD TRUE - LOG_CONFIGURE TRUE - LOG_BUILD TRUE - LOG_INSTALL TRUE - ) - endif() - list(APPEND FORWARD_EP_CMAKE_ARGS -DEP_HTSLIB_BUILT=TRUE) - list(APPEND EXTERNAL_PROJECTS ep_htslib) - else() - message(FATAL_ERROR "Unable to find HTSlib") - endif() -endif() - -# Create the imported target for HTSlib -if (HTSLIB_FOUND AND NOT TARGET HTSlib::HTSlib) - add_library(HTSlib::HTSlib UNKNOWN IMPORTED) - set_target_properties(HTSlib::HTSlib PROPERTIES - IMPORTED_LOCATION "${HTSLIB_LIBRARIES}" - INTERFACE_INCLUDE_DIRECTORIES "${HTSLIB_INCLUDE_DIR}" - ) -endif() - -if (EP_HTSLIB_BUILT AND TARGET HTSlib::HTSlib) - include(TileDBCommon) - install_target_libs(HTSlib::HTSlib) -endif() diff --git a/libtiledbvcf/cmake/Modules/FindSpdlog.cmake b/libtiledbvcf/cmake/Modules/FindSpdlog.cmake deleted file mode 100644 index 3de7e1b75..000000000 --- a/libtiledbvcf/cmake/Modules/FindSpdlog.cmake +++ /dev/null @@ -1,116 +0,0 @@ -# -# FindSpdlog_EP.cmake -# -# -# The MIT License -# -# Copyright (c) 2018-2021 TileDB, Inc. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# -# Finds the Spdlog library, installing with an ExternalProject as necessary. -# This module defines: -# - SPDLOG_INCLUDE_DIR, directory containing headers -# - SPDLOG_FOUND, whether Spdlog has been found -# - The spdlog::spdlog imported target - -# Include some common helper functions. -include(TileDBCommon) - -# If the EP was built, it will install the storage_client-config.cmake file, -# which we can use with find_package. CMake uses CMAKE_PREFIX_PATH to locate find -# modules. -set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "${EP_INSTALL_PREFIX}") - -# First try the CMake find module. -if (TILEDB_SPDLOG_EP_BUILT OR FORCE_EXTERNAL_SPDLOG) - # If we built it from the source always force no default path - SET(SPDLOG_NO_DEFAULT_PATH NO_DEFAULT_PATH) -else() - SET(SPDLOG_NO_DEFAULT_PATH) -endif() - -find_package(spdlog - PATHS ${EP_INSTALL_PREFIX} - ${SPDLOG_NO_DEFAULT_PATH} - ) -set(SPDLOG_FOUND ${spdlog_FOUND}) - -if (NOT SPDLOG_FOUND) - if(SUPERBUILD) - # if building ep_tiledb, make spdlog depend on ep_tiledb, so tiledb finds its required version of spdlog - if (TARGET ep_tiledb) - SET(SPDLOG_DEPENDS ep_tiledb) - else() - SET(SPDLOG_DEPENDS "") - endif() - - message(STATUS "Adding spdlog as an external project") - ExternalProject_Add(ep_spdlog - PREFIX "externals" - # Set download name to avoid collisions with only the version number in the filename - DOWNLOAD_NAME ep_spdlog.zip - URL "https://github.com/gabime/spdlog/archive/v1.12.0.zip" - URL_HASH SHA1=2ea8a77a4a39dc296757620754bc41ad475ca77b - CMAKE_ARGS - -DCMAKE_PREFIX_PATH=${EP_INSTALL_PREFIX} - -DCMAKE_INSTALL_PREFIX=${EP_INSTALL_PREFIX} - -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} - -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} - -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} - -DCMAKE_POSITION_INDEPENDENT_CODE=ON - -DSPDLOG_BUILD_SHARED=OFF - -DSPDLOG_BUILD_EXAMPLE=OFF - LOG_DOWNLOAD TRUE - LOG_CONFIGURE TRUE - LOG_BUILD TRUE - LOG_INSTALL TRUE - LOG_OUTPUT_ON_FAILURE TRUE - DEPENDS ${SPDLOG_DEPENDS}) - list(APPEND EXTERNAL_PROJECTS ep_spdlog) - list(APPEND FORWARD_EP_CMAKE_ARGS - -DTILEDB_SPDLOG_EP_BUILT=TRUE - ) - else() - message(FATAL_ERROR "Unable to find spdlog") - endif() -endif() - -if (spdlog_FOUND AND NOT TARGET spdlog::spdlog) - add_library(spdlog::spdlog INTERFACE IMPORTED) - find_package(fmt QUIET) - if (${fmt_FOUND}) - target_link_libraries(spdlog::spdlog INTERFACE fmt::fmt) - endif() - set_target_properties(spdlog::spdlog PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${SPDLOG_INCLUDE_DIR}" - ) - # If the target is defined we need to handle external fmt build types -elseif(TARGET spdlog::spdlog) - if (SPDLOG_FMT_EXTERNAL) - # Since we are using header only we need to define this - add_definitions("-DSPDLOG_FMT_EXTERNAL=1") - find_package(fmt REQUIRED) - if (${fmt_FOUND}) - target_link_libraries(spdlog::spdlog INTERFACE fmt::fmt) - endif() - endif() -endif() diff --git a/libtiledbvcf/cmake/Modules/FindTileDB_EP.cmake b/libtiledbvcf/cmake/Modules/FindTileDB_EP.cmake index e06c68a09..e69de29bb 100644 --- a/libtiledbvcf/cmake/Modules/FindTileDB_EP.cmake +++ b/libtiledbvcf/cmake/Modules/FindTileDB_EP.cmake @@ -1,122 +0,0 @@ -# -# FindTileDB_EP.cmake -# -# -# The MIT License -# -# Copyright (c) 2018 TileDB, Inc. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# -# Finds the TileDB library, installing with an ExternalProject as necessary. - -# If TileDB was installed as an EP, need to search the EP install path also. -set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "${EP_INSTALL_PREFIX}") - -if (FORCE_EXTERNAL_TILEDB) - find_package(TileDB CONFIG PATHS ${EP_INSTALL_PREFIX} NO_DEFAULT_PATH) -else() - find_package(TileDB CONFIG) -endif() - -if (TILEDB_FOUND) - if(CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]") - get_target_property(TILEDB_LIB TileDB::tiledb_shared IMPORTED_LOCATION_DEBUG) - else() - get_target_property(TILEDB_LIB TileDB::tiledb_shared IMPORTED_LOCATION_RELEASE) - endif() - message(STATUS "Found TileDB: ${TILEDB_LIB}") -else() - if (SUPERBUILD) - message(STATUS "Adding TileDB as an external project") - if (TILEDB_S3 STREQUAL "OFF") - message(STATUS "TileDB will be built WITHOUT S3 support") - endif() - - # Try to download prebuilt artifacts unless the user specifies to build from source - if(DOWNLOAD_TILEDB_PREBUILT) - if (WIN32) # Windows - SET(DOWNLOAD_URL "https://github.com/TileDB-Inc/TileDB/releases/download/2.27.0/tiledb-windows-x86_64-2.27.0-2862c30.zip") - SET(DOWNLOAD_SHA1 "fff5b9dda8b6d9fcd09210ebf286f0e076af1263") - elseif(APPLE) # OSX - - if (CMAKE_OSX_ARCHITECTURES STREQUAL x86_64 OR CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64)|(AMD64|amd64)|(^i.86$)") - SET(DOWNLOAD_URL "https://github.com/TileDB-Inc/TileDB/releases/download/2.27.0/tiledb-macos-x86_64-2.27.0-2862c30.tar.gz") - SET(DOWNLOAD_SHA1 "d03aefe7d444dba8f3eecfc80e0f73286b38bf8c") - elseif (CMAKE_OSX_ARCHITECTURES STREQUAL arm64 OR CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") - SET(DOWNLOAD_URL "https://github.com/TileDB-Inc/TileDB/releases/download/2.27.0/tiledb-macos-arm64-2.27.0-2862c30.tar.gz") - SET(DOWNLOAD_SHA1 "af8251851951efc0edb084500a4b27e425719876") - endif() - else() # Linux - SET(DOWNLOAD_URL "https://github.com/TileDB-Inc/TileDB/releases/download/2.27.0/tiledb-linux-x86_64-2.27.0-2862c30.tar.gz") - SET(DOWNLOAD_SHA1 "4407506d36f85aede71cdba875729a1442f5fa73") - endif() - - ExternalProject_Add(ep_tiledb - PREFIX "externals" - URL ${DOWNLOAD_URL} - URL_HASH SHA1=${DOWNLOAD_SHA1} - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - UPDATE_COMMAND "" - PATCH_COMMAND "" - TEST_COMMAND "" - INSTALL_COMMAND - ${CMAKE_COMMAND} -E copy_directory ${EP_BASE}/src/ep_tiledb ${EP_INSTALL_PREFIX} - LOG_DOWNLOAD TRUE - LOG_CONFIGURE FALSE - LOG_BUILD FALSE - LOG_INSTALL FALSE - ) - else() # Build from source - ExternalProject_Add(ep_tiledb - PREFIX "externals" - URL "https://github.com/TileDB-Inc/TileDB/archive/2.27.0.zip" - URL_HASH SHA1=d18d7c7600e290300010c057f8dafa9721a6ffa2 - DOWNLOAD_NAME "tiledb.zip" - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${EP_INSTALL_PREFIX} - -DCMAKE_PREFIX_PATH=${EP_INSTALL_PREFIX} - -DTILEDB_S3=${TILEDB_S3} - -DTILEDB_SKIP_S3AWSSDK_DIR_LENGTH_CHECK=ON # for windows build - -DTILEDB_VERBOSE=ON - -DTILEDB_SERIALIZATION=ON - -DTILEDB_TESTS=OFF - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - UPDATE_COMMAND "" - INSTALL_COMMAND - ${CMAKE_COMMAND} --build . --target install-tiledb - LOG_DOWNLOAD TRUE - LOG_CONFIGURE TRUE - LOG_BUILD TRUE - LOG_INSTALL TRUE - ) - endif() - - list(APPEND FORWARD_EP_CMAKE_ARGS -DEP_TILEDB_BUILT=TRUE) - list(APPEND EXTERNAL_PROJECTS ep_tiledb) - else() - message(FATAL_ERROR "Unable to find TileDB library.") - endif() -endif() - -if (EP_TILEDB_BUILT AND TARGET TileDB::tiledb_shared) - include(TileDBCommon) - install_target_libs(TileDB::tiledb_shared) -endif() diff --git a/libtiledbvcf/cmake/Modules/TileDBCommon.cmake b/libtiledbvcf/cmake/Modules/TileDBCommon.cmake deleted file mode 100644 index 2e08ed342..000000000 --- a/libtiledbvcf/cmake/Modules/TileDBCommon.cmake +++ /dev/null @@ -1,100 +0,0 @@ -# -# TileDBCommon.cmake -# -# -# The MIT License -# -# Copyright (c) 2018-2022 TileDB, Inc. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# -# This file defines some common helper functions used by the external projects. -# - -# Get library directory for multiarch linux distros -include(GNUInstallDirs) - -# -# Stores the IMPORTED_LOCATION* target property of LIB_TARGET in RESULT_VAR. -# On Windows, preferentially tries the IMPORTED_IMPLIB* target property instead. -# -function(get_imported_location RESULT_VAR LIB_TARGET) - if (WIN32) - # Try several methods to find the imported location. - get_target_property(TMP ${LIB_TARGET} IMPORTED_IMPLIB) - if (TMP MATCHES "NOTFOUND") - get_target_property(TMP ${LIB_TARGET} IMPORTED_IMPLIB_RELWITHDEBINFO) - endif() - if (TMP MATCHES "NOTFOUND") - get_target_property(TMP ${LIB_TARGET} IMPORTED_IMPLIB_RELEASE) - endif() - if (TMP MATCHES "NOTFOUND") - get_target_property(TMP ${LIB_TARGET} IMPORTED_IMPLIB_DEBUG) - endif() - endif() - # Try several methods to find the imported location. - if (TMP MATCHES "NOTFOUND" OR NOT WIN32) - get_target_property(TMP ${LIB_TARGET} IMPORTED_LOCATION) - endif() - if (TMP MATCHES "NOTFOUND") - get_target_property(TMP ${LIB_TARGET} IMPORTED_LOCATION_RELWITHDEBINFO) - endif() - if (TMP MATCHES "NOTFOUND") - get_target_property(TMP ${LIB_TARGET} IMPORTED_LOCATION_RELEASE) - endif() - if (TMP MATCHES "NOTFOUND") - get_target_property(TMP ${LIB_TARGET} IMPORTED_LOCATION_DEBUG) - endif() - set(${RESULT_VAR} "${TMP}" PARENT_SCOPE) -endfunction() - -# -# Concatenates the library name of the given imported target to the installation -# prefix and stores the result in RESULT_VAR. If the given library does not reside -# in the external projects build directory (i.e. it was not built by an EP), then -# just return the imported location. -# -function(get_installed_location RESULT_VAR LIB_TARGET) - get_imported_location(IMP_LOC ${LIB_TARGET}) - if ("${IMP_LOC}" MATCHES "^${EP_BASE}") - get_filename_component(LIB_NAME "${IMP_LOC}" NAME) - set(INSTALLED_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${LIB_NAME}") - else() - set(INSTALLED_PATH "${IMP_LOC}") - endif() - set(${RESULT_VAR} "${INSTALLED_PATH}" PARENT_SCOPE) -endfunction() - -# -# Adds imported libraries from the given target to the TileDB installation -# manifest. -# -function(install_target_libs LIB_TARGET) - get_imported_location(TARGET_LIBRARIES ${LIB_TARGET}) - if (TARGET_LIBRARIES MATCHES "NOTFOUND") - message(FATAL_ERROR "Could not determine library location for ${LIB_TARGET}") - endif() - if (WIN32 AND ${TARGET_LIBRARIES} MATCHES "${CMAKE_SHARED_LIBRARY_SUFFIX}$") - install(FILES ${TARGET_LIBRARIES} DESTINATION ${CMAKE_INSTALL_BINDIR}) - else() - get_filename_component(ABS_PATH ${TARGET_LIBRARIES} REALPATH) - install(FILES ${ABS_PATH} DESTINATION lib) - endif() -endfunction() - diff --git a/libtiledbvcf/cmake/Superbuild.cmake b/libtiledbvcf/cmake/Superbuild.cmake deleted file mode 100644 index ced7e1f88..000000000 --- a/libtiledbvcf/cmake/Superbuild.cmake +++ /dev/null @@ -1,121 +0,0 @@ -# -# Superbuild.cmake -# -# -# The MIT License -# -# Copyright (c) 2018-2021 TileDB, Inc. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - -include(ExternalProject) - -############################################################ -# Common variables -############################################################ - -# Build paths for external projects -set(EP_BASE "${CMAKE_CURRENT_BINARY_DIR}/externals") -set(EP_SOURCE_DIR "${EP_BASE}/src") -set(EP_INSTALL_PREFIX "${EP_BASE}/install") - -# A variable that will hold extra variables to pass to the regular -# non-superbuild build process as CMake arguments. -set(FORWARD_EP_CMAKE_ARGS) - -# Variable that will hold a list of all the external projects added -# as a part of the superbuild. -set(EXTERNAL_PROJECTS) - -# Forward any additional CMake args to the non-superbuild. -set(INHERITED_CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} - -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DEP_BASE=${EP_BASE} - -DFORCE_EXTERNAL_HTSLIB=${FORCE_EXTERNAL_HTSLIB} - -DFORCE_EXTERNAL_TILEDB=${FORCE_EXTERNAL_TILEDB} - -DTILEDB_S3=${TILEDB_S3} - -DTILEDB_WERROR=${TILEDB_WERROR} - -DTileDB_DIR=${TileDB_DIR} - -DSANITIZER=${SANITIZER} - -DOVERRIDE_INSTALL_PREFIX=${OVERRIDE_INSTALL_PREFIX} -) - -############################################################ -# Set up external projects for dependencies -############################################################ - -# These includes modify the EXTERNAL_PROJECTS variable. - -include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/FindCLI11.cmake) -include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/FindHTSlib.cmake) -# need spdlog to set up any of its needed targets... -include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/FindSpdlog.cmake) -#... before tiledb sets up only half of them... -include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/FindTileDB_EP.cmake) -include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/FindCatch2.cmake) - -############################################################ -# 'make format' target -############################################################ - -set(SCRIPTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../ci") - -find_package(ClangTools) -if (${CLANG_FORMAT_FOUND}) - # Runs clang-format and updates files in place. - add_custom_target(format ${SCRIPTS_DIR}/run-clang-format.sh ${CMAKE_CURRENT_SOURCE_DIR}/src ${CLANG_FORMAT_BIN} 1 - `find ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/test - -name \\*.cc -or -name \\*.c -or -name \\*.h`) - - # Runs clang-format and exits with a non-zero exit code# if any files need to - # be reformatted - add_custom_target(check-format ${SCRIPTS_DIR}/run-clang-format.sh ${CMAKE_CURRENT_SOURCE_DIR}/src ${CLANG_FORMAT_BIN} 0 - `find ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/test - -name \\*.cc -or -name \\*.c -or -name \\*.h`) -endif() - -############################################################ -# Set up the regular build (i.e. non-superbuild). -############################################################ - -ExternalProject_Add(libtiledbvcf - SOURCE_DIR ${PROJECT_SOURCE_DIR} - CMAKE_ARGS - -DSUPERBUILD=OFF - ${INHERITED_CMAKE_ARGS} - ${FORWARD_EP_CMAKE_ARGS} - INSTALL_COMMAND "" - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/libtiledbvcf - DEPENDS ${EXTERNAL_PROJECTS} -) - -# make install-libtiledbvcf -add_custom_target(install-libtiledbvcf - COMMAND ${CMAKE_COMMAND} --build . --target install --config ${CMAKE_BUILD_TYPE} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/libtiledbvcf -) - -# make check -add_custom_target(check - COMMAND ${CMAKE_COMMAND} --build . --target check --config ${CMAKE_BUILD_TYPE} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/libtiledbvcf -) diff --git a/libtiledbvcf/cmake/TileDBToolchain.cmake b/libtiledbvcf/cmake/TileDBToolchain.cmake new file mode 100644 index 000000000..3ab287ca4 --- /dev/null +++ b/libtiledbvcf/cmake/TileDBToolchain.cmake @@ -0,0 +1,84 @@ +# +# cmake/TileDBToolchain.cmake +# +# The MIT License +# +# Copyright (c) 2023 TileDB, Inc. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# +############################################################ +# TileDB Toolchain Setup +############################################################ + +if (NOT DEFINED CMAKE_TOOLCHAIN_FILE) + if(DEFINED ENV{VCPKG_ROOT}) + set(CMAKE_TOOLCHAIN_FILE + "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" + CACHE STRING "Vcpkg toolchain file") + elseif(NOT (DEFINED ENV{TILEDB_DISABLE_AUTO_VCPKG} OR TILEDB_DISABLE_AUTO_VCPKG)) + # Inspired from https://github.com/Azure/azure-sdk-for-cpp/blob/azure-core_1.10.3/cmake-modules/AzureVcpkg.cmake + message("TILEDB_DISABLE_AUTO_VCPKG is not defined. Fetch a local copy of vcpkg.") + # To help with resolving conflicts, when you update the commit, also update its date. + set(VCPKG_COMMIT_STRING b171feebd4f8b7943b56356f9ec1d4dbe44ab82f) # 2024-10-17 + message("Vcpkg commit string used: ${VCPKG_COMMIT_STRING}") + include(FetchContent) + FetchContent_Declare( + vcpkg + GIT_REPOSITORY https://github.com/microsoft/vcpkg.git + GIT_TAG ${VCPKG_COMMIT_STRING} + ) + FetchContent_MakeAvailable(vcpkg) + set(CMAKE_TOOLCHAIN_FILE "${vcpkg_SOURCE_DIR}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "Vcpkg toolchain file") + endif() +endif() + +if(TILEDB_SANITIZER STREQUAL "address") + if(NOT TILEDB_VCPKG_BASE_TRIPLET) + message(FATAL_ERROR "TILEDB_VCPKG_BASE_TRIPLET must be defined when building with ASAN.") + endif() + set(VCPKG_TARGET_TRIPLET "${TILEDB_VCPKG_BASE_TRIPLET}-asan") +endif() + +get_cmake_property(is_multi_config GENERATOR_IS_MULTI_CONFIG) +# On Windows vcpkg always builds dependencies with symbols. +# https://github.com/microsoft/vcpkg/blob/master/scripts/toolchains/windows.cmake +if(NOT WIN32 AND NOT is_multi_config AND CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" AND NOT VCPKG_TARGET_TRIPLET) + if(TILEDB_SANITIZER STREQUAL "address") + message(FATAL_ERROR "Cannot enable both RelWithDebInfo and ASAN at the same time.") + endif() + if(TILEDB_VCPKG_BASE_TRIPLET) + message(STATUS "Overriding vcpkg triplet to ${TILEDB_VCPKG_BASE_TRIPLET}-relwithdebinfo") + set(VCPKG_TARGET_TRIPLET "${TILEDB_VCPKG_BASE_TRIPLET}-relwithdebinfo") + else() + message(WARNING "Dependencies will be built without symbols. You have to set either VCPKG_TARGET_TRIPLET or TILEDB_VCPKG_BASE_TRIPLET.") + endif() +endif() + +set(VCPKG_INSTALL_OPTIONS "--no-print-usage") + +macro(tiledb_vcpkg_enable_if tiledb_feature vcpkg_feature) + if(${tiledb_feature}) + list(APPEND VCPKG_MANIFEST_FEATURES ${vcpkg_feature}) + endif() +endmacro() + +tiledb_vcpkg_enable_if(TILEDBVCF_ENABLE_TESTS "tests") + +message("Using vcpkg features: ${VCPKG_MANIFEST_FEATURES}") \ No newline at end of file diff --git a/libtiledbvcf/cmake/patches/cli11-2.1.0.patch b/libtiledbvcf/cmake/patches/cli11-2.1.0.patch deleted file mode 100644 index 3e7e88112..000000000 --- a/libtiledbvcf/cmake/patches/cli11-2.1.0.patch +++ /dev/null @@ -1,33 +0,0 @@ -diff --git a/CLI11.hpp b/CLI11.hpp -index e6c3f6d..e42abad 100644 ---- a/CLI11.hpp -+++ b/CLI11.hpp -@@ -8829,8 +8829,8 @@ inline std::string Formatter::make_groups(const App *app, AppFormatMode mode) co - if(!group.empty() && !opts.empty()) { - out << make_group(group, false, opts); - -- if(group != groups.back()) -- out << "\n"; -+ //if(group != groups.back()) -+ // out << "\n"; - } - } - -@@ -8838,7 +8838,7 @@ inline std::string Formatter::make_groups(const App *app, AppFormatMode mode) co - } - - inline std::string Formatter::make_description(const App *app) const { -- std::string desc = app->get_description(); -+ std::string desc = "\n" + app->get_description(); - auto min_options = app->get_require_option_min(); - auto max_options = app->get_require_option_max(); - if(app->get_required()) { -@@ -8860,7 +8860,7 @@ inline std::string Formatter::make_description(const App *app) const { - } else if(min_options > 0) { - desc += " \n[At least " + std::to_string(min_options) + " of the following options are required]"; - } -- return (!desc.empty()) ? desc + "\n" : std::string{}; -+ return (!desc.empty()) ? desc + "\n\n" : std::string{}; - } - - inline std::string Formatter::make_usage(const App *app, std::string name) const { diff --git a/libtiledbvcf/cmake/patches/htslib-1.10-config.patch b/libtiledbvcf/cmake/patches/htslib-1.10-config.patch deleted file mode 100644 index 2c6e7443d..000000000 --- a/libtiledbvcf/cmake/patches/htslib-1.10-config.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 6821fc8ed88706e9282b561e74dfa45dac4d74c8 Mon Sep 17 00:00:00 2001 -From: John Marshall -Date: Fri, 1 Jan 2021 10:37:22 +0000 -Subject: [PATCH] Don't set $host_alias as that confuses autoconf 2.70 - -Autoconf 2.70 is more careful about cross compilation, so with this -version using AC_FUNC_MMAP implies AC_CANONICAL_HOST and hence computes -$build/build_alias/host/host_alias/etc. Setting $host_alias ourselves -interferes with that. Hat tip Matthias Klose (via debbug#978835). - -As autoconf 2.70 implicitly uses AC_CANONICAL_HOST, it requires (and its -autoreconf --install installs) config.guess and config.sub. Ignore those, -and ignore install-sh as well for good measure. ---- -diff --git a/configure.ac b/configure.ac -index 9bd1642d7..f473c97e5 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -137,9 +137,9 @@ AC_ARG_ENABLE([s3], - [support Amazon AWS S3 URLs])], - [], [enable_s3=check]) - --test -n "$host_alias" || host_alias=unknown-`uname -s` --AC_MSG_CHECKING([shared library type for $host_alias]) --case $host_alias in -+basic_host=${host_alias:-unknown-`uname -s`} -+AC_MSG_CHECKING([shared library type for $basic_host]) -+case $basic_host in - *-cygwin* | *-CYGWIN*) - host_result="Cygwin DLL" - PLATFORM=CYGWIN diff --git a/libtiledbvcf/ports/README.md b/libtiledbvcf/ports/README.md new file mode 100644 index 000000000..e0da49eb6 --- /dev/null +++ b/libtiledbvcf/ports/README.md @@ -0,0 +1,35 @@ +# Port Overlays + +This directory contains the custom vcpkg port overlays we're using for building dependencies. + +## Adding a Port + +> [!IMPORTANT] +> Port overlays should be used as a temporary measure to fix issues with upstream ports or to add new ports that are not yet available to vcpkg. Once the upstream ports are fixed or added, the overlay ports should be removed. + +If modifying an existing port, you have to first determine the version of the port in the `microsoft/vcpkg` repository and extract it using a tool. If the port does not have a version pin in the [`vcpkg.json`](../vcpkg.json) manifest (in either a `version>=` field or an entry in the `overrides` section), browse the `microsoft/vcpkg` repository in the commit specified in the `builtin-baseline` field and copy the port directory from there. + +If the port does have a version pin, and for instance we wanted to modify the curl port, which is in version 8.4.0, we would look in the [`versions/c-/curl.json` file](https://github.com/microsoft/vcpkg/blob/master/versions/c-/curl.json) and find the treeish listed for 8.4.0. One thing to pay attention to here is that there can be multiple port versions for a given dependency version. So we want to pick the highest port version for the dependency at the version we are upgrading. In our hypothetical curl case that I may have just done, this gives us a treeish value of: + + `6125c796d6e2913a89a2996d7082375ce16b02dd` + +Once we have the tree-ish, we just need to be able to extract all of the files and store them in our overlay ports directory. The easiest approach for this is to use something like [this script](https://gist.github.com/mhl/498447/b245d48f2a22301415a30ca8a68241f96e0b3861) to do just that. If you put that script on your path (and remember to `chmod +x path/to/extract-tree-from-git.py`) you can follow these simple steps for updating the port: + +```bash +$ rm ports/curl/* +$ cd path/to/microsoft/vcpkg +$ extract-tree-from-git.py 6125c796d6e2913a89a2996d7082375ce16b02dd path/to/tiledb/ports/curl/ +$ cd path/to/tiledb-vcf +$ git add ports +$ git commit +``` + +After copying the port, add an entry to the table below. You should also contribute your changes to vcpkg and/or the upstream package repository. + +For ease of review when patching existing ports, you are recommended to make one commit that copies the upstream port unchanged, and another commit that makes the changes you need. + +## List of port overlays + +| Port | Reason | +|----------|--------------------------------------------------------------------------------------------------| +| `htslib` | Patching to fix failures when statically linking. (https://github.com/awslabs/aws-c-io/pull/664) | diff --git a/libtiledbvcf/ports/htslib/0001-set-linkage.patch b/libtiledbvcf/ports/htslib/0001-set-linkage.patch new file mode 100644 index 000000000..d28886a80 --- /dev/null +++ b/libtiledbvcf/ports/htslib/0001-set-linkage.patch @@ -0,0 +1,26 @@ +diff --git a/Makefile b/Makefile +index 99142c8..97cd369 100644 +--- a/Makefile ++++ b/Makefile +@@ -857,15 +857,19 @@ $(srcprefix)htslib.map: libhts.so + rm -f $@.tmp ; \ + fi + +-install: libhts.a $(BUILT_PROGRAMS) $(BUILT_PLUGINS) installdirs install-$(SHLIB_FLAVOUR) install-pkgconfig ++install: $(BUILT_PROGRAMS) $(BUILT_PLUGINS) installdirs install-pkgconfig + $(INSTALL_PROGRAM) $(BUILT_PROGRAMS) $(DESTDIR)$(bindir) + if test -n "$(BUILT_PLUGINS)"; then $(INSTALL_PROGRAM) $(BUILT_PLUGINS) $(DESTDIR)$(plugindir); fi + $(INSTALL_DATA) $(SRC)htslib/*.h $(DESTDIR)$(includedir)/htslib +- $(INSTALL_DATA) libhts.a $(DESTDIR)$(libdir)/libhts.a + $(INSTALL_MAN) $(SRC)annot-tsv.1 $(SRC)bgzip.1 $(SRC)htsfile.1 $(SRC)tabix.1 $(DESTDIR)$(man1dir) + $(INSTALL_MAN) $(SRC)faidx.5 $(SRC)sam.5 $(SRC)vcf.5 $(DESTDIR)$(man5dir) + $(INSTALL_MAN) $(SRC)htslib-s3-plugin.7 $(DESTDIR)$(man7dir) + ++install-static: install ++ $(INSTALL_DATA) libhts.a $(DESTDIR)$(libdir)/libhts.a ++ ++install-dynamic: install install-$(SHLIB_FLAVOUR) ++ + installdirs: + $(INSTALL_DIR) $(DESTDIR)$(bindir) $(DESTDIR)$(includedir) $(DESTDIR)$(includedir)/htslib $(DESTDIR)$(libdir) $(DESTDIR)$(man1dir) $(DESTDIR)$(man5dir) $(DESTDIR)$(man7dir) $(DESTDIR)$(pkgconfigdir) + if test -n "$(plugindir)"; then $(INSTALL_DIR) $(DESTDIR)$(plugindir); fi diff --git a/libtiledbvcf/ports/htslib/0002-pthread-flag.patch b/libtiledbvcf/ports/htslib/0002-pthread-flag.patch new file mode 100644 index 000000000..7318c8984 --- /dev/null +++ b/libtiledbvcf/ports/htslib/0002-pthread-flag.patch @@ -0,0 +1,78 @@ +diff --git a/Makefile b/Makefile +index f6e154f..fb4f527 100644 +--- a/Makefile ++++ b/Makefile +@@ -137,6 +137,8 @@ HTS_BUILD_AVX2 = + HTS_BUILD_AVX512 = + HTS_BUILD_SSE4 = + ++PTHREAD = -pthread ++ + include htslib_vars.mk + include htscodecs.mk + +@@ -183,10 +185,10 @@ config_vars.h: + .SUFFIXES: .bundle .c .cygdll .dll .o .pico .so + + .c.o: +- $(CC) $(CFLAGS) $(TARGET_CFLAGS) $(ALL_CPPFLAGS) -c -o $@ $< ++ $(CC) $(CFLAGS) $(TARGET_CFLAGS) $(ALL_CPPFLAGS) $(PTHREAD) -c -o $@ $< + + .c.pico: +- $(CC) $(CFLAGS) $(TARGET_CFLAGS) $(ALL_CPPFLAGS) $(EXTRA_CFLAGS_PIC) -c -o $@ $< ++ $(CC) $(CFLAGS) $(TARGET_CFLAGS) $(ALL_CPPFLAGS) $(PTHREAD) $(EXTRA_CFLAGS_PIC) -c -o $@ $< + + + LIBHTS_OBJS = \ +@@ -358,7 +360,7 @@ print-config: + # file used at runtime (when $LD_LIBRARY_PATH includes the build directory). + + libhts.so: $(LIBHTS_OBJS:.o=.pico) +- $(CC) -shared -Wl,-soname,libhts.so.$(LIBHTS_SOVERSION) $(VERSION_SCRIPT_LDFLAGS) $(LDFLAGS) -o $@ $(LIBHTS_OBJS:.o=.pico) $(LIBS) -lpthread ++ $(CC) -shared -Wl,-soname,libhts.so.$(LIBHTS_SOVERSION) $(VERSION_SCRIPT_LDFLAGS) $(LDFLAGS) -o $@ $(LIBHTS_OBJS:.o=.pico) $(LIBS) $(PTHREAD) + ln -sf $@ libhts.so.$(LIBHTS_SOVERSION) + + # Similarly this also creates libhts.NN.dylib as a byproduct, so that programs +@@ -370,10 +372,10 @@ libhts.dylib: $(LIBHTS_OBJS) + ln -sf $@ libhts.$(LIBHTS_SOVERSION).dylib + + cyghts-$(LIBHTS_SOVERSION).dll libhts.dll.a: $(LIBHTS_OBJS) +- $(CC) -shared -Wl,--out-implib=libhts.dll.a -Wl,--enable-auto-import $(LDFLAGS) -o $@ -Wl,--whole-archive $(LIBHTS_OBJS) -Wl,--no-whole-archive $(LIBS) -lpthread ++ $(CC) -shared -Wl,--out-implib=libhts.dll.a -Wl,--enable-auto-import $(LDFLAGS) -o $@ -Wl,--whole-archive $(LIBHTS_OBJS) -Wl,--no-whole-archive $(LIBS) $(PTHREAD) + + hts-$(LIBHTS_SOVERSION).dll hts.dll.a: $(LIBHTS_OBJS) +- $(CC) -shared -Wl,--out-implib=hts.dll.a -Wl,--enable-auto-import -Wl,--exclude-all-symbols $(LDFLAGS) -o $@ -Wl,--whole-archive $(LIBHTS_OBJS) -Wl,--no-whole-archive $(LIBS) -lpthread ++ $(CC) -shared -Wl,--out-implib=hts.dll.a -Wl,--enable-auto-import -Wl,--exclude-all-symbols $(LDFLAGS) -o $@ -Wl,--whole-archive $(LIBHTS_OBJS) -Wl,--no-whole-archive $(LIBS) $(PTHREAD) + + hts-$(LIBHTS_SOVERSION).def: hts-$(LIBHTS_SOVERSION).dll + gendef hts-$(LIBHTS_SOVERSION).dll +@@ -420,7 +422,7 @@ hts-object-files: $(LIBHTS_OBJS) + # may not be able to access libhts symbols via the main program's libhts + # if that was dynamically loaded without an explicit RTLD_GLOBAL. + %.so: %.pico libhts.so +- $(CC) -shared -Wl,-E $(LDFLAGS) -o $@ $< libhts.so $(LIBS) -lpthread ++ $(CC) -shared -Wl,-E $(LDFLAGS) -o $@ $< libhts.so $(LIBS) $(PTHREAD) + + # For programs *statically* linked to libhts.a, on macOS loading a plugin + # linked to a shared libhts.NN.dylib would lead to conflicting duplicate +@@ -501,16 +503,16 @@ htscodecs/htscodecs/rANS_static32x16pr_avx512.o htscodecs/htscodecs/rANS_static3 + htscodecs/htscodecs/rANS_static32x16pr_sse4.o htscodecs/htscodecs/rANS_static32x16pr_sse4.pico: TARGET_CFLAGS = $(HTS_CFLAGS_SSE4) + + annot-tsv: annot-tsv.o libhts.a +- $(CC) $(LDFLAGS) -o $@ annot-tsv.o libhts.a $(LIBS) -lpthread ++ $(CC) $(LDFLAGS) -o $@ annot-tsv.o libhts.a $(LIBS) $(PTHREAD) + + bgzip: bgzip.o libhts.a +- $(CC) $(LDFLAGS) -o $@ bgzip.o libhts.a $(LIBS) -lpthread ++ $(CC) $(LDFLAGS) -o $@ bgzip.o libhts.a $(LIBS) $(PTHREAD) + + htsfile: htsfile.o libhts.a +- $(CC) $(LDFLAGS) -o $@ htsfile.o libhts.a $(LIBS) -lpthread ++ $(CC) $(LDFLAGS) -o $@ htsfile.o libhts.a $(LIBS) $(PTHREAD) + + tabix: tabix.o libhts.a +- $(CC) $(LDFLAGS) -o $@ tabix.o libhts.a $(LIBS) -lpthread ++ $(CC) $(LDFLAGS) -o $@ tabix.o libhts.a $(LIBS) $(PTHREAD) + + annot-tsv.o: annot-tsv.c config.h $(htslib_hts_h) $(htslib_hts_defs_h) $(htslib_khash_str2int_h) $(htslib_kstring_h) $(htslib_kseq_h) $(htslib_bgzf_h) $(htslib_regidx_h) + bgzip.o: bgzip.c config.h $(htslib_bgzf_h) $(htslib_hts_h) $(htslib_hfile_h) diff --git a/libtiledbvcf/ports/htslib/0003-no-tests.patch b/libtiledbvcf/ports/htslib/0003-no-tests.patch new file mode 100644 index 000000000..9c4a9f993 --- /dev/null +++ b/libtiledbvcf/ports/htslib/0003-no-tests.patch @@ -0,0 +1,13 @@ +diff --git a/Makefile b/Makefile +index fb4f527..751df4b 100644 +--- a/Makefile ++++ b/Makefile +@@ -111,7 +111,7 @@ BUILT_THRASH_PROGRAMS = \ + test/thrash_threads6 \ + test/thrash_threads7 + +-all: lib-static lib-shared $(BUILT_PROGRAMS) plugins $(BUILT_TEST_PROGRAMS) \ ++all: lib-static lib-shared $(BUILT_PROGRAMS) plugins \ + htslib_static.mk htslib-uninstalled.pc + + ALL_CPPFLAGS = -I. $(CPPFLAGS) diff --git a/libtiledbvcf/ports/htslib/0004-fix-find-htscodecs.patch b/libtiledbvcf/ports/htslib/0004-fix-find-htscodecs.patch new file mode 100644 index 000000000..4fc6e2d7a --- /dev/null +++ b/libtiledbvcf/ports/htslib/0004-fix-find-htscodecs.patch @@ -0,0 +1,22 @@ +diff --git a/configure.ac b/configure.ac +index 49f2cbc..434086f 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -156,7 +156,7 @@ m4_ifdef([PKG_PROG_PKG_CONFIG], [PKG_PROG_PKG_CONFIG], [PKG_CONFIG=""]) + need_crypto=no + pc_requires= + static_LDFLAGS=$LDFLAGS +-static_LIBS='-lpthread -lz -lm' ++static_LIBS='-pthread -lz -lm' + private_LIBS=$LDFLAGS + + AC_ARG_ENABLE([versioned-symbols], +@@ -404,7 +404,7 @@ AS_IF([test "x$with_external_htscodecs" != "xno"], + AC_CHECK_HEADER([htscodecs/rANS_static4x16.h],[], + [libhtscodecs='missing header'],[;]) + AC_CHECK_LIB([htscodecs],[rans_compress_bound_4x16], +- [:],[libhtscodecs='missing library']) ++ [:],[libhtscodecs='missing library'], ["$static_LIBS"]) + AS_IF([test "$libhtscodecs" = "ok"], + [AC_DEFINE([HAVE_EXTERNAL_LIBHTSCODECS], 1, [Define if using an external libhtscodecs]) + LIBS="-lhtscodecs $LIBS" diff --git a/libtiledbvcf/ports/htslib/0005-remove-duplicate-lhts.patch b/libtiledbvcf/ports/htslib/0005-remove-duplicate-lhts.patch new file mode 100644 index 000000000..c040e9b61 --- /dev/null +++ b/libtiledbvcf/ports/htslib/0005-remove-duplicate-lhts.patch @@ -0,0 +1,11 @@ +diff --git a/htslib.pc.in b/htslib.pc.in +index d969d6b..fdeeba9 100644 +--- a/htslib.pc.in ++++ b/htslib.pc.in +@@ -11,5 +11,5 @@ Description: C library for high-throughput sequencing data formats + Version: @-PACKAGE_VERSION@ + Cflags: -I${includedir} + Libs: -L${libdir} -lhts +-Libs.private: -L${libdir} @private_LIBS@ -lhts -lm -lpthread ++Libs.private: -L${libdir} @private_LIBS@ -lm -lpthread + Requires.private: zlib @pc_requires@ diff --git a/libtiledbvcf/ports/htslib/portfile.cmake b/libtiledbvcf/ports/htslib/portfile.cmake new file mode 100644 index 000000000..346742875 --- /dev/null +++ b/libtiledbvcf/ports/htslib/portfile.cmake @@ -0,0 +1,54 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO samtools/htslib + REF "${VERSION}" + SHA512 b9de3769db6153f66348c7c4ffbfc5ac7cd4a4d4450c9d1c5ea8fdd8f4f9d38d1d0ba5b4ac9c53f1a754d3985dc483fe22e76f93a8bbe8ae29ef3b98136e7d2e + HEAD_REF develop + PATCHES + 0001-set-linkage.patch + 0002-pthread-flag.patch + 0003-no-tests.patch + 0004-fix-find-htscodecs.patch + 0005-remove-duplicate-lhts.patch +) + +set(FEATURE_OPTIONS "") + +macro(enable_feature feature switch) + if("${feature}" IN_LIST FEATURES) + list(APPEND FEATURE_OPTIONS "--enable-${switch}") + else() + list(APPEND FEATURE_OPTIONS "--disable-${switch}") + endif() +endmacro() + +enable_feature("bzip2" "bz2") +enable_feature("lzma" "lzma") + +if("deflate" IN_LIST FEATURES) + list(APPEND FEATURE_OPTIONS "--with-libdeflate") +else() + list(APPEND FEATURE_OPTIONS "--without-libdeflate") +endif() + +vcpkg_configure_make( + AUTOCONFIG + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + --with-external-htscodecs + --disable-libcurl + --disable-gcs + --disable-s3 + --disable-plugins + ${FEATURE_OPTIONS} +) + +vcpkg_install_make( + INSTALL_TARGET install-${VCPKG_LIBRARY_LINKAGE} +) + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") + +vcpkg_fixup_pkgconfig() + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") diff --git a/libtiledbvcf/ports/htslib/vcpkg.json b/libtiledbvcf/ports/htslib/vcpkg.json new file mode 100644 index 000000000..c271cbe17 --- /dev/null +++ b/libtiledbvcf/ports/htslib/vcpkg.json @@ -0,0 +1,32 @@ +{ + "name": "htslib", + "version": "1.20", + "description": "C library for high-throughput sequencing data formats", + "homepage": "https://github.com/samtools/htslib", + "license": "MIT", + "supports": "!windows", + "dependencies": [ + "htscodecs", + "zlib" + ], + "features": { + "bzip2": { + "description": "Enable support for BZ2-compressed CRAM files", + "dependencies": [ + "bzip2" + ] + }, + "deflate": { + "description": "Use libdeflate for faster crc and deflate algorithms", + "dependencies": [ + "libdeflate" + ] + }, + "lzma": { + "description": "Enable support for LZMA-compressed CRAM files", + "dependencies": [ + "liblzma" + ] + } + } +} diff --git a/libtiledbvcf/src/CMakeLists.txt b/libtiledbvcf/src/CMakeLists.txt index 1b3ceca9f..37ae9131b 100644 --- a/libtiledbvcf/src/CMakeLists.txt +++ b/libtiledbvcf/src/CMakeLists.txt @@ -1,42 +1,33 @@ -message(STATUS "Starting TileDB-VCF build.") - -############################################################ -# Find required dependencies -############################################################ - -find_package(CLI11 REQUIRED) -find_package(HTSlib REQUIRED) -find_package(Spdlog REQUIRED) -find_package(TileDB_EP REQUIRED) - ############################################################ # Get source commit hash ############################################################ +# TODO: This won't work in sdist + find_package(Git REQUIRED) execute_process( - COMMAND "${GIT_EXECUTABLE}" describe --exact-match --tags HEAD - WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" - RESULT_VARIABLE res - OUTPUT_VARIABLE BUILD_COMMIT_HASH - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) + COMMAND "${GIT_EXECUTABLE}" describe --exact-match --tags HEAD + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + RESULT_VARIABLE res + OUTPUT_VARIABLE BUILD_COMMIT_HASH + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) # If we didn't find a tag name let's grab the SHA if (res) execute_process( - COMMAND "${GIT_EXECUTABLE}" describe --dirty=-modified --always - WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" - RESULT_VARIABLE res - OUTPUT_VARIABLE BUILD_COMMIT_HASH - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) + COMMAND "${GIT_EXECUTABLE}" describe --dirty=-modified --always + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + RESULT_VARIABLE res + OUTPUT_VARIABLE BUILD_COMMIT_HASH + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) endif() set_property(GLOBAL APPEND - PROPERTY CMAKE_CONFIGURE_DEPENDS - "${CMAKE_SOURCE_DIR}/.git/index") + PROPERTY CMAKE_CONFIGURE_DEPENDS + "${CMAKE_SOURCE_DIR}/.git/index") message(STATUS "Building with commit hash ${BUILD_COMMIT_HASH}") @@ -45,77 +36,97 @@ message(STATUS "Building with commit hash ${BUILD_COMMIT_HASH}") ############################################################ set(TILEDB_VCF_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/c_api/tiledbvcf.cc - ${CMAKE_CURRENT_SOURCE_DIR}/dataset/attribute_buffer_set.cc - ${CMAKE_CURRENT_SOURCE_DIR}/dataset/tiledbvcfdataset.cc - ${CMAKE_CURRENT_SOURCE_DIR}/htslib_plugin/hfile_tiledb_vfs.c - ${CMAKE_CURRENT_SOURCE_DIR}/read/bcf_exporter.cc - ${CMAKE_CURRENT_SOURCE_DIR}/read/delete_exporter.cc - ${CMAKE_CURRENT_SOURCE_DIR}/read/exporter.cc - ${CMAKE_CURRENT_SOURCE_DIR}/read/in_memory_exporter.cc - ${CMAKE_CURRENT_SOURCE_DIR}/read/pvcf_exporter.cc - ${CMAKE_CURRENT_SOURCE_DIR}/read/read_query_results.cc - ${CMAKE_CURRENT_SOURCE_DIR}/read/reader.cc - ${CMAKE_CURRENT_SOURCE_DIR}/read/tsv_exporter.cc - ${CMAKE_CURRENT_SOURCE_DIR}/stats/array_buffers.cc - ${CMAKE_CURRENT_SOURCE_DIR}/stats/arrow_adapter.cc - ${CMAKE_CURRENT_SOURCE_DIR}/stats/allele_count.cc - ${CMAKE_CURRENT_SOURCE_DIR}/stats/column_buffer.cc - ${CMAKE_CURRENT_SOURCE_DIR}/stats/managed_query.cc - ${CMAKE_CURRENT_SOURCE_DIR}/stats/sample_stats.cc - ${CMAKE_CURRENT_SOURCE_DIR}/stats/variant_stats.cc - ${CMAKE_CURRENT_SOURCE_DIR}/stats/variant_stats_reader.cc - ${CMAKE_CURRENT_SOURCE_DIR}/utils/bitmap.cc - ${CMAKE_CURRENT_SOURCE_DIR}/utils/buffer.cc - ${CMAKE_CURRENT_SOURCE_DIR}/utils/logger.cc - ${CMAKE_CURRENT_SOURCE_DIR}/utils/normalize.cc - ${CMAKE_CURRENT_SOURCE_DIR}/utils/sample_utils.cc - ${CMAKE_CURRENT_SOURCE_DIR}/utils/utils.cc - ${CMAKE_CURRENT_SOURCE_DIR}/vcf/bed_file.cc - ${CMAKE_CURRENT_SOURCE_DIR}/vcf/region.cc - ${CMAKE_CURRENT_SOURCE_DIR}/vcf/vcf_merger.cc - ${CMAKE_CURRENT_SOURCE_DIR}/vcf/vcf_utils.cc - ${CMAKE_CURRENT_SOURCE_DIR}/vcf/vcf_v2.cc - ${CMAKE_CURRENT_SOURCE_DIR}/vcf/vcf_v3.cc - ${CMAKE_CURRENT_SOURCE_DIR}/vcf/vcf_v4.cc - ${CMAKE_CURRENT_SOURCE_DIR}/write/record_heap_v2.cc - ${CMAKE_CURRENT_SOURCE_DIR}/write/record_heap_v3.cc - ${CMAKE_CURRENT_SOURCE_DIR}/write/record_heap_v4.cc - ${CMAKE_CURRENT_SOURCE_DIR}/write/writer_worker_v2.cc - ${CMAKE_CURRENT_SOURCE_DIR}/write/writer_worker_v3.cc - ${CMAKE_CURRENT_SOURCE_DIR}/write/writer_worker_v4.cc - ${CMAKE_CURRENT_SOURCE_DIR}/write/writer.cc + ${CMAKE_CURRENT_SOURCE_DIR}/c_api/tiledbvcf.cc + ${CMAKE_CURRENT_SOURCE_DIR}/dataset/attribute_buffer_set.cc + ${CMAKE_CURRENT_SOURCE_DIR}/dataset/tiledbvcfdataset.cc + ${CMAKE_CURRENT_SOURCE_DIR}/htslib_plugin/hfile_tiledb_vfs.c + ${CMAKE_CURRENT_SOURCE_DIR}/read/bcf_exporter.cc + ${CMAKE_CURRENT_SOURCE_DIR}/read/delete_exporter.cc + ${CMAKE_CURRENT_SOURCE_DIR}/read/exporter.cc + ${CMAKE_CURRENT_SOURCE_DIR}/read/in_memory_exporter.cc + ${CMAKE_CURRENT_SOURCE_DIR}/read/pvcf_exporter.cc + ${CMAKE_CURRENT_SOURCE_DIR}/read/read_query_results.cc + ${CMAKE_CURRENT_SOURCE_DIR}/read/reader.cc + ${CMAKE_CURRENT_SOURCE_DIR}/read/tsv_exporter.cc + ${CMAKE_CURRENT_SOURCE_DIR}/stats/array_buffers.cc + ${CMAKE_CURRENT_SOURCE_DIR}/stats/arrow_adapter.cc + ${CMAKE_CURRENT_SOURCE_DIR}/stats/allele_count.cc + ${CMAKE_CURRENT_SOURCE_DIR}/stats/column_buffer.cc + ${CMAKE_CURRENT_SOURCE_DIR}/stats/managed_query.cc + ${CMAKE_CURRENT_SOURCE_DIR}/stats/sample_stats.cc + ${CMAKE_CURRENT_SOURCE_DIR}/stats/variant_stats.cc + ${CMAKE_CURRENT_SOURCE_DIR}/stats/variant_stats_reader.cc + ${CMAKE_CURRENT_SOURCE_DIR}/utils/bitmap.cc + ${CMAKE_CURRENT_SOURCE_DIR}/utils/buffer.cc + ${CMAKE_CURRENT_SOURCE_DIR}/utils/logger.cc + ${CMAKE_CURRENT_SOURCE_DIR}/utils/normalize.cc + ${CMAKE_CURRENT_SOURCE_DIR}/utils/sample_utils.cc + ${CMAKE_CURRENT_SOURCE_DIR}/utils/utils.cc + ${CMAKE_CURRENT_SOURCE_DIR}/vcf/bed_file.cc + ${CMAKE_CURRENT_SOURCE_DIR}/vcf/region.cc + ${CMAKE_CURRENT_SOURCE_DIR}/vcf/vcf_merger.cc + ${CMAKE_CURRENT_SOURCE_DIR}/vcf/vcf_utils.cc + ${CMAKE_CURRENT_SOURCE_DIR}/vcf/vcf_v2.cc + ${CMAKE_CURRENT_SOURCE_DIR}/vcf/vcf_v3.cc + ${CMAKE_CURRENT_SOURCE_DIR}/vcf/vcf_v4.cc + ${CMAKE_CURRENT_SOURCE_DIR}/write/record_heap_v2.cc + ${CMAKE_CURRENT_SOURCE_DIR}/write/record_heap_v3.cc + ${CMAKE_CURRENT_SOURCE_DIR}/write/record_heap_v4.cc + ${CMAKE_CURRENT_SOURCE_DIR}/write/writer_worker_v2.cc + ${CMAKE_CURRENT_SOURCE_DIR}/write/writer_worker_v3.cc + ${CMAKE_CURRENT_SOURCE_DIR}/write/writer_worker_v4.cc + ${CMAKE_CURRENT_SOURCE_DIR}/write/writer.cc ) set(TILEDB_VCF_EXTERNAL_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/../external/base64/base64.cc + ${CMAKE_CURRENT_SOURCE_DIR}/../external/base64/base64.cc ) -add_library(TILEDB_VCF_OBJECTS OBJECT - ${TILEDB_VCF_SOURCES} - ${TILEDB_VCF_EXTERNAL_SOURCES} +file(GLOB_RECURSE TILEDB_VCF_HEADERS CONFIGURE_DEPENDS *.h) + +add_library( + tiledbvcf + ${TILEDB_VCF_SOURCES} + ${TILEDB_VCF_EXTERNAL_SOURCES} ) -set_property(TARGET TILEDB_VCF_OBJECTS PROPERTY POSITION_INDEPENDENT_CODE ON) +target_sources( + tiledbvcf + PUBLIC FILE_SET HEADERS + BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} + FILES ${TILEDB_VCF_HEADERS} +) -target_include_directories(TILEDB_VCF_OBJECTS - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/../external - ${CMAKE_CURRENT_SOURCE_DIR} - $ - $ - $ +set_property(TARGET tiledbvcf PROPERTY POSITION_INDEPENDENT_CODE ON) + +target_compile_features(tiledbvcf PUBLIC cxx_std_20) + +target_include_directories( + tiledbvcf + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/../external + ${CMAKE_CURRENT_SOURCE_DIR} +) + +target_link_libraries( + tiledbvcf + PUBLIC + HTSlib::HTSlib + TileDB::tiledb_shared + spdlog::spdlog ) -target_compile_definitions(TILEDB_VCF_OBJECTS PRIVATE - -DBUILD_COMMIT_HASH="${BUILD_COMMIT_HASH}" +target_compile_definitions( + tiledbvcf + PRIVATE + -DBUILD_COMMIT_HASH="${BUILD_COMMIT_HASH}" ) ############################################################ # Compile options/definitions ############################################################ if (SANITIZER) - string( TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER ) + string( TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER) if (NOT CMAKE_BUILD_TYPE_LOWER MATCHES "debug") message(FATAL_ERROR "Sanitizers only enabled for Debug build") endif() @@ -125,84 +136,57 @@ if (SANITIZER) else() message(STATUS "The TileDB-VCF library is compiled with sanitizer ${SANITIZER} enabled") endif() - target_compile_options(TILEDB_VCF_OBJECTS + target_compile_options(tiledbvcf PRIVATE -g -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize=${SANITIZER} - ) -endif() - -############################################################ -# tiledbvcf library target -############################################################ - -add_library(tiledbvcf SHARED - $ -) -if (WIN32) - # tiledb_vcf_unit ref's symbols that are not explicitly part of the exported public interface. - # Since Windows/MSVC does not make all symbols in a shared library visible, - # Use a cmake feature on a target specifically for tiledb_vcf_unit to export all symbols. - add_library(tiledbvcf4test SHARED - $ ) - set_property(TARGET tiledbvcf4test PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON) endif() -if(!WIN32) - target_link_libraries(tiledbvcf - PUBLIC - HTSlib::HTSlib - TileDB::tiledb_shared - spdlog::spdlog - ) -else() - target_link_libraries(tiledbvcf - PUBLIC - HTSlib::HTSlib - TileDB::tiledb_shared - # spdlog is somehow building under tiledbvcf using HEADER_ONLY source code paths, - # which results in multiply defined symbols being complained about by the msvc linker. - # tiledbvcf does not seem to be -requesting- ...HEADER_ONLY anywhere I've found and spdlog -default- - # build mode is supposed to be ...COMPILED_LIB, but something is interfering somewhere. - # spdlog::spdlog - ) -endif() - -if (WIN32) -target_link_libraries(tiledbvcf4test - PUBLIC - HTSlib::HTSlib - TileDB::tiledb_shared +target_include_directories( + tiledbvcf + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/c_api + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} ) -endif() # Sanitizer linker flags if (SANITIZER) - target_link_libraries(tiledbvcf + target_link_libraries( + tiledbvcf INTERFACE -fsanitize=${SANITIZER} - ) + ) if (WIN32) - target_link_libraries(tiledbvcf4test - INTERFACE - -fsanitize=${SANITIZER} - ) + target_link_libraries( + tiledbvcf4test + INTERFACE + -fsanitize=${SANITIZER} + ) endif() endif() # List of API headers (to be installed) -set(TILEDB_VCF_PUBLIC_HEADERS - ${CMAKE_CURRENT_SOURCE_DIR}/c_api/tiledbvcf.h - ${CMAKE_CURRENT_SOURCE_DIR}/c_api/tiledbvcf_enum.h +set( + TILEDB_VCF_PUBLIC_HEADERS + ${CMAKE_CURRENT_SOURCE_DIR}/c_api/tiledbvcf.h + ${CMAKE_CURRENT_SOURCE_DIR}/c_api/tiledbvcf_enum.h ) ############################################################ # CLI executable target ############################################################ -add_executable(tiledbvcf-bin - $ - ${CMAKE_CURRENT_SOURCE_DIR}/cli/tiledbvcf.cc +add_executable( + tiledbvcf-bin + ${CMAKE_CURRENT_SOURCE_DIR}/cli/tiledbvcf.cc +) + +target_link_libraries( + tiledbvcf-bin + PUBLIC + tiledbvcf + CLI11::CLI11 ) if (WIN32) @@ -211,44 +195,24 @@ else() set_target_properties(tiledbvcf-bin PROPERTIES OUTPUT_NAME tiledbvcf) endif() -if(!WIN32) - target_link_libraries(tiledbvcf-bin - PUBLIC - CLI11::CLI11 - HTSlib::HTSlib - TileDB::tiledb_shared - spdlog::spdlog - ) -else() - target_link_libraries(tiledbvcf-bin - PUBLIC - CLI11::CLI11 - HTSlib::HTSlib - TileDB::tiledb_shared - # spdlog is somehow building under tiledbvcf using HEADER_ONLY source code paths, - # which results in multiply defined symbols being complained about by the msvc linker. - # tiledbvcf does not seem to be -requesting- ...HEADER_ONLY anywhere I've found and spdlog -default- - # build mode is supposed to be ...COMPILED_LIB, but something is interfering somewhere. - # spdlog::spdlog - ) -endif() - # Sanitizer linker flags if (SANITIZER) - target_link_libraries(tiledbvcf-bin + target_link_libraries( + tiledbvcf-bin INTERFACE -fsanitize=${SANITIZER} - ) + ) endif() if (NOT APPLE AND NOT WIN32) target_link_libraries(tiledbvcf-bin PRIVATE pthread) endif() -target_include_directories(tiledbvcf-bin - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/../external +target_include_directories( + tiledbvcf-bin + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/../external ) ############################################################ @@ -258,8 +222,9 @@ target_include_directories(tiledbvcf-bin include(GenerateExportHeader) # Generates the file 'tiledbvcf_export.h' suitable for the current compiler. -generate_export_header(TILEDB_VCF_OBJECTS - BASE_NAME tiledbvcf +generate_export_header( + tiledbvcf + BASE_NAME tiledbvcf ) # Set variables in the parent scope so the tests can reference it. @@ -269,74 +234,61 @@ set(TILEDB_VCF_EXPORT_HEADER "${CMAKE_CURRENT_BINARY_DIR}/tiledbvcf_export.h") set(TILEDB_VCF_EXPORT_HEADER "${TILEDB_VCF_EXPORT_HEADER}" PARENT_SCOPE) # Set related compiler settings -target_compile_definitions(TILEDB_VCF_OBJECTS PRIVATE -DTILEDB_VCF_OBJECTS_EXPORTS) -target_include_directories(TILEDB_VCF_OBJECTS PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +#target_compile_definitions(TILEDB_VCF_OBJECTS PRIVATE -DTILEDB_VCF_OBJECTS_EXPORTS) +#target_include_directories(TILEDB_VCF_OBJECTS PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) target_include_directories(tiledbvcf-bin PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) # Add the generated header to the public headers list list(APPEND TILEDB_VCF_PUBLIC_HEADERS - "${TILEDB_VCF_EXPORT_HEADER}" + "${TILEDB_VCF_EXPORT_HEADER}" ) # Set the public headers, which are the ones that get installed. -set_target_properties(tiledbvcf - PROPERTIES - PUBLIC_HEADER "${TILEDB_VCF_PUBLIC_HEADERS}" +set_target_properties( + tiledbvcf + PROPERTIES + PUBLIC_HEADER "${TILEDB_VCF_PUBLIC_HEADERS}" ) ############################################################ # Installation ############################################################ -include(GNUInstallDirs) - -# Set rpath to be relative to the .so. -if (APPLE) - set_target_properties(tiledbvcf PROPERTIES INSTALL_RPATH "@loader_path/") -else() - set_target_properties(tiledbvcf PROPERTIES INSTALL_RPATH "$ORIGIN/") - if(WIN32) - set_target_properties(tiledbvcf4test PROPERTIES INSTALL_RPATH "$ORIGIN/") - endif() +if(TILEDBVCF_INSTALL_TILEDB) + install( + IMPORTED_RUNTIME_ARTIFACTS + TileDB::tiledb_shared + RUNTIME DESTINATION "${LOCAL_INSTALL_PREFIX}" + LIBRARY DESTINATION "${LOCAL_INSTALL_PREFIX}lib" + ) endif() -set_property( - TARGET tiledbvcf-bin - PROPERTY INSTALL_RPATH - "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" - "${CMAKE_INSTALL_PREFIX}/lib" +install( + TARGETS tiledbvcf-bin + RUNTIME DESTINATION "${LOCAL_INSTALL_PREFIX}bin" ) -if (WIN32) - set(TILEDBVCF_EXTRA_INSTALL_TARGETS tiledbvcf4test) -endif() -# TBD: how to handle the tiledbvcf4test, don't really want it part of ultimate distribution... -# ... does release packaging simply need to ignore it? - -if(WIN32) - # Having the .dll and the .exe with the same name was resulting in a .exp - # file for the .exe being 'last out' (replacing one of same name for the .dll) - # and was causing the python api extension - # to link to the .exe, which was not functional. - # So, tiledbvcf-bin now sets an output (above somewhere) of tiledbvcfcli.exe - # and we install it here RENAMEing it to match the known name in pre-existing - # *nix world. - install(PROGRAMS $ - RENAME tiledbvcf.exe - DESTINATION ${CMAKE_INSTALL_BINDIR} - ) -else() - install( - TARGETS tiledbvcf-bin - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - ) -endif() - install( - TARGETS tiledbvcf ${TILEDBVCF_EXTRA_INSTALL_TARGETS} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/tiledbvcf + TARGETS tiledbvcf + RUNTIME DESTINATION "${LOCAL_INSTALL_PREFIX}" + LIBRARY DESTINATION "${LOCAL_INSTALL_PREFIX}lib" + FILE_SET HEADERS DESTINATION "${LOCAL_INSTALL_PREFIX}include/tiledbvcf" + PUBLIC_HEADER DESTINATION "${LOCAL_INSTALL_PREFIX}include/tiledbvcf" ) + +if (TILEDBVCF_SET_RPATH) + if (APPLE) + set_target_properties(tiledbvcf-bin PROPERTIES INSTALL_RPATH "@loader_path/../lib") + else() + set_target_properties(tiledbvcf-bin PROPERTIES INSTALL_RPATH "\$ORIGIN/../lib") + endif() + + + if (TILEDBVCF_ENABLE_PYTHON) + if (APPLE) + set_target_properties(tiledbvcf PROPERTIES INSTALL_RPATH "@loader_path") + else() + set_target_properties(tiledbvcf PROPERTIES INSTALL_RPATH "\$ORIGIN") + endif() + endif() +endif() diff --git a/libtiledbvcf/src/cli/tiledbvcf.cc b/libtiledbvcf/src/cli/tiledbvcf.cc index 69a6add10..80063e1b2 100644 --- a/libtiledbvcf/src/cli/tiledbvcf.cc +++ b/libtiledbvcf/src/cli/tiledbvcf.cc @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include +#include #include #include "dataset/tiledbvcfdataset.h" diff --git a/libtiledbvcf/src/dataset/tiledbvcfdataset.cc b/libtiledbvcf/src/dataset/tiledbvcfdataset.cc index 012db126c..c7b56adba 100644 --- a/libtiledbvcf/src/dataset/tiledbvcfdataset.cc +++ b/libtiledbvcf/src/dataset/tiledbvcfdataset.cc @@ -270,7 +270,8 @@ void TileDBVCFDataset::create(const CreationParams& params) { // Log the group structure group.open(TILEDB_READ); - LOG_DEBUG("TileDB Groups: \n{}", group.dump(true)); + // NOTE: On windows group.dump produces memory access violation + // LOG_DEBUG("TileDB Groups: \n{}", group.dump(true)); for (uint64_t i = 0; i < group.member_count(); i++) { auto member = group.member(i); diff --git a/libtiledbvcf/src/stats/column_buffer.cc b/libtiledbvcf/src/stats/column_buffer.cc index 90e0c2d5d..d32b32e22 100644 --- a/libtiledbvcf/src/stats/column_buffer.cc +++ b/libtiledbvcf/src/stats/column_buffer.cc @@ -178,7 +178,7 @@ size_t ColumnBuffer::update_size(const Query& query) { if (offsets_.capacity() < num_offsets + 1) { offsets_.reserve(num_offsets + 1); } - offsets_[num_offsets] = num_elements; + *(offsets_.data() + num_offsets) = num_elements; num_elements_ = num_elements; } else { num_cells_ = num_elements; @@ -198,8 +198,8 @@ std::vector ColumnBuffer::strings() { } std::string_view ColumnBuffer::string_view(uint64_t index) { - auto start = offsets_[index]; - auto len = offsets_[index + 1] - start; + auto start = *(offsets_.data() + index); + auto len = *(offsets_.data() + index + 1) - start; // For the last cell, the length is the remaining bytes in the buffer. if (index == num_cells_ - 1) { diff --git a/libtiledbvcf/src/utils/logger.cc b/libtiledbvcf/src/utils/logger.cc index a24a62915..61f8cb26b 100644 --- a/libtiledbvcf/src/utils/logger.cc +++ b/libtiledbvcf/src/utils/logger.cc @@ -33,10 +33,15 @@ #include "utils/logger.h" +#include + #include #include #include #include +#if _MSC_VER +#include +#endif namespace tiledb::vcf { diff --git a/libtiledbvcf/src/vcf/vcf_merger.cc b/libtiledbvcf/src/vcf/vcf_merger.cc index f60348048..3d32fb755 100644 --- a/libtiledbvcf/src/vcf/vcf_merger.cc +++ b/libtiledbvcf/src/vcf/vcf_merger.cc @@ -1,4 +1,5 @@ #include "vcf_merger.h" +#include namespace tiledb { namespace vcf { diff --git a/libtiledbvcf/test/CMakeLists.txt b/libtiledbvcf/test/CMakeLists.txt index db5893039..cc08bb03e 100644 --- a/libtiledbvcf/test/CMakeLists.txt +++ b/libtiledbvcf/test/CMakeLists.txt @@ -25,15 +25,13 @@ # THE SOFTWARE. # -find_package(HTSlib REQUIRED) -find_package(TileDB_EP REQUIRED) find_package(Catch2 REQUIRED) ############################################################ # Unit test executable ############################################################ -add_executable(tiledb_vcf_unit EXCLUDE_FROM_ALL +add_executable(tiledb_vcf_unit ${CMAKE_CURRENT_SOURCE_DIR}/src/unit-bitmap.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/unit-c-api-reader.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/unit-c-api-writer.cc @@ -58,15 +56,10 @@ target_include_directories(tiledb_vcf_unit ${CMAKE_CURRENT_SOURCE_DIR}/../external/ ) -if (WIN32) - set(NEEDED_TILEDB_VCF_TARGET tiledbvcf4test) -else() - set(NEEDED_TILEDB_VCF_TARGET tiledbvcf) -endif() target_link_libraries(tiledb_vcf_unit - PUBLIC - ${NEEDED_TILEDB_VCF_TARGET} # 'tiledbvcf' or 'tiledbvcf4test' - Catch2::Catch2 + PUBLIC + tiledbvcf + Catch2::Catch2 ) # Sanitizer linker flags diff --git a/libtiledbvcf/test/run-cli-tests.sh b/libtiledbvcf/test/run-cli-tests.sh index 6807ee428..62090d3b4 100755 --- a/libtiledbvcf/test/run-cli-tests.sh +++ b/libtiledbvcf/test/run-cli-tests.sh @@ -12,7 +12,7 @@ set -ex build_dir=$PWD/$1 input_dir=$PWD/$2 -tilevcf=${build_dir}/libtiledbvcf/src/tiledbvcf +tilevcf=${build_dir}/src/tiledbvcf upload_dir=/tmp/tilevcf-upload-dir-$$ # Clean up test outputs diff --git a/libtiledbvcf/vcpkg-configuration.json b/libtiledbvcf/vcpkg-configuration.json new file mode 100644 index 000000000..8ef2cd69a --- /dev/null +++ b/libtiledbvcf/vcpkg-configuration.json @@ -0,0 +1,5 @@ +{ + "overlay-ports": [ + "ports" + ] +} diff --git a/libtiledbvcf/vcpkg.json b/libtiledbvcf/vcpkg.json new file mode 100644 index 000000000..567e2cc7c --- /dev/null +++ b/libtiledbvcf/vcpkg.json @@ -0,0 +1,25 @@ +{ + "dependencies": [ + "cli11", + "spdlog", + { + "name": "htslib", + "platform": "!windows" + } + ], + "features": { + "tests": { + "description": "Build tiledb tests", + "dependencies": [ + "catch2" + ] + } + }, + "builtin-baseline": "b171feebd4f8b7943b56356f9ec1d4dbe44ab82f", + "overrides": [ + { + "name": "catch2", + "version": "2.13.8" + } + ] +} diff --git a/apis/python/pyproject.toml b/pyproject.toml similarity index 84% rename from apis/python/pyproject.toml rename to pyproject.toml index 6604bdb35..6a5f48ee0 100644 --- a/apis/python/pyproject.toml +++ b/pyproject.toml @@ -57,13 +57,22 @@ build-backend = "scikit_build_core.build" [tool.scikit-build] build-dir = "build/{wheel_tag}" metadata.version.provider = "scikit_build_core.metadata.setuptools_scm" -sdist.include = ["src/tiledbvcf/version.py"] +cmake.source-dir = "libtiledbvcf" +sdist.include = ["apis/python/src/tiledbvcf/version.py"] sdist.exclude = [".gitignore", "build-wheels.sh", "conda-env.yml"] wheel.expand-macos-universal-tags = true wheel.license-files = [] +wheel.packages = ["apis/python/src/tiledbvcf"] # NOTE: editable inplace not working yet editable.mode = "inplace" +[tool.scikit-build.cmake.define] +TILEDBVCF_ENABLE_PYTHON = "ON" +TILEDBVCF_ONLY_PYTHON_BINDINGS = "OFF" +TILEDBVCF_SET_RPATH = "ON" +TILEDBVCF_SET_INSTALL_SUBPATH = "ON" +tiledbvcf_DIR = {env="tiledbvcf_DIR"} +TileDB_DIR = {env="TileDB_DIR"} + [tool.setuptools_scm] -root = "../.." -version_file = "src/tiledbvcf/version.py" +version_file = "apis/python/src/tiledbvcf/version.py"