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

[community triplet] adds triplets for building with clang/LLVM for Windows #31028

Draft
wants to merge 35 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
275e1fc
Added clangcl community triplets
walbourn Apr 21, 2023
a18148e
Added arm64 clangcl triplets
walbourn Apr 21, 2023
17a5064
Update scripts/toolchains/clangcl.cmake
walbourn Apr 21, 2023
2556204
Fix try-compile
walbourn Apr 22, 2023
5a2a35c
Additional settings recommended during code review
walbourn Apr 23, 2023
9334f9c
Remove /MP when building clang-cl.exe
walbourn Apr 24, 2023
44c8580
Add UWP suppport for clang
walbourn Apr 24, 2023
b3d05ac
Minor code cleanup
walbourn Apr 24, 2023
f50f265
Fix up find_program to respect LLVMInstallDir
walbourn Apr 27, 2023
a40ac0d
Simplified /MP guard logic
walbourn Apr 27, 2023
4a6392e
Fixed LLVMInstallDir search order and conditioning
walbourn Apr 27, 2023
23e140a
Added clangcl community triplets
walbourn Apr 21, 2023
446ed16
Added arm64 clangcl triplets
walbourn Apr 21, 2023
8303fd3
Update scripts/toolchains/clangcl.cmake
walbourn Apr 21, 2023
08e93de
Fix try-compile
walbourn Apr 22, 2023
f89d722
Additional settings recommended during code review
walbourn Apr 23, 2023
250760e
Remove /MP when building clang-cl.exe
walbourn Apr 24, 2023
f26d077
Add UWP suppport for clang
walbourn Apr 24, 2023
c6014a6
Minor code cleanup
walbourn Apr 24, 2023
dc593a4
Fix up find_program to respect LLVMInstallDir
walbourn Apr 27, 2023
5203831
Simplified /MP guard logic
walbourn Apr 27, 2023
442c245
Fixed LLVMInstallDir search order and conditioning
walbourn Apr 27, 2023
83653fd
Merge branch 'clangcltriplets' of https://github.com/walbourn/vcpkg i…
walbourn Jan 22, 2024
d589ad8
Merge branch 'master' into clangcltriplets
walbourn Feb 16, 2024
8f8349e
Merge branch 'master' into clangcltriplets
walbourn Feb 23, 2024
cfc24ad
Merge branch 'master' into clangcltriplets
walbourn Feb 27, 2024
5376d75
Merge branch 'master' into clangcltriplets
walbourn Mar 12, 2024
1d2598e
Merge branch 'master' into clangcltriplets
walbourn Mar 14, 2024
44e0e34
Merge branch 'master' into clangcltriplets
walbourn Mar 21, 2024
764b768
Merge branch 'master' into clangcltriplets
walbourn Jun 10, 2024
8bb8d7f
Merge branch 'master' into clangcltriplets
walbourn Jul 11, 2024
bd3de62
Update trycompile feedback
walbourn Jul 12, 2024
9641dc4
Merge branch 'master' into clangcltriplets
walbourn Sep 6, 2024
439dd01
Merge branch 'master' into clangcltriplets
walbourn Sep 6, 2024
4af2173
Merge branch 'master' into clangcltriplets
walbourn Nov 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions scripts/toolchains/clangcl.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
if(NOT _VCPKG_CLANGCL_TOOLCHAIN)
set(_VCPKG_CLANGCL_TOOLCHAIN 1)

if(DEFINED ENV{LLVMInstallDir})
cmake_path(SET _vcpkg_llvmbin "$ENV{LLVMInstallDir}/bin" NORMALIZE)
string(REPLACE "\"" "" _vcpkg_llvmbin "${_vcpkg_llvmbin}")
find_program(CMAKE_C_COMPILER "clang-cl.exe" PATHS "${_vcpkg_llvmbin}" REQUIRED NO_DEFAULT_PATH)
find_program(CMAKE_CXX_COMPILER "clang-cl.exe" PATHS "${_vcpkg_llvmbin}" REQUIRED NO_DEFAULT_PATH)
find_program(CMAKE_AR "llvm-lib.exe" PATHS "${_vcpkg_llvmbin}" REQUIRED NO_DEFAULT_PATH)
else()
set(CMAKE_C_COMPILER "clang-cl.exe")
set(CMAKE_CXX_COMPILER "clang-cl.exe")
endif()

if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
set(_vcpkg_clangcl_arch "-m32")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
set(_vcpkg_clangcl_arch "-m64")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm")
set(_vcpkg_clangcl_arch "--target=arm-pc-windows-msvc")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
set(_vcpkg_clangcl_arch "--target=arm64-pc-windows-msvc")
endif()

string(APPEND VCPKG_C_FLAGS " ${_vcpkg_clangcl_arch}")
string(APPEND VCPKG_CXX_FLAGS " ${_vcpkg_clangcl_arch}")

set(VCPKG_MSVC_CXX_WINRT_EXTENSIONS OFF)

list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES ${_vcpkg_clangcl_arch} VCPKG_MSVC_CXX_WINRT_EXTENSIONS)

if((VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") OR (CMAKE_SYSTEM_NAME STREQUAL "WindowsStore"))
include("${CMAKE_CURRENT_LIST_DIR}/uwp.cmake")
elseif(DEFINED XBOX_CONSOLE_TARGET)
include("${CMAKE_CURRENT_LIST_DIR}/xbox.cmake")
else()
include("${CMAKE_CURRENT_LIST_DIR}/windows.cmake")
endif()
endif()
10 changes: 10 additions & 0 deletions triplets/community/arm64-clangcl-dynamic.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
set(VCPKG_TARGET_ARCHITECTURE arm64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE dynamic)
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/../../scripts/toolchains/clangcl.cmake")
set(VCPKG_LOAD_VCVARS_ENV ON)
if(DEFINED VCPKG_PLATFORM_TOOLSET)
set(VCPKG_PLATFORM_TOOLSET ClangCL)
endif()
set(VCPKG_ENV_PASSTHROUGH_UNTRACKED "LLVMInstallDir;LLVMToolsVersion")
set(VCPKG_QT_TARGET_MKSPEC win32-clang-msvc)
10 changes: 10 additions & 0 deletions triplets/community/arm64-clangcl-static.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
set(VCPKG_TARGET_ARCHITECTURE arm64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
walbourn marked this conversation as resolved.
Show resolved Hide resolved
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/../../scripts/toolchains/clangcl.cmake")
set(VCPKG_LOAD_VCVARS_ENV ON)
if(DEFINED VCPKG_PLATFORM_TOOLSET)
set(VCPKG_PLATFORM_TOOLSET ClangCL)
endif()
set(VCPKG_ENV_PASSTHROUGH_UNTRACKED "LLVMInstallDir;LLVMToolsVersion")
set(VCPKG_QT_TARGET_MKSPEC win32-clang-msvc)
13 changes: 13 additions & 0 deletions triplets/community/arm64-clangcl-uwp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
set(VCPKG_TARGET_ARCHITECTURE arm64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE dynamic)

set(VCPKG_CMAKE_SYSTEM_NAME WindowsStore)
set(VCPKG_CMAKE_SYSTEM_VERSION 10.0)

set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/../../scripts/toolchains/clangcl.cmake")
set(VCPKG_LOAD_VCVARS_ENV ON)
if(DEFINED VCPKG_PLATFORM_TOOLSET)
set(VCPKG_PLATFORM_TOOLSET ClangCL)
endif()
set(VCPKG_ENV_PASSTHROUGH_UNTRACKED "LLVMInstallDir;LLVMToolsVersion")
10 changes: 10 additions & 0 deletions triplets/community/x64-clangcl-dynamic.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE dynamic)
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/../../scripts/toolchains/clangcl.cmake")
set(VCPKG_LOAD_VCVARS_ENV ON)
if(DEFINED VCPKG_PLATFORM_TOOLSET)
set(VCPKG_PLATFORM_TOOLSET ClangCL)
endif()
set(VCPKG_ENV_PASSTHROUGH_UNTRACKED "LLVMInstallDir;LLVMToolsVersion")
set(VCPKG_QT_TARGET_MKSPEC win32-clang-msvc)
15 changes: 15 additions & 0 deletions triplets/community/x64-clangcl-scarlett-static.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_ENV_PASSTHROUGH GameDKLatest GRDKLatest GXDKLatest)
set(VCPKG_CMAKE_SYSTEM_VERSION 10.0)
set(VCPKG_CMAKE_CONFIGURE_OPTIONS "-DXBOX_CONSOLE_TARGET=scarlett")
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/../../scripts/toolchains/clangcl.cmake")
set(VCPKG_LOAD_VCVARS_ENV ON)
set(VCPKG_TARGET_IS_XBOX ON)
set(VCPKG_DEP_INFO_OVERRIDE_VARS xbox)
if(DEFINED VCPKG_PLATFORM_TOOLSET)
set(VCPKG_PLATFORM_TOOLSET ClangCL)
endif()
set(VCPKG_ENV_PASSTHROUGH_UNTRACKED "LLVMInstallDir;LLVMToolsVersion")
set(VCPKG_QT_TARGET_MKSPEC win32-clang-msvc)
15 changes: 15 additions & 0 deletions triplets/community/x64-clangcl-scarlett.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE dynamic)
set(VCPKG_ENV_PASSTHROUGH GameDKLatest GRDKLatest GXDKLatest)
set(VCPKG_CMAKE_SYSTEM_VERSION 10.0)
set(VCPKG_CMAKE_CONFIGURE_OPTIONS "-DXBOX_CONSOLE_TARGET=scarlett")
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/../../scripts/toolchains/clangcl.cmake")
set(VCPKG_LOAD_VCVARS_ENV ON)
set(VCPKG_TARGET_IS_XBOX ON)
set(VCPKG_DEP_INFO_OVERRIDE_VARS xbox)
if(DEFINED VCPKG_PLATFORM_TOOLSET)
set(VCPKG_PLATFORM_TOOLSET ClangCL)
endif()
set(VCPKG_ENV_PASSTHROUGH_UNTRACKED "LLVMInstallDir;LLVMToolsVersion")
set(VCPKG_QT_TARGET_MKSPEC win32-clang-msvc)
10 changes: 10 additions & 0 deletions triplets/community/x64-clangcl-static.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/../../scripts/toolchains/clangcl.cmake")
set(VCPKG_LOAD_VCVARS_ENV ON)
if(DEFINED VCPKG_PLATFORM_TOOLSET)
set(VCPKG_PLATFORM_TOOLSET ClangCL)
endif()
set(VCPKG_ENV_PASSTHROUGH_UNTRACKED "LLVMInstallDir;LLVMToolsVersion")
set(VCPKG_QT_TARGET_MKSPEC win32-clang-msvc)
13 changes: 13 additions & 0 deletions triplets/community/x64-clangcl-uwp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE dynamic)

set(VCPKG_CMAKE_SYSTEM_NAME WindowsStore)
set(VCPKG_CMAKE_SYSTEM_VERSION 10.0)

set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/../../scripts/toolchains/clangcl.cmake")
set(VCPKG_LOAD_VCVARS_ENV ON)
if(DEFINED VCPKG_PLATFORM_TOOLSET)
set(VCPKG_PLATFORM_TOOLSET ClangCL)
endif()
set(VCPKG_ENV_PASSTHROUGH_UNTRACKED "LLVMInstallDir;LLVMToolsVersion")
15 changes: 15 additions & 0 deletions triplets/community/x64-clangcl-xboxone-static.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_ENV_PASSTHROUGH GameDKLatest GRDKLatest GXDKLatest)
set(VCPKG_CMAKE_SYSTEM_VERSION 10.0)
set(VCPKG_CMAKE_CONFIGURE_OPTIONS "-DXBOX_CONSOLE_TARGET=xboxone")
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/../../scripts/toolchains/clangcl.cmake")
set(VCPKG_LOAD_VCVARS_ENV ON)
set(VCPKG_TARGET_IS_XBOX ON)
set(VCPKG_DEP_INFO_OVERRIDE_VARS xbox)
if(DEFINED VCPKG_PLATFORM_TOOLSET)
set(VCPKG_PLATFORM_TOOLSET ClangCL)
endif()
set(VCPKG_ENV_PASSTHROUGH_UNTRACKED "LLVMInstallDir;LLVMToolsVersion")
set(VCPKG_QT_TARGET_MKSPEC win32-clang-msvc)
15 changes: 15 additions & 0 deletions triplets/community/x64-clangcl-xboxone.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE dynamic)
set(VCPKG_ENV_PASSTHROUGH GameDKLatest GRDKLatest GXDKLatest)
set(VCPKG_CMAKE_SYSTEM_VERSION 10.0)
set(VCPKG_CMAKE_CONFIGURE_OPTIONS "-DXBOX_CONSOLE_TARGET=xboxone")
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/../../scripts/toolchains/clangcl.cmake")
set(VCPKG_LOAD_VCVARS_ENV ON)
set(VCPKG_TARGET_IS_XBOX ON)
set(VCPKG_DEP_INFO_OVERRIDE_VARS xbox)
if(DEFINED VCPKG_PLATFORM_TOOLSET)
set(VCPKG_PLATFORM_TOOLSET ClangCL)
endif()
set(VCPKG_ENV_PASSTHROUGH_UNTRACKED "LLVMInstallDir;LLVMToolsVersion")
set(VCPKG_QT_TARGET_MKSPEC win32-clang-msvc)