1 include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
2 find_program(EMSDK_EXECUTABLE NAMES emsdk HINTS ENV EMSDK)
3 mark_as_advanced(EMSDK_EXECUTABLE)
5 if(EXISTS "${EMSDK_EXECUTABLE}")
6 get_filename_component(EMSDK ${EMSDK_EXECUTABLE} DIRECTORY)
15 find_program(EMCC_EXECUTABLE NAMES emcc${EMCC_SUFFIX} HINTS ${EMSDK}/upstream/emscripten)
16 mark_as_advanced(EMCC_EXECUTABLE)
18 find_program(EMXX_EXECUTABLE NAMES em++${EMCC_SUFFIX} HINTS ${EMSDK}/upstream/emscripten)
19 mark_as_advanced(EMXX_EXECUTABLE)
21 find_program(EMAR_EXECUTABLE NAMES emar${EMCC_SUFFIX} HINTS ${EMSDK}/upstream/emscripten)
22 mark_as_advanced(EMAR_EXECUTABLE)
24 find_program(EMRANLIB_EXECUTABLE NAMES emranlib${EMCC_SUFFIX} HINTS ${EMSDK}/upstream/emscripten)
25 mark_as_advanced(EMRANLIB_EXECUTABLE)
27 if(EXISTS "${EMCC_EXECUTABLE}")
28 execute_process(COMMAND ${EMCC_EXECUTABLE} -v ERROR_VARIABLE EMSCRIPTEN_VERSION OUTPUT_QUIET)
29 string(REGEX REPLACE ".+clang[^0-9]+([^\n ]+).*" "\\1" EMSDK_COMPILER_VERSION "${EMSCRIPTEN_VERSION}")
30 string(REGEX REPLACE "emcc \\(.*\\) ([^\n ]+).*" "\\1" EMSCRIPTEN_VERSION "${EMSCRIPTEN_VERSION}")
33 find_program(EM_CONFIG_EXECUTABLE NAMES em-config${EMCC_SUFFIX} HINTS ${EMSDK}/upstream/emscripten)
34 mark_as_advanced(EM_CONFIG_EXECUTABLE)
35 if(EXISTS "${EM_CONFIG_EXECUTABLE}")
36 execute_process(COMMAND ${EM_CONFIG_EXECUTABLE} CACHE
37 OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE EMSCRIPTEN_SYSROOT
39 file(TO_CMAKE_PATH "${EMSCRIPTEN_SYSROOT}" EMSCRIPTEN_SYSROOT)
40 set(EMSCRIPTEN_SYSROOT "${EMSCRIPTEN_SYSROOT}/sysroot")
41 execute_process(COMMAND ${EM_CONFIG_EXECUTABLE} NODE_JS
42 OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE NODE_JS
44 string(REGEX REPLACE ".+'([^']+)'.+" "\\1" NODE_JS "${NODE_JS}")
45 if(EXISTS "${NODE_JS}")
46 set(NODE_JS_EXECUTABLE ${NODE_JS} CACHE FILEPATH "Path to a program.")
51 find_program(NODE_JS_EXECUTABLE NAMES nodejs node HINTS ENV EMSDK_NODE)
52 mark_as_advanced(NODE_JS_EXECUTABLE)
54 find_package_handle_standard_args(Emscripten