Skip to content

Commit 6168d53

Browse files
committed
format cmake files
1 parent b2452dd commit 6168d53

15 files changed

+422
-222
lines changed

CMakeLists.txt

+82-42
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ cmake_minimum_required(VERSION 3.22)
44
# from git describe
55
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
66
include(GitVersion)
7-
get_git_version(SLANG_VERSION_NUMERIC SLANG_VERSION_FULL "${CMAKE_CURRENT_LIST_DIR}")
7+
get_git_version(
8+
SLANG_VERSION_NUMERIC
9+
SLANG_VERSION_FULL
10+
"${CMAKE_CURRENT_LIST_DIR}"
11+
)
812

913
#
1014
# Our project
@@ -83,7 +87,11 @@ auto_option(
8387
Aftermath
8488
"Enable Aftermath in GFX, and add aftermath crash example to project"
8589
)
86-
advanced_option(SLANG_ENABLE_DX_ON_VK "Use dxvk and vkd3d-proton for DirectX support" OFF)
90+
advanced_option(
91+
SLANG_ENABLE_DX_ON_VK
92+
"Use dxvk and vkd3d-proton for DirectX support"
93+
OFF
94+
)
8795
advanced_option(SLANG_ENABLE_SLANG_RHI "Use slang-rhi as dependency" ON)
8896

8997
option(SLANG_EMBED_STDLIB_SOURCE "Embed stdlib source in the binary" ON)
@@ -98,31 +106,62 @@ option(SLANG_ENABLE_GFX "Enable gfx targets" ON)
98106
option(SLANG_ENABLE_SLANGD "Enable language server target" ON)
99107
option(SLANG_ENABLE_SLANGC "Enable standalone compiler target" ON)
100108
option(SLANG_ENABLE_SLANGRT "Enable runtime target" ON)
101-
option(SLANG_ENABLE_SLANG_GLSLANG "Enable glslang dependency and slang-glslang wrapper target" ON)
102-
option(SLANG_ENABLE_TESTS "Enable test targets, some tests may require SLANG_ENABLE_GFX, SLANG_ENABLE_SLANGD or SLANG_ENABLE_SLANGRT" ON)
103-
option(SLANG_ENABLE_EXAMPLES "Enable example targets, requires SLANG_ENABLE_GFX" ON)
109+
option(
110+
SLANG_ENABLE_SLANG_GLSLANG
111+
"Enable glslang dependency and slang-glslang wrapper target"
112+
ON
113+
)
114+
option(
115+
SLANG_ENABLE_TESTS
116+
"Enable test targets, some tests may require SLANG_ENABLE_GFX, SLANG_ENABLE_SLANGD or SLANG_ENABLE_SLANGRT"
117+
ON
118+
)
119+
option(
120+
SLANG_ENABLE_EXAMPLES
121+
"Enable example targets, requires SLANG_ENABLE_GFX"
122+
ON
123+
)
104124
option(SLANG_ENABLE_REPLAYER "Enable slang-replay tool" ON)
105125

106-
option(SLANG_GITHUB_TOKEN "Use a given token value for accessing Github REST API" "")
126+
option(
127+
SLANG_GITHUB_TOKEN
128+
"Use a given token value for accessing Github REST API"
129+
""
130+
)
107131

108132
advanced_option(SLANG_USE_SYSTEM_MINIZ "Build using system Miniz library" OFF)
109133
advanced_option(SLANG_USE_SYSTEM_LZ4 "Build using system LZ4 library" OFF)
110-
advanced_option(SLANG_USE_SYSTEM_VULKAN_HEADERS "Build using system Vulkan headers" OFF)
111-
advanced_option(SLANG_USE_SYSTEM_SPIRV_HEADERS "Build using system SPIR-V headers" OFF)
112-
advanced_option(SLANG_USE_SYSTEM_UNORDERED_DENSE "Build using system unordered dense" OFF)
134+
advanced_option(
135+
SLANG_USE_SYSTEM_VULKAN_HEADERS
136+
"Build using system Vulkan headers"
137+
OFF
138+
)
139+
advanced_option(
140+
SLANG_USE_SYSTEM_SPIRV_HEADERS
141+
"Build using system SPIR-V headers"
142+
OFF
143+
)
144+
advanced_option(
145+
SLANG_USE_SYSTEM_UNORDERED_DENSE
146+
"Build using system unordered dense"
147+
OFF
148+
)
113149

114-
option(SLANG_SPIRV_HEADERS_INCLUDE_DIR "Provide a specific path for the SPIR-V headers and grammar files")
150+
option(
151+
SLANG_SPIRV_HEADERS_INCLUDE_DIR
152+
"Provide a specific path for the SPIR-V headers and grammar files"
153+
)
115154
mark_as_advanced(SLANG_SPIRV_HEADERS_INCLUDE_DIR)
116155

117-
if (${SLANG_USE_SYSTEM_LZ4})
156+
if(${SLANG_USE_SYSTEM_LZ4})
118157
add_compile_definitions(SLANG_USE_SYSTEM_LZ4_HEADER)
119158
endif()
120159

121-
if (${SLANG_USE_SYSTEM_SPIRV_HEADERS})
160+
if(${SLANG_USE_SYSTEM_SPIRV_HEADERS})
122161
add_compile_definitions(SLANG_USE_SYSTEM_SPIRV_HEADER)
123162
endif()
124163

125-
if (${SLANG_USE_SYSTEM_UNORDERED_DENSE})
164+
if(${SLANG_USE_SYSTEM_UNORDERED_DENSE})
126165
add_compile_definitions(SLANG_USE_SYSTEM_UNORDERED_DENSE_HEADER)
127166
endif()
128167

@@ -166,9 +205,15 @@ if(SLANG_SLANG_LLVM_FLAVOR MATCHES FETCH_BINARY)
166205
get_best_slang_binary_release_url("${SLANG_GITHUB_TOKEN}" url)
167206
if(NOT DEFINED url)
168207
if(SLANG_SLANG_LLVM_FLAVOR STREQUAL FETCH_BINARY_IF_POSSIBLE)
169-
message(WARNING "Unable to find a prebuilt binary for slang-llvm, Slang will be built without LLVM support. Please consider setting SLANG_SLANG_LLVM_BINARY_URL manually")
208+
message(
209+
WARNING
210+
"Unable to find a prebuilt binary for slang-llvm, Slang will be built without LLVM support. Please consider setting SLANG_SLANG_LLVM_BINARY_URL manually"
211+
)
170212
else()
171-
message(FATAL_ERROR "Unable to find binary release for slang-llvm, please set a different SLANG_SLANG_LLVM_FLAVOR or set SLANG_SLANG_LLVM_BINARY_URL manually")
213+
message(
214+
FATAL_ERROR
215+
"Unable to find binary release for slang-llvm, please set a different SLANG_SLANG_LLVM_FLAVOR or set SLANG_SLANG_LLVM_BINARY_URL manually"
216+
)
172217
endif()
173218
endif()
174219
endif()
@@ -180,21 +225,23 @@ if(SLANG_SLANG_LLVM_FLAVOR MATCHES FETCH_BINARY)
180225
endif()
181226

182227
set(webgpu_dawn_release_tag "webgpu_dawn-0")
183-
if(CMAKE_SYSTEM_NAME MATCHES "Windows" AND
184-
CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64")
185-
set(
186-
SLANG_WEBGPU_DAWN_BINARY_URL
187-
"https://github.com/shader-slang/dawn/releases/download/${webgpu_dawn_release_tag}/webgpu_dawn-windows-x64.zip"
188-
)
228+
if(
229+
CMAKE_SYSTEM_NAME MATCHES "Windows"
230+
AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64"
231+
)
232+
set(SLANG_WEBGPU_DAWN_BINARY_URL
233+
"https://github.com/shader-slang/dawn/releases/download/${webgpu_dawn_release_tag}/webgpu_dawn-windows-x64.zip"
234+
)
189235
endif()
190236

191237
set(slang_tint_release_tag "slang-tint-0")
192-
if(CMAKE_SYSTEM_NAME MATCHES "Windows" AND
193-
CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64")
194-
set(
195-
SLANG_SLANG_TINT_BINARY_URL
196-
"https://github.com/shader-slang/dawn/releases/download/${slang_tint_release_tag}/slang-tint-windows-x64.zip"
197-
)
238+
if(
239+
CMAKE_SYSTEM_NAME MATCHES "Windows"
240+
AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64"
241+
)
242+
set(SLANG_SLANG_TINT_BINARY_URL
243+
"https://github.com/shader-slang/dawn/releases/download/${slang_tint_release_tag}/slang-tint-windows-x64.zip"
244+
)
198245
endif()
199246

200247
#
@@ -230,7 +277,7 @@ endif()
230277

231278
find_package(Threads REQUIRED)
232279

233-
if (${SLANG_USE_SYSTEM_UNORDERED_DENSE})
280+
if(${SLANG_USE_SYSTEM_UNORDERED_DENSE})
234281
find_package(unordered_dense CONFIG QUIET)
235282
endif()
236283

@@ -273,20 +320,13 @@ add_subdirectory(examples)
273320
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
274321
set(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE ON)
275322
set(CPACK_STRIP_FILES FALSE)
276-
install(FILES
277-
"${slang_SOURCE_DIR}/README.md"
278-
"${slang_SOURCE_DIR}/LICENSE"
279-
DESTINATION .
280-
COMPONENT metadata
281-
EXCLUDE_FROM_ALL
282-
)
283-
install(DIRECTORY
284-
"${slang_SOURCE_DIR}/docs/"
285-
DESTINATION share/doc/slang
286-
)
287-
install(DIRECTORY
288-
"${slang_SOURCE_DIR}/include"
289-
DESTINATION .
323+
install(
324+
FILES "${slang_SOURCE_DIR}/README.md" "${slang_SOURCE_DIR}/LICENSE"
325+
DESTINATION .
326+
COMPONENT metadata
327+
EXCLUDE_FROM_ALL
290328
)
329+
install(DIRECTORY "${slang_SOURCE_DIR}/docs/" DESTINATION share/doc/slang)
330+
install(DIRECTORY "${slang_SOURCE_DIR}/include" DESTINATION .)
291331

292332
include(CPack)

cmake/FetchedSharedLibrary.cmake

+14-13
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,24 @@ function(download_and_extract archive_name url)
99
set(archive_path ${url})
1010
else()
1111
message(STATUS "Fetching ${archive_name} from ${url}")
12-
file(DOWNLOAD ${url} ${archive_path}
13-
# SHOW_PROGRESS
14-
STATUS status
12+
file(
13+
DOWNLOAD ${url} ${archive_path}
14+
# SHOW_PROGRESS
15+
STATUS status
1516
)
1617

1718
list(GET status 0 status_code)
1819
list(GET status 1 status_string)
1920
if(NOT status_code EQUAL 0)
20-
message(WARNING "Failed to download ${archive_name} from ${url}: ${status_string}")
21+
message(
22+
WARNING
23+
"Failed to download ${archive_name} from ${url}: ${status_string}"
24+
)
2125
return()
2226
endif()
2327
endif()
2428

25-
file(ARCHIVE_EXTRACT
26-
INPUT ${archive_path}
27-
DESTINATION ${extract_dir}
28-
)
29+
file(ARCHIVE_EXTRACT INPUT ${archive_path} DESTINATION ${extract_dir})
2930

3031
set(${archive_name}_SOURCE_DIR ${extract_dir} PARENT_SCOPE)
3132
message(STATUS "${archive_name} downloaded and extracted to ${extract_dir}")
@@ -51,10 +52,7 @@ function(copy_fetched_shared_library library_name url)
5152
)
5253
macro(from_glob dir)
5354
# A little helper function
54-
file(
55-
GLOB_RECURSE source_object
56-
"${dir}/${shared_library_filename}"
57-
)
55+
file(GLOB_RECURSE source_object "${dir}/${shared_library_filename}")
5856
list(LENGTH source_object nmatches)
5957
if(nmatches EQUAL 0)
6058
message(
@@ -88,7 +86,10 @@ function(copy_fetched_shared_library library_name url)
8886
elseif(ARG_IGNORE_FAILURE)
8987
return()
9088
else()
91-
message(SEND_ERROR "Unable to download and extract ${library_name} from ${url}")
89+
message(
90+
SEND_ERROR
91+
"Unable to download and extract ${library_name} from ${url}"
92+
)
9293
return()
9394
endif()
9495
endif()

0 commit comments

Comments
 (0)