# How to trigger recompilation on change of emcc --pre-js source files?

**URL:** https://discourse.cmake.org/t/how-to-trigger-recompilation-on-change-of-emcc-pre-js-source-files/15669
**Category:** Usage
**Created:** [May 27, 2026, 8:17am UTC](https://discourse.cmake.org/t/how-to-trigger-recompilation-on-change-of-emcc-pre-js-source-files/15669 "2026-05-27T08:17:03Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Shane](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/dbc845/32.png) [@Shane](https://discourse.cmake.org/u/Shane)
#### Post date: [May 27, 2026, 8:17am UTC](https://discourse.cmake.org/t/how-to-trigger-recompilation-on-change-of-emcc-pre-js-source-files/15669/1 "2026-05-27T08:17:04Z")

</div>

Hello,

I have a working `CMakeLists.txt` which uses the [emscripten compiler frontend](https://emscripten.org/docs/tools_reference/emcc.html) (`emcc`). The core source files are written in C++ and when they are changed, `cmake --build` triggers recompilation as expected. `emcc` also accepts auxiliary javascript via the option `--pre-js`. After much experimentation, I found `target_link_options(${PROJECT_NAME} PRIVATE --embed-file assets; -sEXPORT_ES6=1; -sASYNCIFY; --pre-js ${CMAKE_CURRENT_LIST_DIR}/webrtc_check.js)` works but when` webrtc_check.js` changes, `cmake` does not trigger recompilation. Is there a way to solve this problem? Shane

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [May 27, 2026, 7:44pm UTC](https://discourse.cmake.org/t/how-to-trigger-recompilation-on-change-of-emcc-pre-js-source-files/15669/2 "2026-05-27T19:44:40Z")

</div>

Does the [`LINK_DEPENDS`](https://cmake.org/cmake/help/latest/prop_tgt/LINK_DEPENDS.html) target property provide the functionality you’re looking for?

---

<div class="post-metadata">

### Author: ![Shane](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/dbc845/32.png) [@Shane](https://discourse.cmake.org/u/Shane)
#### Post date: [May 28, 2026, 7:06am UTC](https://discourse.cmake.org/t/how-to-trigger-recompilation-on-change-of-emcc-pre-js-source-files/15669/3 "2026-05-28T07:06:38Z")

</div>

> [@craig.scott](#):
>
> [`LINK_DEPENDS`](https://cmake.org/cmake/help/latest/prop_tgt/LINK_DEPENDS.html)

Thanks Craig!

This addition to my CMakeList.txt worked perfectly -

`set_target_properties(${PROJECT_NAME} PROPERTIES LINK_DEPENDS ${CMAKE_CURRENT_LIST_DIR}/webrtc_check.js)`
