Skip to content

Commit

Permalink
[basisu] update to v1.50.0
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Nov 1, 2024
1 parent 4f746bc commit 5a50dde
Show file tree
Hide file tree
Showing 5 changed files with 200 additions and 8 deletions.
179 changes: 179 additions & 0 deletions ports/basisu/0001-cmake.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
Remove once https://github.com/BinomialLLC/basis_universal/pull/383 merged

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8345623d..9563db70 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,6 +5,7 @@ cmake_minimum_required(VERSION 3.5)
project(basisu)
option(STATIC "static linking" FALSE)
option(SAN "sanitize" FALSE)
+option(EXAMPLES "Build examples" TRUE)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)

@@ -174,15 +175,21 @@ add_executable(basisu basisu_tool.cpp)
target_link_libraries(basisu PRIVATE basisu_encoder)

# Create the new example executable and link against the static library
-add_executable(examples example/example.cpp)
-target_link_libraries(examples PRIVATE basisu_encoder)
+if(EXAMPLES)
+ add_executable(examples example/example.cpp)
+ target_link_libraries(examples PRIVATE basisu_encoder)
+endif()

if (ZSTD)
target_compile_definitions(basisu PRIVATE BASISD_SUPPORT_KTX2_ZSTD=1)
- target_compile_definitions(examples PRIVATE BASISD_SUPPORT_KTX2_ZSTD=1)
+ if(EXAMPLES)
+ target_compile_definitions(examples PRIVATE BASISD_SUPPORT_KTX2_ZSTD=1)
+ endif()
else()
target_compile_definitions(basisu PRIVATE BASISD_SUPPORT_KTX2_ZSTD=0)
- target_compile_definitions(examples PRIVATE BASISD_SUPPORT_KTX2_ZSTD=0)
+ if(EXAMPLES)
+ target_compile_definitions(examples PRIVATE BASISD_SUPPORT_KTX2_ZSTD=0)
+ endif()
endif()

if (NOT MSVC)
@@ -192,7 +199,9 @@ if (NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBASISU_SUPPORT_OPENCL=1")

target_include_directories(basisu PRIVATE ${OpenCL_INCLUDE_DIRS})
- target_include_directories(examples PRIVATE ${OpenCL_INCLUDE_DIRS})
+ if(EXAMPLES)
+ target_include_directories(examples PRIVATE ${OpenCL_INCLUDE_DIRS})
+ endif()
target_include_directories(basisu_encoder PRIVATE ${OpenCL_INCLUDE_DIRS})
set(BASISU_EXTRA_LIBS ${OpenCL_LIBRARIES})
endif()
@@ -203,22 +212,30 @@ else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBASISU_SUPPORT_OPENCL=1")

target_include_directories(basisu PRIVATE "OpenCL")
- target_include_directories(examples PRIVATE "OpenCL")
+ if(EXAMPLES)
+ target_include_directories(examples PRIVATE "OpenCL")
+ endif()
target_include_directories(basisu_encoder PRIVATE "OpenCL")

if (BUILD_X64)
target_link_libraries(basisu PRIVATE "${CMAKE_SOURCE_DIR}/OpenCL/lib/OpenCL64.lib")
- target_link_libraries(examples PRIVATE "${CMAKE_SOURCE_DIR}/OpenCL/lib/OpenCL64.lib")
+ if(EXAMPLES)
+ target_link_libraries(examples PRIVATE "${CMAKE_SOURCE_DIR}/OpenCL/lib/OpenCL64.lib")
+ endif()
else()
target_link_libraries(basisu PRIVATE "${CMAKE_SOURCE_DIR}/OpenCL/lib/OpenCL.lib")
- target_link_libraries(examples PRIVATE "${CMAKE_SOURCE_DIR}/OpenCL/lib/OpenCL.lib")
+ if(EXAMPLES)
+ target_link_libraries(examples PRIVATE "${CMAKE_SOURCE_DIR}/OpenCL/lib/OpenCL.lib")
+ endif()
endif()
endif()
endif()

if (NOT MSVC)
target_link_libraries(basisu PRIVATE m pthread ${BASISU_EXTRA_LIBS})
- target_link_libraries(examples PRIVATE m pthread ${BASISU_EXTRA_LIBS})
+ if(EXAMPLES)
+ target_link_libraries(examples PRIVATE m pthread ${BASISU_EXTRA_LIBS})
+ endif()
endif()

if (NOT EMSCRIPTEN)


diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9563db70..f5ffa6de 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -240,15 +240,16 @@ endif()

if (NOT EMSCRIPTEN)
if (UNIX)
- if (CMAKE_BUILD_TYPE STREQUAL Release)
- if (APPLE)
- add_custom_command(TARGET basisu POST_BUILD COMMAND strip -X -x ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/basisu)
- #message("strip command: strip -X -x ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/basisu")
- else()
- add_custom_command(TARGET basisu POST_BUILD COMMAND strip -g -X -x ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/basisu)
- #message("strip command: strip -g -X -x ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/basisu")
- endif()
+ set(STRIP_ARGS -X -x)
+ if (NOT APPLE)
+ list(APPEND STRIP_ARGS -g)
endif()
+ add_custom_command(
+ TARGET basisu POST_BUILD
+ DEPENDS basisu
+ COMMAND $<$<CONFIG:release>:${CMAKE_STRIP}>
+ ARGS ${STRIP_ARGS} $<TARGET_FILE:basisu>
+ )
endif()
endif()



diff --git a/CMakeLists.txt b/CMakeLists.txt
index f5ffa6de..8e20a41f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -169,6 +169,10 @@ endif()

# Create the static library
add_library(basisu_encoder STATIC ${ENCODER_LIB_SRC_LIST})
+target_include_directories(basisu_encoder PUBLIC
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/transcoder>
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/encoder>
+ $<INSTALL_INTERFACE:include>)

# Create the basisu executable and link against the static library
add_executable(basisu basisu_tool.cpp)
@@ -270,3 +274,31 @@ if (MSVC)
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
)
endif()
+
+# Target Installation
+install(TARGETS basisu_encoder basisu EXPORT basisu-targets)
+install(DIRECTORY "./transcoder" DESTINATION "include/basisu/"
+ FILES_MATCHING PATTERN "*.h" PATTERN "*.inc"
+)
+install(DIRECTORY "./encoder" DESTINATION "include/basisu/"
+ FILES_MATCHING PATTERN "*.h"
+)
+
+# CMake Export
+include(CMakePackageConfigHelpers)
+include(GNUInstallDirs)
+configure_package_config_file(
+ ${PROJECT_SOURCE_DIR}/basisu-config.cmake.in
+ ${PROJECT_BINARY_DIR}/basisu-config.cmake
+ INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/basisu)
+export(
+ TARGETS basisu_encoder basisu
+ NAMESPACE basisu::
+ FILE ${PROJECT_BINARY_DIR}/basisu-targets.cmake)
+install(
+ FILES ${PROJECT_BINARY_DIR}/basisu-config.cmake
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/basisu)
+install(
+ EXPORT basisu-targets
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/basisu
+ NAMESPACE basisu::)
diff --git a/basisu-config.cmake.in b/basisu-config.cmake.in
new file mode 100644
index 00000000..6ac330ed
--- /dev/null
+++ b/basisu-config.cmake.in
@@ -0,0 +1,7 @@
+@PACKAGE_INIT@
+
+if (NOT TARGET basisu::basisu_encoder)
+ include(${CMAKE_CURRENT_LIST_DIR}/basisu-targets.cmake)
+endif ()
+
+check_required_components(basisu)
16 changes: 10 additions & 6 deletions ports/basisu/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO BinomialLLC/basis_universal
REF "${VERSION}"
SHA512 7f7dd62741b4a3e13050233a2ed751e6108cde9eab7b05ea5882ded6ab49fe181cc30e795cf73f8fa625a71e77ae891fda5ea84e20b632b1397844d6539715b3
REF "v1_50_0_2"
SHA512 845077e9c88a3610b4845bbf4856a2141d678751eb2b5eba26bb4cbbaa0199ad4eae6a37dee485bfcac9d583ee6dca983f300fb7e2b86dfbc9824b5059e11345
HEAD_REF master
PATCHES
# Remove once https://github.com/BinomialLLC/basis_universal/pull/383 merged
0001-cmake.patch
)

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DBUILD_TESTS=OFF
-DEXAMPLES=OFF
)

vcpkg_cmake_install()

vcpkg_copy_pdbs()

vcpkg_copy_tools(TOOL_NAMES "basisu" AUTO_CLEAN)
set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled)
# Remove unnecessary files
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug")

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")

vcpkg_cmake_config_fixup(PACKAGE_NAME basisu CONFIG_PATH lib/cmake/basisu)

vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
6 changes: 5 additions & 1 deletion ports/basisu/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "basisu",
"version": "1.16.4",
"version": "1.50.0",
"description": "Basis Universal is a supercompressed GPU texture and video compression format that outputs a highly compressed intermediate file format (.basis) that can be quickly transcoded to a wide variety of GPU texture compression formats.",
"homepage": "https://github.com/BinomialLLC/basis_universal",
"license": "Apache-2.0",
Expand All @@ -10,6 +10,10 @@
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}
5 changes: 5 additions & 0 deletions versions/b-/basisu.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "57d534d7389f29881d00661c107892f36b7d3497",
"version": "1.50.0",
"port-version": 0
},
{
"git-tree": "d355537e7392dad769a0c435f2a2cedf310b322c",
"version": "1.16.4",
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@
"port-version": 0
},
"basisu": {
"baseline": "1.16.4",
"baseline": "1.50.0",
"port-version": 0
},
"bcg729": {
Expand Down

0 comments on commit 5a50dde

Please sign in to comment.