Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add KTX_WERROR config option #746

Merged
merged 9 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ jobs:
linux:
runs-on: ubuntu-latest

env:
WERROR: ON

steps:
- uses: actions/checkout@v3
with:
Expand All @@ -50,7 +53,7 @@ jobs:
run: sudo apt-get install -y ninja-build

- name: android_Debug_arm64-v8a
run: ./ci_scripts/build_android_debug.sh
run: ./ci_scripts/build_android.sh
env:
ANDROID_ABI: arm64-v8a
ANDROID_NDK: ${{ steps.setup-ndk.outputs.ndk-path }}
Expand All @@ -63,6 +66,7 @@ jobs:
ANDROID_ABI: arm64-v8a
ANDROID_NDK: ${{ steps.setup-ndk.outputs.ndk-path }}
ASTCENC_ISA: "ASTCENC_ISA_NEON=ON"
CONFIGURATION: Release

# Android ABI x86 is obsolete
# and not supported by ARM ASTC encoder
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/mingw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ on:
jobs:
mingw:
runs-on: windows-latest
env:
WERROR: ON

steps:
- uses: actions/checkout@v3
Expand All @@ -48,7 +50,7 @@ jobs:
- name: Install Ninja
run: choco install ninja --no-progress
- name: Configure Mingw x64
run: cmake -B build -G "Ninja Multi-Config" -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DKTX_FEATURE_TOOLS=TRUE -DKTX_FEATURE_TOOLS_CTS=TRUE
run: cmake -B build -G "Ninja Multi-Config" -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DKTX_FEATURE_TOOLS=TRUE -DKTX_FEATURE_TOOLS_CTS=TRUE -DKTX_WERROR=$WERROR
- name: Build Mingw x64 Debug
run: cmake --build build --config Debug
- name: Build Mingw x64 Release
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ jobs:
PACKAGE: ${{ matrix.options.package }}
SUPPORT_OPENCL: ${{ matrix.options.opencl }}
SUPPORT_SSE: ${{ matrix.options.sse }}
WERROR: ON

CODE_SIGN_TIMESTAMP_URL: "http://timestamp.digicert.com"
AZURE_KEY_VAULT_URL: ${{ secrets.AZURE_KEY_VAULT_URL }}
Expand Down
17 changes: 9 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ env:
- VULKAN_INSTALL_DIR: "$HOME/VulkanSDK/$VULKAN_SDK_VER"
- VULKAN_SDK: "$VULKAN_INSTALL_DIR/macOS"
- WASM_BUILD: NO
- WERROR: ON
jobs:
# FEATURE_TESTS is off for arm64 macOS because we can't even build
# them during CI. CI runs on x86_64 and there is a PostBuild command
Expand Down Expand Up @@ -89,7 +90,7 @@ jobs:
- CMAKE_GEN: Ninja
- CONFIGURATION=Debug
FEATURE_DOC=OFF FEATURE_JNI=ON FEATURE_LOADTESTS=OpenGL+Vulkan FEATURE_TOOLS=ON
SUPPORT_SSE=ON SUPPORT_OPENCL=OFF
SUPPORT_SSE=ON SUPPORT_OPENCL=OFF WERROR=ON
- os: linux
dist: jammy
compiler: gcc
Expand All @@ -100,7 +101,7 @@ jobs:
- CMAKE_GEN: Ninja
- CONFIGURATION=Release
FEATURE_DOC=ON FEATURE_JNI=ON FEATURE_LOADTESTS=OpenGL+Vulkan FEATURE_TOOLS=ON
SUPPORT_SSE=ON SUPPORT_OPENCL=OFF PACKAGE=YES
SUPPORT_SSE=ON SUPPORT_OPENCL=OFF WERROR=ON PACKAGE=YES
- os: linux
arch: arm64
dist: jammy
Expand All @@ -113,7 +114,7 @@ jobs:
- CONFIGURATION=Release
FEATURE_DOC=ON FEATURE_JNI=ON FEATURE_LOADTESTS=OpenGL
FEATURE_TOOLS=ON FEATURE_TOOLS_CTS=OFF
SUPPORT_SSE=OFF SUPPORT_OPENCL=OFF PACKAGE=YES
SUPPORT_SSE=OFF SUPPORT_OPENCL=OFF WERROR=ON PACKAGE=YES
- os: linux
dist: jammy
compiler: gcc
Expand All @@ -122,7 +123,7 @@ jobs:
- CONFIGURATION=Release
FEATURE_DOC=OFF FEATURE_JNI=OFF FEATURE_LOADTESTS=OFF
FEATURE_TOOLS=OFF FEATURE_TOOLS_CTS=OFF
SUPPORT_SSE=ON SUPPORT_OPENCL=ON PACKAGE=NO
SUPPORT_SSE=ON SUPPORT_OPENCL=ON WERROR=ON PACKAGE=NO
- os: linux
dist: jammy
compiler: gcc
Expand All @@ -131,7 +132,7 @@ jobs:
- CONFIGURATION=Release
FEATURE_DOC=OFF FEATURE_JNI=OFF FEATURE_LOADTESTS=OFF
FEATURE_TOOLS=OFF FEATURE_TOOLS_CTS=OFF
SUPPORT_SSE=OFF SUPPORT_OPENCL=ON PACKAGE=NO
SUPPORT_SSE=OFF SUPPORT_OPENCL=ON WERROR=ON PACKAGE=NO
- os: linux
dist: jammy
compiler: gcc
Expand All @@ -140,7 +141,7 @@ jobs:
- CONFIGURATION=Release
FEATURE_DOC=OFF FEATURE_JNI=OFF FEATURE_LOADTESTS=OFF
FEATURE_TOOLS=OFF FEATURE_TOOLS_CTS=OFF
SUPPORT_SSE=OFF SUPPORT_OPENCL=OFF PACKAGE=NO
SUPPORT_SSE=OFF SUPPORT_OPENCL=OFF WERROR=ON PACKAGE=NO
- os: linux
dist: jammy
compiler: clang
Expand All @@ -149,7 +150,7 @@ jobs:
- WASM_BUILD=YES
- CONFIGURATION=Debug
FEATURE_DOC=OFF FEATURE_JNI=OFF FEATURE_LOADTESTS=OpenGL
SUPPORT_SSE=OFF SUPPORT_OPENCL=OFF
SUPPORT_SSE=OFF SUPPORT_OPENCL=OFF WERROR=ON
- os: linux
dist: jammy
compiler: clang
Expand All @@ -158,7 +159,7 @@ jobs:
- WASM_BUILD=YES
- CONFIGURATION=Release
FEATURE_DOC=OFF FEATURE_JNI=OFF FEATURE_LOADTESTS=OpenGL
SUPPORT_SSE=OFF SUPPORT_OPENCL=OFF PACKAGE=YES
SUPPORT_SSE=OFF SUPPORT_OPENCL=OFF WERROR=ON PACKAGE=YES

# Phase 1: Git clone - done automatically.
# Phase 2: Install apt addons.
Expand Down
34 changes: 20 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ CMAKE_DEPENDENT_OPTION( KTX_FEATURE_TOOLS
"NOT IOS;NOT ANDROID;NOT EMSCRIPTEN"
OFF
)
option( KTX_FEATURE_DOC "Create KTX documentation" OFF )
option( KTX_FEATURE_STATIC_LIBRARY "Create static libraries (shared otherwise)" ${LIB_TYPE_DEFAULT} )
option( KTX_FEATURE_JNI "Create Java bindings for libktx" OFF )
option( KTX_FEATURE_TESTS "Create unit tests" ON )
option( KTX_FEATURE_TOOLS_CTS "Enable KTX CLI Tools CTS tests (requires CTS submodule)" OFF )
option( KTX_FEATURE_DOC "Create KTX documentation." OFF )
option( KTX_FEATURE_STATIC_LIBRARY "Create static libraries (shared otherwise)." ${LIB_TYPE_DEFAULT} )
option( KTX_FEATURE_JNI "Create Java bindings for libktx." OFF )
option( KTX_FEATURE_TESTS "Create unit tests." ON )
option( KTX_FEATURE_TOOLS_CTS "Enable KTX CLI Tools CTS tests (requires CTS submodule)." OFF )

if(KTX_FEATURE_TOOLS_CTS AND NOT KTX_FEATURE_TOOLS)
message(WARNING "KTX_FEATURE_TOOLS is not set -> disabling KTX_FEATURE_TOOLS_CTS")
message(WARNING "KTX_FEATURE_TOOLS is not set -> disabling KTX_FEATURE_TOOLS_CTS.")
set(KTX_FEATURE_TOOLS_CTS "OFF")
elseif(KTX_FEATURE_TOOLS_CTS AND NOT KTX_FEATURE_TESTS)
message(WARNING "KTX_FEATURE_TESTS is not set -> disabling KTX_FEATURE_TOOLS_CTS")
message(WARNING "KTX_FEATURE_TESTS is not set -> disabling KTX_FEATURE_TOOLS_CTS.")
set(KTX_FEATURE_TOOLS_CTS "OFF")
endif()

Expand Down Expand Up @@ -92,16 +92,16 @@ endif()


CMAKE_DEPENDENT_OPTION( KTX_EMBED_BITCODE
"Embed bitcode in binaries"
"Embed bitcode in binaries."
OFF
"APPLE AND IOS"
OFF
)

option( KTX_FEATURE_KTX1 "Enable KTX 1 support" ON )
option( KTX_FEATURE_KTX2 "Enable KTX 2 support" ON )
option( KTX_FEATURE_VK_UPLOAD "Enable Vulkan texture upload" ON )
option( KTX_FEATURE_GL_UPLOAD "Enable OpenGL texture upload" ON )
option( KTX_FEATURE_KTX1 "Enable KTX 1 support." ON )
option( KTX_FEATURE_KTX2 "Enable KTX 2 support." ON )
option( KTX_FEATURE_VK_UPLOAD "Enable Vulkan texture upload." ON )
option( KTX_FEATURE_GL_UPLOAD "Enable OpenGL texture upload." ON )
# When a variable like this is set via CMakeUserPresets.json, it no longer
# shows the selectable options provided by the STRINGS property.
set( KTX_FEATURE_LOADTEST_APPS
Expand Down Expand Up @@ -233,12 +233,17 @@ endif()
include(cmake/mkvk.cmake)

# Global compile & link options including optimization flags

option( KTX_WERROR "Make all warnings in KTX code into errors." OFF)

if(MSVC)
add_compile_options( /W4;/WX )
# ";" 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> )
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU"
OR ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
add_compile_options(-Wall -Wextra -Werror)
add_compile_options( -Wall -Wextra $<$<BOOL:${KTX_WERROR}>:-Werror>)
add_compile_options( $<IF:$<CONFIG:Debug>,-O0,-O3> )
if(EMSCRIPTEN)
add_link_options( $<IF:$<CONFIG:Debug>,-gsource-map,-O3> )
Expand Down Expand Up @@ -955,6 +960,7 @@ else()
endif()

# Other external projects
set(FMT_SYSTEM_HEADERS ON)
add_subdirectory(other_projects/fmt)
add_subdirectory(other_projects/cxxopts)

Expand Down
21 changes: 14 additions & 7 deletions ci_scripts/build_android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@ set -e
# Fallback to arm64-v8a
ANDROID_ABI=${ANDROID_ABI:-'arm64-v8a'}
ASTCENC_ISA=${ASTCENC_ISA:-'ASTCENC_ISA_NONE=ON'}
CONFIGURATION=${CONFIGURATION:-Release}

BUILD_DIR="build-android-$ANDROID_ABI"
CONFIGURATION=${CONFIGURATION:-Release}
WERROR=${WERROR:-OFF}

if [ "$CONFIGURATION" = "Debug" ]; then
BUILD_DIR="build-android-$ANDROID_ABI-Debug"
INSTALL_DIR="install-android-debug/$ANDROID_ABI"
else
BUILD_DIR="build-android-$ANDROID_ABI"
INSTALL_DIR="install-android/$ANDROID_ABI"
fi

# You need to set the following environment variables first
# ANDROID_NDK= <Path to Android NDK>
Expand All @@ -23,6 +31,7 @@ cmake_args=("-G" "Ninja" \
"-D" "CMAKE_BUILD_TYPE=$CONFIGURATION" \
"-D" "BASISU_SUPPORT_SSE=OFF" \
"-D" "${ASTCENC_ISA}"
"-D" "KTX_WERROR=$WERROR"
)

config_display="Configure KTX-Software (Android $ANDROID_ABI $CONFIGURATION): "
Expand All @@ -43,10 +52,8 @@ pushd "$BUILD_DIR"
echo "Build KTX-Software (Android $ANDROID_ABI $CONFIGURATION)"
cmake --build . --config $CONFIGURATION -j
# echo "Test KTX-Software (Android $ANDROID_ABI Release)"
# ctest -C Release # --verbose
if [ "$CONFIGURATION" = "Release" ]; then
echo "Install KTX-Software (Android $ANDROID_ABI $CONFIGURATION)"
cmake --install . --config Release --prefix ../install-android/$ANDROID_ABI
fi
# ctest -C $CONFIGURATION # --verbose
echo "Install KTX-Software (Android $ANDROID_ABI $CONFIGURATION)"
cmake --install . --config $CONFIGURATION --prefix ../$INSTALL_DIR

popd
49 changes: 0 additions & 49 deletions ci_scripts/build_android_debug.sh

This file was deleted.

4 changes: 3 additions & 1 deletion ci_scripts/build_ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ FEATURE_TOOLS=${FEATURE_TOOLS:-OFF}
PACKAGE=${PACKAGE:-NO}
SUPPORT_OPENCL=${SUPPORT_OPENCL:-OFF}
SUPPORT_SSE=OFF
WERROR=${WERROR:-OFF}

BUILD_DIR=${BUILD_DIR:-build/ios}

Expand Down Expand Up @@ -67,7 +68,8 @@ cmake_args=("-G" "Xcode" \
"-D" "KTX_FEATURE_TESTS=$FEATURE_TESTS" \
"-D" "KTX_FEATURE_TOOLS=$FEATURE_TOOLS" \
"-D" "BASISU_SUPPORT_OPENCL=$SUPPORT_OPENCL" \
"-D" "BASISU_SUPPORT_SSE=$SUPPORT_SSE"
"-D" "BASISU_SUPPORT_SSE=$SUPPORT_SSE" \
"-D" "KTX_WERROR=$WERROR"
)
config_display="Configure KTX-Software (iOS): "
for arg in "${cmake_args[@]}"; do
Expand Down
4 changes: 3 additions & 1 deletion ci_scripts/build_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ FEATURE_VK_UPLOAD=${FEATURE_VK_UPLOAD:-ON}
PACKAGE=${PACKAGE:-NO}
SUPPORT_SSE=${SUPPORT_SSE:-ON}
SUPPORT_OPENCL=${SUPPORT_OPENCL:-OFF}
WERROR=${WERROR:-OFF}

if [[ "$ARCH" = "aarch64" && "$FEATURE_LOADTESTS" =~ "Vulkan" ]]; then
if [[ "$FEATURE_LOADTESTS" = "Vulkan" ]]; then
Expand Down Expand Up @@ -84,7 +85,8 @@ cmake_args=("-G" "$CMAKE_GEN"
"-D" "KTX_FEATURE_GL_UPLOAD=$FEATURE_GL_UPLOAD" \
"-D" "KTX_FEATURE_VK_UPLOAD=$FEATURE_VK_UPLOAD" \
"-D" "BASISU_SUPPORT_OPENCL=$SUPPORT_OPENCL" \
"-D" "BASISU_SUPPORT_SSE=$SUPPORT_SSE"
"-D" "BASISU_SUPPORT_SSE=$SUPPORT_SSE" \
"-D" "KTX_WERROR=$WERROR"
)
if [ "$ARCH" != $(uname -m) ]; then
cmake_args+=("--toolchain", "cmake/linux-$ARCH-toolchain.cmake")
Expand Down
4 changes: 3 additions & 1 deletion ci_scripts/build_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ FEATURE_TOOLS_CTS=${FEATURE_TOOLS_CTS:-ON}
PACKAGE=${PACKAGE:-NO}
SUPPORT_SSE=${SUPPORT_SSE:-ON}
SUPPORT_OPENCL=${SUPPORT_OPENCL:-OFF}
WERROR=${WERROR:-OFF}

if [ "$ARCHS" = '(ARCHS_STANDARD)' ]; then
BUILD_DIR=${BUILD_DIR:-build/macos-universal}
Expand Down Expand Up @@ -73,7 +74,8 @@ cmake_args=("-G" "Xcode" \
"-D" "KTX_FEATURE_TOOLS=$FEATURE_TOOLS" \
"-D" "KTX_FEATURE_TOOLS_CTS=$FEATURE_TOOLS_CTS" \
"-D" "BASISU_SUPPORT_OPENCL=$SUPPORT_OPENCL" \
"-D" "BASISU_SUPPORT_SSE=$SUPPORT_SSE"
"-D" "BASISU_SUPPORT_SSE=$SUPPORT_SSE" \
"-D" "KTX_WERROR=$WERROR"
)
if [ "$ARCHS" = "x86_64" ]; then cmake_args+=("-D" "ASTCENC_ISA_SSE41=ON"); fi
if [ -n "$MACOS_CERTIFICATES_P12" ]; then
Expand Down
2 changes: 2 additions & 0 deletions ci_scripts/build_wasm_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ FEATURE_TOOLS=${FEATURE_TOOLS:-OFF}
PACKAGE=${PACKAGE:-NO}
SUPPORT_SSE=OFF
SUPPORT_OPENCL=${SUPPORT_OPENCL:-OFF}
WERROR=${WERROR:-OFF}

BUILD_DIR=${BUILD_DIR:-build/web-$CONFIGURATION}

Expand Down Expand Up @@ -76,6 +77,7 @@ docker exec -it emscripten sh -c "emcmake cmake -B$BUILD_DIR . \
-D CMAKE_BUILD_TYPE=$CONFIGURATION \
-D KTX_FEATURE_DOC=OFF \
-D KTX_FEATURE_LOADTEST_APPS=$FEATURE_LOADTESTS \
-D KTX_WERROR=$WERROR \
&& cmake --build $BUILD_DIR"

if [ "$PACKAGE" = "YES" ]; then
Expand Down
2 changes: 2 additions & 0 deletions ci_scripts/build_win.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ $FEATURE_TOOLS_CTS = Set-ConfigVariable FEATURE_TOOLS_CTS "ON"
$PACKAGE = Set-ConfigVariable PACKAGE "NO"
$SUPPORT_SSE = Set-ConfigVariable SUPPORT_SSE "ON"
$SUPPORT_OPENCL = Set-ConfigVariable SUPPORT_OPENCL "OFF"
$WERROR = Set-ConfigVariable WERROR "OFF"
$OPENGL_ES_EMULATOR = Set-ConfigVariable OPENGL_ES_EMULATOR `
"c:/Imagination` Technologies/PowerVR_Graphics/PowerVR_Tools/PVRVFrame/Library/Windows_x86_64"
$CODE_SIGN_KEY_VAULT = Set-ConfigVariable CODE_SIGN_KEY_VAULT ""
Expand Down Expand Up @@ -94,6 +95,7 @@ $cmake_args += @(
"-D", "KTX_FEATURE_TOOLS_CTS=$FEATURE_TOOLS_CTS"
"-D", "BASISU_SUPPORT_SSE=$SUPPORT_SSE"
"-D", "BASISU_SUPPORT_OPENCL=$SUPPORT_OPENCL"
"-D", "KTX_WERROR=$WERROR"
"-D", "CODE_SIGN_KEY_VAULT=$CODE_SIGN_KEY_VAULT"
)
if ($CODE_SIGN_KEY_VAULT) {
Expand Down
2 changes: 0 additions & 2 deletions cmake/cputypetest.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Copyright 2016, Simon Werta (@webmaster128).
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 2.8.12)

set(cputypetest_code "
//
// https://gist.github.com/webmaster128/e08067641df1dd784eb195282fd0912f
Expand Down
Loading