From f503a0b3faf5d324c62881d61e1ba1e0942becd9 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Wed, 21 Aug 2024 15:59:08 +0800 Subject: Dont require llvm for building generators (#4895) * Dont require llvm for building generators * Fetch slang-llvm.so from correct release (#4847) * Fetch slang-llvm.so from correct release Closes https://github.com/shader-slang/slang/issues/4648 Should close https://github.com/shader-slang/slang/issues/4812 * Update docs * Correct documentation on cmake option * Neaten cmake script * Fix fetching on windows --------- Co-authored-by: Yong He * Be a bit more careful dealing with release list fetching failure * clarify error messages --------- Co-authored-by: Yong He --- CMakeLists.txt | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 54eae379b..d2972e642 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,7 @@ include(Glob) include(LLVM) include(SlangTarget) include(AutoOption) +include(GitHubRelease) # # Options @@ -125,25 +126,26 @@ enum_option( "How to get or build slang-llvm:" # Options FETCH_BINARY - "Use a binary distribution of the slang-llvm library instead of building or using LLVM (default for Windows)" + "Use a binary distribution of the slang-llvm library instead of building or using LLVM (default)" USE_SYSTEM_LLVM - "Build slang-llvm using system-provided LLVM and Clang binaries (default for non-Windows hosts)" + "Build slang-llvm using system-provided LLVM and Clang binaries" DISABLE "Do not build llvm or fetch slang-llvm" ) -macro(slang_llvm_binary_url_option version filename) + +if(SLANG_SLANG_LLVM_FLAVOR MATCHES FETCH_BINARY) + # If the user didn't specify a URL, find the best one now + if(NOT SLANG_SLANG_LLVM_BINARY_URL) + get_best_slang_binary_release_url(url) + if(NOT DEFINED url) + message(FATAL_ERROR "Unable to find binary release for slang-llvm, please set a different SLANG_SLANG_LLVM_FLAVOR or set SLANG_SLANG_LLVM_BINARY_URL manually") + endif() + endif() set(SLANG_SLANG_LLVM_BINARY_URL - "https://github.com/shader-slang/slang-llvm/releases/download/${version}/${filename}" + ${url} CACHE STRING "URL specifying the location of the slang-llvm prebuilt library" ) -endmacro() -if(CMAKE_SYSTEM_NAME MATCHES "Windows") - slang_llvm_binary_url_option("v13.x-43" "slang-llvm-13.x-43-win64.zip") -elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin") - slang_llvm_binary_url_option("v13.x-43" "slang-llvm-v13.x-43-macosx-x86_64-release.zip") -else() - slang_llvm_binary_url_option("v13.x-43" "slang-llvm-v13.x-43-linux-x86_64-release.zip") endif() # @@ -392,7 +394,7 @@ if(SLANG_SLANG_LLVM_FLAVOR STREQUAL "FETCH_BINARY") endif() set(slang_llvm_dest_object - ${CMAKE_BINARY_DIR}/$/${runtime_subdir}/${slang_llvm_filename} + ${CMAKE_BINARY_DIR}/$/${module_subdir}/${slang_llvm_filename} ) add_custom_command( OUTPUT ${slang_llvm_dest_object} -- cgit v1.2.3