-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1089 from CesiumGS/ktx-workaround
Download KTX via vcpkg_from_git instead of vcpkg_from_github
- Loading branch information
Showing
9 changed files
with
331 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index 9a56491..d7ca937 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -345,7 +345,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 | ||
@@ -532,7 +531,6 @@ macro(common_libktx_settings target enable_write library_type) | ||
$<INSTALL_INTERFACE:lib/basisu/transcoder> | ||
|
||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/lib/basisu/zstd> | ||
- $<INSTALL_INTERFACE:lib/basisu/zstd> | ||
|
||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/utils> | ||
$<INSTALL_INTERFACE:utils> | ||
@@ -627,6 +625,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 "$<IF:$<TARGET_EXISTS:zstd::libzstd_shared>,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..152ceb5 100644 | ||
--- a/lib/basisu/CMakeLists.txt | ||
+++ b/lib/basisu/CMakeLists.txt | ||
@@ -145,9 +145,6 @@ set(BASISU_SRC_LIST ${COMMON_SRC_LIST} | ||
transcoder/basisu_transcoder.cpp | ||
) | ||
|
||
-if (ZSTD) | ||
- set(BASISU_SRC_LIST ${BASISU_SRC_LIST} zstd/zstd.c) | ||
-endif() | ||
|
||
if (APPLE) | ||
set(BIN_DIRECTORY "bin_osx") | ||
@@ -165,6 +162,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..a337b13 100644 | ||
--- a/lib/basisu/webgl/encoder/CMakeLists.txt | ||
+++ b/lib/basisu/webgl/encoder/CMakeLists.txt | ||
@@ -34,9 +34,6 @@ if (EMSCRIPTEN) | ||
) | ||
|
||
if (KTX2_ZSTANDARD) | ||
- set(SRC_LIST ${SRC_LIST} | ||
- ../../zstd/zstd.c | ||
- ) | ||
set(ZSTD_DEFINITION BASISD_SUPPORT_KTX2_ZSTD=1) | ||
else() | ||
set(ZSTD_DEFINITION BASISD_SUPPORT_KTX2_ZSTD=0) | ||
@@ -55,6 +52,10 @@ if (EMSCRIPTEN) | ||
target_compile_options(basis_encoder.js PRIVATE -fno-strict-aliasing -O3) | ||
|
||
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" | ||
diff --git a/lib/basisu/webgl/transcoder/CMakeLists.txt b/lib/basisu/webgl/transcoder/CMakeLists.txt | ||
index 372653d..5ebc3cf 100644 | ||
--- a/lib/basisu/webgl/transcoder/CMakeLists.txt | ||
+++ b/lib/basisu/webgl/transcoder/CMakeLists.txt | ||
@@ -28,9 +28,6 @@ if (EMSCRIPTEN) | ||
endif() | ||
|
||
if (KTX2_ZSTANDARD) | ||
- set(SRC_LIST ${SRC_LIST} | ||
- ../../zstd/zstddeclib.c | ||
- ) | ||
set(ZSTD_DEFINITION BASISD_SUPPORT_KTX2_ZSTD=1) | ||
else() | ||
set(ZSTD_DEFINITION BASISD_SUPPORT_KTX2_ZSTD=0) | ||
@@ -44,6 +41,10 @@ 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
diff --git a/cmake/version.cmake b/cmake/version.cmake | ||
index 4094df1a..3b2af3bb 100644 | ||
--- a/cmake/version.cmake | ||
+++ b/cmake/version.cmake | ||
@@ -108,8 +108,10 @@ function(generate_version _var ) | ||
set(${_var} "${KTX_VERSION}" PARENT_SCOPE) | ||
endfunction() | ||
|
||
-# Get latest tag | ||
-git_describe_raw(KTX_VERSION_FULL --abbrev=0 --match v[0-9]*) | ||
+if (!KTX_VERSION_FULL) | ||
+ # Get latest tag | ||
+ git_describe_raw(KTX_VERSION_FULL --abbrev=0 --match v[0-9]*) | ||
+endif() | ||
#message("KTX full version: ${KTX_VERSION_FULL}") | ||
|
||
# generate_version(TOKTX_VERSION tools/toktx) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/cmake/version.cmake b/cmake/version.cmake | ||
index 9a90622..0fc3521 100644 | ||
--- a/cmake/version.cmake | ||
+++ b/cmake/version.cmake | ||
@@ -176,7 +176,7 @@ function( create_version_header dest_path target ) | ||
add_custom_command( | ||
OUTPUT ${version_h_output} | ||
# On Windows this command has to be invoked by a shell in order to work | ||
- COMMAND ${BASH_EXECUTABLE} -c "\"./mkversion\" \"-o\" \"version.h\" \"${dest_path}\"" | ||
+ COMMAND "${BASH_EXECUTABLE}" -- ./mkversion -o version.h "${dest_path}" | ||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} | ||
COMMENT "Generate ${version_h_output}" | ||
VERBATIM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index 1500844..810914e 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -263,7 +263,7 @@ if(MSVC) | ||
# ";" argument separator is problematic. Can't use a GenEx `$<IF:` | ||
# because `/W4;/WX` is returned as a single string. | ||
add_compile_options( /W4;$<$<BOOL:${KTX_WERROR}>:/WX> ) | ||
- add_compile_options( $<IF:$<CONFIG:Debug>,/Gz,/O2> ) | ||
+ add_compile_options( $<IF:$<CONFIG:Debug>,,/O2> ) | ||
# Enable UTF-8 support | ||
add_compile_options( $<$<C_COMPILER_ID:MSVC>:/utf-8> ) | ||
add_compile_options( $<$<CXX_COMPILER_ID:MSVC>:/utf-8> ) | ||
@@ -946,6 +946,7 @@ if(EMSCRIPTEN) | ||
endif() | ||
|
||
add_library( objUtil STATIC | ||
+ EXCLUDE_FROM_ALL | ||
utils/argparser.cpp | ||
utils/argparser.h | ||
utils/ktxapp.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index e99fb143..0f69adf7 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -1071,10 +1071,10 @@ endif() | ||
if((KTX_FEATURE_TOOLS OR KTX_FEATURE_TESTS) AND NOT TARGET fmt::fmt) | ||
set(FMT_INSTALL OFF) | ||
set(FMT_SYSTEM_HEADERS ON) | ||
- add_subdirectory(other_projects/fmt) | ||
+ find_package(fmt CONFIG REQUIRED) | ||
endif() | ||
if(KTX_FEATURE_TOOLS AND NOT TARGET cxxopts::cxxopts) | ||
- add_subdirectory(other_projects/cxxopts) | ||
+ find_package(cxxopts CONFIG REQUIRED) | ||
endif() | ||
|
||
# Tools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index e99fb143..072ea889 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -489,7 +489,7 @@ macro(common_libktx_settings target enable_write library_type) | ||
CXX_STANDARD_REQUIRED YES | ||
|
||
) | ||
- if(IOS) | ||
+ if(0) | ||
set_target_properties(${target} PROPERTIES | ||
FRAMEWORK TRUE | ||
) | ||
@@ -1145,7 +1145,7 @@ endif() | ||
# Use of this to install KHR/khr_df.h is due to CMake's failure to | ||
# preserve the include source folder hierarchy. | ||
# See https://gitlab.kitware.com/cmake/cmake/-/issues/16739. | ||
-if (IOS) | ||
+if (0) | ||
set_source_files_properties( | ||
include/KHR/khr_df.h | ||
PROPERTIES MACOSX_PACKAGE_LOCATION Headers/KHR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
vcpkg_from_git( | ||
OUT_SOURCE_PATH SOURCE_PATH | ||
URL "https://github.com/KhronosGroup/KTX-Software.git" | ||
REF 91ace88675ac59a97e55d0378a6602a9ae6b98bd | ||
FETCH_REF "v${VERSION}" | ||
HEAD_REF main | ||
PATCHES | ||
0001-Use-vcpkg-zstd.patch | ||
0002-Fix-versioning.patch | ||
0003-mkversion.patch | ||
0004-quirks.patch | ||
0005-no-vendored-libs.patch | ||
0006-fix-ios-install.patch | ||
) | ||
file(REMOVE "${SOURCE_PATH}/other_include/zstd_errors.h") | ||
|
||
vcpkg_list(SET OPTIONS) | ||
if(VCPKG_TARGET_IS_WINDOWS) | ||
vcpkg_acquire_msys(MSYS_ROOT | ||
PACKAGES | ||
bash | ||
DIRECT_PACKAGES | ||
# Required for "getopt" | ||
"https://repo.msys2.org/msys/x86_64/util-linux-2.35.2-3-x86_64.pkg.tar.zst" | ||
da26540881cd5734072717133307e5d1a27a60468d3656885507833b80f24088c5382eaa0234b30bdd9e8484a6638b4514623f5327f10b19eed36f12158e8edb | ||
# Required for "dos2unix" | ||
"https://mirror.msys2.org/msys/x86_64/dos2unix-7.5.1-1-x86_64.pkg.tar.zst" | ||
83d85e6ccea746ef9e8153a0d605e774dbe7efc0ee952804acfee4ffd7e3b0386a353b45ff989dd99bc3ce75968209fea3d246ad2af88bbb5c4eca12fc5a8f92 | ||
) | ||
vcpkg_add_to_path("${MSYS_ROOT}/usr/bin") | ||
vcpkg_list(APPEND OPTIONS "-DBASH_EXECUTABLE=${MSYS_ROOT}/usr/bin/bash.exe") | ||
endif() | ||
|
||
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" ENABLE_STATIC) | ||
|
||
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS | ||
FEATURES | ||
tools KTX_FEATURE_TOOLS | ||
vulkan KTX_FEATURE_VK_UPLOAD | ||
) | ||
|
||
vcpkg_cmake_configure( | ||
SOURCE_PATH "${SOURCE_PATH}" | ||
OPTIONS | ||
-DKTX_VERSION_FULL=v${VERSION} | ||
-DKTX_FEATURE_TESTS=OFF | ||
-DKTX_FEATURE_LOADTEST_APPS=OFF | ||
-DKTX_FEATURE_STATIC_LIBRARY=${ENABLE_STATIC} | ||
${FEATURE_OPTIONS} | ||
${OPTIONS} | ||
DISABLE_PARALLEL_CONFIGURE | ||
) | ||
|
||
vcpkg_cmake_install() | ||
|
||
if(tools IN_LIST FEATURES) | ||
vcpkg_copy_tools( | ||
TOOL_NAMES | ||
ktx | ||
toktx | ||
ktxsc | ||
ktxinfo | ||
ktx2ktx2 | ||
ktx2check | ||
AUTO_CLEAN | ||
) | ||
else() | ||
vcpkg_copy_pdbs() | ||
endif() | ||
|
||
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/ktx) | ||
|
||
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") | ||
|
||
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") | ||
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin") | ||
endif() | ||
|
||
file(GLOB LICENSE_FILES "${SOURCE_PATH}/LICENSES/*") | ||
file(COPY ${LICENSE_FILES} DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}/LICENSES") | ||
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.md") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"name": "ktx", | ||
"version-semver": "4.3.2", | ||
"description": [ | ||
"The Khronos KTX library and tools.", | ||
"Functions for writing and reading KTX files, and instantiating OpenGL®, OpenGL ES™️ and Vulkan® textures from them." | ||
], | ||
"homepage": "https://github.com/KhronosGroup/KTX-Software", | ||
"license": null, | ||
"supports": "arm64 | x64 | !windows", | ||
"dependencies": [ | ||
{ | ||
"name": "vcpkg-cmake", | ||
"host": true | ||
}, | ||
{ | ||
"name": "vcpkg-cmake-config", | ||
"host": true | ||
}, | ||
"zstd" | ||
], | ||
"features": { | ||
"tools": { | ||
"description": "Build tools", | ||
"supports": "!android & !uwp", | ||
"dependencies": [ | ||
"cxxopts", | ||
"fmt" | ||
] | ||
}, | ||
"vulkan": { | ||
"description": "Build Vulkan support", | ||
"supports": "!emscripten" | ||
} | ||
} | ||
} |