enable build for node
authorKai Ninomiya <kainino@chromium.org>
Thu, 15 Aug 2019 00:30:14 +0000 (17:30 -0700)
committerKai Ninomiya <kainino@chromium.org>
Tue, 20 Aug 2019 20:10:53 +0000 (13:10 -0700)
CMakeLists.txt

index 4ebdb21b028b4a361eeb7a58703514db4f1f07e8..6c84ae84dcf6dd3a0a4a6c571856593ff0240c59 100644 (file)
@@ -33,6 +33,7 @@ option(ENABLE_NV_EXTENSIONS "Enables support of Nvidia-specific extensions" ON)
 
 option(ENABLE_GLSLANG_WEB "Reduces glslang to minumum needed for web use" OFF)
 option(ENABLE_EMSCRIPTEN_SINGLE_FILE "If using emscripten, enables SINGLE_FILE build" OFF)
+option(ENABLE_EMSCRIPTEN_ENVIRONMENT_NODE "If using emscripten, builds to run on Node instead of Web" OFF)
 
 CMAKE_DEPENDENT_OPTION(ENABLE_HLSL "Enables HLSL input support" ON "NOT ENABLE_GLSLANG_WEB" OFF)
 
@@ -113,13 +114,20 @@ if(ENABLE_GLSLANG_WEB)
         add_link_options("SHELL: -s FILESYSTEM=0")
         add_link_options("SHELL: --llvm-lto 1")
         add_link_options("SHELL: --closure 1")
-        add_link_options("SHELL: -s ENVIRONMENT=web,worker")
         add_link_options("SHELL: -s ALLOW_MEMORY_GROWTH=1")
 
         add_link_options("SHELL: -s MODULARIZE=1")
         if(ENABLE_EMSCRIPTEN_SINGLE_FILE)
             add_link_options("SHELL: -s SINGLE_FILE=1")
         endif(ENABLE_EMSCRIPTEN_SINGLE_FILE)
+
+        if(ENABLE_EMSCRIPTEN_ENVIRONMENT_NODE)
+            add_link_options("SHELL: -s ENVIRONMENT=node")
+            add_link_options("SHELL: -s BINARYEN_ASYNC_COMPILATION=0")
+        else()
+            add_link_options("SHELL: -s ENVIRONMENT=web,worker")
+            add_link_options("SHELL: -s EXPORT_ES6=1")
+        endif()
     else()
       if(MSVC)
         add_compile_options(/Os /GR-)