Skip to content

Commit b7c497a

Browse files
authored
Fix up CMake for Xbox platforms for shared lib (#206)
1 parent 1948e94 commit b7c497a

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ project(DirectXMesh
1515
HOMEPAGE_URL "https://go.microsoft.com/fwlink/?LinkID=324981"
1616
LANGUAGES CXX)
1717

18+
if(DEFINED XBOX_CONSOLE_TARGET)
19+
set(CMAKE_CXX_STANDARD_LIBRARIES "")
20+
endif()
21+
1822
option(BUILD_TOOLS "Build meshconvert" ON)
1923

2024
option(BUILD_SHARED_LIBS "Build DirectXMesh as a shared library" OFF)
@@ -83,6 +87,10 @@ if(WIN32 AND BUILD_SHARED_LIBS)
8387

8488
target_compile_definitions(${PROJECT_NAME} PRIVATE DIRECTX_MESH_EXPORT)
8589
target_compile_definitions(${PROJECT_NAME} INTERFACE DIRECTX_MESH_IMPORT)
90+
91+
if(XBOX_CONSOLE_TARGET MATCHES "scarlett|xboxone")
92+
target_link_libraries(${PROJECT_NAME} PRIVATE xgameplatform.lib)
93+
endif()
8694
else()
8795
add_library(${PROJECT_NAME} ${LIBRARY_SOURCES} ${LIBRARY_HEADERS})
8896
endif()

build/CompilerAndLinker.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,14 @@ if(DEFINED XBOX_CONSOLE_TARGET)
203203
message(FATAL_ERROR "Legacy Xbox One XDK required to build for Durango.")
204204
endif()
205205
list(APPEND COMPILER_DEFINES WINAPI_FAMILY=WINAPI_FAMILY_TV_TITLE _XBOX_ONE _TITLE MONOLITHIC=1)
206+
list(APPEND LINKER_SWITCHES /NODEFAULTLIB:kernel32.lib /NODEFAULTLIB:ole32.lib /NODEFAULTLIB:oldnames.lib)
206207
else()
207208
CHECK_INCLUDE_FILE_CXX(gxdk.h GXDK_HEADER)
208209
if(NOT GXDK_HEADER)
209210
message(FATAL_ERROR "Microsoft GDK with Xbox Extensions required to build for Xbox. See https://aka.ms/gdkx")
210211
endif()
211212
list(APPEND COMPILER_DEFINES WINAPI_FAMILY=WINAPI_FAMILY_GAMES)
213+
list(APPEND LINKER_SWITCHES /NODEFAULTLIB:kernel32.lib /NODEFAULTLIB:oldnames.lib)
212214
if(XBOX_CONSOLE_TARGET STREQUAL "scarlett")
213215
CHECK_INCLUDE_FILE_CXX(d3d12_xs.h D3D12XS_HEADER)
214216
if(NOT D3D12XS_HEADER)

build/DirectXMesh-GitHub-GDK-Dev17.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,19 @@ jobs:
265265
inputs:
266266
cwd: '$(Build.SourcesDirectory)'
267267
cmakeArgs: --build out\build\x64-Release-Scarlett-Clang
268+
- task: DeleteFiles@1
269+
inputs:
270+
Contents: 'out/build'
271+
- task: CMake@1
272+
displayName: 'CMake (MSVC, DLL): Config Scarlett Debug'
273+
inputs:
274+
cwd: '$(Build.SourcesDirectory)'
275+
cmakeArgs: --preset=x64-Debug-Scarlett -DBUILD_SHARED_LIBS=ON
276+
- task: CMake@1
277+
displayName: 'CMake (MSVC, DLL): Build Scarlett Debug'
278+
inputs:
279+
cwd: '$(Build.SourcesDirectory)'
280+
cmakeArgs: --build out\build\x64-Debug-Scarlett
268281

269282
- job: BUILD_GDK_CMAKE_XBONE
270283
displayName: 'Microsoft Game Development Kit (GDK) using CMake (XboxOne)'
@@ -371,3 +384,16 @@ jobs:
371384
inputs:
372385
cwd: '$(Build.SourcesDirectory)'
373386
cmakeArgs: --build out\build\x64-Release-XboxOne-Clang
387+
- task: DeleteFiles@1
388+
inputs:
389+
Contents: 'out/build'
390+
- task: CMake@1
391+
displayName: 'CMake (MSVC, DLL): Config XboxOne Debug'
392+
inputs:
393+
cwd: '$(Build.SourcesDirectory)'
394+
cmakeArgs: --preset=x64-Debug-XboxOne -DBUILD_SHARED_LIBS=ON
395+
- task: CMake@1
396+
displayName: 'CMake (MSVC, DLL): Build XboxOne Debug'
397+
inputs:
398+
cwd: '$(Build.SourcesDirectory)'
399+
cmakeArgs: --build out\build\x64-Debug-XboxOne

build/DirectXMesh.rc.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include <winres.h>
1+
#include <winver.h>
22

33
VS_VERSION_INFO VERSIONINFO
44
FILEVERSION 1,0,0,0

0 commit comments

Comments
 (0)