diff --git a/CMakeLists.txt b/CMakeLists.txt index 0653da5..1265f3d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -265,7 +265,6 @@ set(KTX_MAIN_SRC lib/basisu/transcoder/basisu_transcoder.cpp lib/basisu/transcoder/basisu_transcoder.h lib/basisu/transcoder/basisu.h - lib/basisu/zstd/zstd.c lib/checkheader.c lib/dfdutils/createdfd.c lib/dfdutils/colourspaces.c @@ -448,7 +447,6 @@ macro(common_libktx_settings target enable_write library_type) $ $ - $ $ $ @@ -538,6 +536,11 @@ macro(common_libktx_settings target enable_write library_type) target_compile_definitions(${target} PUBLIC KTX_FEATURE_KTX2) endif() + # Use vcpkg zstd + find_package(zstd CONFIG REQUIRED) + set(ZSTD_LIBRARIES "$,zstd::libzstd_shared,zstd::libzstd_static>") + target_link_libraries(${target} PRIVATE ${ZSTD_LIBRARIES}) + if(WIN32) if(MINGW) # Check if the Threads package is provided; if using Mingw it MIGHT be diff --git a/cmake/KtxConfig.cmake b/cmake/KtxConfig.cmake index 6386ba2..537bf4f 100644 --- a/cmake/KtxConfig.cmake +++ b/cmake/KtxConfig.cmake @@ -1,7 +1,8 @@ # Copyright 2015-2020 The Khronos Group Inc. # SPDX-License-Identifier: Apache-2.0 -# include(CMakeFindDependencyMacro) -# find_dependency() +include(CMakeFindDependencyMacro) +find_dependency(Threads) +find_dependency(zstd CONFIG) include("${CMAKE_CURRENT_LIST_DIR}/KtxTargets.cmake") diff --git a/lib/basisu/CMakeLists.txt b/lib/basisu/CMakeLists.txt index 492233a..2663169 100644 --- a/lib/basisu/CMakeLists.txt +++ b/lib/basisu/CMakeLists.txt @@ -146,7 +146,7 @@ set(BASISU_SRC_LIST ${COMMON_SRC_LIST} ) if (ZSTD) - set(BASISU_SRC_LIST ${BASISU_SRC_LIST} zstd/zstd.c) + set(ZSTD_LIBRARIES "$,zstd::libzstd_shared,zstd::libzstd_static>") endif() if (APPLE) @@ -165,6 +165,10 @@ else() target_compile_definitions(basisu PRIVATE BASISD_SUPPORT_KTX2_ZSTD=0) endif() +if(ZSTD_LIBRARIES) + target_link_libraries(basisu ${ZSTD_LIBRARIES}) +endif() + if (NOT MSVC) # For Non-Windows builds, let cmake try and find the system OpenCL headers/libs for us. if (OPENCL_FOUND) diff --git a/lib/basisu/webgl/encoder/CMakeLists.txt b/lib/basisu/webgl/encoder/CMakeLists.txt index 588d91b..edd7457 100644 --- a/lib/basisu/webgl/encoder/CMakeLists.txt +++ b/lib/basisu/webgl/encoder/CMakeLists.txt @@ -34,9 +34,7 @@ if (EMSCRIPTEN) ) if (KTX2_ZSTANDARD) - set(SRC_LIST ${SRC_LIST} - ../../zstd/zstd.c - ) + set(ZSTD_LIBRARIES "$,zstd::libzstd_shared,zstd::libzstd_static>") set(ZSTD_DEFINITION BASISD_SUPPORT_KTX2_ZSTD=1) else() set(ZSTD_DEFINITION BASISD_SUPPORT_KTX2_ZSTD=0) @@ -56,6 +54,10 @@ if (EMSCRIPTEN) target_include_directories(basis_encoder.js PRIVATE ../../transcoder) + if(ZSTD_LIBRARIES) + target_link_libraries(basis_encoder.js ${ZSTD_LIBRARIES}) + endif() + set_target_properties(basis_encoder.js PROPERTIES OUTPUT_NAME "basis_encoder" SUFFIX ".js" diff --git a/lib/basisu/webgl/transcoder/CMakeLists.txt b/lib/basisu/webgl/transcoder/CMakeLists.txt index 372653d..3c9ed0c 100644 --- a/lib/basisu/webgl/transcoder/CMakeLists.txt +++ b/lib/basisu/webgl/transcoder/CMakeLists.txt @@ -28,9 +28,7 @@ if (EMSCRIPTEN) endif() if (KTX2_ZSTANDARD) - set(SRC_LIST ${SRC_LIST} - ../../zstd/zstddeclib.c - ) + set(ZSTD_LIBRARIES "$,zstd::libzstd_shared,zstd::libzstd_static>") set(ZSTD_DEFINITION BASISD_SUPPORT_KTX2_ZSTD=1) else() set(ZSTD_DEFINITION BASISD_SUPPORT_KTX2_ZSTD=0) @@ -45,6 +43,10 @@ if (EMSCRIPTEN) target_compile_options(basis_transcoder.js PRIVATE -O3 -fno-strict-aliasing) target_include_directories(basis_transcoder.js PRIVATE ../../transcoder) + if(ZSTD_LIBRARIES) + target_link_libraries(basis_transcoder.js ${ZSTD_LIBRARIES}) + endif() + set_target_properties(basis_transcoder.js PROPERTIES OUTPUT_NAME "basis_transcoder" SUFFIX ".js"