On Win11, a good way to start is to open a Developer Powershell in terminal.exe. That has all the compilers and tools in the path. Specifically it has cl.exe
, clang.exe
, and clang-cl.exe
. CMake seems to pick cl.exe
by default. Is there a way to get CMake to set up the clang
-based tool chain instead?
I is possible to select the right preset:
/Users/clausklein/Workspace/cmake/WindowsToolchain/example
Claus-iMac:example clausklein$ cmake --list-presets
Available configure presets:
"windows-msvc-x64" - Configure for 'windows-msvc-x64'
"windows-msvc-spectre-x64" - Configure for 'windows-msvc-spectre-x64'
"windows-msvc-amd64" - Configure for 'windows-msvc-amd64'
"windows-msvc-x86" - Configure for 'windows-msvc-x86'
"windows-msvc-arm64" - Configure for 'windows-msvc-arm64'
"windows-clang-x64" - Configure for 'windows-clang-x64'
"windows-clang-amd64" - Configure for 'windows-clang-amd64'
"windows-clangcl-x64" - Configure for 'windows-clangcl-x64'
"windows-clangcl-amd64" - Configure for 'windows-clangcl-amd64'
"ewdk" - EWDK configuration
Claus-iMac:example clausklein$ git describe --tags
v0.9.0
Claus-iMac:example clausklein$
Set CC and CXX env vars before running CMake to the compiler you want.