https://github.com/raysan5/raylib/wiki/Working-for-Web-(HTML5)

  1. Download & Setup Emscripten

    Download and install — Emscripten 4.0.11-git (dev) documentation

  2. Compile raylib with Emscripten

    指定交叉编译工具链文件,并且设置变量 PLATFORM = Web。这样 CmakeLists.txt 里面的 if 判断就知道了这一次编译是 Web 的情况

    cmake .. -DCMAKE_TOOLCHAIN_FILE=/Users/leoua7/Apps/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DPLATFORM=Web
    
  3. Compile our game with Emscripten