diff options
Diffstat (limited to 'dxg/CMakeLists.txt')
| -rw-r--r-- | dxg/CMakeLists.txt | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/dxg/CMakeLists.txt b/dxg/CMakeLists.txt new file mode 100644 index 0000000..1040276 --- /dev/null +++ b/dxg/CMakeLists.txt | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | cmake_minimum_required(VERSION 3.20) | ||
| 2 | |||
| 3 | project(dxg) | ||
| 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 | |||
| 13 | add_library(dxg | ||
| 14 | include/dxg/dxcommon.h | ||
| 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. | ||
| 25 | |||
| 26 | # Use BEFORE so that the D3D headers in the Agility SDK are picked before the | ||
| 27 | # ones in the Windows SDK. | ||
| 28 | target_include_directories(dxg BEFORE PUBLIC | ||
| 29 | include | ||
| 30 | ${AGILITY_SDK_DIR}/include) | ||
| 31 | |||
| 32 | target_link_directories(dxg BEFORE PUBLIC | ||
| 33 | ${AGILITY_SDK_DIR}/bin/x64) | ||
| 34 | |||
| 35 | target_link_libraries(dxg PUBLIC | ||
| 36 | DirectX-Headers | ||
| 37 | D3D12.lib | ||
| 38 | DXGI.lib | ||
| 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() | ||
