diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e87bb07..8a59bfe5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,6 +61,7 @@ elseif(WINDOWS_STORE) endif() include(GNUInstallDirs) +include(build/CompilerAndLinker.cmake) #--- Library set(LIBRARY_HEADERS @@ -224,12 +225,19 @@ else() endif() if(NOT USE_PREBUILT_SHADERS) + if(BUILD_XBOXONE_SHADERS) + else() + find_program(DIRECTX_FXC_TOOL FXC.EXE + HINTS "C:/Program Files (x86)/Windows Kits/10/bin/${CMAKE_SYSTEM_VERSION}/${DIRECTX_HOST_ARCH}" + "C:/Program Files (x86)/Windows Kits/10/bin/${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}/${DIRECTX_HOST_ARCH}") + message(STATUS "Using LegacyShaderCompiler found in ${DIRECTX_FXC_TOOL}") + endif() add_custom_command( OUTPUT "${COMPILED_SHADERS}/SpriteEffect_SpriteVertexShader.inc" MAIN_DEPENDENCY "${PROJECT_SOURCE_DIR}/Src/Shaders/CompileShaders.cmd" DEPENDS ${SHADER_SOURCES} COMMENT "Generating HLSL shaders..." - COMMAND ${CMAKE_COMMAND} -E env CompileShadersOutput="${COMPILED_SHADERS}" CompileShaders.cmd ARGS ${ShaderOpts} > "${COMPILED_SHADERS}/compileshaders.log" + COMMAND ${CMAKE_COMMAND} -E env CompileShadersOutput="${COMPILED_SHADERS}" $<$:LegacyShaderCompiler=${DIRECTX_FXC_TOOL}> CompileShaders.cmd ARGS ${ShaderOpts} > "${COMPILED_SHADERS}/compileshaders.log" WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/Src/Shaders" USES_TERMINAL) endif() @@ -387,8 +395,6 @@ if(MSVC) endif() endif() -include(build/CompilerAndLinker.cmake) - foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME}) target_compile_definitions(${t} PRIVATE ${COMPILER_DEFINES}) target_compile_options(${t} PRIVATE ${COMPILER_SWITCHES}) diff --git a/Src/Shaders/CompileShaders.cmd b/Src/Shaders/CompileShaders.cmd index 642890f9..8ee18443 100644 --- a/Src/Shaders/CompileShaders.cmd +++ b/Src/Shaders/CompileShaders.cmd @@ -32,6 +32,7 @@ goto continue :continuepc +if defined LegacyShaderCompiler goto fxcviaenv set PCFXC="%WindowsSdkVerBinPath%%FXCARCH%\fxc.exe" if exist %PCFXC% goto continue set PCFXC="%WindowsSdkBinPath%%WindowsSDKVersion%\%FXCARCH%\fxc.exe" @@ -40,6 +41,12 @@ set PCFXC="%WindowsSdkDir%bin\%WindowsSDKVersion%\%FXCARCH%\fxc.exe" if exist %PCFXC% goto continue set PCFXC=fxc.exe +goto continue + +:fxcviaenv +set PCFXC="%LegacyShaderCompiler%" +if not exist %PCFXC% goto needfxc +goto continue :continue if not defined CompileShadersOutput set CompileShadersOutput=Compiled @@ -329,6 +336,11 @@ echo %fxc% %fxc% || set error=1 exit /b +:needfxc +echo ERROR: CompileShaders requires FXC.EXE +exit /b 1 + :needxdk echo ERROR: CompileShaders xbox requires the Microsoft Xbox One XDK echo (try re-running from the XDK Command Prompt) +exit /b 1 diff --git a/build/CompilerAndLinker.cmake b/build/CompilerAndLinker.cmake index 1826feb8..6fb54475 100644 --- a/build/CompilerAndLinker.cmake +++ b/build/CompilerAndLinker.cmake @@ -32,6 +32,13 @@ elseif(CMAKE_VS_PLATFORM_NAME_DEFAULT MATCHES "^[Aa][Rr][Mm]64EC$") set(DIRECTX_ARCH arm64ec) endif() +#--- Determines host architecture +if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "[Aa][Rr][Mm]64|aarch64|arm64") + set(DIRECTX_HOST_ARCH arm64) +else() + set(DIRECTX_HOST_ARCH x64) +endif() + #--- Build with Unicode Win32 APIs per "UTF-8 Everywhere" if(WIN32) list(APPEND COMPILER_DEFINES _UNICODE UNICODE) diff --git a/build/DirectXTK-GitHub-Dev17.yml b/build/DirectXTK-GitHub-Dev17.yml index bd979906..677def66 100644 --- a/build/DirectXTK-GitHub-Dev17.yml +++ b/build/DirectXTK-GitHub-Dev17.yml @@ -21,6 +21,7 @@ pr: paths: include: - build/DirectXTK-GitHub-Dev17.yml + - Src/Shaders/CompileShaders.cmd resources: repositories: diff --git a/build/DirectXTK-GitHub-GDK-Dev17.yml b/build/DirectXTK-GitHub-GDK-Dev17.yml index 8c2205de..682a2c47 100644 --- a/build/DirectXTK-GitHub-GDK-Dev17.yml +++ b/build/DirectXTK-GitHub-GDK-Dev17.yml @@ -25,6 +25,7 @@ pr: - build/*.in - build/*.cmake - build/SetupBWOI.* + - Src/Shaders/CompileShaders.cmd resources: repositories: diff --git a/build/DirectXTK-GitHub.yml b/build/DirectXTK-GitHub.yml index 96d387f4..6ca2e5b5 100644 --- a/build/DirectXTK-GitHub.yml +++ b/build/DirectXTK-GitHub.yml @@ -21,6 +21,7 @@ pr: paths: include: - build/DirectXTK-GitHub.yml + - Src/Shaders/CompileShaders.cmd resources: repositories: