diff options
| author | ruki <[email protected]> | 2020-12-27 22:19:43 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-12-27 22:19:53 +0800 |
| commit | 6efd993fa1e0329b46e3e3f81d5d782f8594d642 (patch) | |
| tree | 8e3762cdcb5b4b162705d2608d4b6687fa420c75 | |
| parent | 1fa35fa2f41282eab7105c4c3415b4460e5d395b (diff) | |
improve vsxmake to support debug console
4 files changed, 22 insertions, 1 deletions
diff --git a/xmake/plugins/project/vsxmake/getinfo.lua b/xmake/plugins/project/vsxmake/getinfo.lua index 66c5ede9c..1cc3efac2 100644 --- a/xmake/plugins/project/vsxmake/getinfo.lua +++ b/xmake/plugins/project/vsxmake/getinfo.lua @@ -152,11 +152,26 @@ function _make_targetinfo(mode, arch, target) -- save defines targetinfo.defines = _make_arrs(_get_values_from_target(target, "defines")) + + -- save languages targetinfo.languages = _make_arrs(_get_values_from_target(target, "languages")) if targetinfo.languages then -- fix c++17 to cxx17 for Xmake.props targetinfo.languages = targetinfo.languages:replace("c++", "cxx", {plain = true}) end + + -- save subsystem + local linkflags = linker.linkflags(target:targetkind(), target:sourcekinds(), {target = target}) + for _, linkflag in ipairs(linkflags) do + if linkflag:lower():find("[%-/]subsystem:windows") then + targetinfo.subsystem = "windows" + end + end + if not targetinfo.subsystem then + targetinfo.subsystem = "console" + end + + -- save config flags local flags = {} for k, v in pairs(localcache.get("config", "options_" .. target:name())) do if k ~= "plat" and k ~= "mode" and k ~= "arch" and k ~= "clean" and k ~= "buildir" then diff --git a/xmake/plugins/project/vsxmake/vsproj/Xmake.props b/xmake/plugins/project/vsxmake/vsproj/Xmake.props index 3cce0878a..eaa8472c4 100644 --- a/xmake/plugins/project/vsxmake/vsproj/Xmake.props +++ b/xmake/plugins/project/vsxmake/vsproj/Xmake.props @@ -88,7 +88,6 @@ <ItemDefinitionGroup> <ClCompile> <PreprocessorDefinitions>%(PreprocessorDefinitions);$(XmakeDefines)</PreprocessorDefinitions> - <LanguageStandard Condition="'%(LanguageStandard)' == '' And $(XmakeLanguages.Contains('cxx11'))">stdcpp11</LanguageStandard> <LanguageStandard Condition="'%(LanguageStandard)' == '' And $(XmakeLanguages.Contains('cxx14'))">stdcpp14</LanguageStandard> <LanguageStandard Condition="'%(LanguageStandard)' == '' And $(XmakeLanguages.Contains('cxx17'))">stdcpp17</LanguageStandard> @@ -102,6 +101,11 @@ <LanguageStandard Condition="'%(LanguageStandard)' == '' And $(XmakeLanguages.Contains('gnuxx20'))">stdcpplatest</LanguageStandard> <LanguageStandard Condition="'%(LanguageStandard)' == '' And $(XmakeLanguages.Contains('gnuxx2a'))">stdcpplatest</LanguageStandard> </ClCompile> + + <Link> + <SubSystem Condition="'%(SubSystem)' == '' And $(XmakeSubSystem.Contains('console'))">Console</SubSystem> + <SubSystem Condition="'%(SubSystem)' == '' And $(XmakeSubSystem.Contains('windows'))">Windows</SubSystem> + </Link> </ItemDefinitionGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> diff --git a/xmake/plugins/project/vsxmake/vsproj/Xmake.targets b/xmake/plugins/project/vsxmake/vsproj/Xmake.targets index 44823a853..6ec266f11 100644 --- a/xmake/plugins/project/vsxmake/vsproj/Xmake.targets +++ b/xmake/plugins/project/vsxmake/vsproj/Xmake.targets @@ -135,6 +135,7 @@ MSBuild Properties: XmakeMfcKind: $(XmakeMfcKind) XmakeDefines: $(XmakeDefines) XmakeLanguages: $(XmakeLanguages) + XmakeSubSystem: $(XmakeSubSystem) XmakeIncludeDirs: $(XmakeIncludeDirs) XmakeLinkDirs: $(XmakeLinkDirs) XmakeSourceDirs: $(XmakeSourceDirs) diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/XmakeConfig(mode,arch) b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/XmakeConfig(mode,arch) index 76a1ff3ff..8e1279b37 100644 --- a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/XmakeConfig(mode,arch) +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/XmakeConfig(mode,arch) @@ -7,6 +7,7 @@ <XmakeKind>#kind#</XmakeKind> <XmakeDefines>#defines#</XmakeDefines> <XmakeLanguages>#languages#</XmakeLanguages> + <XmakeSubSystem>#subsystem#</XmakeSubSystem> <XmakeCudaVersion>#cudaver#</XmakeCudaVersion> <XmakeWindowsSdkVersion>#sdkver#</XmakeWindowsSdkVersion> <XmakeMfcKind>#mfckind#</XmakeMfcKind> |
