<!--
***********************************************************************************************
Microsoft.Cpp.ClangCl.Common.targets

WARNING:  DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
          created a backup copy.  Incorrect changes to this file will make it
          impossible to load or build your projects from the command-line or the IDE.

Copyright (C) Microsoft Corporation. All rights reserved.
***********************************************************************************************
-->

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <!-- cleanup properties which are not supported by clang-cl -->
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.ClangCl.Exclusion.props" />
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.LldLink.Exclusion.props" />
  
  <Import Project="$(VCTargetsPath)\Microsoft.CppCommon.targets" />

  <PropertyGroup>
    <ProjectEvaluationFingerprint>$(LLVMInstallDir)|$(LLVMToolsVersion)|$(ProjectEvaluationFingerprint)</ProjectEvaluationFingerprint>
    <_NormalizedLLVMInstallDir>$([System.IO.Path]::GetDirectoryName("$(LLVMInstallDir)\"))</_NormalizedLLVMInstallDir>
    <UsingVSLLVM>false</UsingVSLLVM>
    <UsingVSLLVM Condition="'$(_NormalizedLLVMInstallDir)' != '' AND '$(_NormalizedLLVMInstallDir.StartsWith($(VsInstallRoot), true, null))' == 'true'">true</UsingVSLLVM>
  </PropertyGroup>
  
  <PropertyGroup>
    <_ExecutablePathWasCustomized>false</_ExecutablePathWasCustomized>
    <_ExecutablePathWasCustomized Condition="'$(LLVMInstallDir)'!='$(_DefaultLLVMInstallDir)'">true</_ExecutablePathWasCustomized>
  </PropertyGroup>

  <ItemGroup Condition="'$(ConfigurationType)'!='Utility'">
    <PropertyPageSchema Include="$(VCTargetsPath)$(LangID)\cl_clangcl_extension.xml" />
    <PropertyPageSchema Include="$(VCTargetsPath)$(LangID)\link_lld_extension.xml" />
  </ItemGroup>

  <ItemGroup>
    <PropertyPageSchema Include="$(VCTargetsPath)$(LangID)\general_advanced_llvm.xml"></PropertyPageSchema>
  </ItemGroup>

  <!-- ClangClAdditionalOptions for compat with LLVM extension -->
  <ItemDefinitionGroup>
    <ClCompile>
      <ClangClMode>true</ClangClMode>
      <!-- Conformance mode is ignored by Clang and IntelliSense has a compatibility error when used in clang mode -->
      <ConformanceMode>Default</ConformanceMode>
      <MSCVersion>Default</MSCVersion>
      <AdditionalOptions>$(LlvmArchitectureSwitch) $(ClangClAdditionalOptions) %(AdditionalOptions)</AdditionalOptions>
    </ClCompile>
  </ItemDefinitionGroup>

  <!-- LldLinkAdditionalOptions for compat with LLVM extension -->
  <ItemDefinitionGroup>
    <Link>
      <AdditionalOptions>$(LldLinkAdditionalOptions) %(AdditionalOptions)</AdditionalOptions>
    </Link>
  </ItemDefinitionGroup>

  <!--Disable /LTCG for Librarian if clang-cl is used.-->
  <ItemDefinitionGroup>
    <Lib>
      <LinkTimeCodeGeneration Condition="'$(ConfigurationType)' == 'StaticLibrary'">false</LinkTimeCodeGeneration>
    </Lib>
  </ItemDefinitionGroup>

  <PropertyGroup>
    <FixupCLCompileOptionsDependsOn>
      $(FixupCLCompileOptionsDependsOn);
      ClangClFixupCompileOptions
    </FixupCLCompileOptionsDependsOn>
  </PropertyGroup>

  <Target Name="ClangClFixupCompileOptions"  DependsOnTargets="SetCppLanguageStandardCapabilities">    
    <VCMessage Code="MSB8053" Type="Error" Condition="('%(ClCompile.CompileAsManaged)' != 'false') AND ('%(ClCompile.CompileAsManaged)' != '')" />
    <VCMessage Code="MSB8054" Type="Error" Condition="('%(ClCompile.CompileAsWinRT)' == 'true') OR ('%(ClCompile.WinRTNoStdLib)' == 'true')" />
    <VCMessage Code="MSB8073" Type="Error" Condition="!Exists('$(LLVMInstallDir)\lib\clang\$(LLVMIncludeVersion)')" Arguments="$(LLVMIncludeVersion);'$(LLVMInstallDir)\lib\clang\$(LLVMIncludeVersion)'" />
    <ItemGroup>
      <!-- adjust settings which clang-cl does not support -->
      <ClCompile Condition="'%(ClCompile.StdModulesSupported)' == 'true' and '$(ScanForModuleDependenciesSupported)' != 'true'">
        <CompileAs Condition="'%(ClCompile.CompileAs)' == 'Default' and '%(ClCompile.Extension)' == '.c'">CompileAsC</CompileAs>
        <CompileAs Condition="'%(ClCompile.CompileAs)' == 'Default' and '%(ClCompile.Extension)' != '.c'">CompileAsCpp</CompileAs>
      </ClCompile>
      <ClCompile>
        <DebugInformationFormat Condition="'%(ClCompile.DebugInformationFormat)' == 'ProgramDatabase'">OldStyle</DebugInformationFormat>
        <DebugInformationFormat Condition="'%(ClCompile.DebugInformationFormat)' == 'EditAndContinue'">OldStyle</DebugInformationFormat>
      </ClCompile>
    </ItemGroup>
  </Target>
  

  <Target Name="ClCompile"
          Condition="'@(ClCompile)' != ''"
          DependsOnTargets="SelectClCompile">
    
    <PropertyGroup>
      <CLToolArchitecture Condition="'$(CLToolArchitecture)' == ''">$(VCToolArchitecture)</CLToolArchitecture>
      <CLDeleteOutputOnExecute Condition="'$(CLDeleteOutputOnExecute)' == ''">true</CLDeleteOutputOnExecute>
    </PropertyGroup>

    <ItemGroup>
      <ClNoDependencies Condition="'@(ClNoDependencies)' == '' and '%(ClInclude.NoDependency)' == 'true'" Include="@(ClInclude)"/>
      <ClNoDependencies Condition="'$(NoDependencies)' != ''" Include="$(NoDependencies)" />
    </ItemGroup>

    <!-- copy MultiProcessorCompilation to _MultiProcessorCompilation. MultiProcessorCompilation
      is cleared to avoid passing /MP to clang-cl which generates a warning -->
    <ItemGroup>
      <ClCompile Condition="'%(ClCompile.MultiProcessorCompilation)' == 'true' or '$(MultiProcCL)' == 'true'">
        <_MultiProcessorCompilation>true</_MultiProcessorCompilation>
        <MultiProcessorCompilation>false</MultiProcessorCompilation>
      </ClCompile>
    </ItemGroup>


    <PropertyGroup>
      <ClMutliToolTaskMinimalRebuild>true</ClMutliToolTaskMinimalRebuild>
      <ClMutliToolTaskMinimalRebuild Condition="'$(_BuildActionType)' != 'Build' or '$(ForceRebuild)' == 'true'">false</ClMutliToolTaskMinimalRebuild>
      <ProcessorNumber Condition="'$(ProcessorNumber)' == ''">$(CL_MPCount)</ProcessorNumber>
    </PropertyGroup>

    <!-- Precompiled headers - need to build them first -->
    <CL Condition="'%(ClCompile.PrecompiledHeader)' == 'Create' and '%(ClCompile.ExcludedFromBuild)'!='true' and '%(ClCompile.CompilerIteration)' == ''"
        BuildingInIDE                      ="$(BuildingInsideVisualStudio)"
        Sources                            ="@(ClCompile)"

        AdditionalIncludeDirectories       ="%(ClCompile.AdditionalIncludeDirectories)"
        AdditionalOptions                  ="%(ClCompile.AdditionalOptions)"
        AdditionalUsingDirectories         =""
        AssemblerListingLocation           ="%(ClCompile.AssemblerListingLocation)"
        AssemblerOutput                    ="%(ClCompile.AssemblerOutput)"
        BasicRuntimeChecks                 =""
        BrowseInformation                  =""
        BrowseInformationFile              =""
        BufferSecurityCheck                ="%(ClCompile.BufferSecurityCheck)"
        CallingConvention                  ="%(ClCompile.CallingConvention)"
        ControlFlowGuard                   ="%(ClCompile.ControlFlowGuard)"
        CompileAsManaged                   =""
        CompileAsWinRT                     =""
        CompileAs                          ="%(ClCompile.CompileAs)"
        ConformanceMode                    ="%(ClCompile.ConformanceMode)"
        DebugInformationFormat             ="%(ClCompile.DebugInformationFormat)"
        DiagnosticsFormat                  ="%(ClCompile.DiagnosticsFormat)"
        DisableLanguageExtensions          =""
        DisableSpecificWarnings            =""
        EnableEnhancedInstructionSet       ="%(ClCompile.EnableEnhancedInstructionSet)"
        EnableFiberSafeOptimizations       =""
        EnableParallelCodeGeneration       =""
        EnablePREfast                      =""
        EnforceTypeConversionRules         =""
        ErrorReporting                     =""        
        ExceptionHandling                  ="%(ClCompile.ExceptionHandling)"
        ExpandAttributedSource             =""
        FavorSizeOrSpeed                   ="%(ClCompile.FavorSizeOrSpeed)"
        FloatingPointExceptions            ="%(ClCompile.FloatingPointExceptions)"
        FloatingPointModel                 ="%(ClCompile.FloatingPointModel)"
        ForceConformanceInForLoopScope     =""
        ForcedIncludeFiles                 ="%(ClCompile.ForcedIncludeFiles)"
        ForcedUsingFiles                   =""
        FunctionLevelLinking               ="%(ClCompile.FunctionLevelLinking)"
        GenerateXMLDocumentationFiles      =""
        IgnoreStandardIncludePath          =""       
        InlineFunctionExpansion            ="%(ClCompile.InlineFunctionExpansion)"
        IntrinsicFunctions                 ="%(ClCompile.IntrinsicFunctions)"
        LanguageStandard                   ="%(ClCompile.LanguageStandard)"
        MinimalRebuild                     =""
        MultiProcessorCompilation          =""
        ObjectFileName                     ="%(ClCompile.ObjectFileName)"
        OmitDefaultLibName                 ="%(ClCompile.OmitDefaultLibName)"
        OmitFramePointers                  ="%(ClCompile.OmitFramePointers)"
        OpenMPSupport                      =""
        Optimization                       ="%(ClCompile.Optimization)"
        PrecompiledHeader                  ="%(ClCompile.PrecompiledHeader)"
        PrecompiledHeaderFile              ="%(ClCompile.PrecompiledHeaderFile)"
        PrecompiledHeaderOutputFile        ="%(ClCompile.PrecompiledHeaderOutputFile)"
        PREfastAdditionalOptions           =""
        PREfastAdditionalPlugins           =""
        PREfastLog                         =""
        PREfastProjectDirectory            =""
        PREfastRulesetDirectories          =""
        PREfastRulesetFile                 =""
        PreprocessKeepComments             ="%(ClCompile.PreprocessKeepComments)"
        PreprocessorDefinitions            ="%(ClCompile.PreprocessorDefinitions)"
        PreprocessSuppressLineNumbers      ="%(ClCompile.PreprocessSuppressLineNumbers)"
        PreprocessToFile                   ="%(ClCompile.PreprocessToFile)"
        ProcessorNumber                    ="%(ClCompile.ProcessorNumber)"
        ProgramDataBaseFileName            =""
        RemoveUnreferencedCodeData         =""
        RuntimeLibrary                     ="%(ClCompile.RuntimeLibrary)"
        RuntimeTypeInfo                    ="%(ClCompile.RuntimeTypeInfo)"
        SDLCheck                           =""
        ShowIncludes                       ="%(ClCompile.ShowIncludes)"
        WarningVersion                     ="%(ClCompile.WarningVersion)"
        SmallerTypeCheck                   ="%(ClCompile.SmallerTypeCheck)"
        SpectreMitigation                  ="%(ClCompile.SpectreMitigation)"
        StringPooling                      =""
        StructMemberAlignment              =""
        SupportJustMyCode                  =""
        SuppressStartupBanner              ="%(ClCompile.SuppressStartupBanner)"
        TreatSpecificWarningsAsErrors      =""
        TreatWarningAsError                ="%(ClCompile.TreatWarningAsError)"
        TreatWChar_tAsBuiltInType          =""
        UndefineAllPreprocessorDefinitions ="%(ClCompile.UndefineAllPreprocessorDefinitions)"
        UndefinePreprocessorDefinitions    ="%(ClCompile.UndefinePreprocessorDefinitions)"
        UseFullPaths                       =""
        UseUnicodeForAssemblerListing      ="%(ClCompile.UseUnicodeForAssemblerListing)"
        WarningLevel                       ="%(ClCompile.WarningLevel)"
        WholeProgramOptimization           =""
        WinRTNoStdLib                      ="%(ClCompile.WinRTNoStdLib)"
        XMLDocumentationFileName           ="%(ClCompile.XMLDocumentationFileName)"
        CreateHotpatchableImage            =""

        TrackerLogDirectory                ="%(ClCompile.TrackerLogDirectory)"
        ExcludedInputPaths                 ="%(ClCompile.ExcludedInputPaths)"
        TLogReadFiles                      ="@(CLTLogReadFiles)"
        TLogWriteFiles                     ="@(CLTLogWriteFiles)"
        ToolExe                            ="$(CLToolExe)"
        ToolPath                           ="$(CLToolPath)"
        TrackFileAccess                    ="$(TrackFileAccess)"
        MinimalRebuildFromTracking         ="%(ClCompile.MinimalRebuildFromTracking)"
        ToolArchitecture                   ="$(CLToolArchitecture)"
        TrackerFrameworkPath               ="$(CLTrackerFrameworkPath)"
        TrackerSdkPath                     ="$(CLTrackerSdkPath)"
        TrackedInputFilesToIgnore          ="@(ClNoDependencies)"
        TrackedOutputFilesToIgnore         ="@(ClTrackedOutputFilesToIgnore)"
        DeleteOutputOnExecute              ="$(CLDeleteOutputOnExecute)"

        AcceptableNonZeroExitCodes         ="%(ClCompile.AcceptableNonZeroExitCodes)"
        YieldDuringToolExecution           ="$(ClYieldDuringToolExecution)"
    >
        <Output TaskParameter="ResolvedPathToTool"  PropertyName="_VC_CL_ResolvedPathToTool" />
    </CL>

    <!-- Rest of the sources -->
    <MultiToolTask Condition="'%(ClCompile._MultiProcessorCompilation)' == 'true' and '%(ClCompile.PrecompiledHeader)' != 'Create' and '%(ClCompile.ExcludedFromBuild)'!='true' and '%(ClCompile.CompilerIteration)' == '' and @(ClCompile) != ''"
                  TaskName="Microsoft.Build.CPPTasks.CL"
                  TaskAssemblyName="$(VCTargetsPath)Microsoft.Build.CppTasks.Common.dll"
                  Sources="@(ClCompile)"

                  MaxProcessCount="$(MultiProcMaxCount)"
                  EnforceProcessCountAcrossBuilds="$(EnforceProcessCountAcrossBuilds)"
                  SchedulerName="$(MultiProcSchedulerName)" 
                  TrackFileAccess="$(TrackFileAccess)"
                  TrackedOutputFilesToIgnore ="@(ClTrackedOutputFilesToIgnore)"
                  TrackerLogDirectory="$(TLogLocation)"
                  MinimalRebuildFromTracking="$(ClMutliToolTaskMinimalRebuild)"
                  TLogReadFiles="@(CLTLogReadFiles)"
                  TLogWriteFiles="@(CLTLogWriteFiles)"
                  ToolExe="$(CLToolExe)"
                  ToolPath="$(CLToolPath)"
                  ToolArchitecture="$(CLToolArchitecture)"
                  TrackerFrameworkPath="$(CLTrackerFrameworkPath)"
                  TrackerSdkPath="$(CLTrackerSdkPath)"
    >
      <Output TaskParameter="ResolvedPathToTool"  PropertyName="_VC_CL_ResolvedPathToTool" />
    </MultiToolTask>

    <CL Condition="'%(ClCompile._MultiProcessorCompilation)' != 'true' and '%(ClCompile.PrecompiledHeader)' != 'Create' and '%(ClCompile.ExcludedFromBuild)'!='true' and '%(ClCompile.CompilerIteration)' == '' and @(ClCompile) != ''"
        BuildingInIDE                      ="$(BuildingInsideVisualStudio)"
        Sources                            ="@(ClCompile)"

        AdditionalIncludeDirectories       ="%(ClCompile.AdditionalIncludeDirectories)"
        AdditionalOptions                  ="%(ClCompile.AdditionalOptions)"
        AdditionalUsingDirectories         =""
        AssemblerListingLocation           ="%(ClCompile.AssemblerListingLocation)"
        AssemblerOutput                    ="%(ClCompile.AssemblerOutput)"
        BasicRuntimeChecks                 =""
        BrowseInformation                  =""
        BrowseInformationFile              =""
        BufferSecurityCheck                ="%(ClCompile.BufferSecurityCheck)"
        CallingConvention                  ="%(ClCompile.CallingConvention)"
        ControlFlowGuard                   ="%(ClCompile.ControlFlowGuard)"
        CompileAsManaged                   =""
        CompileAsWinRT                     =""
        CompileAs                          ="%(ClCompile.CompileAs)"
        ConformanceMode                    ="%(ClCompile.ConformanceMode)"
        DebugInformationFormat             ="%(ClCompile.DebugInformationFormat)"
        DiagnosticsFormat                  ="%(ClCompile.DiagnosticsFormat)"
        DisableLanguageExtensions          =""
        DisableSpecificWarnings            =""
        EnableEnhancedInstructionSet       ="%(ClCompile.EnableEnhancedInstructionSet)"
        EnableFiberSafeOptimizations       =""
        EnableParallelCodeGeneration       =""
        EnablePREfast                      =""
        EnforceTypeConversionRules         =""
        ErrorReporting                     =""        
        ExceptionHandling                  ="%(ClCompile.ExceptionHandling)"
        ExpandAttributedSource             =""
        FavorSizeOrSpeed                   ="%(ClCompile.FavorSizeOrSpeed)"
        FloatingPointExceptions            ="%(ClCompile.FloatingPointExceptions)"
        FloatingPointModel                 ="%(ClCompile.FloatingPointModel)"
        ForceConformanceInForLoopScope     =""
        ForcedIncludeFiles                 ="%(ClCompile.ForcedIncludeFiles)"
        ForcedUsingFiles                   =""
        FunctionLevelLinking               ="%(ClCompile.FunctionLevelLinking)"
        GenerateXMLDocumentationFiles      =""
        IgnoreStandardIncludePath          =""       
        InlineFunctionExpansion            ="%(ClCompile.InlineFunctionExpansion)"
        IntrinsicFunctions                 ="%(ClCompile.IntrinsicFunctions)"
        LanguageStandard                   ="%(ClCompile.LanguageStandard)"
        MinimalRebuild                     =""
        MultiProcessorCompilation          =""
        ObjectFileName                     ="%(ClCompile.ObjectFileName)"
        OmitDefaultLibName                 ="%(ClCompile.OmitDefaultLibName)"
        OmitFramePointers                  ="%(ClCompile.OmitFramePointers)"
        OpenMPSupport                      =""
        Optimization                       ="%(ClCompile.Optimization)"
        PrecompiledHeader                  ="%(ClCompile.PrecompiledHeader)"
        PrecompiledHeaderFile              ="%(ClCompile.PrecompiledHeaderFile)"
        PrecompiledHeaderOutputFile        ="%(ClCompile.PrecompiledHeaderOutputFile)"
        PREfastAdditionalOptions           =""
        PREfastAdditionalPlugins           =""
        PREfastLog                         =""
        PREfastProjectDirectory            =""
        PREfastRulesetDirectories          =""
        PREfastRulesetFile                 =""
        PreprocessKeepComments             ="%(ClCompile.PreprocessKeepComments)"
        PreprocessorDefinitions            ="%(ClCompile.PreprocessorDefinitions)"
        PreprocessSuppressLineNumbers      ="%(ClCompile.PreprocessSuppressLineNumbers)"
        PreprocessToFile                   ="%(ClCompile.PreprocessToFile)"
        ProcessorNumber                    ="%(ClCompile.ProcessorNumber)"
        ProgramDataBaseFileName            =""
        RemoveUnreferencedCodeData         =""
        RuntimeLibrary                     ="%(ClCompile.RuntimeLibrary)"
        RuntimeTypeInfo                    ="%(ClCompile.RuntimeTypeInfo)"
        SDLCheck                           =""
        ShowIncludes                       ="%(ClCompile.ShowIncludes)"
        WarningVersion                     ="%(ClCompile.WarningVersion)"
        SmallerTypeCheck                   ="%(ClCompile.SmallerTypeCheck)"
        SpectreMitigation                  ="%(ClCompile.SpectreMitigation)"
        StringPooling                      =""
        StructMemberAlignment              =""
        SupportJustMyCode                  =""
        SuppressStartupBanner              ="%(ClCompile.SuppressStartupBanner)"
        TreatSpecificWarningsAsErrors      =""
        TreatWarningAsError                ="%(ClCompile.TreatWarningAsError)"
        TreatWChar_tAsBuiltInType          =""
        UndefineAllPreprocessorDefinitions ="%(ClCompile.UndefineAllPreprocessorDefinitions)"
        UndefinePreprocessorDefinitions    ="%(ClCompile.UndefinePreprocessorDefinitions)"
        UseFullPaths                       =""
        UseUnicodeForAssemblerListing      ="%(ClCompile.UseUnicodeForAssemblerListing)"
        WarningLevel                       ="%(ClCompile.WarningLevel)"
        WholeProgramOptimization           =""
        WinRTNoStdLib                      ="%(ClCompile.WinRTNoStdLib)"
        XMLDocumentationFileName           ="%(ClCompile.XMLDocumentationFileName)"
        CreateHotpatchableImage            =""

        TrackerLogDirectory                ="%(ClCompile.TrackerLogDirectory)"
        ExcludedInputPaths                 ="%(ClCompile.ExcludedInputPaths)"
        TLogReadFiles                      ="@(CLTLogReadFiles)"
        TLogWriteFiles                     ="@(CLTLogWriteFiles)"
        ToolExe                            ="$(CLToolExe)"
        ToolPath                           ="$(CLToolPath)"
        TrackFileAccess                    ="$(TrackFileAccess)"
        MinimalRebuildFromTracking         ="%(ClCompile.MinimalRebuildFromTracking)"
        ToolArchitecture                   ="$(CLToolArchitecture)"
        TrackerFrameworkPath               ="$(CLTrackerFrameworkPath)"
        TrackerSdkPath                     ="$(CLTrackerSdkPath)"
        TrackedInputFilesToIgnore          ="@(ClNoDependencies)"
        TrackedOutputFilesToIgnore         ="@(ClTrackedOutputFilesToIgnore)"
        DeleteOutputOnExecute              ="$(CLDeleteOutputOnExecute)"
        AcceptableNonZeroExitCodes         ="%(ClCompile.AcceptableNonZeroExitCodes)"
        YieldDuringToolExecution           ="$(ClYieldDuringToolExecution)"
    >
      <Output TaskParameter="ResolvedPathToTool"  PropertyName="_VC_CL_ResolvedPathToTool" />
    </CL>

    <OnError ExecuteTargets="ClangClNotFoundError" />
    <OnError Condition="'$(OnXamlPreCompileErrorTarget)' != ''" ExecuteTargets="$(OnXamlPreCompileErrorTarget)" />
  </Target>

  <Target Name="ClangClNotFoundError">
    <VCMessage Code="MSB8057" Type="Error"  Condition="'$(_ExecutablePathWasCustomized)'=='false' AND '$(_VC_CL_ResolvedPathToTool)'=='$(CLToolExe)'" />
  </Target>

  <Target Name="Link"
          Condition="'@(Link)' != ''"
          DependsOnTargets="ComputeLinkSwitches">
    <ItemGroup>
      <Link>
        <ProfileGuidedDatabase Condition="'%(Link.LinkTimeCodeGeneration)' != 'PGOptimization' and
                                          '%(Link.LinkTimeCodeGeneration)' != 'PGUpdate' and
                                          '%(Link.LinkTimeCodeGeneration)' != 'PGInstrument'"></ProfileGuidedDatabase>
        <ManifestEmbed Condition="'%(Link.ManifestEmbed)' == '' and '$(LegacyManifestEmbedding)' != 'true'">$(EmbedManifest)</ManifestEmbed>
        <ManifestInput Condition="'$(LegacyManifestEmbedding)' != 'true' and '$(EmbedManifest)' == 'true'">@(Link->'%(ManifestInput)');@(Manifest);$(ManifestAdditionalManifestFiles)</ManifestInput>
        <ManifestFile Condition="'$(LegacyManifestEmbedding)' != 'true'" />
      </Link>

      <!-- Remove some Winmd switches if generation is false -->
      <Link>
        <WindowsMetadataFile            Condition="'%(Link.GenerateWindowsMetadata)' == ''" />
        <WindowsMetadataLinkKeyFile     Condition="'%(Link.GenerateWindowsMetadata)' == ''" />
        <WindowsMetadataKeyContainer    Condition="'%(Link.GenerateWindowsMetadata)' == ''" />
        <WindowsMetadataLinkDelaySign   Condition="'%(Link.GenerateWindowsMetadata)' == ''" />
        <WindowsMetadataSignHash        Condition="'%(Link.GenerateWindowsMetadata)' == ''" />
      </Link>

      <!-- Settings needed for lld-link.exe  -->
      <Link>
        <GenerateDebugInformation Condition="'%(Link.GenerateDebugInformation)' != 'false'">DebugFull</GenerateDebugInformation>
      </Link>
    </ItemGroup>

    <Link
        BuildingInIDE                  ="$(BuildingInsideVisualStudio)"
        Sources                        ="@(Link)"

        AdditionalDependencies         ="%(Link.AdditionalDependencies)"
        AdditionalLibraryDirectories   ="%(Link.AdditionalLibraryDirectories)"
        AdditionalManifestDependencies ="%(Link.AdditionalManifestDependencies)"
        AdditionalOptions              ="%(Link.AdditionalOptions)"
        AddModuleNamesToAssembly       =""
        AllowIsolation                 ="%(Link.AllowIsolation)"
        AssemblyDebug                  =""
        AssemblyLinkResource           =""
        BaseAddress                    ="%(Link.BaseAddress)"
        CETCompat                      =""
        ControlFlowGuard               ="$(LinkControlFlowGuard)"
        CLRImageType                   =""
        CLRSupportLastError            =""
        CLRThreadAttribute             =""
        CLRUnmanagedCodeCheck          =""
        CreateHotPatchableImage        =""
        DataExecutionPrevention        ="%(Link.DataExecutionPrevention)"
        DelayLoadDLLs                  ="%(Link.DelayLoadDLLs)"
        DelaySign                      =""
        Driver                         ="%(Link.Driver)"
        EmbedManagedResourceFile       =""
        EnableCOMDATFolding            ="%(Link.EnableCOMDATFolding)"
        EnableUAC                      ="%(Link.EnableUAC)"
        EntryPointSymbol               ="%(Link.EntryPointSymbol)"
        LinkErrorReporting             =""
        FixedBaseAddress               ="%(Link.FixedBaseAddress)"
        ForceFileOutput                ="%(Link.ForceFileOutput)"
        ForceSymbolReferences          ="%(Link.ForceSymbolReferences)"
        FunctionOrder                  ="%(Link.FunctionOrder)"
        GenerateDebugInformation       ="%(Link.GenerateDebugInformation)"
        GenerateManifest               ="$(GenerateManifest)"
        GenerateMapFile                =""
        GenerateWindowsMetadata        =""
        GuardEHContMetadata            =""
        WindowsMetadataFile            =""
        HeapCommitSize                 ="%(Link.HeapCommitSize)"
        HeapReserveSize                ="%(Link.HeapReserveSize)"
        IgnoreAllDefaultLibraries      ="%(Link.IgnoreAllDefaultLibraries)"
        IgnoreEmbeddedIDL              =""
        IgnoreSpecificDefaultLibraries ="%(Link.IgnoreSpecificDefaultLibraries)"
        ImageHasSafeExceptionHandlers  ="%(Link.ImageHasSafeExceptionHandlers)"
        ImportLibrary                  ="%(Link.ImportLibrary)"
        KeyContainer                   =""
        KeyFile                        =""
        LargeAddressAware              ="%(Link.LargeAddressAware)"
        LinkDLL                        ="%(Link.LinkDLL)"
        LinkIncremental                ="$(LinkIncremental)"
        LinkStatus                     =""
        LinkTimeCodeGeneration         =""
        ManifestFile                   ="%(Link.ManifestFile)"
        ManifestEmbed                  ="%(Link.ManifestEmbed)"
        ManifestInput                  ="%(Link.ManifestInput)"
        MapExports                     =""
        MapFileName                    =""
        MergedIDLBaseFileName          =""
        MergeSections                  ="%(Link.MergeSections)"
        MidlCommandFile                =""
        MinimumRequiredVersion         ="%(Link.MinimumRequiredVersion)"
        ModuleDefinitionFile           ="%(Link.ModuleDefinitionFile)"
        MSDOSStubFileName              ="%(Link.MSDOSStubFileName)"
        Natvis                         ="@(Natvis)"
        OptimizeReferences             ="%(Link.OptimizeReferences)"
        OutputFile                     ="%(Link.OutputFile)"
        PreventDllBinding              ="%(Link.PreventDllBinding)"
        Profile                        =""
        ProfileGuidedDatabase          ="%(Link.ProfileGuidedDatabase)"
        ProgramDatabaseFile            ="%(Link.ProgramDatabaseFile)"
        RandomizedBaseAddress          ="%(Link.RandomizedBaseAddress)"
        NoEntryPoint                   ="%(Link.NoEntryPoint)"
        SectionAlignment               ="%(Link.SectionAlignment)"
        SetChecksum                    =""
        ShowProgress                   =""
        SignHash                       =""
        SpecifySectionAttributes       ="%(Link.SpecifySectionAttributes)"
        StackCommitSize                ="%(Link.StackCommitSize)"
        StackReserveSize               ="%(Link.StackReserveSize)"
        StripPrivateSymbols            =""
        SubSystem                      ="%(Link.SubSystem)"
        SupportUnloadOfDelayLoadedDLL  =""
        SupportNobindOfDelayLoadedDLL  =""
        SuppressStartupBanner          =""
        SwapRunFromCD                  =""
        SwapRunFromNET                 =""
        TargetMachine                  ="%(Link.TargetMachine)"
        TerminalServerAware            ="%(Link.TerminalServerAware)"
        TreatLinkerWarningAsErrors     ="%(Link.TreatLinkerWarningAsErrors)"
        TurnOffAssemblyGeneration      =""
        TypeLibraryFile                =""
        TypeLibraryResourceID          =""
        UACExecutionLevel              ="%(Link.UACExecutionLevel)"
        UACUIAccess                    ="%(Link.UACUIAccess)"
        Version                        ="%(Link.Version)"
        WindowsMetadataLinkKeyFile     =""
        WindowsMetadataKeyContainer    =""
        WindowsMetadataLinkDelaySign   =""
        WindowsMetadataSignHash        =""

        TrackerLogDirectory            ="%(Link.TrackerLogDirectory)"

        TLogReadFiles                  ="@(LinkTLogReadFiles)"
        TLogWriteFiles                 ="@(LinkTLogWriteFiles)"
        ToolExe                        ="$(LinkToolExe)"
        ToolPath                       ="$(LinkToolPath)"
        TrackFileAccess                ="$(TrackFileAccess)"
        MinimalRebuildFromTracking     ="$(Link_MinimalRebuildFromTracking)"
        ToolArchitecture               ="$(LinkToolArchitecture)"
        TrackerFrameworkPath           ="$(LinkTrackerFrameworkPath)"
        TrackerSdkPath                 ="$(LinkTrackerSdkPath)"
        TrackedInputFilesToIgnore      ="@(LinkNoDependencies)"

        AcceptableNonZeroExitCodes     ="%(Link.AcceptableNonZeroExitCodes)"
        YieldDuringToolExecution       ="$(LinkYieldDuringToolExecution)"
    >
      <Output TaskParameter="ResolvedPathToTool"  PropertyName="_VC_Link_ResolvedPathToTool" />
      <Output TaskParameter="SkippedExecution" PropertyName="LinkSkippedExecution" />
    </Link>

    <Message Text="$(MSBuildProjectFile) -&gt; $(TargetPath)" Importance="High" Condition="'$(EmbedManifestBy)' != 'LINK' or '$(LegacyManifestEmbedding)' != 'true' or '$(LinkSkippedExecution)' == 'true'"/>
    <VCMessage Code="MSB8033" Type="Message" Arguments="$(MSBuildProjectFile);%(Link.ProgramDatabaseFile)" Importance="High"
             Condition="('$(EmbedManifestBy)' != 'LINK' or '$(LegacyManifestEmbedding)' != 'true' or '$(LinkSkippedExecution)' == 'true') and
             %(Link.GenerateDebugInformation) == 'DebugFastLink' and %(Link.ProgramDataBaseFileName) != ''"/>
    <VCMessage Code="MSB8034" Type="Message" Arguments="$(MSBuildProjectFile);%(Link.ProgramDatabaseFile)" Importance="High"
             Condition="('$(EmbedManifestBy)' != 'LINK' or '$(LegacyManifestEmbedding)' != 'true' or '$(LinkSkippedExecution)' == 'true') and
             %(Link.GenerateDebugInformation) == 'true' and %(Link.ProgramDataBaseFileName) != ''"/>

    <OnError ExecuteTargets="LLDNotFoundError" />
  </Target>

  <Target Name="LLDNotFoundError">
    <VCMessage Code="MSB8057" Type="Error"  Condition="'$(_ExecutablePathWasCustomized)' == 'false' AND '$(_VC_Link_ResolvedPathToTool)' == '$(LinkToolExe)'" />
  </Target>
</Project>
