Skip to content
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

Emscripten SDL2 / WebGL linker flags don't work when using Magnum as CMake subproject #219

Closed
mosra opened this Issue Oct 9, 2017 · 2 comments

Comments

Projects
1 participant
@mosra
Copy link
Owner

mosra commented Oct 9, 2017

Because there's no such thing as INTERFACE_LINK_OPTIONS in CMake yet
(https://gitlab.kitware.com/cmake/cmake/issues/16543), FindMagnum.cmake modifies the global CMAKE_EXE_LINKER_FLAGS to add -s USE_WEBGL2=1 or -s USE_SDL=2 to linker command line. To make things worse, the flags have a space in them so one can't even abuse INTERFACE_LINK_LIBRARIES to send the options to linker (CMake treats entries starting with - as flags instead of libraries).

To have things clean, FindMagnum.cmake modifies the global flags only when given target (Magnum::Magnum or Magnum::Sdl2Application) doesn't exist yet, which means in case Magnum is used as CMake subproject, the flags are not modified at all, causing linker issues.

Putting it here so I don't forget the particulars later. First I wanted to solve this for #218 but I need to invent some solution that doesn't make me angry first.

@mosra mosra added bug labels Oct 9, 2017

@mosra mosra self-assigned this Oct 9, 2017

@mosra mosra added this to TODO in Platforms Nov 5, 2017

@mosra mosra removed buildsystem labels Sep 26, 2018

@mosra mosra removed the bug label Oct 23, 2018

@mosra mosra added this to the 2019.0b milestone Mar 7, 2019

@mosra

This comment has been minimized.

Copy link
Owner Author

mosra commented Mar 7, 2019

Both things seem to be fixed since 3.12:

I'll look into fixing this, together with inventing some (considerably uglier) workaround for earlier versions. CMake 3.7 is the minimum required for Emscripten at the moment and it's also the version shipped in Debian 9, so it'd be nice to keep support for it, instead of forcing everyone to 3.12.

Cc: @FeraiAli

@mosra

This comment has been minimized.

Copy link
Owner Author

mosra commented Mar 12, 2019

Wow, this took a while.

  • the basics, described in this issue, are done in 447fa84. You need to update your copies of FindMagnum.cmake and FindOpenGLES3.cmake; if you can use CMake 3.13 and newer the flags will get passed cleanly via interface of the OpenGLES3::OpenGLES3 target, otherwise the global CMAKE_EXE_LINKER_FLAGS will get modified.
  • problems related to MAGNUM_WEBAPPLICATION_CSS etc. are fixed since mosra/corrade@b916755 and 4b29f64, no need to specify them manually anymore

I tested on a minimal project using CMake subprojects and everything seemed to work correctly with both CMake 3.13 and older versions. However, while upgrading to 1.38.27, I discovered a few more issues:

  • the -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 warning is fixed in 39678da. I traded maintainability for a backwards-incompatible change, so you need to update the HTML markup (and potentially also the JS/CSS files) as described in the changelog
  • adapted the code to Pointer_stringify() removal in 1.38.27 in 80f37d5
  • and fixed EGL context creation for WebGL 2 in 76870e7

@FeraiAli since it's quite a lot changes, ping me again if you have any issues related to this ;)

@mosra mosra closed this Mar 12, 2019

Platforms automation moved this from TODO to Done Mar 12, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.