Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
235 lines (231 loc) · 10.1 KB
/
Copy pathCMakeLists.txt
File metadata and controls
235 lines (231 loc) · 10.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# SPDX-License-Identifier: MIT
cmake_minimum_required(VERSION 3.24)
project(MesaLiberNT LANGUAGES C CXX ASM)
file(STRINGS "${PROJECT_SOURCE_DIR}/VERSION" MESA_VERSION LIMIT_COUNT 1)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${PROJECT_SOURCE_DIR}/VERSION")
# This is the Windows WGL and Lavapipe build of the vendored Mesa snapshot. It
# deliberately uses its own llvm-mingw toolchain, independent of LiberNT's
# SDK/CRT flags.
if(NOT WIN32 OR NOT MINGW OR NOT CMAKE_C_COMPILER_ID STREQUAL "Clang")
message(FATAL_ERROR "Mesa's LiberNT CMake build requires llvm-mingw Clang targeting Windows. See cmake/README.md.")
endif()
set(MESA_ARCH "${CMAKE_SYSTEM_PROCESSOR}" CACHE STRING "Target architecture: arm64, arm64ec, amd64 or i386")
if(MESA_ARCH STREQUAL "aarch64")
set(MESA_ARCH arm64)
elseif(MESA_ARCH STREQUAL "x86_64")
set(MESA_ARCH amd64)
elseif(MESA_ARCH MATCHES "^(x86|i686)$")
set(MESA_ARCH i386)
endif()
if(NOT MESA_ARCH MATCHES "^(arm64|arm64ec|amd64|i386|riscv64)$")
message(FATAL_ERROR "Unsupported MESA_ARCH: ${MESA_ARCH}")
endif()
option(MESA_LLVMPIPE "Build LLVMpipe instead of softpipe" OFF)
option(MESA_LAVAPIPE "Build the Lavapipe Vulkan ICD" OFF)
option(MESA_IMAGINATION "Build the Imagination PowerVR Vulkan ICD over the LiberNT KMT transport" OFF)
option(MESA_ZINK "Build the Zink Gallium driver into the WGL ICD" OFF)
option(MESA_D3D12 "Build the D3D12 Gallium driver into the WGL ICD" OFF)
option(MESA_LIBERNT_SDK "Build against the LiberNT SDK headers, CRT and import libraries" OFF)
option(MESA_ASSERTIONS "Keep assertions enabled in optimized Mesa builds" ON)
set(MESA_WGL_DLL_NAME "mesa_gallium" CACHE STRING "WGL ICD DLL basename")
if(NOT MESA_WGL_DLL_NAME MATCHES "^[A-Za-z0-9_-]+$")
message(FATAL_ERROR "MESA_WGL_DLL_NAME must be a DLL basename without an extension.")
endif()
set(MESA_LIBERNT_SOURCE_DIR "" CACHE PATH "LiberNT source tree providing KMT and zlib headers")
set(MESA_LIBERNT_BUILD_DIR "" CACHE PATH "LiberNT Release build providing KMT and zlib archives")
# A LiberNT tree older than this interface passes the MESA_REACTOS_ names.
foreach(_mesa_name SDK SOURCE_DIR BUILD_DIR)
if(DEFINED MESA_REACTOS_${_mesa_name} AND NOT MESA_LIBERNT_${_mesa_name})
set(MESA_LIBERNT_${_mesa_name} "${MESA_REACTOS_${_mesa_name}}")
endif()
endforeach()
if(EXISTS "${MESA_LIBERNT_SOURCE_DIR}/sdk/include/libernt/libs/zlib/zlib.h")
set(MESA_LIBERNT_INCLUDE_DIR "${MESA_LIBERNT_SOURCE_DIR}/sdk/include/libernt")
else()
# TODO: drop the sdk/include/reactos fallback once every supported LiberNT tree uses sdk/include/libernt
set(MESA_LIBERNT_INCLUDE_DIR "${MESA_LIBERNT_SOURCE_DIR}/sdk/include/reactos")
endif()
set(MESA_LLVM_ROOT "" CACHE PATH "Static Windows LLVM installation for the target architecture")
set(MESA_DIRECTX_HEADERS_ROOT "" CACHE PATH "DirectX-Headers installation used by the Windows Vulkan WSI")
set(MESA_PROFILE "${MESA_ARCH}")
set(_mesa_v3d_default OFF)
if(MESA_ARCH MATCHES "^(arm64|arm64ec|i386)$")
set(_mesa_v3d_default ON)
endif()
option(MESA_V3D "Build the VC4/V3D hardware drivers into the WGL ICD" ${_mesa_v3d_default})
set(_mesa_crocus_default OFF)
if(MESA_ARCH MATCHES "^(amd64|i386)$" AND MESA_LIBERNT_SDK)
set(_mesa_crocus_default ON)
endif()
option(MESA_CROCUS "Build the Crocus driver for Intel Gfx4-8 over the hdgfx D3DKMT transport into the WGL ICD" ${_mesa_crocus_default})
if(NOT MESA_V3D AND MESA_LLVMPIPE AND MESA_ARCH MATCHES "^arm64")
set(MESA_PROFILE "llvm-arm64")
endif()
set(MESA_GALLIVM_ORCJIT 0)
if(MESA_LLVMPIPE AND NOT MESA_ARCH MATCHES "^(arm64|arm64ec|amd64|i386)$")
set(MESA_GALLIVM_ORCJIT 1)
endif()
if(MESA_LLVMPIPE)
if(NOT MESA_ARCH MATCHES "^(arm64|arm64ec|amd64|riscv64)$")
message(FATAL_ERROR "The LiberNT LLVMpipe configuration supports arm64, arm64ec, amd64 and riscv64 only.")
endif()
if(NOT EXISTS "${MESA_LLVM_ROOT}/lib/cmake/llvm/LLVMConfig.cmake")
message(FATAL_ERROR "MESA_LLVM_ROOT must contain a static Windows LLVM installation for ${MESA_ARCH}.")
endif()
set(LLVM_DIR "${MESA_LLVM_ROOT}/lib/cmake/llvm")
find_package(LLVM REQUIRED CONFIG NO_DEFAULT_PATH)
if(NOT LLVM_VERSION_MAJOR EQUAL 22 OR LLVM_ENABLE_SHARED_LIBS)
message(FATAL_ERROR "Mesa LLVMpipe requires static LLVM 22 libraries.")
endif()
if(MESA_ARCH MATCHES "^arm64")
set(_mesa_llvm_target AArch64)
elseif(MESA_ARCH STREQUAL "riscv64")
set(_mesa_llvm_target RISCV)
else()
set(_mesa_llvm_target X86)
endif()
if(NOT _mesa_llvm_target IN_LIST LLVM_TARGETS_TO_BUILD)
message(FATAL_ERROR "LLVM must include the ${_mesa_llvm_target} target.")
endif()
set(_mesa_llvm_orcjit)
if(MESA_GALLIVM_ORCJIT)
set(_mesa_llvm_orcjit orcjit)
endif()
llvm_map_components_to_libnames(MESA_LLVM_LIBRARIES
bitwriter mcdisassembler mcjit ${_mesa_llvm_orcjit} core executionengine scalaropts
transformutils instcombine coroutines passes ${_mesa_llvm_target})
endif()
if(MESA_V3D)
foreach(_mesa_header "${MESA_LIBERNT_INCLUDE_DIR}/libs/zlib/zlib.h" "${MESA_LIBERNT_INCLUDE_DIR}")
if(NOT EXISTS "${_mesa_header}")
message(FATAL_ERROR "Set MESA_LIBERNT_SOURCE_DIR to the LiberNT source tree (missing ${_mesa_header}).")
endif()
endforeach()
set(_mesa_support_archives
sdk/lib/vc4kmt/libvc4kmt.a
sdk/lib/3rdparty/zlib/libzlib.a)
if(MESA_ARCH MATCHES "^arm64")
list(APPEND _mesa_support_archives
sdk/lib/rpi3vc4kmt/librpi3vc4kmt.a)
endif()
foreach(_mesa_archive IN LISTS _mesa_support_archives)
if(NOT EXISTS "${MESA_LIBERNT_BUILD_DIR}/${_mesa_archive}")
message(FATAL_ERROR "Build the LiberNT Release KMT/zlib support libraries first (missing ${MESA_LIBERNT_BUILD_DIR}/${_mesa_archive}).")
endif()
endforeach()
endif()
if(MESA_D3D12 AND (NOT EXISTS "${MESA_DIRECTX_HEADERS_ROOT}/include/directx/d3d12.h" OR
NOT EXISTS "${MESA_DIRECTX_HEADERS_ROOT}/include/dxguids/dxguids.h"))
message(FATAL_ERROR "MESA_D3D12 needs the installed DirectX-Headers in MESA_DIRECTX_HEADERS_ROOT")
endif()
if(MESA_LAVAPIPE)
if(NOT MESA_LLVMPIPE)
message(FATAL_ERROR "MESA_LAVAPIPE requires MESA_LLVMPIPE and its static target LLVM libraries.")
endif()
if(NOT EXISTS "${MESA_DIRECTX_HEADERS_ROOT}/include/directx/d3d12.h" OR
NOT EXISTS "${MESA_DIRECTX_HEADERS_ROOT}/include/dxguids/dxguids.h")
message(FATAL_ERROR "MESA_DIRECTX_HEADERS_ROOT must contain the installed DirectX-Headers include tree.")
endif()
find_program(MESA_GLSLANG_VALIDATOR NAMES glslangValidator REQUIRED)
endif()
if(MESA_IMAGINATION)
if(NOT MESA_LIBERNT_SDK)
message(FATAL_ERROR "MESA_IMAGINATION requires the LiberNT SDK toolchain (MESA_LIBERNT_SDK).")
endif()
if(NOT EXISTS "${MESA_LIBERNT_BUILD_DIR}/sdk/lib/pvrkmt/libpvrkmt.a")
message(FATAL_ERROR "Build the LiberNT pvrkmt transport first (missing ${MESA_LIBERNT_BUILD_DIR}/sdk/lib/pvrkmt/libpvrkmt.a).")
endif()
endif()
find_package(Python3 3.8 REQUIRED COMPONENTS Interpreter)
execute_process(COMMAND "${Python3_EXECUTABLE}" -c "import mako, packaging, yaml"
RESULT_VARIABLE _mesa_python_status ERROR_VARIABLE _mesa_python_error)
if(NOT _mesa_python_status EQUAL 0)
message(FATAL_ERROR "Mesa generators need Python Mako, packaging and PyYAML: ${_mesa_python_error}")
endif()
find_package(BISON 2.7 REQUIRED)
find_package(FLEX REQUIRED)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
endif()
include(GNUInstallDirs)
include(cmake/Helpers.cmake)
include(cmake/CompileOptions.cmake)
include(cmake/Generators.cmake)
if(MESA_LAVAPIPE OR MESA_IMAGINATION OR MESA_ZINK)
include(cmake/VulkanGenerators.cmake)
endif()
if(MESA_IMAGINATION)
include(cmake/ImaginationGenerators.cmake)
endif()
if(MESA_ZINK)
include(cmake/ZinkGenerators.cmake)
endif()
if(MESA_D3D12)
include(cmake/D3D12Generators.cmake)
endif()
if(MESA_CROCUS)
include(cmake/IntelGenerators.cmake)
endif()
add_custom_target(mesa_generated DEPENDS ${MESA_GENERATED_OUTPUTS})
if(MESA_ASSERTIONS)
add_library(mesa_assert_report STATIC EXCLUDE_FROM_ALL cmake/assert/assert_report.c)
endif()
include(cmake/Targets.cmake)
if(MESA_V3D)
include(cmake/V3DTargets.cmake)
include(cmake/D3DTargets.cmake)
endif()
if(MESA_CROCUS)
include(cmake/CrocusTargets.cmake)
endif()
if(MESA_LAVAPIPE)
include(cmake/VulkanTargets.cmake)
endif()
if(MESA_IMAGINATION)
include(cmake/ImaginationTargets.cmake)
endif()
if(MESA_ZINK)
include(cmake/ZinkTargets.cmake)
endif()
if(MESA_D3D12)
include(cmake/D3D12Targets.cmake)
endif()
set_target_properties(mesa_gallium PROPERTIES
OUTPUT_NAME "${MESA_WGL_DLL_NAME}"
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/src/gallium/targets/wgl")
set_target_properties(opengl32 PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/src/gallium/targets/libgl-gdi")
add_custom_target(mesa_wgl ALL DEPENDS mesa_gallium)
install(TARGETS mesa_gallium RUNTIME DESTINATION bin)
if(MESA_V3D)
add_custom_target(mesa_d3d ALL DEPENDS rpi5vc4d3d)
install(TARGETS rpi5vc4d3d RUNTIME DESTINATION bin)
endif()
if(MESA_IMAGINATION)
add_custom_target(mesa_vulkan_powervr ALL DEPENDS vulkan_powervr_mesa powervr_icd)
install(TARGETS vulkan_powervr_mesa RUNTIME DESTINATION bin)
install(FILES "${MESA_POWERVR_MANIFEST}" DESTINATION bin)
endif()
if(MESA_LAVAPIPE)
add_custom_target(mesa_vulkan ALL DEPENDS vulkan_lvp lvp_icd)
install(TARGETS vulkan_lvp RUNTIME DESTINATION bin)
install(FILES "${MESA_LAVAPIPE_MANIFEST}" DESTINATION bin)
endif()
if(MESA_LLVMPIPE)
set(_mesa_renderer "LLVMpipe")
else()
set(_mesa_renderer "Softpipe")
endif()
if(MESA_V3D)
set(_mesa_renderer "V3D + ${_mesa_renderer}")
endif()
if(MESA_CROCUS)
set(_mesa_renderer "Crocus + ${_mesa_renderer}")
endif()
message(STATUS "Mesa CMake: ${MESA_ARCH} ${_mesa_renderer}, WGL=${MESA_WGL_DLL_NAME}.dll, Lavapipe=${MESA_LAVAPIPE}, PowerVR=${MESA_IMAGINATION}")