Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly enable exception support for clang-cl (fixes #90) #91

Merged
merged 1 commit into from
Jul 9, 2022

Conversation

danvratil
Copy link
Collaborator

MSVC requires that exceptions are explicitly enabled using the \EH
flag, so clang-cl copies that behavior. When CMake targets the
Windows-MSVC platform (that is when using "Visual Studio" generator),
CMake takes care of adding \EHsc to CXXFLAGS. However when the
clang-cl compiler is specified manually (CMAKE_CXX_COMPILER) and
another generator, like Ninja is used, then CMake ends up targeting
the Windows-Clang-CXX platform, which does not enable exceptions,
so we have to do that ourselves. To keep the code simple, we do not
try to detect the target platform or such, we simply append the \EHsc
flag when we detect clang-cl.

MSVC requires that exceptions are explicitly enabled using the `\EH`
flag, so clang-cl copies that behavior. When CMake targets the
Windows-MSVC platform (that is when using "Visual Studio" generator),
CMake takes care of adding `\EHsc` to `CXXFLAGS`. However when the
clang-cl compiler is specified manually (`CMAKE_CXX_COMPILER`) and
another generator, like Ninja is used, then CMake ends up targeting
the Windows-Clang-CXX platform, which does not enable exceptions,
so we have to do that ourselves. To keep the code simple, we do not
try to detect the target platform or such, we simply append the `\EHsc`
flag when we detect clang-cl.
@danvratil danvratil force-pushed the bugfix/clang-cl-exceptions branch from 99aa570 to b8708a7 Compare July 9, 2022 11:47
@github-actions
Copy link
Contributor

github-actions bot commented Jul 9, 2022

Unit Test Results

  18 files  +  2    18 suites  +2   14m 17s ⏱️ + 2m 19s
  18 tests ±  0    17 ✔️  -   1  0 💤 ±0  1 +1 
320 runs  +36  316 ✔️ +32  0 💤 ±0  4 +4 

For more details on these failures, see this check.

Results for commit b8708a7. ± Comparison against base commit f1d0a53.

@danvratil danvratil merged commit 2c47a67 into main Jul 9, 2022
@danvratil danvratil deleted the bugfix/clang-cl-exceptions branch July 9, 2022 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant