-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
corrade_add_test() on Emscripten clashes with CMAKE_CROSSCOMPILING_EMULATOR #185
Comments
Yes.
😢 Anything else I could add to mine, apart from the bloated load of automagic crap that's there?
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 |
Actually, I think the right solution is implementing both options. Especially in combination with So, in particular:
|
I began implementing this but ultimately I cannot reproduce the behavior you're describing, at all. The current code in add_test(NAME ${test_name} COMMAND NodeJs::NodeJs ${experimental_wasm_simd} $<TARGET_FILE:${test_name}> ${arguments}) Note the In order to actually make CMake prepend the emulator, I have to change to the following: add_test(NAME ${test_name} COMMAND ${test_name} ${arguments}) But with this I lose the capability to pass arbitrary flags to Node.js, like used to be that flag to enable the SIMD features, and which I suspect I'll need again at some point in the future. So I don't know what exactly is going on in your case, but the behavior I'm seeing at least, feels correct.
|
I'm using the same version here 🍇 We use For completeness sake, I'm testing with Emscripten 3.1.33, and we're on this version of Corrade if it makes a difference. Tests are run with just
No, just cmake with
We use a slightly extended find_program(NODEJS_EXECUTABLE node)
mark_as_advanced(NODEJS_EXECUTABLE)
if(NODEJS_EXECUTABLE)
execute_process(COMMAND ${NODEJS_EXECUTABLE} --version
OUTPUT_VARIABLE NodeJs_VERSION
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NodeJs_VERSION MATCHES "^v[0-9]")
string(SUBSTRING ${NodeJs_VERSION} 1 -1 NodeJs_VERSION)
else()
unset(NodeJs_VERSION)
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(NodeJs
REQUIRED_VARS NODEJS_EXECUTABLE
VERSION_VAR NodeJs_VERSION)
if(NOT TARGET NodeJs::NodeJs)
add_executable(NodeJs::NodeJs IMPORTED)
set_property(TARGET NodeJs::NodeJs PROPERTY IMPORTED_LOCATION ${NODEJS_EXECUTABLE})
endif() |
The only thing that looks related at all is this: https://cmake.org/cmake/help/latest/policy/CMP0158.html But that would only matter if you have that policy enabled (e.g. via |
Woo hoo. So it's indeed only when using their toolchain. Told ya |
In conclusion I think this is a CMake bug, because it shouldn't try to do this for imported targets. In The fix boils down to doing this, which replaces the target with the executable name. diff --git a/modules/UseCorrade.cmake b/modules/UseCorrade.cmake
index 900a63c35..79619fa40 100644
--- a/modules/UseCorrade.cmake
+++ b/modules/UseCorrade.cmake
@@ -504,7 +504,7 @@ function(corrade_add_test test_name)
if(NodeJs_VERSION VERSION_LESS 17)
set(experimental_wasm_simd --experimental-wasm-simd)
endif()
- add_test(NAME ${test_name} COMMAND NodeJs::NodeJs ${experimental_wasm_simd} $<TARGET_FILE:${test_name}> ${arguments})
+ add_test(NAME ${test_name} COMMAND $<TARGET_FILE:NodeJs::NodeJs> ${experimental_wasm_simd} $<TARGET_FILE:${test_name}> ${arguments})
# Embed all files
foreach(file ${files}) |
Thanks for investigating, and great that the fix is so simple 👍 I can't even find much info on what |
The above patch is pushed as d2dd8c4. Besides that, as of 868a502 it's possible to build on Emscripten without having a native corrade-rc available, if |
When
CMAKE_CROSSCOMPILING_EMULATOR
is set to the path to nodejs,corrade_add_test()
finds and prepends nodejs a second time manually toadd_test()
. This leads to node trying to load its own binary and failing:Not sure what "the" correct solution is here. What came to my mind:
CMAKE_CROSSCOMPILING_EMULATOR
in Corrade's toolchain and remove the special handling from UseCorrade.cmake. Might break for some users who rarely update their toolchains.if(NOT CMAKE_CROSSCOMPILING_EMULATOR)
, a bit ugly but it should workThe 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.The text was updated successfully, but these errors were encountered: