ApprovalTests.cpp icon indicating copy to clipboard operation
ApprovalTests.cpp copied to clipboard

Fix compilation with clang on Windows.

Open JKot-Coder opened this issue 2 years ago • 2 comments

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.

JKot-Coder avatar Jul 13 '23 19:07 JKot-Coder

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 avatar Aug 05 '23 17:08 claremacrae

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.

claremacrae avatar Aug 05 '23 17:08 claremacrae