compile tesseract add_library error on Windows

Hello,

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

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 :

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

It’s a behaviour introduced in 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.

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)