@@ -764,7 +764,6 @@ macro(common_libktx_settings target enable_write library_type)
764764 PRIVATE
765765 lib/basis_encode.cpp
766766 lib/astc_codec.cpp
767- ${BASISU_ENCODER_C_SRC}
768767 ${BASISU_ENCODER_CXX_SRC}
769768 lib/writer1.c
770769 lib/writer2.c
@@ -838,6 +837,30 @@ PRIVATE
838837 BASISD_SUPPORT_KTX2=0
839838)
840839
840+ # helper function to append COMPILE_OPTIONS to source file properties
841+ # !! if SRCFILES is a list, remember to quote it !!
842+ # !! like add_source_file_compile_options("${MY_SRC_LIST}" "-Wall") !!
843+ # !! or add_source_file_compile_options("dir/foo.cpp;dir/bar.cpp" "-Wextra") !!
844+ function (add_source_file_compile_options SRCFILES OPTIONS )
845+ foreach (src_file ${SRCFILES} )
846+ get_source_file_property (cur_options
847+ "${src_file} "
848+ COMPILE_OPTIONS
849+ )
850+ if (cur_options)
851+ set_source_files_properties (
852+ "${src_file} "
853+ PROPERTIES COMPILE_OPTIONS "${cur_options} ;${OPTIONS} "
854+ )
855+ else () # if cur_options were undefined or empty ("")
856+ set_source_files_properties (
857+ "${src_file} "
858+ PROPERTIES COMPILE_OPTIONS "${OPTIONS} "
859+ )
860+ endif ()
861+ endforeach ()
862+ endfunction ()
863+
841864# Turn off these warnings until Rich fixes the occurences.
842865# It it not clear to me if generator expressions can be used here
843866# hence the long-winded way.
@@ -848,55 +871,39 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
848871 # It's too much work to discriminate which files need which warnings
849872 # disabled.
850873 ${BASISU_ENCODER_CXX_SRC}
851- 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 "
874+ PROPERTIES COMPILE_OPTIONS "-fno-strict-aliasing;- Wno-sign-compare;-Wno-unused-variable;-Wno-class-memaccess;-Wno-misleading-indentation;-Wno-extra;-Wno-deprecated-copy;-Wno-parentheses"
852875 )
853876 set_source_files_properties (
854877 external/basisu/transcoder/basisu_transcoder.cpp
855- PROPERTIES COMPILE_OPTIONS "-Wno-sign-compare;-Wno-unused-function;-Wno-unused-variable;-Wno-class-memaccess;-Wno-maybe-uninitialized"
878+ PROPERTIES COMPILE_OPTIONS "-fno-strict-aliasing;- Wno-sign-compare;-Wno-unused-function;-Wno-unused-variable;-Wno-class-memaccess;-Wno-maybe-uninitialized"
856879 )
857880 if (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL "11" )
858881 if (${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS "12" )
859- # Version 11 raises several stringop-overflow warnings in some
860- # very hard to decipher code. They appear to be bogus based on
861- # the facts that we have never seen a crash and version 12 no
862- # longer raises the warnings.
863- get_source_file_property (cur_options
864- external/basisu/encoder/basisu_comp.cpp
865- COMPILE_OPTIONS
866- )
867- set_source_files_properties (
868- external/basisu/encoder/basisu_comp.cpp
869- PROPERTIES COMPILE_OPTIONS "${cur_options} ;-Wno-stringop-overflow"
870- )
882+ # Version 11 raises several stringop-overflow warnings in some
883+ # very hard to decipher code. They appear to be bogus based on
884+ # the facts that we have never seen a crash and version 12 no
885+ # longer raises the warnings.
886+ add_source_file_compile_options (
887+ external/basisu/encoder/basisu_comp.cpp
888+ "-Wno-stringop-overflow"
889+ )
871890 endif ()
872891 endif ()
873892 if (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL "12.0" )
874893 # Version 12 newly raises this warning on basisu_uastc_enc.cpp.
875894 # There seems no way for the index calculated by the code at
876895 # line 326, where the error is raised, to be > the array length.
877896 # Also we have never seen any crashes.
878- set_source_files_properties (
897+ add_source_file_compile_options (
879898 external/basisu/encoder/basisu_uastc_enc.cpp
880- PROPERTIES COMPILE_OPTIONS "-Wno-stringop-overflow"
899+ "-Wno-stringop-overflow"
881900 )
882901 endif ()
883902 if (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL "14.0" )
884903 # Version 14 raises stringop-overflow on these files.
885- get_source_file_property (cur_options
886- external/basisu/encoder/basisu_comp.cpp
887- COMPILE_OPTIONS
888- )
889- set_source_files_properties (
890- external/basisu/transcoder/basisu_transcoder.cpp
891- PROPERTIES COMPILE_OPTIONS "${cur_options} ;-Wno-stringop-overflow"
892- )
893- get_source_file_property (cur_options
894- external/basisu/encoder/basisu_bc7enc.cpp
895- COMPILE_OPTIONS
896- )
897- set_source_files_properties (
898- external/basisu/encoder/basisu_bc7enc.cpp
899- PROPERTIES COMPILE_OPTIONS "${cur_options} ;-Wno-stringop-overflow"
904+ add_source_file_compile_options (
905+ "external/basisu/transcoder/basisu_transcoder.cpp;external/basisu/encoder/basisu_bc7enc.cpp"
906+ "-Wno-stringop-overflow"
900907 )
901908 endif ()
902909elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
@@ -919,23 +926,31 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
919926 set ( clang_version ${CMAKE_CXX_COMPILER_VERSION} )
920927 endif ()
921928 # BEWARE: set_source_files_properties is not additive; it replaces.
929+ set_source_files_properties (
930+ ${BASISU_ENCODER_CXX_SRC}
931+ PROPERTIES COMPILE_OPTIONS "-fno-strict-aliasing"
932+ )
933+ set_source_files_properties (
934+ external/basisu/transcoder/basisu_transcoder.cpp
935+ PROPERTIES COMPILE_OPTIONS "-fno-strict-aliasing"
936+ )
922937 if (${clang_version} VERSION_GREATER_EQUAL "12.0.0" )
923- set_source_files_properties ( external/basisu/encoder/basisu_kernels_sse.cpp
924- PROPERTIES COMPILE_OPTIONS "-Wno-unused-parameter;-Wno-deprecated-copy;-Wno-uninitialized-const-reference"
938+ add_source_file_compile_options ( external/basisu/encoder/basisu_kernels_sse.cpp
939+ "-Wno-unused-parameter;-Wno-deprecated-copy;-Wno-uninitialized-const-reference"
925940 )
926941 else ()
927- set_source_files_properties ( external/basisu/encoder/basisu_kernels_sse.cpp
928- PROPERTIES COMPILE_OPTIONS "-Wno-unused-parameter"
942+ add_source_file_compile_options ( external/basisu/encoder/basisu_kernels_sse.cpp
943+ "-Wno-unused-parameter"
929944 )
930945 endif ()
931946 if (${clang_version} VERSION_GREATER_EQUAL "14.0" )
932- set_source_files_properties (
933- ${BASISU_ENCODER_CXX_SRC}
934- PROPERTIES COMPILE_OPTIONS "-Wno-sign-compare;-Wno-unused-variable;-Wno-unused-parameter;-Wno-deprecated-copy-with-user-provided-copy"
947+ add_source_file_compile_options (
948+ " ${BASISU_ENCODER_CXX_SRC} "
949+ "-Wno-sign-compare;-Wno-unused-variable;-Wno-unused-parameter;-Wno-deprecated-copy-with-user-provided-copy"
935950 )
936- set_source_files_properties (
951+ add_source_file_compile_options (
937952 external/basisu/transcoder/basisu_transcoder.cpp
938- PROPERTIES COMPILE_OPTIONS "-Wno-sign-compare;-Wno-unused-function;-Wno-unused-variable"
953+ "-Wno-sign-compare;-Wno-unused-function;-Wno-unused-variable"
939954 )
940955 set_source_files_properties (
941956 external/basisu/zstd/zstd.c
@@ -948,7 +963,7 @@ endif()
948963
949964# Retrieve the final set of properties for use by the transcodetests.
950965# We do this because the CMake feature that would allow the transcodetests
951- # target to retrieve these from the ktx target are not available until
966+ # target to retrieve these from the ktx target is not available until
952967# v18 and we still need to work with v16 in the Emscripten Docker image.
953968get_source_file_property (transcoder_options
954969 external/basisu/transcoder/basisu_transcoder.cpp
@@ -1233,6 +1248,9 @@ if(NOT ${universal_build})
12331248 endif ()
12341249endif ()
12351250
1251+ # setting ASTCENC_DECOMPRESSOR to ON breaks the build, so force it to OFF
1252+ # and hide it from cmake-gui (by using type INTERNAL)
1253+ set (ASTCENC_DECOMPRESSOR OFF CACHE INTERNAL "" )
12361254set (ASTCENC_CLI OFF ) # Only build as library not the CLI astcencoder
12371255# Force static build for astc-encoder
12381256set (BUILD_SHARED_LIBS OFF )
@@ -1243,7 +1261,7 @@ target_compile_definitions(
12431261 ${ASTCENC_LIB_TARGET}
12441262PRIVATE
12451263 # ASTC encoder uses std::mutex. For more info. see comment about
1246- # same setting in libktx starting about line 618 . To be eventually
1264+ # same setting in libktx starting about line 633 . To be eventually
12471265 # removed as noted in that comment.
12481266 $<$<AND :${is_msvccl} ,$<VERSION_GREATER_EQUAL :$<CXX_COMPILER_VERSION >,19.40.33811>>:_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR >
12491267 $<$<AND :${is_clangcl} ,$<VERSION_GREATER_EQUAL :$<CXX_COMPILER_VERSION >,17.0.3>>:_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR >
0 commit comments