Browse Source

CMake: provide paths to Emscripten-specific CSS/JS files.

And install them unconditionally to allow them to be used with
third-party application implementations.
pull/272/head
Vladimír Vondruš 8 years ago
parent
commit
b47db397af
  1. 6
      doc/changelog.dox
  2. 10
      doc/cmake.dox
  3. 21
      doc/platforms-html5.dox
  4. 28
      modules/FindMagnum.cmake
  5. 18
      src/Magnum/Platform/CMakeLists.txt

6
doc/changelog.dox

@ -246,6 +246,12 @@ See also:
using a static build of SDL2 on Linux
- `FindSDL2.cmake` is now able to properly find a debug build of SDL, which
enables Vcpkg to properly copy all dependency DLLs on Windows
- `FindMagnum.cmake` now provides full paths to application JS/CSS files on
@ref platforms-html5 "Emscripten" builds through new `MAGNUM_EMSCRIPTENAPPLICATION_JS`,
`MAGNUM_WINDOWLESSEMSCRIPTENAPPLICATION_JS` and `MAGNUM_WEBAPPLICATION_CSS`
CMake variables. These files are now installed unconditionally even if no
`Platform::*Application` library is built to allow them to be used with
third-party application implementations.
- @ref Trade::ObjImporter "ObjImporter" didn't work with CMake subprojects
due to an embarrassing typo (see
[mosra/magnum#259](https://github.com/mosra/magnum/issues/259))

10
doc/cmake.dox

@ -90,6 +90,16 @@ This module tries to find base Magnum library and then defines:
- `MAGNUM_PLUGINS_AUDIOIMPORTER[|_DEBUG|_RELEASE]_DIR` --- Directory with
dynamic audio importer plugins
If Magnum is built for @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten", the
following variables contain paths to various support files --- see
@ref platforms-html5 for more information about each file:
- `MAGNUM_EMSCRIPTENAPPLICATION_JS` --- Path to the `EmscriptenApplication.js`
file
- `MAGNUM_WINDOWLESSEMSCRIPTENAPPLICATION_JS` --- Path to the
`WindowlessEmscriptenApplication.js` file
- `MAGNUM_WEBAPPLICATION_CSS` --- Path to the `WebApplication.css` file
However, this command will try to find only the base library, not the optional
components. The base library depends on @ref corrade-cmake Corrade and OpenGL
libraries (or OpenGL ES libraries). Additional dependencies are specified by

21
doc/platforms-html5.dox

@ -111,8 +111,10 @@ To target the web browser, you need to provide a HTML markup for your
application. Template one is below. The markup references two files,
`EmscriptenApplication.js` and `WebApplication.css`, both are in the
[src/Magnum/Platform/](https://github.com/mosra/magnum/tree/master/src/Magnum/Platform)
directory in the source tree and are also put into `share/magnum/` inside your
install prefix.
directory in the source tree, are also put into `share/magnum/` inside your
install prefix and if you use CMake, their @ref cmake "full path is available"
through the `MAGNUM_EMSCRIPTENAPPLICATION_JS` and `MAGNUM_WEBAPPLICATION_CSS`
variables.
@code{.html-jinja}
<!DOCTYPE html>
@ -160,8 +162,8 @@ if(CORRADE_TARGET_EMSCRIPTEN)
install(TARGETS my-application DESTINATION ${CMAKE_INSTALL_PREFIX})
install(FILES
my-application.html
EmscriptenApplication.js
WebApplication.css
${MAGNUM_EMSCRIPTENAPPLICATION_JS}
${MAGNUM_WEBAPPLICATION_CSS}
DESTINATION ${CMAKE_INSTALL_PREFIX})
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/my-application.js.mem
@ -209,9 +211,10 @@ Similarly to graphics apps, you need to provide a HTML markup for your
application. Template one is below, its main difference from the one above is
that it shows the console output instead of the canvas. The markup references
two files, `WindowlessEmscriptenApplication.js` and `WebApplication.css`, both
are in the [src/Magnum/Platform/](https://github.com/mosra/magnum/tree/master/src/Magnum/Platform)
directory in the source tree and are also put into `share/magnum/` inside your
install prefix.
are again in the [src/Magnum/Platform/](https://github.com/mosra/magnum/tree/master/src/Magnum/Platform)
directory in the source tree, are put into `share/magnum/` inside your
install prefix and available through `MAGNUM_WINDOWLESSEMSCRIPTENAPPLICATION_JS`
and `MAGNUM_WEBAPPLICATION_CSS` CMake variables.
@code{.html-jinja}
<!DOCTYPE html>
@ -256,8 +259,8 @@ if(CORRADE_TARGET_EMSCRIPTEN)
install(TARGETS my-application DESTINATION ${CMAKE_INSTALL_PREFIX})
install(FILES
my-application.html
WindowlessEmscriptenApplication.js
WebApplication.css
${MAGNUM_WINDOWLESSEMSCRIPTENAPPLICATION_JS}
${MAGNUM_WEBAPPLICATION_CSS}
DESTINATION ${CMAKE_INSTALL_PREFIX})
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/my-application.js.mem

28
modules/FindMagnum.cmake

@ -39,6 +39,14 @@
# MAGNUM_PLUGINS_AUDIOIMPORTER[|_DEBUG|_RELEASE]_DIR - Directory with dynamic
# audio importer plugins
#
# If Magnum is built for Emscripten, the following variables contain paths to
# various support files:
#
# MAGNUM_EMSCRIPTENAPPLICATION_JS - Path to the EmscriptenApplication.js file
# MAGNUM_WINDOWLESSEMSCRIPTENAPPLICATION_JS - Path to the
# WindowlessEmscriptenApplication.js file
# MAGNUM_WEBAPPLICATION_CSS - Path to the WebApplication.css file
#
# This command will try to find only the base library, not the optional
# components. The base library depends on Corrade and OpenGL libraries (or
# OpenGL ES libraries). Additional dependencies are specified by the
@ -922,10 +930,28 @@ foreach(_component ${Magnum_FIND_COMPONENTS})
endif()
endforeach()
# Emscripten-specific files
if(CORRADE_TARGET_EMSCRIPTEN)
find_file(MAGNUM_EMSCRIPTENAPPLICATION_JS EmscriptenApplication.js
PATH_SUFFIXES share/magnum)
find_file(MAGNUM_WINDOWLESSEMSCRIPTENAPPLICATION_JS WindowlessEmscriptenApplication.js
PATH_SUFFIXES share/magnum)
find_file(MAGNUM_WEBAPPLICATION_CSS WebApplication.css
PATH_SUFFIXES share/magnum)
mark_as_advanced(
MAGNUM_EMSCRIPTENAPPLICATION_JS
MAGNUM_WINDOWLESSEMSCRIPTENAPPLICATION_JS
MAGNUM_WEBAPPLICATION_CSS)
set(MAGNUM_EXTRAS_NEEDED
MAGNUM_EMSCRIPTENAPPLICATION_JS
MAGNUM_WINDOWLESSEMSCRIPTENAPPLICATION_JS
MAGNUM_WEBAPPLICATION_CSS)
endif()
# Complete the check with also all components
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Magnum
REQUIRED_VARS MAGNUM_INCLUDE_DIR MAGNUM_LIBRARY
REQUIRED_VARS MAGNUM_INCLUDE_DIR MAGNUM_LIBRARY ${MAGNUM_EXTRAS_NEEDED}
HANDLE_COMPONENTS)
# Create Windowless*Application, *Application and *Context aliases

18
src/Magnum/Platform/CMakeLists.txt

@ -255,21 +255,17 @@ if(WITH_SDL2APPLICATION)
add_library(Magnum::Sdl2Application ALIAS MagnumSdl2Application)
endif()
# JavaScript and CSS stuff for Emscripten
# JavaScript and CSS stuff for Emscripten. Installed unconditionally so it can
# be also used by people who hate the Application classes
if(CORRADE_TARGET_EMSCRIPTEN)
set(MagnumEmscriptenApplication_FILES )
if(WITH_SDL2APPLICATION)
list(APPEND MagnumEmscriptenApplication_FILES EmscriptenApplication.js)
endif()
if(WITH_WINDOWLESSEGLAPPLICATION)
list(APPEND MagnumEmscriptenApplication_FILES WindowlessEmscriptenApplication.js)
endif()
if(WITH_SDL2APPLICATION OR WITH_WINDOWLESSEGLAPPLICATION)
list(APPEND MagnumEmscriptenApplication_FILES WebApplication.css)
set(MagnumEmscriptenApplication_FILES
EmscriptenApplication.js
WindowlessEmscriptenApplication.js
WebApplication.css)
list(APPEND MagnumPlatform_FILES ${MagnumEmscriptenApplication_FILES})
install(FILES ${MagnumEmscriptenApplication_FILES} DESTINATION ${MAGNUM_DATA_INSTALL_DIR})
endif()
endif()
# GLX application
if(WITH_GLXAPPLICATION)

Loading…
Cancel
Save