Commit 5449381
Guard base-n target against parent-project collision (#184)
### Problem
When JsRuntimeHost is embedded via FetchContent in a parent project that
already declares its own `base-n` INTERFACE target — e.g.
**BabylonNative**, which uses base-n for its Window/Canvas polyfills —
configuring fails:
```
CMake Error at .../jsruntimehost-src/CMakeLists.txt:150 (add_library):
add_library cannot create target "base-n" because another target with the
same name already exists. The existing target is an interface library
created in source directory ".../Dependencies".
```
This surfaced now because the merged File / FileReader polyfill (#169)
switched its base64 encoder over to the `base-n` dependency, and
BabylonNative declares `base-n` before it fetches JsRuntimeHost.
### Fix
Guard the `base-n` block with `NOT TARGET base-n` so that when a parent
project already provides the target, JsRuntimeHost adopts it instead of
redeclaring. This is the standard CMake subproject pattern and mirrors
BabylonNative's own `if(NOT TARGET glslang)` guards. Standalone
JsRuntimeHost builds are unaffected (no pre-existing target → block runs
as before).
### Validation
- Standalone `NAPI_JAVASCRIPT_ENGINE=Chakra` configure + `UnitTests`
build: green, File polyfill + base-n link as before.
- Unblocks BabylonJS/BabylonNative#1706 (the consuming PR that re-pins
to merged main).
Co-authored-by: Branimir Karadzic <branimirkaradzic@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 2fc671b commit 5449381
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
| 148 | + | |
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| |||
0 commit comments