diff --git a/.github/workflows/check-libktx-only.yml b/.github/workflows/check-libktx-only.yml index 4e0ff167a..a724eed01 100644 --- a/.github/workflows/check-libktx-only.yml +++ b/.github/workflows/check-libktx-only.yml @@ -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 }} diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 5cb359d3d..e42fd6dfc 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -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 diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index f9bebd886..0e6f165b8 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -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_sources(${target} PRIVATE $) target_include_directories(${target} PRIVATE $) - - # 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() diff --git a/tests/use-ktx/CMakeLists.txt b/tests/use-ktx/CMakeLists.txt index 452ffc2c8..b08f39ccb 100644 --- a/tests/use-ktx/CMakeLists.txt +++ b/tests/use-ktx/CMakeLists.txt @@ -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)