From 6c8ae19be66cee247980a48e736a4e05d14de179 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Tue, 2 Dec 2025 16:39:36 -0800 Subject: Immediate-mode renderer, triangle demo, shader compilation in cmake, Agility SDK --- dxg/CMakeLists.txt | 49 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 9 deletions(-) (limited to 'dxg/CMakeLists.txt') 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) project(dxg) +# Agility SDK. +# Give AGILITY_SDK_BIN PARENT_SCOPE so that it is accessible from the +# install_agility_sdk function below. +set(AGILITY_SDK_DIR "../contrib/microsoft.direct3d.d3d12.1.618.4/build/native") +set(AGILITY_SDK_BIN "${AGILITY_SDK_DIR}/bin/x64" PARENT_SCOPE) + +add_subdirectory(shaders) + add_library(dxg include/dxg/dxcommon.h - src/dxg.c) + include/dxg/dxg.h + include/dxg/imm.h + src/dxcommon.c + src/imm.c) + +# exe must export these so that D3D12.dll can find and load D3D12Core.dll and +# other DLLs from the Agility SDK. +target_compile_definitions(dxg PRIVATE + AGILITY_SDK_VERSION=618 # Must match AGILITY_SDK_DIR above. + AGILITY_SDK_INSTALL=u8".\\\\D3D12\\\\") # Binaries will be copied to this subdirectory. -# target_sources(dxg PUBLIC -# FILE_SET cxx_modules TYPE CXX_MODULES FILES -# asset.ixx -# dxcommon.ixx -# dxg.ixx -# imm.ixx) +# Use BEFORE so that the D3D headers in the Agility SDK are picked before the +# ones in the Windows SDK. +target_include_directories(dxg BEFORE PUBLIC + include + ${AGILITY_SDK_DIR}/include) -target_include_directories(dxg PUBLIC - include) +target_link_directories(dxg BEFORE PUBLIC + ${AGILITY_SDK_DIR}/bin/x64) target_link_libraries(dxg PUBLIC DirectX-Headers D3D12.lib DXGI.lib DXGUID.lib) # For IID_Xyz symbols + +target_link_libraries(dxg PRIVATE + shaders) + +# Function to copy Agility SDK binaries to the D3D12\ directory next to the exe. +# exe targets must call this function. +function(install_agility_sdk exe_path) + cmake_path(APPEND d3d12_path ${exe_path} "D3D12") + if(NOT EXISTS ${d3d12_path}) + message("D3D12 path = ${d3d12_path}") + message("AGILITY_SDK_BIN = ${AGILITY_SDK_BIN}") + file(MAKE_DIRECTORY ${d3d12_path}) + file(COPY ${AGILITY_SDK_BIN}/ DESTINATION ${d3d12_path}) + endif() +endfunction() -- cgit v1.2.3