google / googletest

GoogleTest - Google Testing and Mocking Framework
https://google.github.io/googletest/
BSD 3-Clause "New" or "Revised" License
34.72k stars 10.14k forks source link

SEH '__try' is not supported on this target #3804

Open alessandrofasse opened 2 years ago

alessandrofasse commented 2 years ago

I am trying to build gtest using the newest dpcpp compiler from Intel's OneAPI using cmake(over conan). The following command in the build process

C:\PROGRA~2\Intel\oneAPI\compiler\latest\windows\bin\dpcpp.exe  /nologo /TP -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_LANG_CXX11=1 -IC:\Users\fasse\.conan\data\gtest\1.11.0\_\_\build\64a36df9c6e6617128292406c92cabec8d1db3c6\source_subfolder\googlemock\include -IC:\Users\fasse\.conan\data\gtest\1.11.0\_\_\build\64a36df9c6e6617128292406c92cabec8d1db3c6\source_subfolder\googlemock -IC:\Users\fasse\.conan\data\gtest\1.11.0\_\_\build\64a36df9c6e6617128292406c92cabec8d1db3c6\source_subfolder\googletest\include -IC:\Users\fasse\.conan\data\gtest\1.11.0\_\_\build\64a36df9c6e6617128292406c92cabec8d1db3c6\source_subfolder\googletest /DWIN32 /D_WINDOWS /W4 /GR    -MT /O2 /Ob2 /DNDEBUG  -GS -W4  -wd4251 -wd4275 -nologo -J -D_UNICODE -DUNICODE -DWIN32 -D_WIN32 -DSTRICT -DWIN32_LEAN_AND_MEAN -wd4702 -utf-8 -DGTEST_HAS_PTHREAD=0 -EHsc -D_HAS_EXCEPTIONS=1  -Qstd=c++20 -QMD -QMT source_subfolder\googlemock\CMakeFiles\gmock_main.dir\__\googletest\src\gtest-all.cc.obj -QMF source_subfolder\googlemock\CMakeFiles\gmock_main.dir\__\googletest\src\gtest-all.cc.obj.d /Fosource_subfolder\googlemock\CMakeFiles\gmock_main.dir\__\googletest\src\gtest-all.cc.obj /Fdbin\gmock_main.pdb -c C:\Users\fasse\.conan\data\gtest\1.11.0\_\_\build\64a36df9c6e6617128292406c92cabec8d1db3c6\source_subfolder\googletest\src\gtest-all.cc

yields this error:

C:\Users\fasse\.conan\data\gtest\1.11.0\_\_\build\64a36df9c6e6617128292406c92cabec8d1db3c6\source_subfolder\googletest\src/gtest.cc(2591,3): error: SEH '__try' is not supported on this target

I checked that my cmake script works on linux (also with dpcpp of course) but it is not working on windows. Versions are: Intel OneAPI

& dpcpp --version
Intel(R) oneAPI DPC++/C++ Compiler 2022.0.0 (2022.0.0.20211123)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\PROGRA~2\Intel\oneAPI\compiler\latest\windows\bin-llvm

Cmake

& cmake --version
cmake version 3.23.1
CMake suite maintained and supported by Kitware (kitware.com/cmake).

and conan is on 1.47.0. The build system is ninja

I figured out that this might be a problem with respect to the __try extension of C on Windows for MSVC but I can not use that information to resolve this problem.

derekmauro commented 2 years ago

This compiler isn't on our list of supported compilers. However, we would accept a pull-request from the community to fix this issue.

bbarenblat commented 2 years ago

In the meantime, you may be able to work around the issue by manually defining the GTEST_HAS_SEH preprocessor symbol to 0 before including any googletest headers.