File size: 1,376 Bytes
739258a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
if(EMSCRIPTEN)
    macro( create_host_index_html filename prog_name)
        file( WRITE ${filename}
"<!doctype html>

<head>

    <meta charset=\"utf-8\">

    <title>${prog_name}</title>

</head>

<body oncontextmenu=\"return false;\">

    <canvas id=\"canvas\" tabindex=-1></canvas>

    <script type=\"text/javascript\">

        var canvas = document.getElementById(\"canvas\");

        canvas.width = window.innerWidth;

        canvas.height = window.innerHeight;

        var Module = {};

        Module.canvas = canvas;

        Module.arguments = ['test://'];

        window.onerror = function(message, source, lineno, colno, error) {

          console.log(Module.pango_get_exception_message(error));

          return false;

        };

        window.addEventListener(\"unhandledrejection\", function(promiseRejectionEvent) {

            console.log(Module.pango_get_exception_message(promiseRejectionEvent.reason));

        });

    </script>

    <script type=\"text/javascript\" src=\"${prog_name}.js\"></script>

</body>

</html>")
    endmacro()

    # Override add_executable to make webpage instead
    macro( add_executable prog_name)
        # Create manifest required for APK
        create_host_index_html("${CMAKE_CURRENT_BINARY_DIR}/index.html" "${prog_name}")
        _add_executable(${prog_name} ${ARGN})
    endmacro()
endif()