Description: genomicsdb requires a fork of tiledb which is too different from
 the Debian-packaged one. We provide it as a component.
Author: Pierre Gruet <pgt@debian.org>
Forwarded: not-needed
Last-Update: 2022-07-26

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -44,6 +44,11 @@
 set(HTSLIB genomicsdb-hts)
 include_directories(${CMAKE_SOURCE_DIR}/genomicsdb-htslib)
 
+# add the genomicsdb-tiledb bundled as a component
+add_subdirectory(genomicsdb-tiledb)
+set(TILEDB_LIBRARY tiledb_shared)
+include_directories(${CMAKE_SOURCE_DIR}/genomicsdb-tiledb ${CMAKE_SOURCE_DIR}/genomicsdb-tiledb/core/include/c_api)
+
 #GIT_COMMIT_HASH derived from git tag to be used as part of GENOMICSDB_VERSION
 execute_process(
     COMMAND git log -1 --format=%h
@@ -339,10 +344,6 @@
   include(UseJava)
 endif()
 
-#TileDB
-find_package(TileDB REQUIRED)
-include_directories(${TILEDB_INCLUDE_DIR})
-
 #libcsv
 if(NOT BUILD_DISTRIBUTABLE_LIBRARY AND NOT BUILD_BINDINGS)
     if(USE_LIBCSV)
@@ -407,13 +408,6 @@
 set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O3 -fvisibility=hidden")
 set(CMAKE_CXX_FLAGS_COVERAGE "-DDEBUG -g3 -gdwarf-3 --coverage")
 
-#Clean all
-add_custom_target(clean-all ${CMAKE_MAKE_PROGRAM} clean)
-if(TILEDB_SOURCE_DIR)
-    add_custom_target(clean-TileDB ${CMAKE_COMMAND} -E remove_directory ${TILEDB_DIR_IN_BUILD_DIR})
-    add_dependencies(clean-all clean-TileDB)
-endif()
-
 #Uninstall GenomicsDB
 add_custom_target(
    uninstall-genomicsdb
--- a/cmake/Modules/FindTileDB.cmake
+++ /dev/null
@@ -1,84 +0,0 @@
-#
-# FindTileDB.cmake
-#
-# The MIT License
-#
-# Copyright (c) 2016 MIT and Intel Corporation
-# Copyright (c) 2019-2020 Omics Data Automation, 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.
-#
-# Determine compiler flags for TileDB
-# Once done this will define
-# TILEDB_FOUND - TileDB found
-
-# Update git submodule if necessary
-if((DEFINED TILEDB_SOURCE_DIR) AND (NOT "${TILEDB_SOURCE_DIR}" STREQUAL "") AND (NOT EXISTS "${TILEDB_SOURCE_DIR}/CMakeLists.txt"))
-  MESSAGE(STATUS "Installing submodule TileDB at ${CMAKE_SOURCE_DIR}/dependencies")
-  execute_process(
-    COMMAND git submodule update --recursive --init ${CMAKE_SOURCE_DIR}/dependencies/TileDB
-    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
-    RESULT_VARIABLE submodule_update_exit_code)
-  if(NOT(submodule_update_exit_code EQUAL 0))
-    message(FATAL_ERROR "Failure to update git submodule TileDB")
-  endif()
-  set(TILEDB_SOURCE_DIR "${CMAKE_SOURCE_DIR}/dependencies/TileDB" CACHE PATH "Path to TileDB source directory" FORCE)
-endif()
-
-if(CMAKE_BUILD_TYPE STREQUAL "Release")
-  #TileDB c-api returns a tiledb_errmsg which is what GenomicsDB should rely on
-  set(TILEDB_VERBOSE FALSE CACHE BOOL "Suppress TileDB Verbosity for GenomicsDB" FORCE)
-endif()
-set(TILEDB_DISABLE_TESTING True)
-
-#Zlib
-find_package(ZLIB REQUIRED)
-
-#ZStd
-set(ENABLE_ZSTD TRUE CACHE BOOL "Enable ZStd" FORCE)
-
-if(BUILD_DISTRIBUTABLE_LIBRARY)
-    set(OPENSSL_USE_STATIC_LIBS True)
-endif()
-find_package(OpenSSL REQUIRED) #now performed inside TileDB
-
-#libuuid
-find_package(libuuid REQUIRED)
-
-include(FindPackageHandleStandardArgs)
-
-set(TILEDB_DISABLE_TESTS True CACHE BOOL "Disable TileDB Testing")
-
-#Build if TileDB source directory specified
-if(TILEDB_SOURCE_DIR)
-    #OpenMP
-    if(DISABLE_OPENMP)
-        set(USE_OPENMP False CACHE BOOL "Disable OpenMP" FORCE)
-    else()
-        set(USE_OPENMP True CACHE BOOL "Enable OpenMP" FORCE)
-    endif()
-
-    find_path(TILEDB_INCLUDE_DIR NAMES tiledb.h HINTS "${TILEDB_SOURCE_DIR}/core/include/c_api")
-    find_package_handle_standard_args(TileDB "Could not find TileDB headers ${DEFAULT_MSG}" TILEDB_INCLUDE_DIR)
-    add_subdirectory(${TILEDB_SOURCE_DIR} dependencies/TileDB EXCLUDE_FROM_ALL)
-else()
-    find_path(TILEDB_INCLUDE_DIR NAMES "tiledb.h" HINTS "${TILEDB_INSTALL_DIR}/include")
-    find_library(TILEDB_LIBRARY NAMES libtiledb.a tiledb HINTS "${TILEDB_INSTALL_DIR}" "${TILEDB_INSTALL_DIR}/lib64" "${TILEDB_INSTALL_DIR}/lib")
-    find_package_handle_standard_args(TileDB "Could not find TileDB headers and/or libraries ${DEFAULT_MSG}" TILEDB_INCLUDE_DIR TILEDB_LIBRARY)
-endif()
--- a/genomicsdb-tiledb/examples/CMakeLists.txt
+++ b/genomicsdb-tiledb/examples/CMakeLists.txt
@@ -37,7 +37,7 @@
 file(GLOB TILEDB_EXAMPLE_SOURCES "src/*.cc")
 
 # Include TileDB C API headers
-include_directories("${CMAKE_SOURCE_DIR}/core/include/c_api/")
+include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../core/include/c_api/")
 
 # Initialize name for example binaries
 set(EXAMPLE_BINS)
@@ -59,7 +59,7 @@
 
 # Run a subset of examples for Continuous Integration Testing
 if(NOT TILEDB_DISABLE_TESTING)
-  set(CI_TESTS ${CMAKE_SOURCE_DIR}/examples/run_examples.sh &&
+  set(CI_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/run_examples.sh &&
     echo "Running diff with expected_results" &&
     diff log ${CMAKE_SOURCE_DIR}/examples/expected_results &&
     ${CMAKE_SOURCE_DIR}/examples/run_examples_parallel.sh)
--- a/genomicsdb-tiledb/CMakeLists.txt
+++ b/genomicsdb-tiledb/CMakeLists.txt
@@ -40,7 +40,7 @@
 endif()
 
 set(ENABLE_BLOSC False CACHE BOOL "Enable blosc compression")
-set(ENABLE_ZSTD False CACHE BOOL "Enable zstd compression")
+set(ENABLE_ZSTD True CACHE BOOL "Enable zstd compression")
 set(LIBUUID_DIR "" CACHE PATH "Path to libuuid install directory")
 set(HDFS_SOURCE_DIR "deps/HDFSWrapper/hadoop-hdfs-native" CACHE PATH "Path to modified libhdfs source dir")
 set(AZURE_FSCLIENT_SOURCE_DIR "deps/azure-storage-cpplite" CACHE PATH "Path to modified azure cpp client")
--- a/src/main/CMakeLists.txt
+++ b/src/main/CMakeLists.txt
@@ -119,7 +119,7 @@
   add_dependencies(tiledbgenomicsdb htslib)
 endif()
 target_link_libraries(tiledbgenomicsdb ${HTSLIB_LIBRARY} ${GENOMICSDB_EXTERNAL_DEPENDENCIES_LIBRARIES})
-target_link_libraries(tiledbgenomicsdb genomicsdb-hts)
+target_link_libraries(tiledbgenomicsdb genomicsdb-hts tiledb_shared)
 if(LIBRT_LIBRARY)
     target_link_libraries(tiledbgenomicsdb ${LIBRT_LIBRARY})
 endif()
