diff options
| author | jarcherNV <jarcher@nvidia.com> | 2025-03-06 19:16:27 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-07 03:16:27 +0000 |
| commit | 9d7d943db47dd7805a710431cf7eedc0bec8ecc7 (patch) | |
| tree | 851f51e2087f76b39ea19a8ca4ec8cf4555a4bb2 | |
| parent | 2aaa91007a9f91674033dcb9d88eb9ad7bacae96 (diff) | |
Update build to allow setting external paths (#6528)
* Update build to allow setting external paths
Update the build to allow setting user-specific paths for the external modules.
This allows building Slang without also fetching the external modules, assuming
they are already present elsewhere locally.
| -rw-r--r-- | CMakeLists.txt | 41 | ||||
| -rw-r--r-- | external/CMakeLists.txt | 86 | ||||
| -rw-r--r-- | source/core/slang-dictionary.h | 2 | ||||
| -rw-r--r-- | source/core/slang-hash.h | 2 | ||||
| -rw-r--r-- | source/slang/CMakeLists.txt | 12 |
5 files changed, 130 insertions, 13 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 48d263d14..a74047e0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -166,6 +166,43 @@ option( ) mark_as_advanced(SLANG_SPIRV_HEADERS_INCLUDE_DIR) +# Options for user defined paths for external modules. +advanced_option( + SLANG_OVERRIDE_LZ4_PATH + "Build using user defined path for LZ4" + OFF +) +advanced_option( + SLANG_OVERRIDE_MINIZ_PATH + "Build using user defined path for Miniz" + OFF +) +advanced_option( + SLANG_OVERRIDE_UNORDERED_DENSE_PATH + "Build using user defined path for unordered_dense" + OFF +) +advanced_option( + SLANG_OVERRIDE_VULKAN_HEADERS_PATH + "Build using user defined path for Vulkan headers" + OFF +) +advanced_option( + SLANG_OVERRIDE_SPIRV_HEADERS_PATH + "Build using user defined path for SPIR-V headers" + OFF +) +advanced_option( + SLANG_OVERRIDE_SPIRV_TOOLS_PATH + "Build using user defined path for SPIR-V tools" + OFF +) +advanced_option( + SLANG_OVERRIDE_GLSLANG_PATH + "Build using user defined path for glslang, this also requires " + OFF +) + if(${SLANG_USE_SYSTEM_LZ4}) add_compile_definitions(SLANG_USE_SYSTEM_LZ4_HEADER) endif() @@ -178,6 +215,10 @@ if(${SLANG_USE_SYSTEM_UNORDERED_DENSE}) add_compile_definitions(SLANG_USE_SYSTEM_UNORDERED_DENSE_HEADER) endif() +if(SLANG_OVERRIDE_SPIRV_HEADERS_PATH) + add_compile_definitions(SLANG_USE_SYSTEM_SPIRV_HEADER) +endif() + enum_option( SLANG_LIB_TYPE # Default diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index f23027f68..a590fe538 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -27,13 +27,32 @@ if(NOT SLANG_ENABLE_EXTERNAL_COMPILER_WARNINGS) endif() endif() +# Unordered dense if(NOT ${SLANG_USE_SYSTEM_UNORDERED_DENSE}) - add_subdirectory(unordered_dense EXCLUDE_FROM_ALL ${system}) + if(NOT SLANG_OVERRIDE_UNORDERED_DENSE_PATH) + add_subdirectory(unordered_dense EXCLUDE_FROM_ALL ${system}) + else() + add_subdirectory( + ${SLANG_OVERRIDE_UNORDERED_DENSE_PATH} + unordered_dense + EXCLUDE_FROM_ALL + ${system} + ) + endif() endif() # Miniz if(NOT ${SLANG_USE_SYSTEM_MINIZ}) - add_subdirectory(miniz EXCLUDE_FROM_ALL ${system}) + if(NOT SLANG_OVERRIDE_MINIZ_PATH) + add_subdirectory(miniz EXCLUDE_FROM_ALL ${system}) + else() + add_subdirectory( + ${SLANG_OVERRIDE_MINIZ_PATH} + miniz + EXCLUDE_FROM_ALL + ${system} + ) + endif() set_property(TARGET miniz PROPERTY POSITION_INDEPENDENT_CODE ON) # Work around https://github.com/richgel999/miniz/pull/292 get_target_property(miniz_c_launcher miniz C_COMPILER_LAUNCHER) @@ -46,7 +65,16 @@ endif() # LZ4 if(NOT ${SLANG_USE_SYSTEM_LZ4}) set(LZ4_BUNDLED_MODE ON) - add_subdirectory(lz4/build/cmake EXCLUDE_FROM_ALL ${system}) + if(NOT SLANG_OVERRIDE_LZ4_PATH) + add_subdirectory(lz4/build/cmake EXCLUDE_FROM_ALL ${system}) + else() + add_subdirectory( + ${SLANG_OVERRIDE_LZ4_PATH}/build/cmake + lz4/build/cmake + EXCLUDE_FROM_ALL + ${system} + ) + endif() if(MSVC) target_compile_options( lz4_static @@ -57,7 +85,16 @@ endif() # Vulkan headers if(NOT ${SLANG_USE_SYSTEM_VULKAN_HEADERS}) - add_subdirectory(vulkan EXCLUDE_FROM_ALL ${system}) + if(NOT SLANG_OVERRIDE_VULKAN_HEADERS_PATH) + add_subdirectory(vulkan EXCLUDE_FROM_ALL ${system}) + else() + add_subdirectory( + ${SLANG_OVERRIDE_VULKAN_HEADERS_PATH} + vulkan + EXCLUDE_FROM_ALL + ${system} + ) + endif() endif() # metal-cpp headers @@ -69,22 +106,55 @@ target_include_directories( # SPIRV-Headers if(NOT ${SLANG_USE_SYSTEM_SPIRV_HEADERS}) - add_subdirectory(spirv-headers EXCLUDE_FROM_ALL ${system}) + if(NOT SLANG_OVERRIDE_SPIRV_HEADERS_PATH) + add_subdirectory(spirv-headers EXCLUDE_FROM_ALL ${system}) + else() + add_subdirectory( + ${SLANG_OVERRIDE_SPIRV_HEADERS_PATH} + spirv-headers + EXCLUDE_FROM_ALL + ${system} + ) + endif() endif() if(SLANG_ENABLE_SLANG_GLSLANG) # SPIRV-Tools set(SPIRV_TOOLS_BUILD_STATIC ON) set(SPIRV_WERROR OFF) - set(SPIRV_HEADER_DIR "${CMAKE_CURRENT_LIST_DIR}/spirv-headers/") + # Headers + if(NOT SLANG_OVERRIDE_SPIRV_HEADERS_PATH) + set(SPIRV_HEADER_DIR "${CMAKE_CURRENT_LIST_DIR}/spirv-headers/") + else() + set(SPIRV_HEADER_DIR ${SLANG_OVERRIDE_SPIRV_HEADERS_PATH}) + endif() set(SPIRV_SKIP_TESTS ON) - add_subdirectory(spirv-tools EXCLUDE_FROM_ALL ${system}) + # Tools + if(NOT SLANG_OVERRIDE_SPIRV_TOOLS_PATH) + add_subdirectory(spirv-tools EXCLUDE_FROM_ALL ${system}) + else() + add_subdirectory( + ${SLANG_OVERRIDE_SPIRV_TOOLS_PATH} + spirv-tools + EXCLUDE_FROM_ALL + ${system} + ) + endif() # glslang set(SKIP_GLSLANG_INSTALL ON) set(ENABLE_OPT ON) set(ENABLE_PCH OFF) - add_subdirectory(glslang EXCLUDE_FROM_ALL ${system}) + if(NOT SLANG_OVERRIDE_GLSLANG_PATH) + add_subdirectory(glslang EXCLUDE_FROM_ALL ${system}) + else() + add_subdirectory( + ${SLANG_OVERRIDE_GLSLANG_PATH} + glslang + EXCLUDE_FROM_ALL + ${system} + ) + endif() endif() # imgui diff --git a/source/core/slang-dictionary.h b/source/core/slang-dictionary.h index 79f6dee30..639978a08 100644 --- a/source/core/slang-dictionary.h +++ b/source/core/slang-dictionary.h @@ -1,7 +1,6 @@ #ifndef SLANG_CORE_DICTIONARY_H #define SLANG_CORE_DICTIONARY_H -#include "../../external/unordered_dense/include/ankerl/unordered_dense.h" #include "slang-common.h" #include "slang-exception.h" #include "slang-hash.h" @@ -10,6 +9,7 @@ #include "slang-math.h" #include "slang-uint-set.h" +#include <ankerl/unordered_dense.h> #include <initializer_list> namespace Slang diff --git a/source/core/slang-hash.h b/source/core/slang-hash.h index ebe3d1973..eee58878b 100644 --- a/source/core/slang-hash.h +++ b/source/core/slang-hash.h @@ -1,10 +1,10 @@ #ifndef SLANG_CORE_HASH_H #define SLANG_CORE_HASH_H -#include "../../external/unordered_dense/include/ankerl/unordered_dense.h" #include "slang-math.h" #include "slang.h" +#include <ankerl/unordered_dense.h> #include <cstring> #include <type_traits> diff --git a/source/slang/CMakeLists.txt b/source/slang/CMakeLists.txt index b9e78407b..9c51ed767 100644 --- a/source/slang/CMakeLists.txt +++ b/source/slang/CMakeLists.txt @@ -110,9 +110,15 @@ target_include_directories( # if(NOT SLANG_USE_SYSTEM_SPIRV_HEADERS) - set(SLANG_SPIRV_HEADERS_INCLUDE_DIR - "${slang_SOURCE_DIR}/external/spirv-headers/include" - ) + if(NOT SLANG_OVERRIDE_SPIRV_HEADERS_PATH) + set(SLANG_SPIRV_HEADERS_INCLUDE_DIR + "${slang_SOURCE_DIR}/external/spirv-headers/include" + ) + else() + set(SLANG_SPIRV_HEADERS_INCLUDE_DIR + "${SLANG_OVERRIDE_SPIRV_HEADERS_PATH}/include" + ) + endif() endif() set(SLANG_LOOKUP_GENERATOR_INPUT_JSON |
