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

CMake: Enable using clang-cl on windows #1651

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

enetheru
Copy link
Contributor

@enetheru enetheru commented Nov 24, 2024

As listed here: #1250
clang-cl on windows installed from official llvm website fails because it emulates the msvc interface.

Prior solution assumed that because compiler is clang it uses gnu interface.

CMake offers some helper variables to account for this simulation/emulation of other compilers like:
CMAKE_CXX_COMPILER_FRONTEND_VARIANT

This PR detects the difference and sets the helper variables to match what is in use.
It isn't robust enough to mix and match compiler and linker interfaces though, so using a gnu style linker with an msvc style compiler will fail.

I've tested this on windows and mac, with windows based compilers msvc, msys-gcc msys-clang, llvm, mingw64, without issue.

Fixes #1250

@enetheru enetheru requested a review from a team as a code owner November 24, 2024 03:54
@dsnopek dsnopek added cmake topic:buildsystem Related to the buildsystem or CI setup labels Nov 25, 2024
@dsnopek dsnopek added this to the 4.x milestone Nov 25, 2024
Copy link
Collaborator

@dsnopek dsnopek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I haven't tested (Windows isn't my main dev environment), but the code seems OK from a quick skimming, and CI is passing :-)

@enetheru
Copy link
Contributor Author

I've also fixed the commit message like asked.

@dsnopek
Copy link
Collaborator

dsnopek commented Nov 28, 2024

This one will need a rebase - there's a conflict after having merged a few of your other PRs

When downloading clang from llvm.org the compiler defaults to clang-cl with the msvc compiler interface.

This commit detects that scenario and sets the helper variables to account for it.

Cleans up the other duplicated helper variables that are still in scope.
And fixes formatting.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmake topic:buildsystem Related to the buildsystem or CI setup
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Binding fails on Windows using Ninja + Clang
2 participants