building with ninja and looking closely at the output revealed what's going on. [1] is the output with two `--embed-file path` linker flags appended to `CMAKE_EXE_LINKER_FLAGS`, and [2] is the output for the same done with `target_link_options`. as you can see, [2] clubs both of them together but emcc expected `--embed-file` to just have one argument (if i can call it that). my mistake was that i didn't read the output carefully (i was rushing towards the solution <-- real mistake). what i did to "fix" this was to add quotes around `--embed-file ..@..` linker flags, the quotes made it to the final command [3]. i thought in cmake everything (arguments) is a string, so adding quotes won't hurt.
so now i have to figure out how to pass multiple --embed-file flags to the linker. each tutorial's executable in [0] has it's own assets + the project's assets, so i need atleast two --embed-file flags. searching and reading a bit on the internet, i found [-1] i.e. one can pass a flag as "SHELL:..." and the flag would be passed as a shell string. [-2] explains it well. it works!
about ninja, it's cool! i tried looked on the internet ways to set ninja as the default generator inside the cmake file (so that i don't have to use -G). all i could find was that i can set CMAKE_GENERATOR environment variable. i then thought of editing the environment varialbe from the cmake file, but that didn't do anything `set(ENV{CMAKE_GENERATOR} "Ninja")`. so for now am setting it in the zshrc.
[-1]:
https://gitlab.kitware.com/cmake/cmake/-/issues/15826#note_386473[1]:
```
[79/79] : && /usr/lib/emscripten/emcc -sMAX_WEBGL_VERSION=2 -sNO_DISABLE_EXCEPTION_CATCHING -sASSERTIONS=1 -sWASM=1 -sSAFE_HEAP=1 --embed-file /home/printfdebugging/repos/learnopengl/source/tutorials/hello-triangle/assets@LearnOpenGL/hello-triangle/assets/ --embed-file /home/printfdebugging/repos/learnopengl/assets@LearnOpenGL/assets/ -lGL --js-library /home/printfdebugging/repos/learnopengl/libs/emscripten-glfw/src/js/lib_emscripten_glfw3.js source/tutorials/hello-triangle/CMakeFiles/hello-triangle.dir/source/main.c.o -o source/tutorials/hello-triangle/hello-triangle.html source/core/libcore.a source/loader/libloader.a libs/glad/libglad.a libs/emscripten-glfw/libglfw3.a libs/cglm/libcglm.a cmake/stb/libstb_image.a cmake/stb/libstb_include.a && :
```
[2]:
```
[79/79] : && /usr/lib/emscripten/emcc -sMAX_WEBGL_VERSION=2 -sNO_DISABLE_EXCEPTION_CATCHING -sASSERTIONS=1 -sWASM=1 -sSAFE_HEAP=1 --embed-file /home/printfdebugging/repos/learnopengl/assets@LearnOpenGL/assets/ /home/printfdebugging/repos/learnopengl/source/tutorials/hello-triangle/assets@LearnOpenGL/hello-triangle/assets/ -lGL --js-library /home/printfdebugging/repos/learnopengl/libs/emscripten-glfw/src/js/lib_emscripten_glfw3.js source/tutorials/hello-triangle/CMakeFiles/hello-triangle.dir/source/main.c.o -o source/tutorials/hello-triangle/hello-triangle.html source/core/libcore.a source/loader/libloader.a libs/glad/libglad.a libs/emscripten-glfw/libglfw3.a libs/cglm/libcglm.a cmake/stb/libstb_image.a cmake/stb/libstb_include.a && :
FAILED: [code=1] source/tutorials/hello-triangle/hello-triangle.html
: && /usr/lib/emscripten/emcc -sMAX_WEBGL_VERSION=2 -sNO_DISABLE_EXCEPTION_CATCHING -sASSERTIONS=1 -sWASM=1 -sSAFE_HEAP=1 --embed-file /home/printfdebugging/repos/learnopengl/assets@LearnOpenGL/assets/ /home/printfdebugging/repos/learnopengl/source/tutorials/hello-triangle/assets@LearnOpenGL/hello-triangle/assets/ -lGL --js-library /home/printfdebugging/repos/learnopengl/libs/emscripten-glfw/src/js/lib_emscripten_glfw3.js source/tutorials/hello-triangle/CMakeFiles/hello-triangle.dir/source/main.c.o -o source/tutorials/hello-triangle/hello-triangle.html source/core/libcore.a source/loader/libloader.a libs/glad/libglad.a libs/emscripten-glfw/libglfw3.a libs/cglm/libcglm.a cmake/stb/libstb_image.a cmake/stb/libstb_include.a && :
emcc: error: /home/printfdebugging/repos/learnopengl/source/tutorials/hello-triangle/assets@LearnOpenGL/hello-triangle/assets/: No such file or directory ("/home/printfdebugging/repos/learnopengl/source/tutorials/hello-triangle/assets@LearnOpenGL/hello-triangle/assets/" was expected to be an input file, based on the commandline arguments provided)
ninja: build stopped: subcommand failed.
```
[3]:
```
[79/79] : && /usr/lib/emscripten/emcc -sMAX_WEBGL_VERSION=2 -sNO_DISABLE_EXCEPTION_CATCHING -sASSERTIONS=1 -sWASM=1 -sSAFE_HEAP=1 "--embed-file /home/printfdebugging/repos/learnopengl/assets@LearnOpenGL/assets/" "--embed-file /home/printfdebugging/repos/learnopengl/source/tutorials/hello-triangle/assets@LearnOpenGL/hello-triangle/assets/" -lGL --js-library /home/printfdebugging/repos/learnopengl/libs/emscripten-glfw/src/js/lib_emscripten_glfw3.js source/tutorials/hello-triangle/CMakeFiles/hello-triangle.dir/source/main.c.o -o source/tutorials/hello-triangle/hello-triangle.html source/core/libcore.a source/loader/libloader.a libs/glad/libglad.a libs/emscripten-glfw/libglfw3.a libs/cglm/libcglm.a cmake/stb/libstb_image.a cmake/stb/libstb_include.a && :
```