`target_link_options` should certainly work, and `CMAKE_EXE_LINKER_FLAGS` will also work (the downside is that it applies to all executables).
Can you build with `ninja -v` or `make VERBOSE=1` so you can see the full link command that is being used (if you are not using ninja yet I recommend switching right away). You can then easily see if the `--preload-file` argument is passed to the linker or not. Also, I highly recommend using `--embed-file` over `--preload-file` unless you have a specific reason not to. Embedding files in the binary in more efficient in several ways. cheers, sam On Sun, Dec 14, 2025 at 4:23 PM Sahil Gautam <[email protected]> wrote: > hi, i have been putting together an opengl application and recently i got > to know about Emscripten and wasm, so i got to work to add support for > wasm. i got most of the things working thanks to the demo[2]. most of the > examples (in [2] and elsewhere on the internet) append to > `CMAKE_EXE_LINKER_FLAGS` the wasm specific linker flags including > `--preload-file ... `. i read somewhere while learning cmake "we shouldn't > modify CMAKE_EXE_LINKER_FLAGS directly".. don't remember where i read that. > > so i tried using `target_link_options` but the files don't load and the > .data file isn't created either. i wonder if there's a better way to set > these flags than directly appending to CMAKE_EXE_LINKER_FLAGS and i also > wonder why target_link_options doesn't work. > > i will really appreciate some help. i asked this question on an old github > issue [3] as well, then got the idea of writing to the mailing list. > > regards > sahil gautam > > [1]: https://codeberg.org/printfdebugging/learnopengl > [2]: > https://github.com/pongasoft/emscripten-glfw/blob/master/test/demo/CMakeLists.txt > [3]: > https://github.com/emscripten-core/emscripten/issues/4398#issuecomment-3652385357 > > -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion visit > https://groups.google.com/d/msgid/emscripten-discuss/51dc3253-10d8-4d20-a604-210ab219910cn%40googlegroups.com > <https://groups.google.com/d/msgid/emscripten-discuss/51dc3253-10d8-4d20-a604-210ab219910cn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/emscripten-discuss/CAL_va29LvwOkcmPyZj77kQf5zkRCdBH%2BGCPTqZzikceaa34rVQ%40mail.gmail.com.
