Skip to content

Commit 6ef3802

Browse files
committed
Vendor DirectX-Headers
This simplifies configuration complexity.
1 parent d996f16 commit 6ef3802

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+86957
-7
lines changed

.github/workflows/test-all.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ jobs:
124124
cd llvm-project
125125
mkdir build
126126
cd build
127-
cmake -G Ninja -DCMAKE_BUILD_TYPE=${{ inputs.BuildType }} -C ${{ github.workspace }}/llvm-project/clang/cmake/caches/HLSL.cmake -C ${{ github.workspace }}/HLSLTest/cmake/caches/sccache.cmake -DDIRECTX_HEADERS_PATH=${{ github.workspace }}/DXC/external/DirectX-Headers -DDXC_BUILD_DIR=${{ github.workspace }}/DXC/build/bin -DLLVM_EXTERNAL_HLSLTEST_SOURCE_DIR=${{ github.workspace }}/HLSLTest -DLLVM_EXTERNAL_PROJECTS="HLSLTest" -DLLVM_LIT_ARGS="--xunit-xml-output=testresults.xunit.xml -v" -DHLSLTEST_TEST_CLANG=${{ inputs.Test-Clang }} ${{ github.workspace }}/llvm-project/llvm/
127+
cmake -G Ninja -DCMAKE_BUILD_TYPE=${{ inputs.BuildType }} -C ${{ github.workspace }}/llvm-project/clang/cmake/caches/HLSL.cmake -C ${{ github.workspace }}/HLSLTest/cmake/caches/sccache.cmake -DDXC_BUILD_DIR=${{ github.workspace }}/DXC/build/bin -DLLVM_EXTERNAL_HLSLTEST_SOURCE_DIR=${{ github.workspace }}/HLSLTest -DLLVM_EXTERNAL_PROJECTS="HLSLTest" -DLLVM_LIT_ARGS="--xunit-xml-output=testresults.xunit.xml -v" -DHLSLTEST_TEST_CLANG=${{ inputs.Test-Clang }} ${{ github.workspace }}/llvm-project/llvm/
128128
ninja hlsl-test-depends
129129
- name: Run HLSL Tests
130130
run: |

CMakeLists.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,7 @@ configure_file(
6363
${CMAKE_CURRENT_SOURCE_DIR}/include/HLSLTest/Config.h.in
6464
${CMAKE_CURRENT_BINARY_DIR}/include/HLSLTest/Config.h)
6565

66-
if (D3D12_INCLUDE_DIRS AND NOT DIRECTX_HEADERS_PATH)
67-
set(DIRECTX_HEADERS_PATH ${CURRENT_CMAKE_BINARY_DIR}/DirectX-Headers)
68-
ExternalProject_Add(DIRECTX_HEADERS
69-
GIT_REPOSITORY https://github.com/microsoft/DirectX-Headers.git
70-
SOURCE_DIR ${DIRECTX_HEADERS_PATH})
71-
endif ()
66+
set(DIRECTX_HEADERS_PATH ${CMAKE_CURRENT_SOURCE_DIR}/third-party/DirectX-Headers)
7267

7368
if (WIN32)
7469
message(STATUS "Including vendored zlib")
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
*.psess
2+
*.vsp
3+
*.log
4+
*.err
5+
*.wrn
6+
*.suo
7+
*.sdf
8+
*.user
9+
*.i
10+
*.vspscc
11+
*.opensdf
12+
*.opendb
13+
*.ipch
14+
*.cache
15+
*.tlog
16+
*.lastbuildstate
17+
*.ilk
18+
*.VC.db
19+
*.nupkg
20+
.vs
21+
/out
22+
/CMakeUserPresets.json
23+
/build*
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
cc_library_headers {
2+
name: "DirectX-Headers",
3+
export_include_dirs: ["include", "include/wsl/stubs"],
4+
vendor_available: true,
5+
}
6+
7+
cc_library_static {
8+
name: "DirectX-Guids",
9+
header_libs: ["DirectX-Headers"],
10+
local_include_dirs: ["include/dxguids"],
11+
srcs: ["src/dxguids.cpp"],
12+
cppflags: ["-Wno-non-virtual-dtor", "-Wno-unused-value"],
13+
vendor_available: true,
14+
}
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
3+
cmake_minimum_required(VERSION 3.10.2)
4+
project(DirectX-Headers
5+
LANGUAGES CXX
6+
VERSION 1.614.1
7+
)
8+
include(CTest)
9+
set(CMAKE_CXX_STANDARD 14)
10+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
11+
set(CMAKE_CXX_EXTENSIONS OFF)
12+
enable_testing()
13+
14+
# It's useful to know if you are a top level project or not, if your project is
15+
# being consumed via add_subdirectory
16+
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
17+
set(IS_TOPLEVEL_PROJECT TRUE)
18+
else()
19+
set(IS_TOPLEVEL_PROJECT FALSE)
20+
endif()
21+
22+
# Use DXHEADERS_* prefix to avoid potential name conflicts in cmake-gui, and allow
23+
# grouping by prefix if more options are added
24+
#
25+
# Testing should only be enabled by default if we are top level. Otherwise clients can set it
26+
# either via cmake or cmake-gui
27+
option(DXHEADERS_BUILD_TEST "Build the test" ${IS_TOPLEVEL_PROJECT})
28+
option(DXHEADERS_INSTALL "Installation logic" ${IS_TOPLEVEL_PROJECT})
29+
option(DXHEADERS_BUILD_GOOGLE_TEST "Build the google test suite" ${IS_TOPLEVEL_PROJECT})
30+
31+
include(GNUInstallDirs)
32+
33+
# Enables consumers to add this library as a link target to automatically add
34+
# these include directories, regardless of whether this is referenced via subdirectory
35+
# or from an installed location
36+
add_library(DirectX-Headers STATIC src/d3dx12_property_format_table.cpp)
37+
target_include_directories(DirectX-Headers SYSTEM PUBLIC
38+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
39+
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
40+
)
41+
target_include_directories(DirectX-Headers PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/directx)
42+
43+
add_library(Microsoft::DirectX-Headers ALIAS DirectX-Headers)
44+
45+
add_library(DirectX-Guids STATIC src/dxguids.cpp)
46+
target_link_libraries(DirectX-Guids PRIVATE DirectX-Headers)
47+
48+
add_library(Microsoft::DirectX-Guids ALIAS DirectX-Guids)
49+
50+
# For non-Windows targets, also add the WSL stubs to the include path
51+
if (NOT WIN32)
52+
target_include_directories(DirectX-Headers SYSTEM PUBLIC
53+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/wsl/stubs>"
54+
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/wsl/stubs>"
55+
)
56+
elseif((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
57+
# MinGW has RPC headers which define old versions, and complain if D3D
58+
# headers are included before the RPC headers, since D3D headers were
59+
# generated with new MIDL and "require" new RPC headers.
60+
target_compile_definitions(DirectX-Headers PRIVATE "__REQUIRED_RPCNDR_H_VERSION__=475")
61+
target_compile_definitions(DirectX-Guids PRIVATE "__REQUIRED_RPCNDR_H_VERSION__=475")
62+
endif()
63+
64+
if (DXHEADERS_INSTALL)
65+
# Install the targets
66+
install(TARGETS DirectX-Headers DirectX-Guids
67+
EXPORT DirectX-Headers-Targets
68+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
69+
# Create the targets CMake file which contains the above definitions
70+
install(EXPORT DirectX-Headers-Targets FILE directx-headers-targets.cmake
71+
NAMESPACE Microsoft::
72+
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/directx-headers/cmake)
73+
74+
# Install the actual includes
75+
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/"
76+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
77+
78+
# Create the CMake config files
79+
include(CMakePackageConfigHelpers)
80+
write_basic_package_version_file("directx-headers-config-version.cmake"
81+
VERSION ${PROJECT_VERSION}
82+
COMPATIBILITY SameMajorVersion)
83+
configure_package_config_file(
84+
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/directx-headers-config.cmake.in"
85+
"${CMAKE_CURRENT_BINARY_DIR}/directx-headers-config.cmake"
86+
INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/directx-headers/cmake)
87+
88+
# Install the CMake config files
89+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/directx-headers-config.cmake"
90+
"${CMAKE_CURRENT_BINARY_DIR}/directx-headers-config-version.cmake"
91+
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/directx-headers/cmake)
92+
93+
# Create pkg-config file
94+
include(cmake/JoinPaths.cmake)
95+
# from: https://github.com/jtojnar/cmake-snips#concatenating-paths-when-building-pkg-config-files
96+
join_paths(DIRECTX_INCLUDEDIR_FOR_PKG_CONFIG "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
97+
join_paths(DIRECTX_LIBDIR_FOR_PKG_CONFIG "\${prefix}" "${CMAKE_INSTALL_LIBDIR}")
98+
configure_file(
99+
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/DirectX-Headers.pc.in"
100+
"${CMAKE_CURRENT_BINARY_DIR}/DirectX-Headers.pc" @ONLY)
101+
102+
# Install the pkg-config file
103+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/DirectX-Headers.pc"
104+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
105+
106+
endif()
107+
108+
if (BUILD_TESTING)
109+
if (DXHEADERS_BUILD_TEST)
110+
add_subdirectory(test)
111+
endif()
112+
113+
if (DXHEADERS_BUILD_GOOGLE_TEST)
114+
# We do not want to install GoogleTest when packaging DirectX-Headers.
115+
set(INSTALL_GTEST OFF)
116+
add_subdirectory(googletest)
117+
endif()
118+
endif()

0 commit comments

Comments
 (0)