diff --git a/src/_premake_init.lua b/src/_premake_init.lua
index 0a49df62..717ac4d1 100644
--- a/src/_premake_init.lua
+++ b/src/_premake_init.lua
@@ -183,6 +183,17 @@
kind = "boolean"
}
+ api.register {
+ name = "compileas",
+ scope = "config",
+ kind = "string",
+ allowed = {
+ "Default",
+ "C",
+ "C++",
+ }
+ }
+
api.register {
name = "configmap",
scope = "project",
diff --git a/src/actions/vstudio/vs2010_vcxproj.lua b/src/actions/vstudio/vs2010_vcxproj.lua
index 9d08315f..c3f70184 100644
--- a/src/actions/vstudio/vs2010_vcxproj.lua
+++ b/src/actions/vstudio/vs2010_vcxproj.lua
@@ -1216,9 +1216,9 @@
function m.compileAs(cfg)
- if p.languages.isc(cfg.language) then
+ if p.languages.isc(cfg.compileas) then
m.element("CompileAs", nil, "CompileAsC")
- elseif p.languages.iscpp(cfg.language) then
+ elseif p.languages.iscpp(cfg.compileas) then
m.element("CompileAs", nil, "CompileAsCpp")
end
end
diff --git a/tests/actions/vstudio/vc2010/test_compile_settings.lua b/tests/actions/vstudio/vc2010/test_compile_settings.lua
index ce90bd93..af44e971 100644
--- a/tests/actions/vstudio/vc2010/test_compile_settings.lua
+++ b/tests/actions/vstudio/vc2010/test_compile_settings.lua
@@ -38,7 +38,6 @@
NotUsing
Level3
Disabled
- CompileAsCpp
]]
end
@@ -224,7 +223,6 @@
NotUsing
Level3
Disabled
- CompileAsCpp
]]
end
@@ -237,7 +235,6 @@
NotUsing
Level3
Disabled
- CompileAsCpp
]]
end
@@ -462,7 +459,6 @@
NotUsing
Level3
Disabled
- CompileAsCpp
]]
end
@@ -476,7 +472,6 @@
Level3
None
Disabled
- CompileAsCpp
]]
end
@@ -490,7 +485,6 @@
Level3
EditAndContinue
Disabled
- CompileAsCpp
]]
end
@@ -927,7 +921,6 @@
NotUsing
Level3
Disabled
- CompileAsCpp
]]
end
@@ -1030,7 +1023,6 @@
NotUsing
Level3
Disabled
- CompileAsC
]]
end
@@ -1039,6 +1031,35 @@
language 'C++'
prepare()
test.capture [[
+
+ NotUsing
+ Level3
+ Disabled
+
+ ]]
+ end
+
+
+--
+-- Check handling of the compileAs api
+--
+ function suite.onCompileAsC()
+ compileas 'C'
+ prepare()
+ test.capture [[
+
+ NotUsing
+ Level3
+ Disabled
+ CompileAsC
+
+ ]]
+ end
+
+ function suite.onCompileAsCpp()
+ compileas 'C++'
+ prepare()
+ test.capture [[
NotUsing
Level3