From b4693c758e2aa004a3b018c01f764b1dbb6e91fd Mon Sep 17 00:00:00 2001 From: Branimir Karadzic Date: Fri, 5 Jun 2026 10:51:57 -0700 Subject: [PATCH] Guard base-n target creation against parent-project collision When JsRuntimeHost is embedded via FetchContent in a parent project that already declares its own 'base-n' INTERFACE target (e.g. BabylonNative), the unconditional add_library(base-n INTERFACE) here fails with "add_library cannot create target 'base-n' because another target with the same name already exists". Guard the whole block with NOT TARGET base-n so the parent-provided target wins, matching the standard CMake subproject pattern (and BabylonNative's own 'if(NOT TARGET glslang)' guards). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 26e39f0e..d830dd88 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -145,7 +145,7 @@ if(JSRUNTIMEHOST_POLYFILL_XMLHTTPREQUEST) set_property(TARGET UrlLib PROPERTY FOLDER Dependencies) endif() -if(JSRUNTIMEHOST_POLYFILL_FILE) +if(JSRUNTIMEHOST_POLYFILL_FILE AND NOT TARGET base-n) FetchContent_MakeAvailable_With_Message(base-n) add_library(base-n INTERFACE) target_include_directories(base-n INTERFACE "${base-n_SOURCE_DIR}/include")