mirror of
https://github.com/microsoft/DirectXTex
synced 2024-11-21 12:00:06 +00:00
CMake support for building legacy Xbox One XDK lib (#342)
This commit is contained in:
parent
9175ac8204
commit
12befe5e16
@ -5,6 +5,10 @@ cmake_minimum_required (VERSION 3.20)
|
||||
|
||||
set(DIRECTXTEX_VERSION 1.9.8)
|
||||
|
||||
if(DEFINED XBOX_CONSOLE_TARGET)
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
|
||||
endif()
|
||||
|
||||
project (DirectXTex
|
||||
VERSION ${DIRECTXTEX_VERSION}
|
||||
DESCRIPTION "DirectX Texture Library"
|
||||
@ -209,24 +213,36 @@ 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.")
|
||||
if(XBOX_CONSOLE_TARGET STREQUAL "durango")
|
||||
CHECK_INCLUDE_FILE_CXX(xdk.h XDKLegacy_HEADER)
|
||||
if(NOT XDKLegacy_HEADER)
|
||||
message(FATAL_ERROR "Legacy Xbox One XDK required to build for Durango.")
|
||||
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.")
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC WINAPI_FAMILY=WINAPI_FAMILY_TV_TITLE _XBOX_ONE _TITLE MONOLITHIC=1)
|
||||
else()
|
||||
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)
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown XBOX_CONSOLE_TARGET")
|
||||
endif()
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC _GAMING_XBOX _GAMING_XBOX_XBOXONE)
|
||||
endif()
|
||||
elseif(WINDOWS_STORE)
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC WINAPI_FAMILY=WINAPI_FAMILY_APP)
|
||||
endif()
|
||||
|
||||
#--- Package
|
||||
@ -381,7 +397,7 @@ endif()
|
||||
|
||||
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")
|
||||
elseif(XBOX_CONSOLE_TARGET MATCHES "(xboxone|durango)")
|
||||
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)
|
||||
@ -397,6 +413,9 @@ endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
set(WarningsLib -Wall -Wpedantic -Wextra)
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0)
|
||||
list(APPEND WarningsLib "-Wno-unsafe-buffer-usage")
|
||||
endif()
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE ${WarningsLib})
|
||||
|
||||
set(WarningsEXE ${WarningsLib} "-Wno-c++98-compat" "-Wno-c++98-compat-pedantic" "-Wno-switch" "-Wno-switch-enum" "-Wno-covered-switch-default" "-Wno-language-extension-token" "-Wno-missing-prototypes" "-Wno-global-constructors" "-Wno-double-promotion")
|
||||
@ -474,11 +493,9 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
if(WINDOWS_STORE)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE WINAPI_FAMILY=WINAPI_FAMILY_APP)
|
||||
endif()
|
||||
|
||||
if(BUILD_DX12 OR (${DIRECTX_ARCH} MATCHES "^arm64"))
|
||||
if (XBOX_CONSOLE_TARGET STREQUAL "durango")
|
||||
set(WINVER 0x0602)
|
||||
elseif(BUILD_DX12 OR (${DIRECTX_ARCH} MATCHES "^arm64"))
|
||||
message(STATUS "Building with DirectX 12 Runtime support")
|
||||
set(WINVER 0x0A00)
|
||||
elseif(${DIRECTX_ARCH} MATCHES "^arm")
|
||||
|
@ -129,6 +129,14 @@
|
||||
},
|
||||
"hidden": true
|
||||
},
|
||||
{
|
||||
"name": "Durango",
|
||||
"cacheVariables": {
|
||||
"XBOX_CONSOLE_TARGET": "durango",
|
||||
"BUILD_TESTING": false
|
||||
},
|
||||
"hidden": true
|
||||
},
|
||||
{
|
||||
"name": "VCPKG",
|
||||
"cacheVariables": {
|
||||
@ -196,6 +204,9 @@
|
||||
{ "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-Durango" , "description": "MSVC for x64 (Debug) for legacy Xbox One XDK", "inherits": [ "base", "x64", "Debug", "MSVC", "Durango" ] },
|
||||
{ "name": "x64-Release-Durango" , "description": "MSVC for x64 (Release) for legacy Xbox One XDK", "inherits": [ "base", "x64", "Release", "MSVC", "Durango" ] },
|
||||
|
||||
{ "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" ] },
|
||||
|
@ -12,6 +12,13 @@
|
||||
|
||||
#if defined( __cplusplus )
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wfloat-equal"
|
||||
#pragma clang diagnostic ignored "-Wunknown-warning-option"
|
||||
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
|
||||
#endif
|
||||
|
||||
struct CD3DX12_DEFAULT {};
|
||||
extern const DECLSPEC_SELECTANY CD3DX12_DEFAULT D3D12_DEFAULT;
|
||||
|
||||
@ -6457,6 +6464,10 @@ inline HRESULT CD3DX12FeatureSupport::QueryProtectedResourceSessionTypes(UINT No
|
||||
#undef D3DX12_COM_PTR_GET
|
||||
#undef D3DX12_COM_PTR_ADDRESSOF
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif // defined( __cplusplus )
|
||||
|
||||
#endif //__D3DX12_H__
|
||||
|
@ -126,3 +126,5 @@ This project may contain trademarks or logos for projects, products, or services
|
||||
The DirectXTex library is the work of Chuck Walbourn, with contributions from Matt Lee, Xin Huang, Craig Peeper, and the numerous other Microsoft engineers who developed the D3DX utility library over the years.
|
||||
|
||||
Thanks to Paul Penson for his help with the implementation of ``MemoryStreamOnBlob``.
|
||||
|
||||
Thanks to Andrew Farrier and Scott Matloff for their on-going help with code reviews.
|
Loading…
Reference in New Issue
Block a user