Skip to content

Commit

Permalink
cmake: option to build a static library version of slang (shader-slan…
Browse files Browse the repository at this point in the history
…g#3578)

* cmake: slang lib type setting

* cmake: change name for slang lib type setting

---------

Co-authored-by: Yong He <[email protected]>
  • Loading branch information
fknfilewalker and csyonghe authored Feb 16, 2024
1 parent c639cac commit b50d311
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ option(SLANG_ENABLE_SLANG_GLSLANG "Enable glslang dependency and slang-glslang w
option(SLANG_ENABLE_TESTS "Enable test targets, requires SLANG_ENABLE_GFX, SLANG_ENABLE_SLANGD and SLANG_ENABLE_SLANGRT" ON)
option(SLANG_ENABLE_EXAMPLES "Enable example targets, requires SLANG_ENABLE_GFX" ON)

enum_option(
SLANG_LIB_TYPE
# Default
SHARED
"How to build the slang lib:"
# Options
SHARED
"Build slang as a shared library (default)"
STATIC
"Build slang as a static library"
)

set(SLANG_GENERATORS_PATH
""
CACHE PATH
Expand Down
7 changes: 7 additions & 0 deletions cmake/SlangTarget.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,13 @@ function(slang_add_target dir type)
PUBLIC "${ARG_EXPORT_MACRO_PREFIX}_DYNAMIC"
PRIVATE "${ARG_EXPORT_MACRO_PREFIX}_DYNAMIC_EXPORT"
)
elseif(
target_type STREQUAL STATIC_LIBRARY
)
target_compile_definitions(
${target}
PUBLIC "${ARG_EXPORT_MACRO_PREFIX}_STATIC"
)
endif()
endif()

Expand Down
1 change: 1 addition & 0 deletions docs/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ See the [documentation on testing](../tools/slang-test/README.md) for more infor
| `SLANG_ENABLE_SLANG_GLSLANG` | `TRUE` | Enable glslang dependency and slang-glslang wrapper target |
| `SLANG_ENABLE_TESTS` | `TRUE` | Enable test targets, requires SLANG_ENABLE_GFX, SLANG_ENABLE_SLANGD and SLANG_ENABLE_SLANGRT |
| `SLANG_ENABLE_EXAMPLES` | `TRUE` | Enable example targets, requires SLANG_ENABLE_GFX |
| `SLANG_LIB_TYPE` | `SHARED` | How to build the slang library |
| `SLANG_SLANG_LLVM_FLAVOR` | `FETCH_BINARY` | How to set up llvm support |
| `SLANG_SLANG_LLVM_BINARY_URL` | System dependent | URL specifying the location of the slang-llvm prebuilt library |
| `SLANG_GENERATORS_PATH` | `` | Path to an installed `all-generators` target for cross compilation |
Expand Down
2 changes: 1 addition & 1 deletion source/slang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ target_include_directories(
#
slang_add_target(
.
SHARED
${SLANG_LIB_TYPE}
LINK_WITH_PRIVATE
core
compiler-core
Expand Down

0 comments on commit b50d311

Please sign in to comment.