Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use find_package for the compression libraries when vcpkg is enabled. #4500

Merged
merged 3 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions cmake/Modules/FindBzip2_EP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,17 @@
# - BZIP2_INCLUDE_DIR, directory containing headers
# - BZIP2_LIBRARIES, the Bzip2 library path
# - BZIP2_FOUND, whether Bzip2 has been found
# - The Bzip2::Bzip2 imported target
# - The BZip2::BZip2 imported target

# Include some common helper functions.
include(TileDBCommon)

if(TILEDB_VCPKG)
find_package(BZip2 REQUIRED)
install_target_libs(BZip2::BZip2)
return()
endif()

# First check for a static version in the EP prefix.
find_library(BZIP2_LIBRARIES
NAMES
Expand Down Expand Up @@ -128,15 +134,15 @@ if (NOT BZIP2_FOUND)
endif()
endif()

if (BZIP2_FOUND AND NOT TARGET Bzip2::Bzip2)
add_library(Bzip2::Bzip2 UNKNOWN IMPORTED)
set_target_properties(Bzip2::Bzip2 PROPERTIES
if (BZIP2_FOUND AND NOT TARGET BZip2::BZip2)
add_library(BZip2::BZip2 UNKNOWN IMPORTED)
set_target_properties(BZip2::BZip2 PROPERTIES
IMPORTED_LOCATION "${BZIP2_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${BZIP2_INCLUDE_DIR}"
)
endif()

# If we built a static EP, install it if required.
if (BZIP2_STATIC_EP_FOUND AND TILEDB_INSTALL_STATIC_DEPS)
install_target_libs(Bzip2::Bzip2)
install_target_libs(BZip2::BZip2)
endif()
16 changes: 11 additions & 5 deletions cmake/Modules/FindLZ4_EP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,17 @@
# - LZ4_INCLUDE_DIR, directory containing headers
# - LZ4_LIBRARIES, the LZ4 library path
# - LZ4_FOUND, whether LZ4 has been found
# - The LZ4::LZ4 imported target
# - The lz4::lz4 imported target

# Include some common helper functions.
include(TileDBCommon)

if(TILEDB_VCPKG)
find_package(lz4 REQUIRED)
install_target_libs(lz4::lz4)
return()
endif()

# First check for a static version in the EP prefix.
find_library(LZ4_LIBRARIES
NAMES
Expand Down Expand Up @@ -116,15 +122,15 @@ endif()

set(ignoreUnusedWarning "${TILEDB_LZ4_EP_BUILT}")

if (LZ4_FOUND AND NOT TARGET LZ4::LZ4)
add_library(LZ4::LZ4 UNKNOWN IMPORTED)
set_target_properties(LZ4::LZ4 PROPERTIES
if (LZ4_FOUND AND NOT TARGET lz4::lz4)
add_library(lz4::lz4 UNKNOWN IMPORTED)
set_target_properties(lz4::lz4 PROPERTIES
IMPORTED_LOCATION "${LZ4_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${LZ4_INCLUDE_DIR}"
)
endif()

# If we built a static EP, install it if required.
if (LZ4_STATIC_EP_FOUND AND TILEDB_INSTALL_STATIC_DEPS)
install_target_libs(LZ4::LZ4)
install_target_libs(lz4::lz4)
endif()
22 changes: 17 additions & 5 deletions cmake/Modules/FindZstd_EP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,22 @@
# - ZSTD_INCLUDE_DIR, directory containing headers
# - ZSTD_LIBRARIES, the Zstd library path
# - ZSTD_FOUND, whether Zstd has been found
# - The Zstd::Zstd imported target
# - The ${ZSTD_TARGET} imported target

# Include some common helper functions.
include(TileDBCommon)

if (TILEDB_VCPKG)
find_package(zstd CONFIG REQUIRED)
if (TARGET zstd::libzstd_static)
set(ZSTD_TARGET zstd::libzstd_static)
else()
set(ZSTD_TARGET zstd::libzstd_shared)
endif()
install_target_libs(${ZSTD_TARGET})
return()
endif()

# First check for a static version in the EP prefix.
find_library(ZSTD_LIBRARIES
NAMES
Expand Down Expand Up @@ -118,15 +129,16 @@ if (NOT ZSTD_FOUND)
endif()
endif()

if (ZSTD_FOUND AND NOT TARGET Zstd::Zstd)
add_library(Zstd::Zstd UNKNOWN IMPORTED)
set_target_properties(Zstd::Zstd PROPERTIES
if (ZSTD_FOUND AND NOT ZSTD_TARGET)
add_library(zstd::libzstd UNKNOWN IMPORTED)
set_target_properties(zstd::libzstd PROPERTIES
IMPORTED_LOCATION "${ZSTD_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${ZSTD_INCLUDE_DIR}"
)
set(ZSTD_TARGET zstd::libzstd)
endif()

# If we built a static EP, install it if required.
if (ZSTD_STATIC_EP_FOUND AND TILEDB_INSTALL_STATIC_DEPS)
install_target_libs(Zstd::Zstd)
install_target_libs(${ZSTD_TARGET})
endif()
2 changes: 1 addition & 1 deletion experimental/experimental_examples/cpp_api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ find_package(Bzip2_EP REQUIRED)
function(build_TileDB_experimental_example_cppapi TARGET)
add_executable(${TARGET}_exp_cpp EXCLUDE_FROM_ALL ${TARGET}.cc)
target_link_libraries(${TARGET}_exp_cpp PUBLIC local_install tiledb_shared)
target_link_libraries(${TARGET}_exp_cpp PUBLIC Bzip2::Bzip2)
target_link_libraries(${TARGET}_exp_cpp PUBLIC BZip2::BZip2)
if (NOT WIN32)
# On Linux, must explicitly link -lpthread -ldl in order for static linking
# to libzstd or libcurl to work.
Expand Down
12 changes: 6 additions & 6 deletions tiledb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -694,10 +694,10 @@ find_package(Zstd_EP REQUIRED)
find_package(Magic_EP REQUIRED)
target_link_libraries(TILEDB_CORE_OBJECTS_ILIB
INTERFACE
Bzip2::Bzip2
LZ4::LZ4
BZip2::BZip2
lz4::lz4
ZLIB::ZLIB
Zstd::Zstd
${ZSTD_TARGET}
libmagic
)
if (TILEDB_VCPKG)
Expand Down Expand Up @@ -987,10 +987,10 @@ if (TILEDB_STATIC)
endif()
endmacro()

append_dep_lib(Bzip2::Bzip2)
append_dep_lib(LZ4::LZ4)
append_dep_lib(BZip2::BZip2)
append_dep_lib(lz4::lz4)
append_dep_lib(ZLIB::ZLIB)
append_dep_lib(Zstd::Zstd)
append_dep_lib(${ZSTD_TARGET})
append_dep_lib(CapnProto::capnp)
append_dep_lib(CapnProto::capnp-json)
append_dep_lib(CapnProto::kj)
Expand Down
2 changes: 1 addition & 1 deletion tiledb/sm/compressors/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ commence(object_library compressors)
find_package(LZ4_EP REQUIRED)
find_package(Zlib_EP REQUIRED)
find_package(Zstd_EP REQUIRED)
this_target_link_libraries(Bzip2::Bzip2 LZ4::LZ4 ZLIB::ZLIB Zstd::Zstd)
this_target_link_libraries(BZip2::BZip2 lz4::lz4 ZLIB::ZLIB ${ZSTD_TARGET})
conclude(object_library)

#
Expand Down
Loading