CMakeLists.txt : clang++ generating WASM ?

I am looking into direct generation of *.wasm via clang/clang++ (currently using 17)

My usage experience with CMake has generally been generating *.o, *.so and executable.

I do have a Makefile way of doing things (clang → WASM) but was hoping to leverage CMake if possible.

I am aware of the existence of emscripten-cmake however, I am not using the emscripten approach.

Cheers

not using the emscripten approach

You mean, you’d like to compile a C++ project into WebAssembly without using Emscripten compiler? I would actually be curious to learn how does one do that.

I have an example project for the “opposite” case - that is with using Emscripten compiler - but looks like it won’t be of interest for you then.

My use case and requirements fit within the above, YMMV.

It looks like a toolchain file would be needed. There, you can set the executable extension to .wasm (as it is linker output that is WASM-loadable, not the .o file). You can probably start from an Emscripten toolchain and adapt it as needed.