diff options
| author | 3gg <3gg@shellblade.net> | 2025-12-02 16:39:36 -0800 |
|---|---|---|
| committer | 3gg <3gg@shellblade.net> | 2025-12-02 16:39:36 -0800 |
| commit | 6c8ae19be66cee247980a48e736a4e05d14de179 (patch) | |
| tree | d860767907bf0cbe17ec66422e11bea700cf56d9 /dxg/CMakeLists.txt | |
| parent | 8f594c8ebd11f0e5f8a0c6369c3fe7383d250cbe (diff) | |
Diffstat (limited to 'dxg/CMakeLists.txt')
| -rw-r--r-- | dxg/CMakeLists.txt | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/dxg/CMakeLists.txt b/dxg/CMakeLists.txt index b7607c0..1040276 100644 --- a/dxg/CMakeLists.txt +++ b/dxg/CMakeLists.txt | |||
| @@ -2,22 +2,53 @@ cmake_minimum_required(VERSION 3.20) | |||
| 2 | 2 | ||
| 3 | project(dxg) | 3 | project(dxg) |
| 4 | 4 | ||
| 5 | # Agility SDK. | ||
| 6 | # Give AGILITY_SDK_BIN PARENT_SCOPE so that it is accessible from the | ||
| 7 | # install_agility_sdk function below. | ||
| 8 | set(AGILITY_SDK_DIR "../contrib/microsoft.direct3d.d3d12.1.618.4/build/native") | ||
| 9 | set(AGILITY_SDK_BIN "${AGILITY_SDK_DIR}/bin/x64" PARENT_SCOPE) | ||
| 10 | |||
| 11 | add_subdirectory(shaders) | ||
| 12 | |||
| 5 | add_library(dxg | 13 | add_library(dxg |
| 6 | include/dxg/dxcommon.h | 14 | include/dxg/dxcommon.h |
| 7 | src/dxg.c) | 15 | include/dxg/dxg.h |
| 16 | include/dxg/imm.h | ||
| 17 | src/dxcommon.c | ||
| 18 | src/imm.c) | ||
| 19 | |||
| 20 | # exe must export these so that D3D12.dll can find and load D3D12Core.dll and | ||
| 21 | # other DLLs from the Agility SDK. | ||
| 22 | target_compile_definitions(dxg PRIVATE | ||
| 23 | AGILITY_SDK_VERSION=618 # Must match AGILITY_SDK_DIR above. | ||
| 24 | AGILITY_SDK_INSTALL=u8".\\\\D3D12\\\\") # Binaries will be copied to this subdirectory. | ||
| 8 | 25 | ||
| 9 | # target_sources(dxg PUBLIC | 26 | # Use BEFORE so that the D3D headers in the Agility SDK are picked before the |
| 10 | # FILE_SET cxx_modules TYPE CXX_MODULES FILES | 27 | # ones in the Windows SDK. |
| 11 | # asset.ixx | 28 | target_include_directories(dxg BEFORE PUBLIC |
| 12 | # dxcommon.ixx | 29 | include |
| 13 | # dxg.ixx | 30 | ${AGILITY_SDK_DIR}/include) |
| 14 | # imm.ixx) | ||
| 15 | 31 | ||
| 16 | target_include_directories(dxg PUBLIC | 32 | target_link_directories(dxg BEFORE PUBLIC |
| 17 | include) | 33 | ${AGILITY_SDK_DIR}/bin/x64) |
| 18 | 34 | ||
| 19 | target_link_libraries(dxg PUBLIC | 35 | target_link_libraries(dxg PUBLIC |
| 20 | DirectX-Headers | 36 | DirectX-Headers |
| 21 | D3D12.lib | 37 | D3D12.lib |
| 22 | DXGI.lib | 38 | DXGI.lib |
| 23 | DXGUID.lib) # For IID_Xyz symbols | 39 | DXGUID.lib) # For IID_Xyz symbols |
| 40 | |||
| 41 | target_link_libraries(dxg PRIVATE | ||
| 42 | shaders) | ||
| 43 | |||
| 44 | # Function to copy Agility SDK binaries to the D3D12\ directory next to the exe. | ||
| 45 | # exe targets must call this function. | ||
| 46 | function(install_agility_sdk exe_path) | ||
| 47 | cmake_path(APPEND d3d12_path ${exe_path} "D3D12") | ||
| 48 | if(NOT EXISTS ${d3d12_path}) | ||
| 49 | message("D3D12 path = ${d3d12_path}") | ||
| 50 | message("AGILITY_SDK_BIN = ${AGILITY_SDK_BIN}") | ||
| 51 | file(MAKE_DIRECTORY ${d3d12_path}) | ||
| 52 | file(COPY ${AGILITY_SDK_BIN}/ DESTINATION ${d3d12_path}) | ||
| 53 | endif() | ||
| 54 | endfunction() | ||
