diff --git a/cmake/Modules/Platform/Emscripten.cmake b/cmake/Modules/Platform/Emscripten.cmake index 1fa0878b21854..d2c413176f2e3 100644 --- a/cmake/Modules/Platform/Emscripten.cmake +++ b/cmake/Modules/Platform/Emscripten.cmake @@ -258,3 +258,14 @@ if ("${CMAKE_GENERATOR}" MATCHES "^Visual Studio.*") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${EMSCRIPTEN_VS_LINKER_FLAGS}" CACHE STRING "") set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${EMSCRIPTEN_VS_LINKER_FLAGS}" CACHE STRING "") endif() + +if (NOT DEFINED CMAKE_CROSSCOMPILING_EMULATOR) + find_program(NODE_JS_EXECUTABLE NAMES nodejs node) + if(NODE_JS_EXECUTABLE) + set(CMAKE_CROSSCOMPILING_EMULATOR "${NODE_JS_EXECUTABLE}" CACHE FILEPATH "Path to the emulator for the target system.") + endif() +endif() +# No-op on CMAKE_CROSSCOMPILING_EMULATOR so older versions of cmake do not +# complain about unused CMake variable. +if(CMAKE_CROSSCOMPILING_EMULATOR) +endif() diff --git a/emcmake b/emcmake index 8a672eeb7e839..7bea9e8d0e313 100755 --- a/emcmake +++ b/emcmake @@ -4,5 +4,6 @@ import os, subprocess, sys from tools import shared configure_path = shared.path_from_root('emconfigure') -exit(subprocess.call([shared.PYTHON, configure_path] + sys.argv[1:])) - +exit(subprocess.call([shared.PYTHON, configure_path] + \ + sys.argv[1] + \ + ['-DCMAKE_CROSSCOMPILING_EMULATOR=' + shared.NODE_JS] + sys.argv[2:]))