samdauwe / BabylonCpp

A port of Babylon.js to C++
Apache License 2.0
284 stars 37 forks source link

Fix emscripten #78

Closed pthom closed 4 years ago

pthom commented 4 years ago

This PR fixes the emscripten build. BabylonStudio now runs correctly again under emscripten.

It should also fix the CI error in SamplesTest.

Notes:

New dependencies

It adds 2 new dependencies:

CMake exports

I disabled the exports inside BabylonCpp/CMakeLists. The original implementation was using old cmake style variables and made it impossible to use transitive dependencies.

We will need to study this subject later, but the current implementation was making it difficult to write concise cmake files.

See commit https://github.com/samdauwe/BabylonCpp/commit/f13bfa4abb06e6ddd174af226c0f2714463d4406

babylon/core/log_trace.h:

It enables to add traces to a cpp file: this is expecially useful for emscripten where debugging via trace is often the most efficient way to debug (alas...)

It is activated manually per cpp file.

In order to use it in a cpp file, you need to 1/ #define BABYLON_LOG_TRACE_ON and 2/ #include <babylon/core/log_trace.h:> in this file. Then you can use the macros

In order to disable it for this file, just comment out #define BABYLON_LOG_TRACE_ON in this file

Windows dll linking

I had to fight some more in order to solve some dll linking errors under windows.

samdauwe commented 4 years ago

Good news that BabylonStudio runs correctly again under emscripten! Thanks for the PR and the extra information!

samdauwe commented 4 years ago

Hello Pascal,

The changes that were made related to the exports inside the CMake files were not compatible with recent CMake versions (like you can see in the CI for Linux/OSX and Windows).

I could not quickly resolve the issues so I had to restore the CMake files to their previous version to get a functional master branch. I can have a look at them later if needed.

Cheers, Sam