[GH-ISSUE #1733] _add_library cannot create ALIAS target "SPIRV-Headers::SPIRV-Headers" #599

Closed
opened 2026-02-27 21:07:07 +03:00 by kerem · 8 comments
Owner

Originally created by @nicovil on GitHub (Dec 10, 2024).
Original GitHub issue: https://github.com/shadps4-emu/shadPS4/issues/1733

I use to compile ShadPS4 with Visual Studio 2022 and CMake and everything worked well until one of the last updates.

I'm getting this error when processing the CMakeFile.txt:

CMake Error at C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/vcpkg/scripts/buildsystems/vcpkg.cmake:639 (_add_library):
  _add_library cannot create ALIAS target "SPIRV-Headers::SPIRV-Headers"
  because another target with the same name already exists.
Call Stack (most recent call first):
  externals/sirit/CMakeLists.txt:91 (add_library)

When I debug the makefile I located that this issue is being triggered when adding subdirectory:

add_subdirectory(sirit)

Is there any special flag that must be added to use sirit module?

I noticed sirit makefile has a flag named SIRIT_USE_SYSTEM_SPIRV_HEADERS that defines if SPIRV-Headers are added or not, should I set this flag?

Thanks!

Originally created by @nicovil on GitHub (Dec 10, 2024). Original GitHub issue: https://github.com/shadps4-emu/shadPS4/issues/1733 I use to compile ShadPS4 with Visual Studio 2022 and CMake and everything worked well until one of the last updates. I'm getting this error when processing the CMakeFile.txt: ``` CMake Error at C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/vcpkg/scripts/buildsystems/vcpkg.cmake:639 (_add_library): _add_library cannot create ALIAS target "SPIRV-Headers::SPIRV-Headers" because another target with the same name already exists. Call Stack (most recent call first): externals/sirit/CMakeLists.txt:91 (add_library) ``` When I debug the makefile I located that this issue is being triggered when adding subdirectory: `add_subdirectory(sirit)` Is there any special flag that must be added to use sirit module? I noticed sirit makefile has a flag named **SIRIT_USE_SYSTEM_SPIRV_HEADERS** that defines if SPIRV-Headers are added or not, should I set this flag? Thanks!
kerem closed this issue 2026-02-27 21:07:08 +03:00
Author
Owner

@Hermiten commented on GitHub (Dec 11, 2024):

Maybe for you @abouvier ?

<!-- gh-comment-id:2537332547 --> @Hermiten commented on GitHub (Dec 11, 2024): Maybe for you @abouvier ?
Author
Owner

@abouvier commented on GitHub (Dec 12, 2024):

Did you install spirv-headers via vcpkg? Anyway, you should post the full CMake output.

And yes, using SIRIT_USE_SYSTEM_SPIRV_HEADERS will probably solve your problem, because headers were found somewhere on your system.

<!-- gh-comment-id:2537455910 --> @abouvier commented on GitHub (Dec 12, 2024): Did you install `spirv-headers` via `vcpkg`? Anyway, you should post the full CMake output. And yes, using `SIRIT_USE_SYSTEM_SPIRV_HEADERS` will probably solve your problem, because headers were found somewhere on your system.
Author
Owner

@nicovil commented on GitHub (Dec 12, 2024):

Hi abouvier,

spirv-headers external sub module is located under externals/sirit/externals/spirv-headers by git when submodules are installed recursively during checkout under externals folder as usual.

What I copied in my first message was the CMake error I catched in a CMake debug session, now I attached the full CMake output (without debugging) that if you check doesn't have any reference to sirit:

cmake_output.txt

I tried adding adding SIRIT_USE_SYSTEM_SPIRV_HEADERS flag and recreated CMake cache and now it doesn't founds the required cmake files for spirv-headers-config, this is the error:

CMake Error at C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/vcpkg/scripts/buildsystems/vcpkg.cmake:859 (_find_package):
1> [CMake]   By not providing "FindSPIRV-Headers.cmake" in CMAKE_MODULE_PATH this
1> [CMake]   project has asked CMake to find a package configuration file provided by
1> [CMake]   "SPIRV-Headers", but CMake did not find one.
1> [CMake] 
1> [CMake]   Could not find a package configuration file provided by "SPIRV-Headers"
1> [CMake]   with any of the following names:
1> [CMake] 
1> [CMake]     SPIRV-HeadersConfig.cmake
1> [CMake]     spirv-headers-config.cmake
1> [CMake] 
1> [CMake]   Add the installation prefix of "SPIRV-Headers" to CMAKE_PREFIX_PATH or set
1> [CMake]   "SPIRV-Headers_DIR" to a directory containing one of the above files.  If
1> [CMake]   "SPIRV-Headers" provides a separate development package or SDK, be sure it
1> [CMake]   has been installed.

So I figured out that sirit/externals/spirv-headers has not been built/installed by cmake, then I went to that folder and did it manually:

cmake --build . --target install --config Release

And together with SIRIT_USE_SYSTEM_SPIRV_HEADERS flag ShadPS4 compiled flawlessly. However this needs the extra step of manual build for spirv-headers and install to program files in windows to work (I guess it's the same for bin folder in linux).

I guess there is some missing step in makelists to allow SPIRV-Headers to be used without installing? or it's a pre-requisite and it was not documented yet in "build instructions" ?

<!-- gh-comment-id:2539060168 --> @nicovil commented on GitHub (Dec 12, 2024): Hi abouvier, spirv-headers external sub module is located under **externals/sirit/externals/spirv-headers** by git when submodules are installed recursively during checkout under externals folder as usual. What I copied in my first message was the CMake error I catched in a CMake debug session, now I attached the full CMake output (without debugging) that if you check doesn't have any reference to sirit: [cmake_output.txt](https://github.com/user-attachments/files/18112713/cmake_output.txt) I tried adding adding SIRIT_USE_SYSTEM_SPIRV_HEADERS flag and recreated CMake cache and now it doesn't founds the required cmake files for spirv-headers-config, this is the error: ``` CMake Error at C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/vcpkg/scripts/buildsystems/vcpkg.cmake:859 (_find_package): 1> [CMake] By not providing "FindSPIRV-Headers.cmake" in CMAKE_MODULE_PATH this 1> [CMake] project has asked CMake to find a package configuration file provided by 1> [CMake] "SPIRV-Headers", but CMake did not find one. 1> [CMake] 1> [CMake] Could not find a package configuration file provided by "SPIRV-Headers" 1> [CMake] with any of the following names: 1> [CMake] 1> [CMake] SPIRV-HeadersConfig.cmake 1> [CMake] spirv-headers-config.cmake 1> [CMake] 1> [CMake] Add the installation prefix of "SPIRV-Headers" to CMAKE_PREFIX_PATH or set 1> [CMake] "SPIRV-Headers_DIR" to a directory containing one of the above files. If 1> [CMake] "SPIRV-Headers" provides a separate development package or SDK, be sure it 1> [CMake] has been installed. ``` So I figured out that **sirit/externals/spirv-headers** has not been built/installed by cmake, then I went to that folder and did it manually: `cmake --build . --target install --config Release` And together with **SIRIT_USE_SYSTEM_SPIRV_HEADERS** flag ShadPS4 compiled flawlessly. However this needs the extra step of manual build for spirv-headers and install to program files in windows to work (I guess it's the same for bin folder in linux). I guess there is some missing step in makelists to allow SPIRV-Headers to be used without installing? or it's a pre-requisite and it was not documented yet in "build instructions" ?
Author
Owner

@abouvier commented on GitHub (Dec 13, 2024):

This will be fixed by https://github.com/shadps4-emu/sirit/pull/5.
But I don't know why it didn't affect everyone but just you :$

<!-- gh-comment-id:2540322671 --> @abouvier commented on GitHub (Dec 13, 2024): This will be fixed by https://github.com/shadps4-emu/sirit/pull/5. But I don't know why it didn't affect everyone but just you :$
Author
Owner

@nicovil commented on GitHub (Dec 13, 2024):

This will be fixed by shadps4-emu/sirit#5. But I don't know why it didn't affect everyone but just you :$

That's a good question, I guess people workarounded the issue and didn't reported it.

Thanks you very much for your help, looking forward for your pull request to be added to main!

<!-- gh-comment-id:2541893303 --> @nicovil commented on GitHub (Dec 13, 2024): > This will be fixed by [shadps4-emu/sirit#5](https://github.com/shadps4-emu/sirit/pull/5). But I don't know why it didn't affect everyone but just you :$ That's a good question, I guess people workarounded the issue and didn't reported it. Thanks you very much for your help, looking forward for your pull request to be added to main!
Author
Owner

@nicovil commented on GitHub (Dec 13, 2024):

FYI, I uninstalled SPIRV-HEADERS from my system, restored original siri submodule with GIT and added manually the modifications you made in your pull request to siri makelist and now the build works like a charm.

<!-- gh-comment-id:2541919610 --> @nicovil commented on GitHub (Dec 13, 2024): FYI, I uninstalled SPIRV-HEADERS from my system, restored original siri submodule with GIT and added manually the modifications you made in your pull request to siri makelist and now the build works like a charm.
Author
Owner

@polybiusproxy commented on GitHub (Dec 13, 2024):

I have gotten this as well, I just resolved it by removing vcpkg, I was not using it anyways.

<!-- gh-comment-id:2541920745 --> @polybiusproxy commented on GitHub (Dec 13, 2024): I have gotten this as well, I just resolved it by removing vcpkg, I was not using it anyways.
Author
Owner

@abouvier commented on GitHub (Dec 14, 2024):

This will be fixed by shadps4-emu/sirit#5. But I don't know why it didn't affect everyone but just you :$

That's a good question, I guess people workarounded the issue and didn't reported it.

It's because you use vcpkg and there is something related to cmake_policy in vcpkg/scripts/buildsystems/vcpkg.cmake that activate this error.

<!-- gh-comment-id:2542925736 --> @abouvier commented on GitHub (Dec 14, 2024): > > This will be fixed by [shadps4-emu/sirit#5](https://github.com/shadps4-emu/sirit/pull/5). But I don't know why it didn't affect everyone but just you :$ > > That's a good question, I guess people workarounded the issue and didn't reported it. It's because you use vcpkg and there is something related to cmake_policy in `vcpkg/scripts/buildsystems/vcpkg.cmake` that activate this error.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/shadPS4#599
No description provided.