Skip to content

Commit caa200f

Browse files
committed
CMakeLists.txt: Set -fno-strict-aliasing for basisu
Several basisu headers demand doing this ("Important: If compiling with gcc, be sure strict aliasing is disabled: -fno-strict-aliasing") and their own CMakeLists.txt (that's not used here) also sets it and explicitly mentions (in a comment in its first line) that strict aliasing optimizations must be disabled for both the encoder and decoder
1 parent 31753f8 commit caa200f

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

CMakeLists.txt

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
847847
# It's too much work to discriminate which files need which warnings
848848
# disabled.
849849
${BASISU_ENCODER_CXX_SRC}
850-
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"
850+
PROPERTIES COMPILE_OPTIONS "-Wno-sign-compare;-Wno-unused-variable;-Wno-class-memaccess;-Wno-misleading-indentation;-Wno-extra;-Wno-deprecated-copy;-Wno-parentheses"
851851
)
852852
set_source_files_properties(
853853
external/basisu/transcoder/basisu_transcoder.cpp
@@ -945,6 +945,26 @@ else()
945945
message(FATAL_ERROR "${CMAKE_CXX_COMPILER_ID} not yet supported.")
946946
endif()
947947

948+
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
949+
# Basis Universal requires strict aliasing to be disabled for GCC and Clang
950+
get_source_file_property(cur_options
951+
external/basisu/encoder/basisu_comp.cpp
952+
COMPILE_OPTIONS
953+
)
954+
set_source_files_properties(
955+
${BASISU_ENCODER_CXX_SRC}
956+
PROPERTIES COMPILE_OPTIONS "${cur_options};-fno-strict-aliasing"
957+
)
958+
get_source_file_property(cur_options
959+
external/basisu/transcoder/basisu_transcoder.cpp
960+
COMPILE_OPTIONS
961+
)
962+
set_source_files_properties(
963+
external/basisu/transcoder/basisu_transcoder.cpp
964+
PROPERTIES COMPILE_OPTIONS "${cur_options};-fno-strict-aliasing"
965+
)
966+
endif()
967+
948968
# Retrieve the final set of properties for use by the transcodetests.
949969
# We do this because the CMake feature that would allow the transcodetests
950970
# target to retrieve these from the ktx target are not available until

0 commit comments

Comments
 (0)