diff --git a/modules/vstudio/_preload.lua b/modules/vstudio/_preload.lua
index d61e1bb64..c8da21c07 100644
--- a/modules/vstudio/_preload.lua
+++ b/modules/vstudio/_preload.lua
@@ -277,6 +277,22 @@
kind = "string",
}
+ -- Directory of LLVM install
+ p.api.register {
+ name = "llvmdir",
+ scope = "config",
+ kind = "directory",
+ tokens = "true",
+ }
+
+ -- Version of LLVM Install
+ p.api.register {
+ name = "llvmversion",
+ scope = "config",
+ kind = "string",
+ tokens = "true",
+ }
+
--
-- Decide when the full module should be loaded.
--
diff --git a/modules/vstudio/tests/vc2019/test_toolset_settings.lua b/modules/vstudio/tests/vc2019/test_toolset_settings.lua
index df5c60731..8dee1364d 100644
--- a/modules/vstudio/tests/vc2019/test_toolset_settings.lua
+++ b/modules/vstudio/tests/vc2019/test_toolset_settings.lua
@@ -59,6 +59,45 @@
end
+---
+-- Check the project settings with the llvm version
+---
+
+ function suite.toolsetClang_llvmVersion()
+ toolset "clang"
+ llvmversion "16"
+ prepare()
+ test.capture [[
+
+ Application
+ false
+ Unicode
+ ClangCL
+ 16
+
+ ]]
+ end
+
+---
+-- Check the project settings with the llvm version
+---
+
+ function suite.toolsetClang_llvmDir()
+ toolset "clang"
+ llvmdir "llvm/dir"
+ prepare()
+ test.capture [[
+
+ Application
+ false
+ Unicode
+ ClangCL
+ llvm\dir
+
+ ]]
+ end
+
+
--
-- If AllModulesPublic flag is set, add element (supported from VS2019)
--
diff --git a/modules/vstudio/vs2010_vcxproj.lua b/modules/vstudio/vs2010_vcxproj.lua
index e9ec8525e..ba7a9a0c9 100644
--- a/modules/vstudio/vs2010_vcxproj.lua
+++ b/modules/vstudio/vs2010_vcxproj.lua
@@ -224,6 +224,7 @@
return {
m.configurationType,
m.platformToolset,
+ m.llvmTools,
m.toolsVersion,
}
else
@@ -238,6 +239,7 @@
m.enableUnityBuild,
m.sanitizers,
m.toolsVersion,
+ m.llvmTools,
m.wholeProgramOptimization,
m.nmakeOutDirs,
m.windowsSDKDesktopARMSupport,
@@ -2784,6 +2786,19 @@
end
end
+ function m.llvmTools(cfg)
+ local llvmdir = cfg.llvmdir
+ local llvmversion = cfg.llvmversion
+
+ if llvmdir and _ACTION >= "vs2019" then
+ m.element("LLVMInstallDir", nil, vstudio.path(cfg, llvmdir))
+ end
+
+ if llvmversion and _ACTION >= "vs2019" then
+ m.element("LLVMToolsVersion", nil, llvmversion)
+ end
+ end
+
function m.enableUnityBuild(cfg)
if _ACTION >= "vs2017" and cfg.enableunitybuild then
m.element("EnableUnitySupport", nil, iif(cfg.enableunitybuild == "On", "true", "false"))
diff --git a/website/docs/llvmdir.md b/website/docs/llvmdir.md
new file mode 100644
index 000000000..b961b7ca9
--- /dev/null
+++ b/website/docs/llvmdir.md
@@ -0,0 +1,23 @@
+Specifies a custom LLVM install location for Visual Studio.
+
+```lua
+llvmdir "path"
+```
+
+### Parameters ###
+
+`path` specifies a directory containing the LLVM installation.
+
+### Applies To ###
+
+Project configurations.
+
+### Availability ###
+
+Premake 5.0.0 beta 3 or later for Visual Studio 2019 and later.
+
+## Examples ##
+
+```lua
+llvmdir "/path/to/install"
+```
diff --git a/website/docs/llvmversion.md b/website/docs/llvmversion.md
new file mode 100644
index 000000000..c8aea82d8
--- /dev/null
+++ b/website/docs/llvmversion.md
@@ -0,0 +1,23 @@
+Specifies a version for a custom installation of LLVM for Visual Studio.
+
+```lua
+llvmversion "version"
+```
+
+### Parameters ###
+
+`version` specifies the version of the LLVM installation.
+
+### Applies To ###
+
+Project configurations.
+
+### Availability ###
+
+Premake 5.0.0 beta 3 or later for Visual Studio 2019 and later.
+
+## Examples ##
+
+```lua
+llvmversion "16"
+```
diff --git a/website/sidebars.js b/website/sidebars.js
index df5803ad2..04856f005 100644
--- a/website/sidebars.js
+++ b/website/sidebars.js
@@ -203,6 +203,8 @@ module.exports = {
'links',
'locale',
'location',
+ 'llvmdir',
+ 'llvmversion',
'makesettings',
'namespace',
'nativewchar',