cmake_modules/FindEmscripten.cmake
changeset 11659 870f22de388b
equal deleted inserted replaced
11658:ef625fe6eaaa 11659:870f22de388b
       
     1 # - Try to find the Clang/LLVM executable
       
     2 # Once done this will define
       
     3 #
       
     4 #  EMSCRIPTEN_FOUND       - system has Clang
       
     5 #  EMSCRIPTEN_VERSION     - Clang version
       
     6 #  EMSCRIPTEN_EXECUTABLE  - Clang executable
       
     7 #
       
     8 # Copyright (c) 2013, Vittorio Giovara <vittorio.giovara@gmail.com>
       
     9 #
       
    10 # Redistribution and use is allowed according to the terms of the BSD license.
       
    11 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
       
    12 
       
    13 find_program(EMSCRIPTEN_EXECUTABLE
       
    14         NAMES emcc
       
    15         PATHS /opt/local/bin /usr/local/bin /usr/bin)
       
    16 
       
    17 if (EMSCRIPTEN_EXECUTABLE)
       
    18     execute_process(COMMAND ${EMSCRIPTEN_EXECUTABLE} -v
       
    19                     OUTPUT_VARIABLE EMSCRIPTEN_VERSION_OUTPUT
       
    20                     ERROR_VARIABLE EMSCRIPTEN_VERSION_ERROR
       
    21                     RESULT_VARIABLE EMSCRIPTEN_VERSION_RESULT
       
    22                     OUTPUT_STRIP_TRAILING_WHITESPACE
       
    23                     )
       
    24 
       
    25     if(${EMSCRIPTEN_VERSION_RESULT} EQUAL 0)
       
    26         string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" EMSCRIPTEN_VERSION "${EMSCRIPTEN_VERSION_OUTPUT}")
       
    27         string(REGEX REPLACE "([0-9]+\\.[0-9]+\\.[0-9]+)" "\\1" EMSCRIPTEN_VERSION "${EMSCRIPTEN_VERSION}")
       
    28     else()
       
    29         message(SEND_ERROR "Command \"${EMSCRIPTEN_EXECUTABLE} --version\" failed with output: ${EMSCRIPTEN_VERSION_ERROR}")
       
    30     endif()
       
    31 endif()
       
    32 
       
    33 include(FindPackageHandleStandardArgs)
       
    34 find_package_handle_standard_args(Emscripten DEFAULT_MSG EMSCRIPTEN_EXECUTABLE EMSCRIPTEN_VERSION)
       
    35 mark_as_advanced(EMSCRIPTEN_VERSION)
       
    36