From e032d57642d2a042b9445b2199277bb24fee2eb5 Mon Sep 17 00:00:00 2001 From: Niranjan Nilakantan Date: Wed, 24 May 2023 12:48:51 -0700 Subject: Build googletest with IntelLLVM compilers. Use the same flags as Clang if the compiler id is IntelLLVM. IntelLLVM warns if a double constant is assigned to a float. ``` [build] .../googletest/googletest/include/gtest/gtest-printers.h:516:17: warning: implicit conversion between floating point types of different sizes [-Wimplicit-float-size-conversion] [build] mulfor6 = 1e1; ``` IntelLLVM uses fp-model=fast by default, breaking IsNan and IsInf tests. Use -ffp-model=precise to fix this. IntelLLVM does not support -Wchar-subscripts Fixes #4255 --- googletest/cmake/internal_utils.cmake | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake index fa7da4e..f45a3be 100644 --- a/googletest/cmake/internal_utils.cmake +++ b/googletest/cmake/internal_utils.cmake @@ -94,12 +94,18 @@ macro(config_compiler_and_linker) if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") set(cxx_base_flags "${cxx_base_flags} -utf-8") endif() - elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR + CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM") set(cxx_base_flags "-Wall -Wshadow -Wconversion -Wundef") set(cxx_exception_flags "-fexceptions") set(cxx_no_exception_flags "-fno-exceptions") - set(cxx_strict_flags "-W -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wredundant-decls") + set(cxx_strict_flags "-W -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wunused-parameter -Wcast-align -Winline -Wredundant-decls") set(cxx_no_rtti_flags "-fno-rtti") + if (CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM") + set(cxx_base_flags "${cxx_base_flags} -Wno-implicit-float-size-conversion -ffp-model=precise") + else() + set(cxx_strict_flags "${cxx_strict_flags} -Wchar-subscripts") + endif() elseif (CMAKE_COMPILER_IS_GNUCXX) set(cxx_base_flags "-Wall -Wshadow -Wundef") if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0.0) -- cgit v0.12 From 029d3dddd4ba2788c5203490e63a24c02328bff8 Mon Sep 17 00:00:00 2001 From: niranjan Date: Wed, 24 May 2023 17:33:46 -0700 Subject: Disable some warnings for IntelLLVM on Windows. Use /fp:precise to override IntelLLVM's default of /fp:fast. This makes IsInf and IsNan work as expected by googletest. ``` [build]...\googletest\googlemock\test\gmock-function-mocker_test.cc(143,21): error: 'VoidReturning' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-override] [build] MOCK_METHOD(void, VoidReturning, (int n)); // NOLINT ``` ``` [build] ...\googletest\googlemock\test\gmock-function-mocker_test.cc(182,20): error: exception specification of overriding function is more lax than base version [-Werror,-Wmicrosoft-exception-spec] [build] MOCK_METHOD(int, CTNullary, (), (Calltype(STDMETHODCALLTYPE))); ``` ``` [build] ...\googletest\googletest\test\googletest-death-test-test.cc(209,5): error: unused function 'DieInCRTDebugElse12' [-Werror,-Wunused-function] [build] int DieInCRTDebugElse12(int* sideeffect) { [build] ^ ``` ``` [build] ...\googletest\googletest\test\gtest_unittest.cc(4096,7): error: variable 'n' set but not used [-Werror,-Wunused-but-set-variable] [build] int n = 0; ``` --- googletest/cmake/internal_utils.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake index f45a3be..e7927a3 100644 --- a/googletest/cmake/internal_utils.cmake +++ b/googletest/cmake/internal_utils.cmake @@ -94,6 +94,9 @@ macro(config_compiler_and_linker) if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") set(cxx_base_flags "${cxx_base_flags} -utf-8") endif() + if (CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM") + set(cxx_base_flags "${cxx_base_flags} /fp:precise -Wno-inconsistent-missing-override -Wno-microsoft-exception-spec -Wno-unused-function -Wno-unused-but-set-variable") + endif() elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM") set(cxx_base_flags "-Wall -Wshadow -Wconversion -Wundef") -- cgit v0.12