mirror of
https://github.com/microsoft/DirectXTex
synced 2024-11-09 14:30:05 +00:00
CMake updated to support building for Xbox (#320)
This commit is contained in:
parent
1cef43a2bf
commit
0a4e51a5fd
@ -59,6 +59,8 @@ endif()
|
||||
if(DEFINED XBOX_CONSOLE_TARGET)
|
||||
set(BUILD_DX11 OFF)
|
||||
set(BUILD_DX12 ON)
|
||||
set(BUILD_TOOLS OFF)
|
||||
set(BUILD_SAMPLE OFF)
|
||||
endif()
|
||||
|
||||
include(GNUInstallDirs)
|
||||
@ -187,7 +189,32 @@ endif()
|
||||
if(directx-headers_FOUND)
|
||||
message(STATUS "Using DirectX-Headers package")
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC Microsoft::DirectX-Headers)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE USING_DIRECTX_HEADERS)
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC USING_DIRECTX_HEADERS)
|
||||
endif()
|
||||
|
||||
include(CheckIncludeFileCXX)
|
||||
|
||||
if(DEFINED XBOX_CONSOLE_TARGET)
|
||||
message(STATUS "Building for Xbox Console Target: ${XBOX_CONSOLE_TARGET}")
|
||||
set(CMAKE_REQUIRED_QUIET ON)
|
||||
CHECK_INCLUDE_FILE_CXX(gxdk.h GXDK_HEADER)
|
||||
if(NOT GXDK_HEADER)
|
||||
message(FATAL_ERROR "Microsoft GDK with Xbox Extensions required to build for Xbox. See https://aka.ms/gdkx")
|
||||
endif()
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC WINAPI_FAMILY=WINAPI_FAMILY_GAMES)
|
||||
if(XBOX_CONSOLE_TARGET STREQUAL "scarlett")
|
||||
CHECK_INCLUDE_FILE_CXX(d3d12_xs.h D3D12XS_HEADER)
|
||||
if(NOT D3D12XS_HEADER)
|
||||
message(FATAL_ERROR "Microsoft GDK with Xbox Extensions environment needs to be set for Xbox Series X|S.")
|
||||
endif()
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC _GAMING_XBOX _GAMING_XBOX_SCARLETT)
|
||||
elseif(XBOX_CONSOLE_TARGET STREQUAL "xboxone")
|
||||
CHECK_INCLUDE_FILE_CXX(d3d12_x.h D3D12X_HEADER)
|
||||
if(NOT D3D12X_HEADER)
|
||||
message(FATAL_ERROR "Microsoft GDK with Xbox Extensions environment needs to be set for Xbox One.")
|
||||
endif()
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC _GAMING_XBOX _GAMING_XBOX_XBOXONE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#--- Package
|
||||
@ -336,7 +363,11 @@ else()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(NOT (${DIRECTX_ARCH} MATCHES "^arm"))
|
||||
if(XBOX_CONSOLE_TARGET STREQUAL "scarlett")
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE $<IF:$<CXX_COMPILER_ID:MSVC>,/favor:AMD64 /arch:AVX2,-march=znver2>)
|
||||
elseif(XBOX_CONSOLE_TARGET STREQUAL "xboxone")
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE $<IF:$<CXX_COMPILER_ID:MSVC>,/favor:AMD64 /arch:AVX,-march=btver2)
|
||||
elseif(NOT (${DIRECTX_ARCH} MATCHES "^arm"))
|
||||
if(${CMAKE_SIZEOF_VOID_P} EQUAL "4")
|
||||
set(ARCH_SSE2 $<$<CXX_COMPILER_ID:MSVC>:/arch:SSE2> $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-msse2>)
|
||||
else()
|
||||
@ -374,6 +405,13 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(CMAKE_INTERPROCEDURAL_OPTIMIZATION)
|
||||
message(STATUS "Building using Whole Program Optimization")
|
||||
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
||||
target_compile_options(${t} PRIVATE /Gy /Gw)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.24)
|
||||
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
||||
target_compile_options(${t} PRIVATE /ZH:SHA_256)
|
||||
@ -398,6 +436,12 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.35)
|
||||
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
||||
target_compile_options(${t} PRIVATE /Zc:templateScope /Zc:checkGwOdr)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(BC_USE_OPENMP)
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE /openmp /Zc:twoPhase-)
|
||||
if(BUILD_TOOLS AND BUILD_DX11 AND WIN32 AND (NOT WINDOWS_STORE))
|
||||
|
@ -55,7 +55,11 @@
|
||||
},
|
||||
{
|
||||
"name": "Release",
|
||||
"cacheVariables": { "CMAKE_BUILD_TYPE": "RelWithDebInfo" },
|
||||
"cacheVariables":
|
||||
{
|
||||
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
|
||||
"CMAKE_INTERPROCEDURAL_OPTIMIZATION": true
|
||||
},
|
||||
"hidden": true
|
||||
},
|
||||
|
||||
@ -109,6 +113,22 @@
|
||||
},
|
||||
"hidden": true
|
||||
},
|
||||
{
|
||||
"name": "Scarlett",
|
||||
"cacheVariables": {
|
||||
"XBOX_CONSOLE_TARGET": "scarlett",
|
||||
"BUILD_TESTING": false
|
||||
},
|
||||
"hidden": true
|
||||
},
|
||||
{
|
||||
"name": "XboxOne",
|
||||
"cacheVariables": {
|
||||
"XBOX_CONSOLE_TARGET": "xboxone",
|
||||
"BUILD_TESTING": false
|
||||
},
|
||||
"hidden": true
|
||||
},
|
||||
{
|
||||
"name": "VCPKG",
|
||||
"cacheVariables": {
|
||||
@ -170,6 +190,12 @@
|
||||
{ "name": "x86-Debug-Win7" , "description": "MSVC for x86 (Debug) for Windows 7", "inherits": [ "base", "x86", "Debug", "MSVC", "Win7" ] },
|
||||
{ "name": "x86-Release-Win7" , "description": "MSVC for x86 (Release) for Windows 7", "inherits": [ "base", "x86", "Release", "MSVC", "Win7" ] },
|
||||
|
||||
{ "name": "x64-Debug-Scarlett" , "description": "MSVC for x64 (Debug) for Xbox Series X|S", "inherits": [ "base", "x64", "Debug", "MSVC", "Scarlett" ] },
|
||||
{ "name": "x64-Release-Scarlett" , "description": "MSVC for x64 (Release) for Xbox Series X|S", "inherits": [ "base", "x64", "Release", "MSVC", "Scarlett" ] },
|
||||
|
||||
{ "name": "x64-Debug-XboxOne" , "description": "MSVC for x64 (Debug) for Xbox One", "inherits": [ "base", "x64", "Debug", "MSVC", "XboxOne" ] },
|
||||
{ "name": "x64-Release-XboxOne" , "description": "MSVC for x64 (Release) for Xbox One", "inherits": [ "base", "x64", "Release", "MSVC", "XboxOne" ] },
|
||||
|
||||
{ "name": "x64-Debug-VCPKG" , "description": "MSVC for x64 (Debug) using VCPKG", "inherits": [ "base", "x64", "Debug", "MSVC", "VCPKG" ] },
|
||||
{ "name": "x64-Release-VCPKG" , "description": "MSVC for x64 (Release) using VCPKG", "inherits": [ "base", "x64", "Release", "MSVC", "VCPKG" ] },
|
||||
{ "name": "x86-Debug-VCPKG" , "description": "MSVC for x86 (Debug) using VCPKG", "inherits": [ "base", "x86", "Debug", "MSVC", "VCPKG" ] },
|
||||
|
@ -5,13 +5,15 @@ rem Licensed under the MIT License.
|
||||
setlocal
|
||||
set error=0
|
||||
|
||||
if %PROCESSOR_ARCHITECTURE%.==ARM64. (set FXCARCH=arm64) else (if %PROCESSOR_ARCHITECTURE%.==AMD64. (set FXCARCH=x64) else (set FXCARCH=x86))
|
||||
|
||||
set FXCOPTS=/nologo /WX /Ges /Zi /Zpc /Qstrip_reflect /Qstrip_debug
|
||||
|
||||
set PCFXC="%WindowsSdkVerBinPath%x86\fxc.exe"
|
||||
set PCFXC="%WindowsSdkVerBinPath%%FXCARCH%\fxc.exe"
|
||||
if exist %PCFXC% goto continue
|
||||
set PCFXC="%WindowsSdkBinPath%%WindowsSDKVersion%\x86\fxc.exe"
|
||||
set PCFXC="%WindowsSdkBinPath%%WindowsSDKVersion%\%FXCARCH%\fxc.exe"
|
||||
if exist %PCFXC% goto continue
|
||||
set PCFXC="%WindowsSdkDir%bin\%WindowsSDKVersion%\x86\fxc.exe"
|
||||
set PCFXC="%WindowsSdkDir%bin\%WindowsSDKVersion%\%FXCARCH%\fxc.exe"
|
||||
if exist %PCFXC% goto continue
|
||||
|
||||
set PCFXC=fxc.exe
|
||||
|
Loading…
Reference in New Issue
Block a user