CMake project for Emscripten
<p>I want to make CMake and Emscripten friends. Didn't find more or less informative documentation on the Emscripten project website, but they provide CMake toolchain file so I think it should be possible.
So far very basic compilation without advanced parameters works fine, but I have issues while using <code>embind</code> and preloading files.</p>

<ol>
<li>Linking process seems to miss Emscripten "binaries" and produces warnings for all embind related functions like this one: <code>warning: unresolved symbol: _embind_register_class</code> which results in respective errors while loading compiled JS file in rowser.</li>
<li>No <code>.data</code> file is generated during the compilation.</li>
</ol>

<p>I've created a minimalistic example which includes two targets: one "normal" (client) and one manual (manual-client) which simply runs emcc as I expect it to be run: <a href="https://github.com/xwaffelx/minimal-cmake-emscripten-project/blob/master/README.md" rel="noreferrer">https://github.com/xwaffelx/minimal-cmake-emscripten-project/blob/master/README.md</a></p>

<p>Although manual way works, I don't think it is a proper way to do it...</p>

<p>--- Update ---</p>

<p>As requested, here is even more short example:</p>

<ol>
<li>CMakeLists.txt file
<pre><code>cmake_minimum_required(VERSION 2.8)
cmake_policy(SET CMP0015 NEW)
project(emtest)
set(CMAKE_VERBOSE_MAKEFILE on)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/build.emscripten)
include_directories("lib/assimp/include")
link_directories("lib/assimp/lib-js")
link_libraries("assimp")
file(GLOB_RECURSE CORE_HDR src/<em>.h)
file(GLOB_RECURSE CORE_SRC src/</em>.cpp)
add_definitions("-s DEMANGLE_SUPPORT=1 --preload-file ${CMAKE_SOURCE_DIR}/assets --bind")
add_executable(client ${CORE_SRC} ${CORE_HDR})
</pre></code></li>
</ol>

<p>Result should be equivalent to running the following command manualy:
<pre><code>emcc 
    -Ilib/assimp/include 
    -s DEMANGLE_SUPPORT=1
    --preload-file assets
    --bind
    Application.cpp 
    lib/assimp/lib-js/libassimp.so 
    -o client.js</pre></code></p>

<p>Here is the Application.cpp:</p>

<pre><code>#include "Application.h"

#include &lt;iostream&gt;

#include &lt;assimp/Importer.hpp&gt;
#include &lt;assimp/scene.h&gt;
#include &lt;assimp/postprocess.h&gt;

void Application::Initialize() {
    std::cout &lt;&lt; "Initializing application." &lt;&lt; std::endl;
    Assimp::Importer importer; // For test purpose
}

void Application::SayHello() {
    std::cout &lt;&lt; "Hello!" &lt;&lt; std::endl;
}
</code></pre>

<p>and Application.h:</p>

<pre><code>#ifndef APPLICATION_H
#define APPLICATION_H

#include &lt;emscripten/html5.h&gt;
#include &lt;emscripten/bind.h&gt;

namespace e = emscripten;

class Application {
public:
    void Initialize();
    void SayHello();
};

EMSCRIPTEN_BINDINGS(EMTest) {
  e::class_&lt;Application&gt;("Application")
    .constructor()
      .function("Initialize", &amp;Application::Initialize)
      .function("SayHello", &amp;Application::SayHello);
}

#endif
</code></pre>

<p>THen I run cmake as follows:
<code>cmake -DCMAKE_TOOLCHAIN_PATH=path/to/Emscripten.cmake .. &amp;&amp; make</code>
However, warnings like <code>warning: unresolved symbol: _embind_register_class</code> are produced during linking and running the code and no preloaded data in <code>client.data</code> file is created while compiling CMake project. At the same time no warnings and everything runs OK while compiling manually.</p>