<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - LLVM CMake do not work with vcpkg LibXml2 port"
   href="https://bugs.llvm.org/show_bug.cgi?id=50965">50965</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LLVM CMake do not work with vcpkg LibXml2 port
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Build scripts
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>cmake
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>clemens.wasser@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I am currently trying to build LLVM with multiple Projects enabled and with
LibXml2 on Windows.
For that I am using vcpkg and it's LibXml2 port from this pull request:
<a href="https://github.com/microsoft/vcpkg/pull/17945">https://github.com/microsoft/vcpkg/pull/17945</a> (since the current port on master
is broken)
However I am facing the following error:

---

CMake Error at
E:/git/vcpkg/installed/x64-windows-static/share/libxml2/vcpkg-cmake-wrapper.cmake:43
(target_link_libraries):
  Cannot specify link libraries for target "LibXml2::LibXml2" which is not
  built by this project.
Call Stack (most recent call first):
  E:/git/vcpkg/scripts/buildsystems/vcpkg.cmake:725 (include)
  E:/git/llvm-project/clang/CMakeLists.txt:207 (find_package)

---

The problem is that find_package for LibXml2 gets called multiple times and
that the LibXml2::LibXml2 target is immutable after the first call, which is
bad, because vcpkg-cmake-wrapper.cmake tries to modify the target nevertheless
(which causes the issue shown above):
<a href="https://github.com/Neumann-A/vcpkg/blob/10faaac739b2c2454f85414f532c58d67dc90e49/ports/libxml2/vcpkg-cmake-wrapper.cmake#L43">https://github.com/Neumann-A/vcpkg/blob/10faaac739b2c2454f85414f532c58d67dc90e49/ports/libxml2/vcpkg-cmake-wrapper.cmake#L43</a>)
Is the LibXml2::LibXml2 target maybe mistakenly exported globally?
Or couldn't you just call find_package once for LibXml2 and use that target
everywhere?</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>