Skip to content

Commit

Permalink
[directx12-agility] New port for using Microsoft.Direct3D.D3D12 (#37398)
Browse files Browse the repository at this point in the history
  • Loading branch information
walbourn authored Mar 13, 2024
1 parent 08a6d35 commit 74e71c6
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 0 deletions.
41 changes: 41 additions & 0 deletions ports/directx12-agility/directx12-config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
get_filename_component(_dx12_root "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_dx12_root "${_dx12_root}" PATH)
get_filename_component(_dx12_root "${_dx12_root}" PATH)

if (EXISTS "${_dx12_root}/bin/D3D12Core.dll")

find_library(D3D12_LIB NAMES d3d12)

if("${D3D12_LIB}" STREQUAL "D3D12_LIB-NOTFOUND")
message(FATAL_ERROR "D3D12.LIB import library from the Windows SDK is required")
endif()

add_library(Microsoft::DirectX12-Core SHARED IMPORTED)
set_target_properties(Microsoft::DirectX12-Core PROPERTIES
IMPORTED_LOCATION_RELEASE "${_dx12_root}/bin/D3D12Core.dll"
IMPORTED_LOCATION_DEBUG "${_dx12_root}/debug/bin/D3D12Core.dll"
IMPORTED_IMPLIB "${D3D12_LIB}"
IMPORTED_CONFIGURATIONS "Debug;Release"
IMPORTED_LINK_INTERFACE_LANGUAGES "C")

add_library(Microsoft::DirectX12-Layers SHARED IMPORTED)
set_target_properties(Microsoft::DirectX12-Layers PROPERTIES
IMPORTED_LOCATION_RELEASE "${_dx12_root}/debug/bin/d3d12SDKLayers.dll"
IMPORTED_LOCATION_DEBUG "${_dx12_root}/debug/bin/d3d12SDKLayers.dll"
IMPORTED_IMPLIB "${D3D12_LIB}"
IMPORTED_CONFIGURATIONS "Debug;Release"
IMPORTED_LINK_INTERFACE_LANGUAGES "C")

add_library(Microsoft::DirectX12-Agility INTERFACE IMPORTED)
set_target_properties(Microsoft::DirectX12-Agility PROPERTIES
INTERFACE_LINK_LIBRARIES "Microsoft::DirectX12-Core;Microsoft::DirectX12-Layers")

set(directx12-agility_FOUND TRUE)

else()

set(directx12-agility_FOUND FALSE)

endif()

unset(_dx12_root)
43 changes: 43 additions & 0 deletions ports/directx12-agility/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
set(VCPKG_POLICY_DLLS_IN_STATIC_LIBRARY enabled)
set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled)
set(VCPKG_POLICY_DLLS_WITHOUT_LIBS enabled)
set(VCPKG_POLICY_MISMATCHED_NUMBER_OF_BINARIES enabled)

vcpkg_download_distfile(ARCHIVE
URLS "https://www.nuget.org/api/v2/package/Microsoft.Direct3D.D3D12/${VERSION}"
FILENAME "Microsoft.Direct3D.D3D12.${VERSION}.zip"
SHA512 9703445beb09808f1edf1320605d870fdfbd74b728227df2c9c99a560400c653f38960b6f54f45dc36fcb2609acb412d30307391ee02df53bc636e2c4c89f22c
)

vcpkg_extract_source_archive(
PACKAGE_PATH
ARCHIVE ${ARCHIVE}
NO_REMOVE_ONE_LEVEL
)

if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
set(REDIST_ARCH win32)
else()
set(REDIST_ARCH ${VCPKG_TARGET_ARCHITECTURE})
endif()

file(COPY "${PACKAGE_PATH}/build/native/bin/${REDIST_ARCH}/D3D12Core.dll" "${PACKAGE_PATH}/build/native/bin/${REDIST_ARCH}/D3D12Core.pdb"
DESTINATION "${CURRENT_PACKAGES_DIR}/bin")

file(COPY "${PACKAGE_PATH}/build/native/bin/${REDIST_ARCH}/D3D12Core.dll" "${PACKAGE_PATH}/build/native/bin/${REDIST_ARCH}/D3D12Core.pdb"
DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin")
file(COPY "${PACKAGE_PATH}/build/native/bin/${REDIST_ARCH}/d3d12SDKLayers.dll" "${PACKAGE_PATH}/build/native/bin/${REDIST_ARCH}/d3d12SDKLayers.pdb"
DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin")

file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/${PORT}")

file(COPY "${PACKAGE_PATH}/build/native/bin/${REDIST_ARCH}/d3dconfig.exe" "${PACKAGE_PATH}/build/native/bin/${REDIST_ARCH}/d3dconfig.pdb"
DESTINATION "${CURRENT_PACKAGES_DIR}/tools//${PORT}")

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")

file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
vcpkg_install_copyright(FILE_LIST "${PACKAGE_PATH}/LICENSE.txt")

configure_file("${CMAKE_CURRENT_LIST_DIR}/directx12-config.cmake.in" "${CURRENT_PACKAGES_DIR}/share/${PORT}/${PORT}-config.cmake" @ONLY)
14 changes: 14 additions & 0 deletions ports/directx12-agility/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
The DirectX 12 Agility SDK package provides CMake targets:

find_package(directx-headers CONFIG REQUIRED)
find_package(directx12-agility CONFIG REQUIRED)
target_link_libraries(main PRIVATE Microsoft::DirectX-Headers Microsoft::DirectX-Guids Microsoft::DirectX12-Agility)

if(TARGET Microsoft::DirectX12-Agility)
file(MAKE_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/D3D12")
add_custom_command(TARGET main POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_PROPERTY:Microsoft::DirectX12-Core,IMPORTED_LOCATION_RELEASE> $<TARGET_FILE_DIR:main>/D3D12
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_PROPERTY:Microsoft::DirectX12-Layers,IMPORTED_LOCATION_DEBUG> $<TARGET_FILE_DIR:main>/D3D12
COMMAND_EXPAND_LISTS
)
endif()
20 changes: 20 additions & 0 deletions ports/directx12-agility/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "directx12-agility",
"version": "1.613.0",
"description": "DirectX 12 Agility SDK",
"homepage": "https://aka.ms/directx12agility",
"documentation": "https://devblogs.microsoft.com/directx/gettingstarted-dx12agility/",
"license": null,
"supports": "windows & !uwp & !xbox",
"dependencies": [
"directx-headers",
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}
4 changes: 4 additions & 0 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -2212,6 +2212,10 @@
"baseline": "1.613.0",
"port-version": 0
},
"directx12-agility": {
"baseline": "1.613.0",
"port-version": 0
},
"directxmath": {
"baseline": "2024-02-14",
"port-version": 1
Expand Down
9 changes: 9 additions & 0 deletions versions/d-/directx12-agility.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "9ff3410dacd22191327748dd1949cfcaf8e337f4",
"version": "1.613.0",
"port-version": 0
}
]
}

0 comments on commit 74e71c6

Please sign in to comment.