Skip to content

Commit

Permalink
Support clang-cl from Windows.Clang.toolchain.cmake (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkSchofield committed Oct 12, 2023
2 parents ddef546 + 5a32aca commit 2b72525
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Expand Up @@ -31,7 +31,7 @@ jobs:
fail-fast: false
matrix:
configuration: [ Debug, Release ]
buildPreset: [ windows-msvc-x64, windows-msvc-amd64, windows-msvc-x86, windows-msvc-arm64, windows-clang-x64, windows-clang-amd64 ]
buildPreset: [ windows-msvc-x64, windows-msvc-amd64, windows-msvc-x86, windows-msvc-arm64, windows-clang-x64, windows-clang-amd64, windows-clangcl-x64, windows-clangcl-amd64 ]
runs-on: windows-latest
steps:
- name: Checkout
Expand Down
14 changes: 12 additions & 2 deletions Windows.Clang.toolchain.cmake
Expand Up @@ -89,16 +89,26 @@ findVisualStudio(
installationPath VS_INSTALLATION_PATH
)

set(TOOLCHAIN_C_COMPILER_EXE clang.exe)
if(CMAKE_C_COMPILER_FRONTEND_VARIANT STREQUAL MSVC)
set(TOOLCHAIN_C_COMPILER_EXE clang-cl.exe)
endif()

find_program(CMAKE_C_COMPILER
clang.exe
${TOOLCHAIN_C_COMPILER_EXE}
HINTS
"${VS_INSTALLATION_PATH}/VC/Tools/Llvm/x64/bin"
"$ENV{ProgramFiles}/LLVM/bin"
REQUIRED
)

set(TOOLCHAIN_CXX_COMPILER_EXE clang++.exe)
if(CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL MSVC)
set(TOOLCHAIN_CXX_COMPILER_EXE clang-cl.exe)
endif()

find_program(CMAKE_CXX_COMPILER
clang++.exe
${TOOLCHAIN_CXX_COMPILER_EXE}
HINTS
"${VS_INSTALLATION_PATH}/VC/Tools/Llvm/x64/bin"
"$ENV{ProgramFiles}/LLVM/bin"
Expand Down
42 changes: 42 additions & 0 deletions example/CMakePresets.json
Expand Up @@ -43,6 +43,22 @@
},
"binaryDir": "${sourceDir}/__output/${presetName}"
},
{
"name": "windows-clangcl",
"inherits": "windows",
"hidden": true,
"displayName": "Windows-only configuration",
"description": "This build is only available on Windows",
"generator": "Ninja Multi-Config",
"cacheVariables": {
"CMAKE_C_COMPILER_FRONTEND_VARIANT": "MSVC",
"CMAKE_CXX_COMPILER_FRONTEND_VARIANT": "MSVC",
"CMAKE_TOOLCHAIN_FILE": "../Windows.Clang.toolchain.cmake",
"CMAKE_VS_VERSION_RANGE": "[16.0,18.0)",
"CMAKE_VS_VERSION_PRERELEASE": "ON"
},
"binaryDir": "${sourceDir}/__output/${presetName}"
},
{
"name": "ewdk",
"displayName": "EWDK configuration",
Expand Down Expand Up @@ -110,6 +126,24 @@
"CMAKE_SYSTEM_PROCESSOR": "AMD64",
"CLANG_TIDY_CHECKS": "bugprone*,-bugprone-easily-swappable-parameters"
}
},
{
"name": "windows-clangcl-x64",
"inherits": "windows-clangcl",
"displayName": "Configure for 'windows-clangcl-x64'",
"binaryDir": "${sourceDir}/__output/${presetName}",
"cacheVariables": {
"CMAKE_SYSTEM_PROCESSOR": "x64"
}
},
{
"name": "windows-clangcl-amd64",
"inherits": "windows-clangcl",
"displayName": "Configure for 'windows-clangcl-amd64'",
"binaryDir": "${sourceDir}/__output/${presetName}",
"cacheVariables": {
"CMAKE_SYSTEM_PROCESSOR": "AMD64"
}
}
],
"buildPresets": [
Expand Down Expand Up @@ -137,6 +171,14 @@
"name": "windows-clang-amd64",
"configurePreset": "windows-clang-amd64"
},
{
"name": "windows-clangcl-x64",
"configurePreset": "windows-clangcl-x64"
},
{
"name": "windows-clangcl-amd64",
"configurePreset": "windows-clangcl-amd64"
},
{
"name": "ewdk",
"configurePreset": "ewdk"
Expand Down
Binary file modified example/WindowsApplication/WindowsApplication.rc
Binary file not shown.

0 comments on commit 2b72525

Please sign in to comment.