BinomialLLC / basis_universal

Basis Universal GPU Texture Codec
Apache License 2.0
2.72k stars 267 forks source link

clang & gcc throw many warnings #294

Open MarkCallow opened 2 years ago

MarkCallow commented 2 years ago

There are a lot of warnings in the basis_universal code from both clang and gcc (current and previous versions) that I currently have suppressed in my build. Please add builds using these compilers to your CI and fix the warnings. Here are the warnings I am suppressing:

if(MSVC)
# Currently no need to disable any warnings in basisu code. Rich fixed them.
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
    set_source_files_properties(
        # It's too much work to discriminate which files need which warnings
        # disabled.
        ${BASISU_ENCODER_CXX_SRC}
        PROPERTIES COMPILE_OPTIONS "-Wno-sign-compare;-Wno-unused-variable;-Wno-class-memaccess;-Wno-misleading-indentation;-Wno-extra;-Wno-deprecated-copy;-Wno-parentheses;-Wno-strict-aliasing"
    )
    set_source_files_properties(
        lib/basisu/transcoder/basisu_transcoder.cpp
        PROPERTIES COMPILE_OPTIONS "-Wno-sign-compare;-Wno-unused-function;-Wno-unused-variable;-Wno-class-memaccess;-Wno-maybe-uninitialized"
    )
    if (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL "11.0")
        set_source_files_properties(
            lib/basisu/zstd/zstd.c
            PROPERTIES COMPILE_OPTIONS "-Wno-unused-but-set-variable"
        )
    endif()
elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
    if (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL "12.0.5")
        set_source_files_properties( lib/basisu/encoder/basisu_kernels_sse.cpp
            PROPERTIES COMPILE_OPTIONS "-Wno-unused-parameter;-Wno-deprecated-copy;-Wno-uninitialized-const-reference"
            )
    else()
        set_source_files_properties( lib/basisu/encoder/basisu_kernels_sse.cpp
            PROPERTIES COMPILE_OPTIONS "-Wno-unused-parameter"
        )
    endif()
    if (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL "13.1")
        set_source_files_properties(
            # We haven't fixed zstd.c because the fix would have to be applied
            # every time the upstream script is used to create an updated
            # single file decoder.
            lib/basisu/zstd/zstd.c
            PROPERTIES COMPILE_OPTIONS "-Wno-unused-but-set-variable"
        )
    endif()
    if (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL "15.0")
        # These are for Emscripten which is ahead of xcode in its clang
        # version. Also future proofing for when xcode catches up.
        set_source_files_properties(
            ${BASISU_ENCODER_CXX_SRC}
            PROPERTIES COMPILE_OPTIONS "-Wno-sign-compare;-Wno-unused-variable;-Wno-unused-parameter"
        )
        set_source_files_properties(
            lib/basisu/transcoder/basisu_transcoder.cpp
            PROPERTIES COMPILE_OPTIONS "-Wno-sign-compare;-Wno-unused-function;-Wno-unused-variable"
        )
        set_source_files_properties(
            lib/basisu/zstd/zstd.c
            PROPERTIES COMPILE_OPTIONS "-Wno-unused-but-set-variable;-Wno-bitwise-instead-of-logical"
        )
    endif()
else()
    message(ERROR "${CMAKE_CXX_COMPILER_ID} not yet supported.")
endif()

The unused-but-set-variable warning is the subject of issue #293 and the deprecated-copy warning is the subject of issue #242 .