-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Description
I’m posting this to clarify the current transition regarding Emscripten support in CMake. This is useful for developers who use emscripten with cmake. It would also help to get the communitiy's needs and wants discussed.
We started working on this really just so that VTK.wasm can be built and distributed as shared libraries. It would be unfair to do this work with just VTK in mind because this undertaking will have a big effect on other projects too.
Native Support (CMake 4.2+): You can build without emcmake by using -DCMAKE_SYSTEM_NAME=Emscripten. This supports the -DBUILD_SHARED_LIBS=ON, provided you pass the correct linker flags (-sSIDE_MODULE=1 for libs, -sMAIN_MODULE=1 for executables).
When to still use emcmake: Upstream support is not yet complete. If you need to find dependencies in the emsdk sysroot (e.g., find_package(OpenGL)) among other things, you must still use the emcmake wrapper. This is tracked upstream in Issue #27460.
Relevant MRs:
cmake/cmake#10832 (Platform modules)
cmake/cmake#11206 (Drop hard-coded flags)
cmake/cmake#11204 (support downstream toolchain)
Mega issue upstream:
cmake/cmake!18423