diff --git a/modules/shader_compiler/CMakeLists.txt b/modules/shader_compiler/CMakeLists.txt index a00a896d500647b7ed38768f26235d36c8df6d29..4dc2c556ab096af3b4141a45b8be2bb1c1df2d50 100644 --- a/modules/shader_compiler/CMakeLists.txt +++ b/modules/shader_compiler/CMakeLists.txt @@ -53,6 +53,9 @@ include(config/GLSLANG.cmake) include(config/Murmur3.cmake) include(config/Shady.cmake) +# Check and load SLANG +include(config/SLANG.cmake) + # link the required libraries to the module target_link_libraries(vkcv_shader_compiler ${vkcv_shader_compiler_libraries} vkcv) diff --git a/modules/shader_compiler/config/SLANG.cmake b/modules/shader_compiler/config/SLANG.cmake new file mode 100644 index 0000000000000000000000000000000000000000..e9f5c26aeb3a9cc73417ebc6b883e2026d63b05f --- /dev/null +++ b/modules/shader_compiler/config/SLANG.cmake @@ -0,0 +1,9 @@ + +use_git_submodule("${vkcv_shader_compiler_lib_path}/slang" slang_status) + +if (${slang_status}) + add_subdirectory(config/slang) + + list(APPEND vkcv_shader_compiler_libraries slang) + list(APPEND vkcv_shader_compiler_includes ${vkcv_shader_compiler_lib}) +endif () diff --git a/modules/shader_compiler/config/slang/CMakeLists.txt b/modules/shader_compiler/config/slang/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..9c1a50bcf5816e502c1077123ebbb32a45bf90c0 --- /dev/null +++ b/modules/shader_compiler/config/slang/CMakeLists.txt @@ -0,0 +1,45 @@ +cmake_minimum_required(VERSION 3.9) + +project(slang) + +# settings c++ standard for slang +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +find_package(Vulkan REQUIRED) + +set(slang_base external/source/base) + +set(slang_dir ../../${vkcv_shader_compiler_lib}/slang) + +set(slang_source ${slang_dir}/source) +set(slang_source_compiler_core ${slang_source}/compiler-core) +set(slang_source_core ${slang_source}/core) +set(slang_source_slang ${slang_source}/slang) + +file(GLOB slang_sources + ${slang_source_compiler_core}/*.cpp + ${slang_source_core}/*.cpp + ${slang_source_slang}/*.cpp +) + +if (${VMA_STATIC_VULKAN_FUNCTIONS}) + add_library(slang STATIC ${slang_sources}) +else() + add_library(slang SHARED ${slang_sources}) +endif() + +set_target_properties( + slang PROPERTIES + + CXX_EXTENSIONS OFF + CXX_STANDARD ${CMAKE_CXX_STANDARD} + CXX_STANDARD_REQUIRED ON +) + +target_include_directories(slang PUBLIC ${slang_base} ${slang_source}) + +# Only link to Vulkan if static linking is used +if (NOT ${VMA_DYNAMIC_VULKAN_FUNCTIONS}) + target_link_libraries(slang PUBLIC Vulkan::Vulkan) +endif()