approvals / ApprovalTests.cpp

Native ApprovalTests for C++ on Linux, Mac and Windows
https://approvaltestscpp.readthedocs.io/en/latest/
Apache License 2.0
317 stars 51 forks source link

Fix compilation with clang on Windows. #209

Open JKot-Coder opened 1 year ago

JKot-Coder commented 1 year ago

Description

This change addresses an issue where compilation fails on Windows with Clang due to unknown options "/W4 /WX" being passed to the Clang compiler.

The solution

The rationale behind this change is that CMAKE_CXX_SIMULATE_ID is intended to specify only the ABI of the compiler, whereas CMAKE_CXX_COMPILER_FRONTEND_VARIANT is used to specify the command-line argument style. By using CMAKE_CXX_COMPILER_FRONTEND_VARIANT, we ensure that the correct options are passed to the Clang compiler on Windows, resolving the compilation failure.

For both clang.exe and clang-cl.exe CMAKE_CXX_SIMULATE_ID is defined as MVSC, but CMAKE_CXX_COMPILER_FRONTEND_VARIANT is defined "GNU" in first case and "MVSC" in second.

claremacrae commented 1 year ago

Hi, many thanks for offering this change.

Before I merge this, I would like to set up a failing build in order to see the problem in action.

For this reason, I spent today getting most of the GitHub Actions builds back to green here.

In fact, I was hoping I would see a failure that would be fixed by merging this...

claremacrae commented 1 year ago

We do have a CI build that uses Windows VS-latest and clangcl.

Do you happen to have a build in GitHub Actions that I could check, to see how it is set up, and add it to the GitHub Actions here, please?

Then I can see it fail, and go ahead and merge your fix and see it pass.