vcpkg/ports/ktx/0001-Use-vcpkg-zstd.patch
JonLiu1993 7ad9757560
[ktx] update to 4.0.0 release (#18644)
* [ktx] update to 4.0.0

* update version

* fix-arm64-error

* update version

* fix ci error

* update version
2021-09-03 16:31:10 -07:00

109 lines
4.1 KiB
Diff

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0bdb708..356c160 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -121,7 +121,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
@@ -227,7 +226,6 @@ macro(commom_lib_settings lib write)
$<INSTALL_INTERFACE:lib/basisu/transcoder>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/lib/basisu/transcoder>
- $<INSTALL_INTERFACE:lib/basisu/zstd>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/other_include>
$<INSTALL_INTERFACE:other_include>
@@ -309,6 +307,11 @@ macro(commom_lib_settings lib write)
endif()
if(WIN32)
+ find_package(zstd CONFIG REQUIRED)
+ target_link_libraries(
+ ${lib}
+ $<IF:$<TARGET_EXISTS:zstd::libzstd_shared>,zstd::libzstd_shared,zstd::libzstd_static>
+ )
# By wrapping in generator expression we force multi configuration generators (like Visual Studio)
# to take the exact path and not change it.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${KTX_BUILD_DIR}/$<CONFIG>>)
diff --git a/lib/basisu/CMakeLists.txt b/lib/basisu/CMakeLists.txt
index 78dd110..e155896 100644
--- a/lib/basisu/CMakeLists.txt
+++ b/lib/basisu/CMakeLists.txt
@@ -118,7 +118,7 @@ set(BASISU_SRC_LIST ${COMMON_SRC_LIST}
)
if (ZSTD)
- set(BASISU_SRC_LIST ${BASISU_SRC_LIST} zstd/zstd.c)
+ set(ZSTD_LIBRARIES "$<IF:$<TARGET_EXISTS:zstd::libzstd_shared>,zstd::libzstd_shared,zstd::libzstd_static>")
endif()
if (APPLE)
@@ -137,6 +137,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)
target_link_libraries(basisu m pthread)
endif()
diff --git a/lib/basisu/webgl/encoder/CMakeLists.txt b/lib/basisu/webgl/encoder/CMakeLists.txt
index e365e1b..6e6a7a5 100644
--- a/lib/basisu/webgl/encoder/CMakeLists.txt
+++ b/lib/basisu/webgl/encoder/CMakeLists.txt
@@ -36,9 +36,7 @@ if (EMSCRIPTEN)
)
if (KTX2_ZSTANDARD)
- set(SRC_LIST ${SRC_LIST}
- ../../zstd/zstd.c
- )
+ set(ZSTD_LIBRARIES "$<IF:$<TARGET_EXISTS:zstd::libzstd_shared>,zstd::libzstd_shared,zstd::libzstd_static>")
set(ZSTD_DEFINITION BASISD_SUPPORT_KTX2_ZSTD=1)
else()
set(ZSTD_DEFINITION BASISD_SUPPORT_KTX2_ZSTD=0)
@@ -58,6 +56,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..2e19ece 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 "$<IF:$<TARGET_EXISTS:zstd::libzstd_shared>,zstd::libzstd_shared,zstd::libzstd_static>")
set(ZSTD_DEFINITION BASISD_SUPPORT_KTX2_ZSTD=1)
else()
set(ZSTD_DEFINITION BASISD_SUPPORT_KTX2_ZSTD=0)
@@ -44,7 +42,9 @@ if (EMSCRIPTEN)
target_compile_definitions(basis_transcoder.js PRIVATE NDEBUG BASISD_SUPPORT_UASTC=1 BASISD_SUPPORT_BC7=1 BASISD_SUPPORT_ATC=0 BASISD_SUPPORT_ASTC_HIGHER_OPAQUE_QUALITY=0 BASISD_SUPPORT_PVRTC2=0 BASISD_SUPPORT_FXT1=0 BASISD_SUPPORT_ETC2_EAC_RG11=0 BASISU_SUPPORT_ENCODING=0 ${KTX2_DEFINITION} ${ZSTD_DEFINITION} )
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"