17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-18 00:59:18 +02:00
Files
maszyna/betterRenderer/mashadercompiler/CMakeLists.txt
maj00r fcbf034a91 spell the delay-load flag for the driver in use
clang's GNU driver read /DELAYLOAD:dxcompiler.dll as a file name. CMake's
LINKER: prefix emits -Xlinker for it and passes it bare under MSVC.

The other raw linker flags in the tree sit inside if(MSVC), which is
false for this driver, so they never reach the command line.
2026-09-10 14:08:48 +02:00

35 lines
1.3 KiB
CMake

cmake_minimum_required(VERSION 3.24)
set(CMAKE_CXX_STANDARD 17)
project(MaSzynaShaderCompiler)
file(GLOB_RECURSE src "src/*.cpp" "src/*.hpp")
# Confirmed to work with DXC distributed via VCPKG. Your mileage may vary
# TODO Make sure that it works as well for people who do not use VCPKG
find_package(directx-dxc CONFIG REQUIRED)
add_executable(MaSzynaShaderCompiler ${src})
target_link_libraries(MaSzynaShaderCompiler nvrhi yaml-cpp Microsoft::DirectXShaderCompiler Microsoft::DXIL)
if (WIN32)
target_link_libraries(MaSzynaShaderCompiler delayimp)
# LINKER: lets CMake spell this for whichever driver is in use - passed
# straight through, clang's GNU driver reads /DELAYLOAD as a file name.
target_link_options(MaSzynaShaderCompiler PRIVATE "LINKER:/DELAYLOAD:dxcompiler.dll")
endif ()
# We later pass the DXIL.dll parent directory as first argument to MaSzynaShaderCompiler so that it can sign DX12 shaders
get_target_property(dxil_dll_path Microsoft::DXIL IMPORTED_LOCATION_RELEASE)
if(NOT dxil_dll_path)
get_target_property(dxil_dll_path Microsoft::DXIL IMPORTED_LOCATION_DEBUG)
endif()
if(NOT dxil_dll_path)
message(FATAL_ERROR "DXIL.dll not found")
endif()
get_filename_component(dxil_dll_path ${dxil_dll_path} DIRECTORY)
set_target_properties(MaSzynaShaderCompiler PROPERTIES dxil_path "${dxil_dll_path}")