Examples for using CMake with Emscripten and Visual Studio 2019
Steps
- Install Visual Studio 2019 with CMake check box. Any version. This should also install Ninja build system.
- Install Emscripten SDK 2.0.11+ recommended
- Start Visual Studio 2019
- In Solution Explorer Tab select the file CMakeSettings.json
- Right click mouse select 'Edit CMake Setting'
- Select 'WASM-Release'
- Select build menu 'Build All'
- Should generate file HelloWASM\MyFirstWASM.html
- Use a http server and open generated file in Web Browser ie localhost:81/MyFirstWASM.html
- Repeat steps for WASM-Debug
- If you have problems check to be sure enviroment variable EMSCRIPTEN is set to correct install path.
Other useful CMAKE variables that can be set in CMakeSettings.json
- CMAKE_EXE_LINKER_FLAGS - command line linker flags
- CMAKE_CXX_FLAGS - command line flags to pass to clang cpp compiler
- CMAKE_C_FLAGS - command line flags to pass to clang for c compiler