Sfoglia il codice sorgente

Use CMake construct instead of '|grep' to determine emcc version.
So that, the detection logic works on Windows host system too.

Yao Wei Tjong 姚伟忠 10 anni fa
parent
commit
cf68e3900e
1 ha cambiato i file con 6 aggiunte e 3 eliminazioni
  1. 6 3
      CMake/Toolchains/emscripten.toolchain.cmake

+ 6 - 3
CMake/Toolchains/emscripten.toolchain.cmake

@@ -42,9 +42,12 @@ if (NOT EXISTS ${EMSCRIPTEN_ROOT_PATH}/emcc)
     message (FATAL_ERROR "Could not find Emscripten cross compilation tool. "
         "Use EMSCRIPTEN_ROOT_PATH environment variable or build option to specify the location of the toolchain.")
 endif ()
-if (NOT EMCC_VERSION AND NOT CMAKE_HOST_WIN32)
-    execute_process (COMMAND ${EMSCRIPTEN_ROOT_PATH}/emcc --version COMMAND grep -oP \\d+\\.\\d+\\.\\d+ RESULT_VARIABLE EXIT_CODE OUTPUT_VARIABLE EMCC_VERSION ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
-    set (EMCC_VERSION ${EMCC_VERSION} CACHE STRING "emcc version on Unix-alike host system")
+if (NOT EMCC_VERSION)
+    execute_process (COMMAND ${EMSCRIPTEN_ROOT_PATH}/emcc --version RESULT_VARIABLE EXIT_CODE OUTPUT_VARIABLE EMCC_VERSION ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
+    if (EXIT_CODE EQUAL 0)
+        string (REGEX MATCH "[^ .]+\\.[^.]+\\.[^ ]+" EMCC_VERSION ${EMCC_VERSION})
+    endif ()
+    set (EMCC_VERSION ${EMCC_VERSION} CACHE STRING "emcc version being used in this build tree")    # Cache the result even when there was error in determining the version
 endif ()
 if (CMAKE_HOST_WIN32)
     set (TOOL_EXT .bat)