Skip to content

Fix CMake toolchain file for clang-cl with - args - #16343

Open
TGillingham wants to merge 1 commit into
mesonbuild:masterfrom
TGillingham:clang-cl-cmake-cmdline-option
Open

TGillingham wants to merge 1 commit into
mesonbuild:masterfrom
TGillingham:clang-cl-cmake-cmdline-option

Conversation

@TGillingham

Copy link
Copy Markdown

The target for clang-cl is determined in part by passing args like -m32, which don't follow the msvc argument syntax.

This caused problems with the generated CMake toolchain file when attempting a cross compilation with clang-cl: the -m32 argument was not detected as a command line option, so clang-cl was set as the CMAKE_C_COMPILER_LAUNCHER, and -m32 was set as the CMAKE_C_COMPILER.

Detect when clang-cl is in use and consider both / and - as command line option prefixes. With this change, a binary such as ['clang-cl', '-m32'] will generate CMake toolchain file that uses clang-cl instead of -m32 as the compiler.

The target for clang-cl is determined in part by passing args like `-m32`,
which don't follow the msvc argument syntax.

This caused problems with the generated CMake toolchain file when
attempting a cross compilation with clang-cl: the `-m32` argument
was not detected as a command line option, so clang-cl was set as the
`CMAKE_C_COMPILER_LAUNCHER`, and `-m32` was set as the `CMAKE_C_COMPILER`.

Detect when clang-cl is in use and consider both `/` and `-` as command
line option prefixes. With this change, a binary such as `['clang-cl',
'-m32']` will generate CMake toolchain file that uses `clang-cl` instead of
`-m32` as the compiler.
@TGillingham
TGillingham marked this pull request as ready for review November 6, 2026 14:52
@TGillingham
TGillingham requested a review from mensinda as a code owner November 6, 2026 14:52
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