mirror of
https://github.com/KhronosGroup/KTX-Software.git
synced 2026-01-18 17:41:19 +01:00
Combine lib dependencies into static libktx on all desktop platforms (#1090)
Previously this was only done on macOS - using `libtool`. Changed to a simple, though hard to find, cross-platform way to do this via CMake. Add CI test of build and use of a static library. Remove macOS 13 build from CI as these runner images have been retired from GitHub Actions.
This commit is contained in:
17
.github/workflows/check-libktx-only.yml
vendored
17
.github/workflows/check-libktx-only.yml
vendored
@@ -59,6 +59,7 @@ jobs:
|
||||
matrix:
|
||||
os: [ macos-latest, ubuntu-latest, windows-latest ]
|
||||
config: [ Release ]
|
||||
static: [ OFF, ON ]
|
||||
generator: [ 'Ninja Multi-Config' ]
|
||||
exclude:
|
||||
- os: windows-latest
|
||||
@@ -70,6 +71,12 @@ jobs:
|
||||
# how to change the behaviour. Use VS.
|
||||
- os: windows-latest
|
||||
generator: 'Visual Studio 17 2022'
|
||||
config: Release
|
||||
static: OFF
|
||||
- os: windows-latest
|
||||
generator: 'Visual Studio 17 2022'
|
||||
config: Release
|
||||
static: ON
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
@@ -78,6 +85,8 @@ jobs:
|
||||
BUILD_DIR_UKP: "build/ukp"
|
||||
SOURCE_DIR_LIB: "lib"
|
||||
SOURCE_DIR_UKP: "tests/use-ktx"
|
||||
# In theory it should not matter, but this image is chosen to exercise
|
||||
# some of the functions in one of the library dependencies.
|
||||
KTX2_TEST_FILE: "tests/testimages/kodim17_basis.ktx2"
|
||||
WERROR: ON
|
||||
|
||||
@@ -96,10 +105,9 @@ jobs:
|
||||
- name: Build libktx with top-level project
|
||||
run: cmake --build ${{ env.BUILD_DIR_TL }} --config=Release
|
||||
|
||||
- name: Configure as sub-project
|
||||
run: cmake -S ${{ env.SOURCE_DIR_UKP }} -B ${{ env.BUILD_DIR_UKP }} -G "${{ matrix.generator }}" -DLIBKTX_WERROR=${{ env.WERROR }}
|
||||
|
||||
- name: Build use-ktx and libktx projects
|
||||
- name: Configure as sub-project, static library is ${{ matrix.static }}
|
||||
run: cmake -S ${{ env.SOURCE_DIR_UKP }} -B ${{ env.BUILD_DIR_UKP }} -G "${{ matrix.generator }}" -DLIBKTX_WERROR=${{ env.WERROR }} -DUSE_STATIC_LIBRARY=${{ matrix.static }}
|
||||
- name: Build use-ktx and libktx projects, static library is ${{ matrix.static }}
|
||||
run: cmake --build ${{ env.BUILD_DIR_UKP }} --config=Release
|
||||
|
||||
- name: Prepare version number and architecture for artifact
|
||||
@@ -121,6 +129,7 @@ jobs:
|
||||
run: ${{ env.BUILD_DIR_UKP }}/Release/use-ktx ${{ env.KTX2_TEST_FILE }}
|
||||
|
||||
- name: Upload artifact libktx
|
||||
if: matrix.static == 'OFF'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: libktx-${{ env.KTX_VERSION }}-${{ runner.os }}-${{ env.ARCH }}
|
||||
|
||||
10
.github/workflows/macos.yml
vendored
10
.github/workflows/macos.yml
vendored
@@ -88,16 +88,6 @@ jobs:
|
||||
doc: ON, jni: ON, loadtests: OpenGL+Vulkan, py: ON, tools: ON, tools_cts: ON,
|
||||
package: YES, sse: ON, opencl: OFF
|
||||
}
|
||||
- name: Test macOS 13 build
|
||||
os: macos-13
|
||||
options: {
|
||||
# graphviz no longer supports macOS 13 so doc: OFF.
|
||||
# ts-graphviz/setup-graphviz@v2 does not support specifying a
|
||||
# version on macOS.
|
||||
config: 'Debug,Release', platform: macOS,
|
||||
doc: OFF, jni: ON, loadtests: OpenGL+Vulkan, py: ON, tests: OFF, tools: ON, tools_cts: OFF,
|
||||
package: OFF, sse: ON, opencl: OFF
|
||||
}
|
||||
- name: Build for iOS
|
||||
os: macos-latest
|
||||
generator: Xcode
|
||||
|
||||
@@ -470,19 +470,10 @@ macro(common_libktx_settings target enable_write library_type)
|
||||
endmacro(common_libktx_settings)
|
||||
|
||||
macro(add_lib_dependencies target lib)
|
||||
if(NOT BUILD_SHARED_LIBS AND APPLE)
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
# Make a single static library to simplify linking.
|
||||
add_dependencies(${target} ${lib})
|
||||
add_custom_command( TARGET ${target}
|
||||
POST_BUILD
|
||||
COMMAND libtool -static -o $<TARGET_FILE:${target}> $<TARGET_FILE:${target}> $<TARGET_FILE:${lib}>
|
||||
)
|
||||
target_sources(${target} PRIVATE $<TARGET_OBJECTS:${lib}>)
|
||||
target_include_directories(${target} PRIVATE $<TARGET_PROPERTY:${lib},INTERFACE_INCLUDE_DIRECTORIES>)
|
||||
|
||||
# Don't know libtool equivalent on Windows or Emscripten. Applications
|
||||
# will have to link with both ktx and ${ASTCENC_LIB_TARGET}. Static libs
|
||||
# are unlikely to be used on Windows so not a problem there. For Emscripten
|
||||
# everything is built into the JS module so not an issue there either.
|
||||
else()
|
||||
target_link_libraries(${target} PRIVATE ${lib})
|
||||
endif()
|
||||
|
||||
@@ -22,6 +22,8 @@ project(use-ktx
|
||||
DESCRIPTION "Test using libktx project independently of KTX-Software"
|
||||
)
|
||||
|
||||
option(USE_STATIC_LIBRARY "Build and use static library" OFF)
|
||||
|
||||
set(path_to_ktx ../../lib)
|
||||
|
||||
if(WIN32)
|
||||
@@ -31,11 +33,18 @@ if(WIN32)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
endif()
|
||||
|
||||
if(USE_STATIC_LIBRARY)
|
||||
message("Building and using static library")
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
else()
|
||||
message("Building and using shared library")
|
||||
endif()
|
||||
add_subdirectory(${path_to_ktx} ktx)
|
||||
|
||||
add_executable(use-ktx
|
||||
use-ktx.cc
|
||||
)
|
||||
|
||||
# libktx adds KHRONOS_STATIC as a public define so no need to set it here.
|
||||
target_compile_features(use-ktx PRIVATE cxx_std_20)
|
||||
target_link_libraries(use-ktx PRIVATE ktx)
|
||||
|
||||
Reference in New Issue
Block a user