@@ -22,8 +22,6 @@ include(CMakeDependentOption)
2222include (cmake/codesign.cmake )
2323include (cmake/cputypetest.cmake )
2424
25- find_package (OpenCL )
26-
2725# OPTIONS
2826
2927if ( IOS OR EMSCRIPTEN )
@@ -64,6 +62,10 @@ CMAKE_DEPENDENT_OPTION( BASISU_SUPPORT_OPENCL
6462 OFF
6563)
6664
65+ if (BASISU_SUPPORT_OPENCL)
66+ find_package (OpenCL )
67+ endif ()
68+
6769if (BASISU_SUPPORT_OPENCL AND WIN32 AND NOT OpenCL_FOUND)
6870 # To avoid fiddly setting up of OpenCL on Windows CI VMs, use copy in repo.
6971 set (OpenCL_INCLUDE_DIR
@@ -212,13 +214,11 @@ include(cmake/mkvk.cmake)
212214
213215# Global compile & link options including optimization flags
214216if (MSVC )
215- # With /W4 VS2015 (V19.0) issues many warnings that VS2017 & 2019 don't
216- # so only increase warning level for recent versions.
217- add_compile_options ($<$<VERSION_GREATER_EQUAL :${CMAKE_CXX_COMPILER_VERSION} ,19.16>:/W4 >)
217+ add_compile_options ( /W4;/WX )
218218 add_compile_options ( $<IF :$<CONFIG :Debug >,/Gz ,/O2 > )
219219elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU"
220220 OR ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" )
221- add_compile_options (-Wall -Wextra )
221+ add_compile_options (-Wall -Wextra -Werror )
222222 add_compile_options ( $<IF :$<CONFIG :Debug >,-O0 ,-O3 > )
223223 if (EMSCRIPTEN)
224224 add_link_options ( $<IF :$<CONFIG :Debug >,-gsource -map ,-O3 > )
@@ -606,10 +606,39 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
606606 lib/basisu/transcoder/basisu_transcoder.cpp
607607 PROPERTIES COMPILE_OPTIONS "-Wno-sign-compare;-Wno-unused-function;-Wno-unused-variable;-Wno-class-memaccess;-Wno-maybe-uninitialized"
608608 )
609- if (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL "11.0" )
609+ if (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL "11" )
610+ # class-memaccess warnings n basisu_comp.cpp have been
611+ # fixed. Fixing those in the included basisu_miniz.h is
612+ # more intrusive than I want to attempt.
613+ #
614+ # The extra warnings are raised in basisu_miniz.h.
610615 set_source_files_properties (
611- lib/basisu/zstd/zstd.c
612- PROPERTIES COMPILE_OPTIONS "-Wno-unused-but-set-variable"
616+ lib/basisu/encoder/basisu_comp.cpp
617+ PROPERTIES COMPILE_OPTIONS "-Wno-class-memaccess;-Wno-extra"
618+ )
619+ if (${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS "12" )
620+ # Version 11 raises several stringop-overflow warnings in some
621+ # very hard to decipher code. They appear to be bogus based on
622+ # the facts that we have never seen a crash and version 12 no
623+ # longer raises the warnings.
624+ get_source_file_property (cur_options
625+ lib/basisu/encoder/basisu_comp.cpp
626+ COMPILE_OPTIONS
627+ )
628+ set_source_files_properties (
629+ lib/basisu/encoder/basisu_comp.cpp
630+ PROPERTIES COMPILE_OPTIONS "${cur_options} ;-Wno-stringop-overflow"
631+ )
632+ endif ()
633+ endif ()
634+ if (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL "12.0" )
635+ # Version 12 newly raises this warning on basisu_uastc_enc.cpp.
636+ # There seems no way for the index calculated by the code at
637+ # line 326, where the error is raised, to be > the array length.
638+ # Also we have never seen any crashes.
639+ set_source_files_properties (
640+ lib/basisu/encoder/basisu_uastc_enc.cpp
641+ PROPERTIES COMPILE_OPTIONS "-Wno-stringop-overflow"
613642 )
614643 endif ()
615644elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
@@ -631,31 +660,16 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
631660 else ()
632661 set ( clang_version ${CMAKE_CXX_COMPILER_VERSION} )
633662 endif ()
663+ # BEWARE: set_source_files_properties is not additive; it replaces.
634664 if (${clang_version} VERSION_GREATER_EQUAL "12.0.0" )
635665 set_source_files_properties ( lib/basisu/encoder/basisu_kernels_sse.cpp
636666 PROPERTIES COMPILE_OPTIONS "-Wno-unused-parameter;-Wno-deprecated-copy;-Wno-uninitialized-const-reference"
637667 )
638- # Primarily an issue on windows using clang/clangcl
639- # Lowest tested clang version was 12.0.0 and highest was 14.0.4
640- set_source_files_properties (
641- lib/basisu/zstd/zstd.c
642- PROPERTIES COMPILE_OPTIONS "-Wno-unused-function"
643- )
644668 else ()
645669 set_source_files_properties ( lib/basisu/encoder/basisu_kernels_sse.cpp
646670 PROPERTIES COMPILE_OPTIONS "-Wno-unused-parameter"
647671 )
648672 endif ()
649- if (${clang_version} VERSION_GREATER_EQUAL "13.0.0" )
650- get_source_file_property (zstd_options lib/basisu/zstd/zstd.c COMPILE_OPTIONS )
651- set_source_files_properties (
652- # We haven't fixed zstd.c because the fix would have to be applied
653- # every time the upstream script is used to create an updated
654- # single file decoder.
655- lib/basisu/zstd/zstd.c
656- PROPERTIES COMPILE_OPTIONS "${zstd_options} ;-Wno-unused-but-set-variable"
657- )
658- endif ()
659673 if (${clang_version} VERSION_GREATER_EQUAL "15.0" )
660674 # These are for Emscripten which is ahead of xcode in its clang
661675 # version. Also future proofing for when xcode catches up.
@@ -669,13 +683,23 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
669683 )
670684 set_source_files_properties (
671685 lib/basisu/zstd/zstd.c
672- PROPERTIES COMPILE_OPTIONS "-Wno-unused-but-set-variable;-Wno-bitwise-instead-of-logical "
686+ PROPERTIES COMPILE_OPTIONS "-Wno-unused-function "
673687 )
674688 endif ()
675689else ()
676690 message (FATAL_ERROR "${CMAKE_CXX_COMPILER_ID} not yet supported." )
677691endif ()
678692
693+ # Retrieve the final set of properties for use by the transcodetests.
694+ # We do this because the CMake feature that would allow the transcodetests
695+ # target to retrieve these from the ktx target are not available until
696+ # v18 and we still need to work with v16 in the Emscripten Docker image.
697+ get_source_file_property (transcoder_options
698+ lib/basisu/transcoder/basisu_transcoder.cpp
699+ COMPILE_OPTIONS
700+ )
701+ get_source_file_property (zstd_options lib/basisu/zstd/zstd.c COMPILE_OPTIONS )
702+
679703target_include_directories (
680704 ktx
681705PRIVATE
0 commit comments