mosra / corrade

C++11 multiplatform utility library
https://magnum.graphics/corrade/
Other
484 stars 106 forks source link

corrade_add_test() on Emscripten clashes with CMAKE_CROSSCOMPILING_EMULATOR #185

Open pezcode opened 2 hours ago

pezcode commented 2 hours ago

When CMAKE_CROSSCOMPILING_EMULATOR is set to the path to nodejs, corrade_add_test() finds and prepends nodejs a second time manually to add_test(). This leads to node trying to load its own binary and failing:

/emsdk/node/14.18.2_64bit/bin/node:1 ELF ^ SyntaxError: Invalid or unexpected token

Not sure what "the" correct solution is here. What came to my mind:

The official Emscripten toolchain file sets CMAKE_CROSSCOMPILING_EMULATOR, I think compatibility with it is fairly important. We've been using the Corrade toolchain, but the official one has a few advantages and works well these days, so we'd prefer to use that.

mosra commented 2 hours ago

I think compatibility with it is fairly important

Yes.

but the official one has a few advantages and works well these days

:cry: Anything else I could add to mine, apart from the bloated load of automagic crap that's there?

remove the special handling from UseCorrade.cmake. Might break for some users who rarely update their toolchains.

I'm for this option. Toolchains breakage is fine, it breaks every second Emscripten update anyway. Plus, in many cases people are using a toolchain from within a Corrade submodule, so they get the update implicitly.

Additionally, if you're willing to make a PR for this, you could attempt to do the same treatment for the corrade-rc binary. It's been on my TODO list for a while, to not require an external build of it if CMAKE_CROSSCOMPILING_EMULATOR is set. Related is also https://github.com/mosra/corrade/issues/81.

mosra commented 1 hour ago

Actually, I think the right solution is implementing both options. Especially in combination with corrade-rc being run through Node.js, which is anything but fast.

So, in particular: