Skip to content

Commit

Permalink
Turn off spam warning from clang 20.
Browse files Browse the repository at this point in the history
Fix FP settings for libktx build.
  • Loading branch information
MarkCallow committed Aug 27, 2024
1 parent a46e85f commit bdb2f92
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 22 deletions.
38 changes: 17 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,10 @@ endif()

# For Visual Studio prior to 2022 (compiler < 19.30) /fp:strict
# For Visual Studio 2022 (compiler >= 19.30) /fp:precise
# For Visual Studio 2022 ClangCL seems to have accidentally enabled contraction by default,
# so behaves differently to CL.exe. Use the -Xclang argument to workaround and allow access
# GNU-style switch to control contraction and force disable.
# For Visual Studio 2022 ClangCL has enabled contraction by default,
# which is the same as standard clang, so behaves differently to
# CL.exe. Use the -Xclang argument to access GNU-style switch to
# control contraction and force disable.

# On CMake 3.25 or older CXX_COMPILER_FRONTEND_VARIANT is not always set
if(CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "")
Expand All @@ -338,6 +339,7 @@ set(is_gnu_fe1 "$<STREQUAL:${CMAKE_CXX_COMPILER_FRONTEND_VARIANT},GNU>")
set(is_gnu_fe2 "$<STREQUAL:${CMAKE_CXX_COMPILER_FRONTEND_VARIANT},AppleClang>")
# Compiler accepts GNU-style command line options
set(is_gnu_fe "$<OR:${is_gnu_fe1},${is_gnu_fe2}>")
#add_custom_target(debug_isgnufe1 COMMAND ${CMAKE_COMMAND} -E echo "is_gnufe1_exp = $<STREQUAL:${CMAKE_CXX_COMPILER_FRONTEND_VARIANT},GNU>")

# Compiler is Visual Studio cl.exe
set(is_msvccl "$<AND:${is_msvc_fe},$<CXX_COMPILER_ID:MSVC>>")
Expand All @@ -346,24 +348,18 @@ set(is_clangcl "$<AND:${is_msvc_fe},$<CXX_COMPILER_ID:Clang>>")
# Compiler is upstream clang with the standard frontend
set(is_clang "$<AND:${is_gnu_fe},$<CXX_COMPILER_ID:Clang,AppleClang>>")

if(${is_msvccl} AND $<VERSION_LESS:$<CXX_COMPILER_VERSION>,19.30>)
add_compile_options(/fp:strict)
endif()
if(${is_msvccl} AND $<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,19.30>)
add_compile_options(/fp:precise)
endif()
if(${is_clangcl})
add_compile_options(/fp:precise)
endif()
if(${is_clangcl} AND $<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,14.0.0>)
add_compile_options(-Xclang -ffp-contract=off)
endif()
if(${is_clang} AND $<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,10.0.0>)
add_compile_options(-ffp-model=precise)
endif()
if(${is_gnu_fe})
add_compile_options(-ffp-contract=off)
endif()
add_compile_options(
$<$<AND:${is_msvccl},$<VERSION_LESS:$<CXX_COMPILER_VERSION>,19.30>>:/fp:strict>
$<$<AND:${is_msvccl},$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,19.30>>:/fp:precise>
$<${is_clangcl}:/fp:precise>
$<$<AND:${is_clangcl},$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,14.0.0>>:-Xclang$<SEMICOLON>-ffp-contract=off>
$<$<AND:${is_clang},$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,10.0.0>>:-ffp-model=precise>
$<${is_gnu_fe}:-ffp-contract=off>
# Hide noise from clang and clangcl 20 warning the 2nd fp option changes
# one of the settings made the first.
$<$<AND:${is_clang},$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,20.0.0>>:-Wno-overriding-option>
)
#add_custom_target(debug_gnufe_ffpcontract COMMAND ${CMAKE_COMMAND} -E echo "ffp_contract = $<${is_gnu_fe}:-ffp-contract=off>")

set(KTX_BUILD_DIR "${CMAKE_BINARY_DIR}")

Expand Down
1 change: 1 addition & 0 deletions external/astc-encoder/Source/cmake_core.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ macro(astcenc_set_properties ASTCENC_TARGET_NAME ASTCENC_IS_VENEER)
$<${is_gnu_fe}:-Wno-float-equal>
$<${is_gnu_fe}:-Wno-deprecated-declarations>
$<${is_gnu_fe}:-Wno-atomic-implicit-seq-cst>
$<${is_clang}:-Wno-overriding-option>

# Clang 10 also throws up warnings we need to investigate (ours)
$<${is_gnu_fe}:-Wno-cast-align>
Expand Down
8 changes: 7 additions & 1 deletion scripts/build_wasm_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,18 @@ mkdir -p $BUILD_DIR
# emcmake uses the "Unix Makefiles" generator on Linux which does not
# support multiple configurations.
echo "Configure and Build KTX-Software (Web $CONFIGURATION)"

# Uncomment and set to desired targets if you don't want to build everything.
#targets="--target debug_isgnufe1 --target debug_gnufe_ffpcontract"
# Uncomment to have make run in verbose mode.
#verbose_make="-- VERBOSE=1"

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"
&& cmake --build $BUILD_DIR $targets $verbose_make"

if [ "$PACKAGE" = "YES" ]; then
echo "Pack KTX-Software (Web $CONFIGURATION)"
Expand Down

0 comments on commit bdb2f92

Please sign in to comment.