diff --git a/modules/vstudio/tests/vc2010/test_compile_settings.lua b/modules/vstudio/tests/vc2010/test_compile_settings.lua
index 1894873c..27b1be99 100644
--- a/modules/vstudio/tests/vc2010/test_compile_settings.lua
+++ b/modules/vstudio/tests/vc2010/test_compile_settings.lua
@@ -1671,4 +1671,59 @@
Disabled
]]
- end
\ No newline at end of file
+ end
+
+--
+-- If consumewinrtextension flag is set, add element
+--
+
+ function suite.onconsumewinrtextensionOff()
+ p.action.set("vs2019")
+ consumewinrtextension "Off"
+ prepare()
+ test.capture [[
+
+ NotUsing
+ Level3
+ Disabled
+ false
+ ]]
+ end
+
+ function suite.onconsumewinrtextensionOn()
+ p.action.set("vs2019")
+ consumewinrtextension "On"
+ prepare()
+ test.capture [[
+
+ NotUsing
+ Level3
+ Disabled
+ true
+ ]]
+ end
+
+ function suite.onconsumewinrtextensionNotSpecified()
+ p.action.set("vs2019")
+ prepare()
+ test.capture [[
+
+ NotUsing
+ Level3
+ Disabled
+
+ ]]
+ end
+
+ function suite.onconsumewinrtextensionOn_BeforeVS2019()
+ p.action.set("vs2017")
+ consumewinrtextension "On"
+ prepare()
+ test.capture [[
+
+ NotUsing
+ Level3
+ Disabled
+
+ ]]
+ end
diff --git a/modules/vstudio/tests/vc2010/test_files.lua b/modules/vstudio/tests/vc2010/test_files.lua
index acd8d0e2..380c1a4d 100644
--- a/modules/vstudio/tests/vc2010/test_files.lua
+++ b/modules/vstudio/tests/vc2010/test_files.lua
@@ -903,3 +903,37 @@
]]
end
+
+--
+-- test consumewinrtextension set for a single file
+--
+
+ function suite.consumewinrtextensionPerFile()
+ p.action.set("vs2019")
+ files { "hello.cpp", "hello2.cpp" }
+ filter { "files:hello.cpp" }
+ consumewinrtextension 'On'
+ prepare()
+ test.capture [[
+
+
+ true
+
+
+
+ ]]
+ end
+
+ function suite.consumewinrtextensionPerFile_BeforeVS2019()
+ p.action.set("vs2017")
+ files { "hello.cpp", "hello2.cpp" }
+ filter { "files:hello.cpp" }
+ consumewinrtextension 'On'
+ prepare()
+ test.capture [[
+
+
+
+
+ ]]
+ end
diff --git a/modules/vstudio/vs2010_vcxproj.lua b/modules/vstudio/vs2010_vcxproj.lua
index de21df21..b28a2f07 100644
--- a/modules/vstudio/vs2010_vcxproj.lua
+++ b/modules/vstudio/vs2010_vcxproj.lua
@@ -393,7 +393,8 @@
m.conformanceMode,
m.structMemberAlignment,
m.useFullPaths,
- m.removeUnreferencedCodeData
+ m.removeUnreferencedCodeData,
+ m.compileAsWinRT,
}
if cfg.kind == p.STATICLIB then
@@ -816,6 +817,7 @@
m.compileAs,
m.runtimeTypeInfo,
m.warningLevelFile,
+ m.compileAsWinRT,
}
else
return {
@@ -1544,6 +1546,14 @@
end
end
+ function m.compileAsWinRT(cfg, condition)
+ if _ACTION >= "vs2019" then
+ if cfg and cfg.consumewinrtextension ~= nil then
+ m.element("CompileAsWinRT", condition, iif(cfg.consumewinrtextension, "true", "false"))
+ end
+ end
+ end
+
function m.additionalCompileOptions(cfg, condition)
local opts = cfg.buildoptions
if _ACTION == "vs2015" or vstudio.isMakefile(cfg) then
diff --git a/src/_premake_init.lua b/src/_premake_init.lua
index 45b45c99..d0cbf7cc 100644
--- a/src/_premake_init.lua
+++ b/src/_premake_init.lua
@@ -203,6 +203,12 @@
kind = "list:string",
}
+ api.register {
+ name = "consumewinrtextension",
+ scope = "config",
+ kind = "boolean",
+ }
+
api.register {
name = "copylocal",
scope = "config",
diff --git a/website/docs/consumewinrtextension.md b/website/docs/consumewinrtextension.md
new file mode 100644
index 00000000..781d86c6
--- /dev/null
+++ b/website/docs/consumewinrtextension.md
@@ -0,0 +1,28 @@
+Enables the WinRT extension, C++/CX, for the specified projects/files.
+
+```lua
+consumewinrtextension "value"
+```
+
+### Parameters ###
+
+`value` is one of:
+* `Default` - Compiles the file using the default for the toolset. (Default is `Off`)
+* `On` - Compiles the file with the WinRT extension enabled.
+* `Off` - Compiles the file without the WinRT extension enabled.
+
+### Applies To ###
+
+The `workspace`, `project` or `file` scope.
+
+### Availability ###
+
+Premake 5.0.0 Beta 2 or later and only implemented for Visual Studio 2019+.
+
+### Examples ###
+
+```lua
+filter { "files:**_winrt.cpp" }
+ consumewinrtextension "On"
+```
+
diff --git a/website/sidebars.js b/website/sidebars.js
index 6b7cde18..2768e51f 100644
--- a/website/sidebars.js
+++ b/website/sidebars.js
@@ -94,6 +94,7 @@ module.exports = {
'configuration',
'configurations',
'conformancemode',
+ 'consumewinrtextension',
'copylocal',
'cppdialect',
'csversion',