aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/ports/zeroc-ice/change_to_mt.ps1
blob: 91306095423bd0c395ae5a8bc91c4d569186b981 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
$projFilePath = $args[0]
$crtLinkage = $args[1]

if($projFilePath)
{
  $xpath = "/rs:Project/rs:ItemGroup/rs:ProjectConfiguration"
  $xmldoc = New-Object System.Xml.XmlDocument
  $xmldoc.load($projFilePath)
  $nsmgr = New-Object System.Xml.XmlNamespaceManager($xmldoc.NameTable);
  $nsmgr.AddNamespace("rs", "http://schemas.microsoft.com/developer/msbuild/2003");
  $root = $xmldoc.DocumentElement

  foreach($conf in $root.ItemDefinitionGroup)
  {
    if($conf.Condition)
    {
      if(-Not ($conf.ClCompile.RuntimeLibrary))
      {
        $rtl = $xmldoc.CreateElement("RuntimeLibrary", $conf.ClCompile.NamespaceURI)
        $conf.ClCompile.AppendChild($rtl)
      }

      if($conf.Condition.Contains("Debug"))
      {
        if($crtLinkage -eq "static")
        {
          $conf.ClCompile.RuntimeLibrary = "MultithreadedDebug"
        }
        else
        {
          $conf.ClCompile.RuntimeLibrary = "MultithreadedDebugDLL"
        }
      }
      else
      {
        if($crtLinkage -eq "static")
        {
          $conf.ClCompile.RuntimeLibrary = "Multithreaded"
        }
        else
        {
          $conf.ClCompile.RuntimeLibrary = "MultithreadedDLL"
        }
      }
    }
  }
  $xmldoc.save($projFilePath)
}
else
{
  Write-Error "Error: No path defined!"
}