# compile tesseract add\_library error on Windows

**URL:** https://discourse.cmake.org/t/compile-tesseract-add-library-error-on-windows/15365
**Category:** Usage
**Created:** [December 6, 2025, 6:22am UTC](https://discourse.cmake.org/t/compile-tesseract-add-library-error-on-windows/15365 "2025-12-06T06:22:04Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![pol2095](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/e99b99/32.png) [@pol2095](https://discourse.cmake.org/u/pol2095)
#### Post date: [December 6, 2025, 6:22am UTC](https://discourse.cmake.org/t/compile-tesseract-add-library-error-on-windows/15365/1 "2025-12-06T06:22:04Z")

</div>

Hello,

When I compile Teseract on Windows, I have this `sw` message error in VisualStudio CMake :

```auto
CMake Error at out/build/x64-Release/.sw/cmake/CMakeLists.txt:1706 (add_library):
  add_library cannot create ALIAS target "org.sw.demo.python.lib-3" because
  another target with the same name already exists. C:\Users\user\CMake\tesseract\out/build/x64-Release/.sw/cmake/CMakeLists.txt	1706

```

in `tesseract\out\build\x64-Debug\.sw\cmake\CMakeLists.txt` I have :

```auto
if (NOT TARGET org.sw.demo.python.lib-3.10.13)
    add_library(org.sw.demo.python.lib-3.10.13 SHARED IMPORTED GLOBAL)

    add_dependencies(org.sw.demo.python.lib-3.10.13 sw_build_dependencies)

    add_library(org.sw.demo.python.lib-3.10 ALIAS org.sw.demo.python.lib-3.10.13)
    add_library(org.sw.demo.python.lib-3 ALIAS org.sw.demo.python.lib-3.10.13)
    add_library(org.sw.demo.python.lib ALIAS org.sw.demo.python.lib-3.10.13)
endif()

if (NOT TARGET org.sw.demo.python.lib-3.13.7)
    add_library(org.sw.demo.python.lib-3.13.7 SHARED IMPORTED GLOBAL)

    add_dependencies(org.sw.demo.python.lib-3.13.7 sw_build_dependencies)

    add_library(org.sw.demo.python.lib-3.13 ALIAS org.sw.demo.python.lib-3.13.7)
    add_library(org.sw.demo.python.lib-3 ALIAS org.sw.demo.python.lib-3.13.7)
    add_library(org.sw.demo.python.lib ALIAS org.sw.demo.python.lib-3.13.7)
endif()

```

how I prevent this ?

Thanks

---

<div class="post-metadata">

### Author: ![Andrej730](https://discourse.cmake.org/user_avatar/discourse.cmake.org/andrej730/32/5752_2.png) [@Andrej730](https://discourse.cmake.org/u/Andrej730)
#### Post date: [December 7, 2025, 4:53pm UTC](https://discourse.cmake.org/t/compile-tesseract-add-library-error-on-windows/15365/2 "2025-12-07T16:53:16Z")

</div>

It’s a behaviour introduced in [https://cmake.org/cmake/help/latest/policy/CMP0107.html](https://cmake.org/cmake/help/latest/policy/CMP0107.html).

You can either set policy to `OLD` with `cmake_policy(SET CMP0107 OLD) ` if you want this build to succeed, but it would be better to change the code to avoid redefining aliases.

No idea what Teseract is, but if the goal of the code is to create aliases based on the most recent Python version, then maybe lines below can be replaced with something like `set(latest_python org.sw.demo.python.lib-3.10.13)` and only at the end add those aliases based on the final value of `latest_python`.

```cmake
add_library(org.sw.demo.python.lib-3 ALIAS org.sw.demo.python.lib-3.10.13)
add_library(org.sw.demo.python.lib ALIAS org.sw.demo.python.lib-3.10.13)

```
