@@ -28,6 +28,14 @@ FetchContent_Declare(CMakeExtensions
2828FetchContent_Declare (googletest
2929 URL "https://github.com/google/googletest/archive/refs/tags/v1.17.0.tar.gz"
3030 EXCLUDE_FROM_ALL )
31+ FetchContent_Declare (hermes
32+ GIT_REPOSITORY https://github.com/facebook/hermes.git
33+ # Pinned to the tip of the `static_h` branch as of 2026-06-03 so CI is
34+ # reproducible. Bump this SHA when you intentionally want to pick up
35+ # upstream Hermes changes — keep it on the static_h branch (Static
36+ # Hermes is the variant our NAPI integration targets).
37+ GIT_TAG 348582831f50954895da8e80cc91112d51036c69
38+ EXCLUDE_FROM_ALL )
3139FetchContent_Declare (ios -cmake
3240 GIT_REPOSITORY https://github.com/leetal/ios -cmake.git
3341 GIT_TAG 4.4.1
@@ -144,6 +152,33 @@ if(BABYLON_DEBUG_TRACE)
144152 add_definitions (-DBABYLON_DEBUG_TRACE )
145153endif ()
146154
155+ if (NAPI_JAVASCRIPT_ENGINE STREQUAL "Hermes" )
156+ # Configure Hermes static_h options BEFORE making it available so that
157+ # cache variables take effect. We disable the parts of Hermes we don't
158+ # need (the unit-test suite, debugger) to keep build time reasonable and
159+ # to avoid pulling extra targets into our build tree. Notably we leave
160+ # HERMES_ENABLE_NAPI ON (the default) — that's the whole point of
161+ # integrating Hermes here.
162+ #
163+ # HERMES_ENABLE_TOOLS must stay ON: even when HERMES_ENABLE_TEST_SUITE is
164+ # OFF, Hermes unconditionally adds external/node-api-cts and
165+ # external/node-api-tests whenever HERMES_ENABLE_NAPI is on, and those
166+ # subdirectories reference the `hermes` CLI tool target via
167+ # $<TARGET_FILE:hermes>. CMake fails to generate if the target doesn't
168+ # exist, so we let Hermes build its tools. None of them ship in our
169+ # final binaries because they're EXCLUDE_FROM_ALL via FetchContent.
170+ set (HERMES_ENABLE_TOOLS ON CACHE BOOL "" FORCE )
171+ set (HERMES_ENABLE_TEST_SUITE OFF CACHE BOOL "" FORCE )
172+ set (HERMES_ENABLE_DEBUGGER OFF CACHE BOOL "" FORCE )
173+ set (HERMES_BUILD_APPLE_FRAMEWORK OFF CACHE BOOL "" FORCE )
174+ set (HERMES_ENABLE_NAPI ON CACHE BOOL "" FORCE )
175+ # Hermes ships its own bundled gtest as `llvh-gtest` (a different
176+ # CMake target name from googletest's `gtest`), so the two coexist
177+ # without clashing. We never link llvh-gtest into our UnitTests
178+ # executable, so there's no duplicate-symbol issue at link time.
179+ FetchContent_MakeAvailable_With_Message (hermes )
180+ endif ()
181+
147182if (NAPI_JAVASCRIPT_ENGINE STREQUAL "V8" AND JSRUNTIMEHOST_CORE_APPRUNTIME_V8_INSPECTOR)
148183 FetchContent_MakeAvailable_With_Message (asio )
149184 add_library (asio INTERFACE )
0 commit comments