Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix up CMake for Xbox platforms for shared lib #587

Merged
merged 3 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ project (DirectXTex
HOMEPAGE_URL "https://go.microsoft.com/fwlink/?LinkId=248926"
LANGUAGES CXX)

if(DEFINED XBOX_CONSOLE_TARGET)
set(CMAKE_CXX_STANDARD_LIBRARIES "")
endif()

option(BUILD_TOOLS "Build tex command-line tools" ON)

option(BUILD_SHARED_LIBS "Build DirectXTex as a shared library" OFF)
Expand Down Expand Up @@ -233,6 +237,14 @@ if(WIN32 AND BUILD_SHARED_LIBS)

target_compile_definitions(${PROJECT_NAME} PRIVATE DIRECTX_TEX_EXPORT)
target_compile_definitions(${PROJECT_NAME} INTERFACE DIRECTX_TEX_IMPORT)

if(XBOX_CONSOLE_TARGET MATCHES "scarlett")
target_link_libraries(${PROJECT_NAME} PRIVATE xgameplatform.lib xg_xs.lib xmem.lib)
elseif(XBOX_CONSOLE_TARGET MATCHES "xboxone")
target_link_libraries(${PROJECT_NAME} PRIVATE xgameplatform.lib xg_x.lib xmem.lib)
elseif(XBOX_CONSOLE_TARGET MATCHES "durango")
target_link_libraries(${PROJECT_NAME} PRIVATE kernelx.lib xg_x.lib combase.lib)
endif()
else()
add_library(${PROJECT_NAME} ${LIBRARY_SOURCES} ${LIBRARY_HEADERS})
endif()
Expand Down
2 changes: 2 additions & 0 deletions build/CompilerAndLinker.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,14 @@ if(DEFINED XBOX_CONSOLE_TARGET)
message(FATAL_ERROR "Legacy Xbox One XDK required to build for Durango.")
endif()
list(APPEND COMPILER_DEFINES WINAPI_FAMILY=WINAPI_FAMILY_TV_TITLE _XBOX_ONE _TITLE MONOLITHIC=1)
list(APPEND LINKER_SWITCHES /NODEFAULTLIB:kernel32.lib /NODEFAULTLIB:ole32.lib /NODEFAULTLIB:oldnames.lib)
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()
list(APPEND COMPILER_DEFINES WINAPI_FAMILY=WINAPI_FAMILY_GAMES)
list(APPEND LINKER_SWITCHES /NODEFAULTLIB:kernel32.lib /NODEFAULTLIB:oldnames.lib)
if(XBOX_CONSOLE_TARGET STREQUAL "scarlett")
CHECK_INCLUDE_FILE_CXX(d3d12_xs.h D3D12XS_HEADER)
if(NOT D3D12XS_HEADER)
Expand Down
26 changes: 26 additions & 0 deletions build/DirectXTex-GitHub-GDK-Dev17.yml
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,19 @@ jobs:
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out\build\x64-Release-Scarlett-Clang
- task: DeleteFiles@1
inputs:
Contents: 'out/build'
- task: CMake@1
displayName: 'CMake (MSVC, DLL): Config Scarlett Debug'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --preset=x64-Debug-Scarlett -DBUILD_SHARED_LIBS=ON
- task: CMake@1
displayName: 'CMake (MSVC, DLL): Build Scarlett Debug'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out\build\x64-Debug-Scarlett

- job: BUILD_GDK_CMAKE_XBONE
displayName: 'Microsoft Game Development Kit (GDK) using CMake (XboxOne)'
Expand Down Expand Up @@ -413,3 +426,16 @@ jobs:
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out\build\x64-Release-XboxOne-Clang
- task: DeleteFiles@1
inputs:
Contents: 'out/build'
- task: CMake@1
displayName: 'CMake (MSVC, DLL): Config XboxOne Debug'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --preset=x64-Debug-XboxOne -DBUILD_SHARED_LIBS=ON
- task: CMake@1
displayName: 'CMake (MSVC, DLL): Build XboxOne Debug'
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: --build out\build\x64-Debug-XboxOne
2 changes: 1 addition & 1 deletion build/DirectXTex.rc.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <winres.h>
#include <winver.h>

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,0
Expand Down
Loading