static void GenerateItemGroupDef(XmlOutputGen output, List <ProjectConfiguration> projConfigs) { foreach (ProjectConfiguration conf in projConfigs) { ItemDefinitionGroup itemDefGroup = conf.ItemDefinitionGroup; output.BeginElem(nameof(ItemDefinitionGroup)); { output.AddAttribute("Condition", conf.Config.Condition); ClCompile clcompile = itemDefGroup.ClCompile; output.BeginElem(nameof(ClCompile)); { output.AppendSimpleElem(nameof(clcompile.AdditionalIncludeDirectories), clcompile.AdditionalIncludeDirectories); output.AppendSimpleElem(nameof(clcompile.AssemblerListingLocation), clcompile.AssemblerListingLocation); output.AppendSimpleElem(nameof(clcompile.BasicRuntimeChecks), clcompile.BasicRuntimeChecks); output.AppendSimpleElem(nameof(clcompile.CompileAs), clcompile.CompileAs); output.AppendSimpleElem(nameof(clcompile.DebugInformationFormat), clcompile.DebugInformationFormat); output.AppendSimpleElem(nameof(clcompile.ExceptionHandling), clcompile.ExceptionHandling); output.AppendSimpleElem(nameof(clcompile.FloatingPointModel), clcompile.FloatingPointModel); output.AppendSimpleElem(nameof(clcompile.InlineFunctionExpansion), clcompile.InlineFunctionExpansion); output.AppendSimpleElem(nameof(clcompile.IntrinsicFunctions), clcompile.IntrinsicFunctions); output.AppendSimpleElem(nameof(clcompile.Optimization), clcompile.Optimization); output.AppendSimpleElem(nameof(clcompile.PrecompiledHeader), clcompile.PrecompiledHeader); output.AppendSimpleElem(nameof(clcompile.RuntimeLibrary), clcompile.RuntimeLibrary); output.AppendSimpleElem(nameof(clcompile.RuntimeTypeInfo), clcompile.RuntimeTypeInfo); output.AppendSimpleElem(nameof(clcompile.UseFullPaths), clcompile.UseFullPaths); output.AppendSimpleElem(nameof(clcompile.WarningLevel), clcompile.WarningLevel); output.AppendSimpleElem(nameof(clcompile.PreprocessorDefinitions), clcompile.PreprocessorDefinitions); output.AppendSimpleElem(nameof(clcompile.ObjectFileName), clcompile.ObjectFileName); } output.EndElem(); //----- ResourceCompile resCompile = itemDefGroup.ResourceCompile; output.BeginElem(nameof(ResourceCompile)); { output.AppendSimpleElem(nameof(resCompile.PreprocessorDefinitions), resCompile.PreprocessorDefinitions); output.AppendSimpleElem(nameof(resCompile.AdditionalIncludeDirectories), resCompile.AdditionalIncludeDirectories); } output.EndElem(); //----- Midl midl = itemDefGroup.Midl; output.BeginElem(nameof(Midl)); { output.AppendSimpleElem(nameof(midl.AdditionalIncludeDirectories), midl.AdditionalIncludeDirectories); output.AppendSimpleElem(nameof(midl.OutputDirectory), midl.OutputDirectory); output.AppendSimpleElem(nameof(midl.HeaderFileName), midl.HeaderFileName); output.AppendSimpleElem(nameof(midl.TypeLibraryName), midl.TypeLibraryName); output.AppendSimpleElem(nameof(midl.InterfaceIdentifierFileName), midl.InterfaceIdentifierFileName); output.AppendSimpleElem(nameof(midl.ProxyFileName), midl.ProxyFileName); } output.EndElem(); //----- Link link = itemDefGroup.Link; output.BeginElem(nameof(Link)); { output.AppendSimpleElem(nameof(link.AdditionalDependencies), link.AdditionalDependencies); output.AppendSimpleElem(nameof(link.AdditionalLibraryDirectories), link.AdditionalLibraryDirectories); output.AppendSimpleElem(nameof(link.AdditionalOptions), link.AdditionalOptions); output.AppendSimpleElem(nameof(link.GenerateDebugInformation), link.GenerateDebugInformation); output.AppendSimpleElem(nameof(link.IgnoreSpecificDefaultLibraries), link.IgnoreSpecificDefaultLibraries); output.AppendSimpleElem(nameof(link.ImportLibrary), link.ImportLibrary); output.AppendSimpleElem(nameof(link.ProgramDataBaseFile), link.ProgramDataBaseFile); output.AppendSimpleElem(nameof(link.SubSystem), link.SubSystem); } output.EndElem(); //----- output.BeginElem(nameof(ProjectReference)); { ProjectReference projRef = itemDefGroup.ProjectReference; output.AppendSimpleElem(nameof(projRef.LinkLibraryDependencies), projRef.LinkLibraryDependencies); } output.EndElem(); } output.EndElem(); } }
ProjectConfiguration NewProjectConfig() { //---------------- string combine = _config + "|" + _platform; var conf = new ProjectConfiguration() { Configuration = _config, Platform = _platform, Include = combine, Config = new ConfigurationPropertyGroup() { ConfigurationType = _configType, CharacterSet = _charset, PlatformToolset = _platformToolSet, } }; string additionalIncludeDirs = FullProjBuildPath + ";"; if (AdditionalIncludeDirs.Count > 0) { for (int i = 0; i < AdditionalIncludeDirs.Count; ++i) { additionalIncludeDirs += AdditionalIncludeDirs[i] + ";"; } } ConfigurationPropertyGroup configGroup = conf.Config; ConditionConfig conditionConfig = new ConditionConfig(); configGroup.ConditionConfig = conditionConfig; configGroup.Condition = conditionConfig.Condition = "'$(Configuration)|$(Platform)'=='" + combine + "'"; conditionConfig.OutDir = _outdir; conditionConfig.IntDir = ProjectName + ".dir\\" + _config + "\\"; conditionConfig.TargetName = ProjectName; conditionConfig.TargetExt = _extension; conditionConfig.LinkIncremental = _linkIncremental; conditionConfig.GenerateManifest = "true"; //---- ClCompile clCompile = new ClCompile(); clCompile.AdditionalIncludeDirectories = additionalIncludeDirs + "%(AdditionalIncludeDirectories)"; clCompile.AssemblerListingLocation = _initDir; clCompile.CompileAs = "CompileAsCpp"; clCompile.ExceptionHandling = "Sync"; clCompile.FloatingPointModel = "Fast"; //debug if (_proj_config == ProjectConfigKind.Debug) { clCompile.DebugInformationFormat = "ProgramDatabase"; clCompile.BasicRuntimeChecks = "EnableFastChecks"; clCompile.InlineFunctionExpansion = "Disabled"; clCompile.Optimization = "Disabled"; clCompile.RuntimeLibrary = "MultiThreadedDebugDLL"; clCompile.PreprocessorDefinitions = "WIN32;_WINDOWS;CMAKE_INTDIR=\"Debug\";%(PreprocessorDefinitions)"; } else { clCompile.DebugInformationFormat = ""; clCompile.InlineFunctionExpansion = "AnySuitable"; clCompile.Optimization = "MaxSpeed"; clCompile.RuntimeLibrary = "MultiThreadedDLL"; clCompile.PreprocessorDefinitions = "WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"Release\";%(PreprocessorDefinitions)"; } clCompile.ObjectFileName = _initDir; clCompile.WarningLevel = "Level3"; clCompile.UseFullPaths = "false"; clCompile.RuntimeTypeInfo = "true"; clCompile.PrecompiledHeader = "NotUsing"; clCompile.IntrinsicFunctions = "true"; //---------------------------------------------------- ResourceCompile resCompile = new ResourceCompile(); if (_proj_config == ProjectConfigKind.Debug) { resCompile.PreprocessorDefinitions = "WIN32;_DEBUG;_WINDOWS;CMAKE_INTDIR=\"Debug\";%(PreprocessorDefinitions)"; } else { resCompile.PreprocessorDefinitions = "WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"Release\";%(PreprocessorDefinitions)"; } resCompile.AdditionalIncludeDirectories = additionalIncludeDirs + "%(AdditionalIncludeDirectories)"; //---------------------------------------------------- Midl midl = new Midl(); midl.AdditionalIncludeDirectories = additionalIncludeDirs + "%(AdditionalIncludeDirectories)"; midl.OutputDirectory = "$(ProjectDir)/$(IntDir)"; midl.HeaderFileName = "%(Filename).h"; midl.TypeLibraryName = "%(Filename).tlb"; midl.InterfaceIdentifierFileName = "%(Filename)_i.c"; midl.ProxyFileName = "%(Filename)_p.c"; //---------------------------------------------------- string link_additional_opts = "/machine:x64"; Link link = new Link(); link.AdditionalDependencies = "kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib"; link.AdditionalLibraryDirectories = "%(AdditionalLibraryDirectories)"; link.AdditionalOptions = "%(AdditionalOptions) " + link_additional_opts; //*** link.SubSystem = "Console"; link.ProgramDataBaseFile = _outdir + "/" + ProjectName + ".pdb"; link.ImportLibrary = _outdir + "/" + ProjectName + ".lib"; if (_proj_config == ProjectConfigKind.Debug) { link.GenerateDebugInformation = "true"; } else { link.GenerateDebugInformation = "false"; } link.IgnoreSpecificDefaultLibraries = "%(IgnoreSpecificDefaultLibraries)"; //----------- ProjectReference projRef = new ProjectReference(); projRef.LinkLibraryDependencies = "false"; //------------- ItemDefinitionGroup itemDefs = new ItemDefinitionGroup(); itemDefs.ClCompile = clCompile; itemDefs.ResourceCompile = resCompile; itemDefs.Midl = midl; itemDefs.Link = link; itemDefs.ProjectReference = projRef; conf.ItemDefinitionGroup = itemDefs; return(conf); }