intel / intel-graphics-compiler

Other
596 stars 155 forks source link

add_custom_target cannot create target "SPIRV-Tools" with -DIGC_OPTION__SPIRV_TOOLS_MODE=Prebuilds #278

Closed frantisekz closed 1 year ago

frantisekz commented 1 year ago

Since 385f67c0b9a0eda6a65c56616e84bb2d612f82cf , using Prebuilds mode for IGC_OPTION__SPIRV_TOOLS_MODE results in configure phase failure with:

-- ============================ SPIRV-Tools project ============================
-- [SPIRV-Tools] : IGC_OPTION__SPIRV_TOOLS_MODE set to Prebuilds
-- [SPIRV-Tools] : IGC_OPTION__USE_PREINSTALLED_SPIRV_HEADERS set to ON
-- [SPIRV-Tools] : Using default path /builddir/build/BUILD/intel-graphics-compiler-igc-1.0.12812.21/IGC/../../SPIRV-Headers
-- [SPIRV-Tools] : Searching prebuilt SPIRV-Tools package
-- [SPIRV-Tools] : Found prebuilt SPIRV-Tools package in: /usr/lib64/cmake/SPIRV-Tools/SPIRV-ToolsConfig.cmake
CMake Error at external/SPIRV-Tools/CMakeLists.txt:36 (add_custom_target):
  add_custom_target cannot create target "SPIRV-Tools" because an imported
  target with the same name already exists.
Call Stack (most recent call first):
  IGC/CMakeLists.txt:1427 (include)

The build directory is always pristine (I am using Feodra packaging workflow even for local builds), external/SPIRV-Tools/ contains just the CMakeLists.txt file. I was able to "workaround" this issue with following patch, which partially reverts the mentioned commit:

--- a/external/SPIRV-Tools/CMakeLists.txt
+++ b/external/SPIRV-Tools/CMakeLists.txt
@@ -33,7 +33,6 @@ if(IGC_OPTION__SPIRV_TOOLS_MODE STREQUAL PREBUILDS_MODE_NAME)
  set(IGC_BUILD__SPIRV-Tools_DIR "${SPIRV-Tools_ROOT_DIR}")

  set(INCLUDE_DIRS_LIST "${SPIRV-Tools_ROOT_DIR}/include" "${SPIRV-Headers_INCLUDE_DIR}")
- add_custom_target(SPIRV-Tools)
  set_target_properties(SPIRV-Tools PROPERTIES INCLUDE_DIRECTORIES "${INCLUDE_DIRS_LIST}")
  set(IGC_BUILD__PROJ__SPIRV-Tools SPIRV-Tools)

-- 
Quetzonarch commented 1 year ago

Hi @frantisekz, thanks for noticing this issue. We have a suggestion of a solution for this problem which we're currently testing, but it might take a bit of time before it arrives.

mnaczk commented 1 year ago

Fix proposition added by commit https://github.com/intel/intel-graphics-compiler/commit/8068732355d18464a9fcb6846c225929349b450c Thank @Quetzonarch

@frantisekz Could please check if this resolves your issue?

ConiKost commented 1 year ago

Seems to fix the issue for me.

mnaczk commented 1 year ago

I have marked the issue as resolved. If the issue persists, @frantisekz, please feel free to reopen it.