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. 22
      src/Magnum/Platform/CMakeLists.txt

6
doc/changelog.dox

@ -246,6 +246,12 @@ See also:
using a static build of SDL2 on Linux using a static build of SDL2 on Linux
- `FindSDL2.cmake` is now able to properly find a debug build of SDL, which - `FindSDL2.cmake` is now able to properly find a debug build of SDL, which
enables Vcpkg to properly copy all dependency DLLs on Windows 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 - @ref Trade::ObjImporter "ObjImporter" didn't work with CMake subprojects
due to an embarrassing typo (see due to an embarrassing typo (see
[mosra/magnum#259](https://github.com/mosra/magnum/issues/259)) [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 - `MAGNUM_PLUGINS_AUDIOIMPORTER[|_DEBUG|_RELEASE]_DIR` --- Directory with
dynamic audio importer plugins 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 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 components. The base library depends on @ref corrade-cmake Corrade and OpenGL
libraries (or OpenGL ES libraries). Additional dependencies are specified by 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, application. Template one is below. The markup references two files,
`EmscriptenApplication.js` and `WebApplication.css`, both are in the `EmscriptenApplication.js` and `WebApplication.css`, both are in the
[src/Magnum/Platform/](https://github.com/mosra/magnum/tree/master/src/Magnum/Platform) [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 directory in the source tree, are also put into `share/magnum/` inside your
install prefix. 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} @code{.html-jinja}
<!DOCTYPE html> <!DOCTYPE html>
@ -160,8 +162,8 @@ if(CORRADE_TARGET_EMSCRIPTEN)
install(TARGETS my-application DESTINATION ${CMAKE_INSTALL_PREFIX}) install(TARGETS my-application DESTINATION ${CMAKE_INSTALL_PREFIX})
install(FILES install(FILES
my-application.html my-application.html
EmscriptenApplication.js ${MAGNUM_EMSCRIPTENAPPLICATION_JS}
WebApplication.css ${MAGNUM_WEBAPPLICATION_CSS}
DESTINATION ${CMAKE_INSTALL_PREFIX}) DESTINATION ${CMAKE_INSTALL_PREFIX})
install(FILES install(FILES
${CMAKE_CURRENT_BINARY_DIR}/my-application.js.mem ${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 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 that it shows the console output instead of the canvas. The markup references
two files, `WindowlessEmscriptenApplication.js` and `WebApplication.css`, both two files, `WindowlessEmscriptenApplication.js` and `WebApplication.css`, both
are in the [src/Magnum/Platform/](https://github.com/mosra/magnum/tree/master/src/Magnum/Platform) are again 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 directory in the source tree, are put into `share/magnum/` inside your
install prefix. install prefix and available through `MAGNUM_WINDOWLESSEMSCRIPTENAPPLICATION_JS`
and `MAGNUM_WEBAPPLICATION_CSS` CMake variables.
@code{.html-jinja} @code{.html-jinja}
<!DOCTYPE html> <!DOCTYPE html>
@ -256,8 +259,8 @@ if(CORRADE_TARGET_EMSCRIPTEN)
install(TARGETS my-application DESTINATION ${CMAKE_INSTALL_PREFIX}) install(TARGETS my-application DESTINATION ${CMAKE_INSTALL_PREFIX})
install(FILES install(FILES
my-application.html my-application.html
WindowlessEmscriptenApplication.js ${MAGNUM_WINDOWLESSEMSCRIPTENAPPLICATION_JS}
WebApplication.css ${MAGNUM_WEBAPPLICATION_CSS}
DESTINATION ${CMAKE_INSTALL_PREFIX}) DESTINATION ${CMAKE_INSTALL_PREFIX})
install(FILES install(FILES
${CMAKE_CURRENT_BINARY_DIR}/my-application.js.mem ${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 # MAGNUM_PLUGINS_AUDIOIMPORTER[|_DEBUG|_RELEASE]_DIR - Directory with dynamic
# audio importer plugins # 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 # This command will try to find only the base library, not the optional
# components. The base library depends on Corrade and OpenGL libraries (or # components. The base library depends on Corrade and OpenGL libraries (or
# OpenGL ES libraries). Additional dependencies are specified by the # OpenGL ES libraries). Additional dependencies are specified by the
@ -922,10 +930,28 @@ foreach(_component ${Magnum_FIND_COMPONENTS})
endif() endif()
endforeach() 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 # Complete the check with also all components
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Magnum 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) HANDLE_COMPONENTS)
# Create Windowless*Application, *Application and *Context aliases # Create Windowless*Application, *Application and *Context aliases

22
src/Magnum/Platform/CMakeLists.txt

@ -255,20 +255,16 @@ if(WITH_SDL2APPLICATION)
add_library(Magnum::Sdl2Application ALIAS MagnumSdl2Application) add_library(Magnum::Sdl2Application ALIAS MagnumSdl2Application)
endif() 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) if(CORRADE_TARGET_EMSCRIPTEN)
set(MagnumEmscriptenApplication_FILES ) set(MagnumEmscriptenApplication_FILES
if(WITH_SDL2APPLICATION) EmscriptenApplication.js
list(APPEND MagnumEmscriptenApplication_FILES EmscriptenApplication.js) WindowlessEmscriptenApplication.js
endif() WebApplication.css)
if(WITH_WINDOWLESSEGLAPPLICATION)
list(APPEND MagnumEmscriptenApplication_FILES WindowlessEmscriptenApplication.js) list(APPEND MagnumPlatform_FILES ${MagnumEmscriptenApplication_FILES})
endif() install(FILES ${MagnumEmscriptenApplication_FILES} DESTINATION ${MAGNUM_DATA_INSTALL_DIR})
if(WITH_SDL2APPLICATION OR WITH_WINDOWLESSEGLAPPLICATION)
list(APPEND MagnumEmscriptenApplication_FILES WebApplication.css)
list(APPEND MagnumPlatform_FILES ${MagnumEmscriptenApplication_FILES})
install(FILES ${MagnumEmscriptenApplication_FILES} DESTINATION ${MAGNUM_DATA_INSTALL_DIR})
endif()
endif() endif()
# GLX application # GLX application

Loading…
Cancel
Save