Skip to content

Commit 952d74f

Browse files
authored
Add KTX_FEATURE_JS option controlling whether ktx_js[_read] are built. (#1073)
(Reopening #1072, now targeting `main`) Adds a new CMake option called `KTX_FEATURE_JS`. It defaults to ON, but when set to OFF, `ktx_js` and `ktx_js_read` are not built, even under Emscripten. My use-case for this is compiling [Cesium for Unity](https://github.com/CesiumGS/cesium-unity) for the web. Compiling Unity applications to WebAssembly requires using Unity's version of Emscripten, which is quite old (v3.1.39), and is not able to compile `ktx_js` successfully. This isn't really worth fixing because the JavaScript bindings aren't used in this context anyway. KTX functionality is only called from Emscripten'd native code, never from regular JS code. So with this low-impact PR, it's easy to disable this unnecessary part of the KTX software suite in order to get a successful build. The slightly bigger picture here is to then expose this via a vcpkg feature flag.
1 parent 6765255 commit 952d74f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ option( KTX_FEATURE_JNI "Create Java bindings for libktx." OFF )
4444
option( KTX_FEATURE_PY "Create Python source distribution." OFF )
4545
option( KTX_FEATURE_TESTS "Create unit tests." ON )
4646
option( KTX_FEATURE_TOOLS_CTS "Enable KTX CLI Tools CTS tests (requires CTS submodule)." OFF )
47+
option( KTX_FEATURE_JS "Enable JavaScript bindings in Emscripten builds." ON )
4748

4849
if(KTX_FEATURE_TOOLS_CTS AND NOT KTX_FEATURE_TOOLS)
4950
message(WARNING "KTX_FEATURE_TOOLS is not set -> disabling KTX_FEATURE_TOOLS_CTS.")
@@ -243,7 +244,7 @@ endif()
243244

244245
create_version_file()
245246

246-
if(EMSCRIPTEN)
247+
if(EMSCRIPTEN AND KTX_FEATURE_JS)
247248
set(
248249
KTX_EM_COMMON_LINK_FLAGS
249250
--bind

0 commit comments

Comments
 (0)