In a mixed C/C++/Swift CMake project on Windows, which C/C++ compiler should I use: clang, clang-cl, or MSVC?
I want to drive this setting through a CMakePresets.json:
"configurePresets": [
{
"name": "debug",
"displayName": "CMake Configure (Debug)",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_C_COMPILER": "clang-cl",
"CMAKE_CXX_COMPILER": "clang-cl",
Specifying clang-cl gives me:
>cmake --preset debug
-- The C compiler identification is Clang 19.1.5 with MSVC-like command-line
-- The CXX compiler identification is Clang 19.1.5 with MSVC-like command-line
-- The Swift compiler identification is Apple 6.3
Using clang and clang++ from the Swift toolchain
"configurePresets": [
{
"name": "debug",
"displayName": "CMake Configure (Debug)",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/debug",
"cacheVariables": {
"CMAKE_C_COMPILER": "$env{SWIFT_TOOLCHAIN_PATH}/bin/clang.exe",
"CMAKE_CXX_COMPILER": "$env{SWIFT_TOOLCHAIN_PATH}/bin/clang++.exe",
"SWIFT_TOOLCHAIN_PATH": "$env{SWIFT_TOOLCHAIN_PATH}",
"CMAKE_Swift_COMPILER": "$env{SWIFT_COMPILER}",
gives me
>cmake --preset debug
-- The C compiler identification is Clang 19.1.5 with GNU-like command-line
-- The CXX compiler identification is Clang 19.1.5 with GNU-like command-line
-- The Swift compiler identification is Apple 6.3
Edit: I guess this is what I want.
Not specifying a CMAKE_C(XX)_COMPILER results in MSVC:
E:\sandbox\ktraunmueller\compositor\Sources\Win\Compositor-Win>cmake --preset debug
-- The C compiler identification is MSVC 19.42.34435.0
-- The CXX compiler identification is MSVC 19.42.34435.0
-- The Swift compiler identification is Apple 6.3