@@ -73,27 +73,52 @@ endif()
7373
7474# Set paths to D3Dcompiler_47.dll, dxcompiler.dll, and dxil.dll
7575if (MSVC )
76- if (${CMAKE_SIZEOF_VOID_P} EQUAL 8)
77- set (ARCH_SUFFIX "x64" )
78- else ()
79- set (ARCH_SUFFIX "x86" )
80- endif ()
81-
82- # Note that CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION is stated to be defined when targeting Windows 10
83- # and above, however it is also defined when targeting 8.1 and Visual Studio 2019 (but not VS2017)
8476 if ("${WINDOWS_SDK_VERSION} " VERSION_GREATER_EQUAL "10.0" AND WINDOWS_SDK_BIN_DIR)
85- set (VS_D3D_COMPILER_PATH " \" ${WINDOWS_SDK_BIN_DIR} \\ D3Dcompiler_47.dll\" " CACHE INTERNAL "D3Dcompiler_47.dll path " )
77+ set (D3D_COMPILER_PATH " ${WINDOWS_SDK_BIN_DIR} / D3Dcompiler_47.dll" )
8678
8779 # DXC is only present in Windows SDK starting with version 10.0.17763.0
8880 if ("${WINDOWS_SDK_VERSION} " VERSION_GREATER_EQUAL "10.0.17763.0" )
89- set (VS_DXC_COMPILER_PATH " \" ${WINDOWS_SDK_BIN_DIR} \\ dxcompiler.dll\" " CACHE INTERNAL "dxcompiler.dll path " )
90- set (VS_DXIL_SIGNER_PATH "\" ${WINDOWS_SDK_BIN_DIR} \\ dxil.dll\" " CACHE INTERNAL "dxil.dll path " )
81+ set (DXC_COMPILER_PATH " ${WINDOWS_SDK_BIN_DIR} / dxcompiler.dll" )
82+ set (DXIL_SIGNER_PATH "${WINDOWS_SDK_BIN_DIR} / dxil.dll" )
9183 endif ()
9284 elseif ("${WINDOWS_SDK_VERSION} " VERSION_EQUAL "8.1" )
9385 # D3Dcompiler_47.dll from Win8.1 SDK is ancient (from 2013) and fails to
9486 # compile a number of test shaders. Use the compiler from Visual Studio
9587 # executable path instead
96- set (VS_D3D_COMPILER_PATH "\" $(VC_ExecutablePath_x64_${ARCH_SUFFIX} )\\ D3Dcompiler_47.dll\" " CACHE INTERNAL "D3Dcompiler_47.dll path" )
88+ if (CMAKE_AR AND IS_ABSOLUTE "${CMAKE_AR} " )
89+ get_filename_component (CMAKE_AR_DIR "${CMAKE_AR} " DIRECTORY )
90+ set (D3D_COMPILER_PATH "${CMAKE_AR_DIR} /D3Dcompiler_47.dll" )
91+ endif ()
92+ endif ()
93+
94+ if (D3D_COMPILER_PATH)
95+ if (EXISTS "${D3D_COMPILER_PATH} " )
96+ message (STATUS "Found D3Dcompiler_47.dll: ${D3D_COMPILER_PATH} " )
97+ set (D3D_COMPILER_PATH "${D3D_COMPILER_PATH} " CACHE INTERNAL "D3Dcompiler_47.dll path" )
98+ else ()
99+ message (WARNING "Cannot find D3Dcompiler_47.dll. File does not exist: ${D3D_COMPILER_PATH} " )
100+ unset (D3D_COMPILER_PATH CACHE )
101+ endif ()
102+ endif ()
103+
104+ if (DXC_COMPILER_PATH)
105+ if (EXISTS "${DXC_COMPILER_PATH} " )
106+ message (STATUS "Found dxcompiler.dll: ${DXC_COMPILER_PATH} " )
107+ set (DXC_COMPILER_PATH "${DXC_COMPILER_PATH} " CACHE INTERNAL "dxcompiler.dll path" )
108+ else ()
109+ message (WARNING "Cannot find dxcompiler.dll. File does not exist: ${DXC_COMPILER_PATH} " )
110+ unset (DXC_COMPILER_PATH CACHE )
111+ endif ()
112+ endif ()
113+
114+ if (DXIL_SIGNER_PATH)
115+ if (EXISTS "${DXIL_SIGNER_PATH} " )
116+ message (STATUS "Found dxil.dll: ${DXIL_SIGNER_PATH} " )
117+ set (DXIL_SIGNER_PATH "${DXIL_SIGNER_PATH} " CACHE INTERNAL "dxil.dll path" )
118+ else ()
119+ message (WARNING "Cannot find dxil.dll. File does not exist: ${DXIL_SIGNER_PATH} " )
120+ unset (DXIL_SIGNER_PATH CACHE )
121+ endif ()
97122 endif ()
98123endif ()
99124
0 commit comments