Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix and document static build #6374

Merged
merged 4 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmake/CompilerFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ function(set_default_compile_options target)
$<$<BOOL:${SLANG_ENABLE_FULL_DEBUG_VALIDATION}>:SLANG_ENABLE_FULL_IR_VALIDATION>
$<$<BOOL:${SLANG_ENABLE_IR_BREAK_ALLOC}>:SLANG_ENABLE_IR_BREAK_ALLOC>
$<$<BOOL:${SLANG_ENABLE_DX_ON_VK}>:SLANG_CONFIG_DX_ON_VK>
$<$<STREQUAL:${SLANG_LIB_TYPE},STATIC>:STB_IMAGE_STATIC>
)

if(SLANG_ENABLE_ASAN)
Expand Down
15 changes: 15 additions & 0 deletions docs/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,21 @@ cmake -B build -G Ninja
cmake --build build -j
```

## Static linking against libslang

If linking against a static `libslang.a` you will need to link against some
dependencies also if you're not already incorporating them into your project.

You will need to link against:

```
${SLANG_DIR}/build/Release/lib/libslang.a
${SLANG_DIR}/build/Release/lib/libcompiler-core.a
${SLANG_DIR}/build/Release/lib/libcore.a
${SLANG_DIR}/build/external/miniz/libminiz.a
${SLANG_DIR}/build/external/lz4/build/cmake/liblz4.a
```

## Notes

[^1] below 3.25, CMake lacks the ability to mark directories as being
Expand Down
12 changes: 10 additions & 2 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,19 @@ endif()

# imgui
add_library(imgui INTERFACE)
target_include_directories(imgui INTERFACE "${CMAKE_CURRENT_LIST_DIR}/imgui")
target_include_directories(
imgui
${system}
INTERFACE "${CMAKE_CURRENT_LIST_DIR}/imgui"
)

# stb
add_library(stb INTERFACE)
target_include_directories(stb INTERFACE "${CMAKE_CURRENT_LIST_DIR}/stb")
target_include_directories(
stb
${system}
INTERFACE "${CMAKE_CURRENT_LIST_DIR}/stb"
)

# slang-rhi
if(SLANG_ENABLE_SLANG_RHI)
Expand Down
Loading