Skip to content
This repository was archived by the owner on Feb 23, 2026. It is now read-only.

Commit b5ba81b

Browse files
committed
Added DIRECTXTK_INTEGRATION build option to CMake
1 parent 9b5ce62 commit b5ba81b

2 files changed

Lines changed: 38 additions & 6 deletions

File tree

CMakeLists.txt

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ project (DXUT
1313

1414
option(ENABLE_CODE_ANALYSIS "Use Static Code Analysis on build" OFF)
1515

16+
option(DIRECTXTK_INTEGRATION "Support mixing with DirectX Tool Kit" OFF)
17+
1618
set(CMAKE_CXX_STANDARD 17)
1719
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1820
set(CMAKE_CXX_EXTENSIONS OFF)
@@ -37,25 +39,32 @@ include(GNUInstallDirs)
3739

3840
#--- Core Library
3941
set(CORE_LIBRARY_HEADERS
40-
Core/DDSTextureLoader.h
4142
Core/dxerr.h
4243
Core/DXUT.h
4344
Core/DXUTDevice11.h
4445
Core/DXUTmisc.h
45-
Core/ScreenGrab.h
46-
Core/WICTextureLoader.h
4746
)
4847

4948
set(CORE_LIBRARY_SOURCES
50-
Core/DDSTextureLoader.cpp
5149
Core/dxerr.cpp
5250
Core/DXUT.cpp
5351
Core/DXUTDevice11.cpp
5452
Core/DXUTmisc.cpp
55-
Core/ScreenGrab.cpp
56-
Core/WICTextureLoader.cpp
5753
)
5854

55+
if (NOT DIRECTXTK_INTEGRATION)
56+
list(APPEND CORE_LIBRARY_HEADERS
57+
Core/DDSTextureLoader.h
58+
Core/ScreenGrab.h
59+
Core/WICTextureLoader.h
60+
)
61+
list(APPEND CORE_LIBRARY_SOURCES
62+
Core/DDSTextureLoader.cpp
63+
Core/ScreenGrab.cpp
64+
Core/WICTextureLoader.cpp
65+
)
66+
endif()
67+
5968
add_library(${PROJECT_NAME} STATIC ${CORE_LIBRARY_SOURCES} ${CORE_LIBRARY_HEADERS})
6069

6170
#--- Optional Library
@@ -111,6 +120,15 @@ target_include_directories(${PROJECT_NAME}Opt PUBLIC
111120
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}>
112121
PRIVATE Core/)
113122

123+
if (DIRECTXTK_INTEGRATION)
124+
target_compile_definitions(${PROJECT_NAME} PRIVATE USE_DIRECTXTK)
125+
target_compile_definitions(${PROJECT_NAME}Opt PRIVATE USE_DIRECTXTK)
126+
127+
find_package(directxtk REQUIRED)
128+
target_link_libraries(${PROJECT_NAME} PRIVATE Microsoft::DirectXTK)
129+
target_link_libraries(${PROJECT_NAME}Opt PRIVATE Microsoft::DirectXTK)
130+
endif()
131+
114132
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11)
115133
target_compile_features(${PROJECT_NAME}Opt PUBLIC cxx_std_11)
116134

CMakePresets.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@
9494
},
9595
"hidden": true
9696
},
97+
{
98+
"name": "DXTK",
99+
"cacheVariables": {
100+
"DIRECTXTK_INTEGRATION": true
101+
},
102+
"hidden": true
103+
},
97104

98105
{ "name": "x64-Debug" , "description": "MSVC for x64 (Debug)", "inherits": [ "base", "x64", "Debug", "MSVC" ] },
99106
{ "name": "x64-Release" , "description": "MSVC for x64 (Release)", "inherits": [ "base", "x64", "Release", "MSVC" ] },
@@ -102,6 +109,13 @@
102109
{ "name": "arm64-Debug" , "description": "MSVC for ARM64 (Debug)", "inherits": [ "base", "ARM64", "Debug", "MSVC" ] },
103110
{ "name": "arm64-Release" , "description": "MSVC for ARM64 (Release)", "inherits": [ "base", "ARM64", "Release", "MSVC" ] },
104111

112+
{ "name": "x64-Debug-DXTK" , "description": "MSVC for x64 (Debug) w/ DirectX Tool Kit", "inherits": [ "base", "x64", "Debug", "MSVC", "DXTK", "VCPKG" ] },
113+
{ "name": "x64-Release-DXTK" , "description": "MSVC for x64 (Release) w/ DirectX Tool Kit", "inherits": [ "base", "x64", "Release", "MSVC", "DXTK", "VCPKG" ] },
114+
{ "name": "x86-Debug-DXTK" , "description": "MSVC for x86 (Debug) w/ DirectX Tool Kit", "inherits": [ "base", "x86", "Debug", "MSVC", "DXTK", "VCPKG" ] },
115+
{ "name": "x86-Release-DXTK" , "description": "MSVC for x86 (Release) w/ DirectX Tool Kit", "inherits": [ "base", "x86", "Release", "MSVC", "DXTK", "VCPKG" ] },
116+
{ "name": "arm64-Debug-DXTK" , "description": "MSVC for ARM64 (Debug) w/ DirectX Tool Kit", "inherits": [ "base", "ARM64", "Debug", "MSVC", "DXTK", "VCPKG" ] },
117+
{ "name": "arm64-Release-DXTK" , "description": "MSVC for ARM64 (Release) w/ DirectX Tool Kit", "inherits": [ "base", "ARM64", "Release", "MSVC", "DXTK", "VCPKG" ] },
118+
105119
{ "name": "x64-Debug-Clang" , "description": "Clang/LLVM for x64 (Debug)", "inherits": [ "base", "x64", "Debug", "Clang" ] },
106120
{ "name": "x64-Release-Clang" , "description": "Clang/LLVM for x64 (Release)", "inherits": [ "base", "x64", "Release", "Clang" ] },
107121
{ "name": "x86-Debug-Clang" , "description": "Clang/LLVM for x86 (Debug)", "inherits": [ "base", "x86", "Debug", "Clang" ], "environment": { "CXXFLAGS": "-m32" } },

0 commit comments

Comments
 (0)