Fix for "Option 'spirv-ext' registered more than once" error. Bug: https://bugs.gentoo.org/959744 Upstream PR: https://github.com/KhronosGroup/SPIRV-LLVM-Translator/pull/3218 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,13 +102,6 @@ if(LLVM_SPIRV_BUILD_EXTERNAL) message(STATUS "Found LLVM: ${LLVM_VERSION}") - is_llvm_target_library("SPIRV" spirv_present_result INCLUDED_TARGETS) - if(spirv_present_result) - message(STATUS "Found SPIR-V Backend") - set(SPIRV_BACKEND_FOUND TRUE) - add_compile_definitions(LLVM_SPIRV_BACKEND_TARGET_PRESENT) - endif() - option(CCACHE_ALLOWED "allow use of ccache" TRUE) find_program(CCACHE_EXE_FOUND ccache) if(CCACHE_EXE_FOUND AND CCACHE_ALLOWED) @@ -118,6 +111,13 @@ if(LLVM_SPIRV_BUILD_EXTERNAL) endif() endif() +is_llvm_target_library("SPIRV" spirv_present_result INCLUDED_TARGETS) +if(spirv_present_result) + message(STATUS "Found SPIR-V Backend") + set(SPIRV_BACKEND_FOUND TRUE) + add_compile_definitions(LLVM_SPIRV_BACKEND_TARGET_PRESENT) +endif() + set(LLVM_SPIRV_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include) # first try locating SPIRV-Tools via pkgconfig (the old way)