summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Lipp <15105596+fknfilewalker@users.noreply.github.com>2024-02-16 06:15:18 +0100
committerGitHub <noreply@github.com>2024-02-15 21:15:18 -0800
commitb50d311b66ec0a7f7122767a8363c896805c2df6 (patch)
tree3cd8b321ad53f7a4a80fd369e1a71922d34e65c8
parentc639cac500893674240dc3aa6f67ef33b6ae3717 (diff)
cmake: option to build a static library version of slang (#3578)
* cmake: slang lib type setting * cmake: change name for slang lib type setting --------- Co-authored-by: Yong He <yonghe@outlook.com>
-rw-r--r--CMakeLists.txt12
-rw-r--r--cmake/SlangTarget.cmake7
-rw-r--r--docs/building.md1
-rw-r--r--source/slang/CMakeLists.txt2
4 files changed, 21 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a295e81a4..8b5683c15 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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
diff --git a/cmake/SlangTarget.cmake b/cmake/SlangTarget.cmake
index 44d6c945c..cb4443d0e 100644
--- a/cmake/SlangTarget.cmake
+++ b/cmake/SlangTarget.cmake
@@ -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()
diff --git a/docs/building.md b/docs/building.md
index 3cac636a1..89ee9a998 100644
--- a/docs/building.md
+++ b/docs/building.md
@@ -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 |
diff --git a/source/slang/CMakeLists.txt b/source/slang/CMakeLists.txt
index cbec1c793..320cd0ce9 100644
--- a/source/slang/CMakeLists.txt
+++ b/source/slang/CMakeLists.txt
@@ -243,7 +243,7 @@ target_include_directories(
#
slang_add_target(
.
- SHARED
+ ${SLANG_LIB_TYPE}
LINK_WITH_PRIVATE
core
compiler-core