Skip to content

Commit 5ceef13

Browse files
Fix and document static build (#6374)
* Set static stbi flag for static builds * Add missing SYSTEM directive for external includes * Add instructions for linking statically against slang --------- Co-authored-by: Yong He <yonghe@outlook.com>
1 parent ad69ebd commit 5ceef13

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

cmake/CompilerFlags.cmake

+1
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ function(set_default_compile_options target)
205205
$<$<BOOL:${SLANG_ENABLE_FULL_DEBUG_VALIDATION}>:SLANG_ENABLE_FULL_IR_VALIDATION>
206206
$<$<BOOL:${SLANG_ENABLE_IR_BREAK_ALLOC}>:SLANG_ENABLE_IR_BREAK_ALLOC>
207207
$<$<BOOL:${SLANG_ENABLE_DX_ON_VK}>:SLANG_CONFIG_DX_ON_VK>
208+
$<$<STREQUAL:${SLANG_LIB_TYPE},STATIC>:STB_IMAGE_STATIC>
208209
)
209210

210211
if(SLANG_ENABLE_ASAN)

docs/building.md

+15
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,21 @@ cmake -B build -G Ninja
321321
cmake --build build -j
322322
```
323323

324+
## Static linking against libslang
325+
326+
If linking against a static `libslang.a` you will need to link against some
327+
dependencies also if you're not already incorporating them into your project.
328+
329+
You will need to link against:
330+
331+
```
332+
${SLANG_DIR}/build/Release/lib/libslang.a
333+
${SLANG_DIR}/build/Release/lib/libcompiler-core.a
334+
${SLANG_DIR}/build/Release/lib/libcore.a
335+
${SLANG_DIR}/build/external/miniz/libminiz.a
336+
${SLANG_DIR}/build/external/lz4/build/cmake/liblz4.a
337+
```
338+
324339
## Notes
325340

326341
[^1] below 3.25, CMake lacks the ability to mark directories as being

external/CMakeLists.txt

+10-2
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,19 @@ endif()
8989

9090
# imgui
9191
add_library(imgui INTERFACE)
92-
target_include_directories(imgui INTERFACE "${CMAKE_CURRENT_LIST_DIR}/imgui")
92+
target_include_directories(
93+
imgui
94+
${system}
95+
INTERFACE "${CMAKE_CURRENT_LIST_DIR}/imgui"
96+
)
9397

9498
# stb
9599
add_library(stb INTERFACE)
96-
target_include_directories(stb INTERFACE "${CMAKE_CURRENT_LIST_DIR}/stb")
100+
target_include_directories(
101+
stb
102+
${system}
103+
INTERFACE "${CMAKE_CURRENT_LIST_DIR}/stb"
104+
)
97105

98106
# slang-rhi
99107
if(SLANG_ENABLE_SLANG_RHI)

0 commit comments

Comments
 (0)