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

base-emscripten: Use EmscriptenApplication #17

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 12 additions & 39 deletions modules/FindMagnum.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@
# Primitives - Primitives library
# SceneGraph - SceneGraph library
# Shaders - Shaders library
# Shapes - Shapes library
# Text - Text library
# TextureTools - TextureTools library
# Trade - Trade library
# Vk - Vk library
# AndroidApplication - Android application
# EmscriptenApplication - Emscripten application
# GlfwApplication - GLFW application
# GlutApplication - GLUT application
# GlxApplication - GLX application
# Sdl2Application - SDL2 application
# XEglApplication - X/EGL application
Expand Down Expand Up @@ -332,14 +332,12 @@ endif()
set(_MAGNUM_LIBRARY_COMPONENT_LIST
Audio DebugTools GL MeshTools Primitives SceneGraph Shaders Text
TextureTools Trade Vk
AndroidApplication GlfwApplication GlutApplication GlxApplication
AndroidApplication EmscriptenApplication GlfwApplication GlxApplication
Sdl2Application XEglApplication WindowlessCglApplication
WindowlessEglApplication WindowlessGlxApplication WindowlessIosApplication WindowlessWglApplication WindowlessWindowsEglApplication
WindowlessEglApplication WindowlessGlxApplication WindowlessIosApplication
WindowlessWglApplication WindowlessWindowsEglApplication
CglContext EglContext GlxContext WglContext
OpenGLTester)
if(MAGNUM_BUILD_DEPRECATED)
list(APPEND _MAGNUM_LIBRARY_COMPONENT_LIST Shapes)
endif()
set(_MAGNUM_PLUGIN_COMPONENT_LIST
AnyAudioImporter AnyImageConverter AnyImageImporter AnySceneImporter
MagnumFont MagnumFontConverter ObjImporter TgaImageConverter TgaImporter
Expand All @@ -352,20 +350,16 @@ set(_MAGNUM_Audio_DEPENDENCIES )

set(_MAGNUM_DebugTools_DEPENDENCIES )
if(MAGNUM_TARGET_GL)
# MeshTools, Primitives, SceneGraph, Shaders and Shapes are used only for
# GL renderers. All of this is optional, compiled in only if the base
# library was selected.
# MeshTools, Primitives, SceneGraph and Shaders are used only for GL
# renderers. All of this is optional, compiled in only if the base library
# was selected.
list(APPEND _MAGNUM_DebugTools_DEPENDENCIES MeshTools Primitives SceneGraph Shaders Trade GL)
set(_MAGNUM_DebugTools_MeshTools_DEPENDENCY_IS_OPTIONAL ON)
set(_MAGNUM_DebugTools_Primitives_DEPENDENCY_IS_OPTIONAL ON)
set(_MAGNUM_DebugTools_SceneGraph_DEPENDENCY_IS_OPTIONAL ON)
set(_MAGNUM_DebugTools_Shaders_DEPENDENCY_IS_OPTIONAL ON)
set(_MAGNUM_DebugTools_Trade_DEPENDENCY_IS_OPTIONAL ON)
set(_MAGNUM_DebugTools_GL_DEPENDENCY_IS_OPTIONAL ON)
if(MAGNUM_BUILD_DEPRECATED)
list(APPEND _MAGNUM_DebugTools_DEPENDENCIES Shapes)
set(_MAGNUM_DebugTools_Shapes_DEPENDENCY_IS_OPTIONAL ON)
endif()
endif()

set(_MAGNUM_MeshTools_DEPENDENCIES )
Expand Down Expand Up @@ -398,9 +392,6 @@ endif()
set(_MAGNUM_Primitives_DEPENDENCIES Trade)
set(_MAGNUM_SceneGraph_DEPENDENCIES )
set(_MAGNUM_Shaders_DEPENDENCIES GL)
if(MAGNUM_BUILD_DEPRECATED)
set(_MAGNUM_Shapes_DEPENDENCIES SceneGraph)
endif()
set(_MAGNUM_Text_DEPENDENCIES TextureTools)
if(MAGNUM_TARGET_GL)
list(APPEND _MAGNUM_Text_DEPENDENCIES GL)
Expand All @@ -413,13 +404,16 @@ endif()

set(_MAGNUM_Trade_DEPENDENCIES )
set(_MAGNUM_AndroidApplication_DEPENDENCIES GL)
set(_MAGNUM_EmscriptenApplication_DEPENDENCIES GL)
if(MAGNUM_TARGET_GL)
list(APPEND _MAGNUM_EmscriptenApplication_DEPENDENCIES GL)
endif()

set(_MAGNUM_GlfwApplication_DEPENDENCIES )
if(MAGNUM_TARGET_GL)
list(APPEND _MAGNUM_GlfwApplication_DEPENDENCIES GL)
endif()

set(_MAGNUM_GlutApplication_DEPENDENCIES GL)
set(_MAGNUM_GlxApplication_DEPENDENCIES GL)

set(_MAGNUM_Sdl2Application_DEPENDENCIES )
Expand Down Expand Up @@ -646,26 +640,6 @@ foreach(_component ${Magnum_FIND_COMPONENTS})
endif()
endif()

# GLUT application dependencies
elseif(_component STREQUAL GlutApplication)
find_package(GLUT)
set_property(TARGET Magnum::${_component} APPEND PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${GLUT_INCLUDE_DIR})
set_property(TARGET Magnum::${_component} APPEND PROPERTY
INTERFACE_LINK_LIBRARIES ${GLUT_glut_LIBRARY})

# With GLVND (since CMake 3.11) we need to explicitly link to
# GLX because libOpenGL doesn't provide it. Also can't use
# OpenGL_OpenGL_FOUND, because that one is set also if GLVND is
# *not* found. WTF. I don't think GLUT works with EGL, so not
# handling that.
set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL)
if(OPENGL_opengl_LIBRARY)
set_property(TARGET Magnum::${_component} APPEND PROPERTY
INTERFACE_LINK_LIBRARIES OpenGL::GLX)
endif()

# SDL2 application dependencies
elseif(_component STREQUAL Sdl2Application)
find_package(SDL2)
Expand Down Expand Up @@ -846,7 +820,6 @@ foreach(_component ${Magnum_FIND_COMPONENTS})

# No special setup for SceneGraph library
# No special setup for Shaders library
# No special setup for Shapes library

# Text library
elseif(_component STREQUAL Text)
Expand Down
8 changes: 7 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
find_package(Magnum REQUIRED GL Sdl2Application)
find_package(Magnum REQUIRED GL)

if(CORRADE_TARGET_EMSCRIPTEN)
find_package(Magnum REQUIRED EmscriptenApplication)
else()
find_package(Magnum REQUIRED Sdl2Application)
endif()

set_directory_properties(PROPERTIES CORRADE_USE_PEDANTIC_FLAGS ON)

Expand Down
4 changes: 4 additions & 0 deletions src/MyApplication.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#include <Magnum/GL/DefaultFramebuffer.h>
#ifndef CORRADE_TARGET_EMSCRIPTEN
#include <Magnum/Platform/Sdl2Application.h>
#else
#include <Magnum/Platform/EmscriptenApplication.h>
#endif

using namespace Magnum;

Expand Down