Skip to content

Commit

Permalink
Copy Emscripten boilerplate right next to the built executables.
Browse files Browse the repository at this point in the history
So these can be run directly from the build dir.
  • Loading branch information
mosra committed Oct 22, 2019
1 parent d64c155 commit 09d5e01
Show file tree
Hide file tree
Showing 12 changed files with 132 additions and 12 deletions.
12 changes: 11 additions & 1 deletion src/arealights/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,18 @@ if(CORRADE_TARGET_EMSCRIPTEN)
MagnumPlugins::StbTrueTypeFont)
endif()

# Installation for Emscripten
# For Emscripten copy the boilerplate next to the executable so it can be run
# directly from the build dir; provide an install target as well
if(CORRADE_TARGET_EMSCRIPTEN)
add_custom_command(TARGET magnum-arealights POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${MAGNUM_EMSCRIPTENAPPLICATION_JS}
${MAGNUM_WEBAPPLICATION_CSS}
$<TARGET_FILE_DIR:magnum-arealights>
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/arealights.html
$<TARGET_FILE_DIR:magnum-arealights>/magnum-arealights.html)

install(FILES arealights.html DESTINATION ${MAGNUM_DEPLOY_PREFIX}/arealights RENAME index.html)
install(TARGETS magnum-arealights DESTINATION ${MAGNUM_DEPLOY_PREFIX}/arealights)
install(FILES
Expand Down
12 changes: 11 additions & 1 deletion src/audio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,18 @@ if(CORRADE_TARGET_EMSCRIPTEN)
MagnumPlugins::StbVorbisAudioImporter)
endif()

# Installation for Emscripten
# For Emscripten copy the boilerplate next to the executable so it can be run
# directly from the build dir; provide an install target as well
if(CORRADE_TARGET_EMSCRIPTEN)
add_custom_command(TARGET magnum-audio POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${MAGNUM_EMSCRIPTENAPPLICATION_JS}
${MAGNUM_WEBAPPLICATION_CSS}
$<TARGET_FILE_DIR:magnum-audio>
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/audio.html
$<TARGET_FILE_DIR:magnum-audio>/magnum-audio.html)

install(FILES audio.html DESTINATION ${MAGNUM_DEPLOY_PREFIX}/audio RENAME index.html)
install(TARGETS magnum-audio DESTINATION ${MAGNUM_DEPLOY_PREFIX}/audio)
install(FILES
Expand Down
12 changes: 11 additions & 1 deletion src/box2d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,18 @@ target_link_libraries(magnum-box2d PRIVATE
Magnum::Trade
Box2D::Box2D)

# Installation for Emscripten
# For Emscripten copy the boilerplate next to the executable so it can be run
# directly from the build dir; provide an install target as well
if(CORRADE_TARGET_EMSCRIPTEN)
add_custom_command(TARGET magnum-box2d POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${MAGNUM_EMSCRIPTENAPPLICATION_JS}
${MAGNUM_WEBAPPLICATION_CSS}
$<TARGET_FILE_DIR:magnum-box2d>
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/box2d.html
$<TARGET_FILE_DIR:magnum-box2d>/magnum-box2d.html)

install(FILES box2d.html DESTINATION ${MAGNUM_DEPLOY_PREFIX}/box2d RENAME index.html)
install(TARGETS magnum-box2d DESTINATION ${MAGNUM_DEPLOY_PREFIX}/box2d)
install(FILES
Expand Down
12 changes: 11 additions & 1 deletion src/bullet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,18 @@ target_link_libraries(magnum-bullet PRIVATE
Magnum::Trade
MagnumIntegration::Bullet)

# Installation for Emscripten
# For Emscripten copy the boilerplate next to the executable so it can be run
# directly from the build dir; provide an install target as well
if(CORRADE_TARGET_EMSCRIPTEN)
add_custom_command(TARGET magnum-bullet POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${MAGNUM_EMSCRIPTENAPPLICATION_JS}
${MAGNUM_WEBAPPLICATION_CSS}
$<TARGET_FILE_DIR:magnum-bullet>
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/bullet.html
$<TARGET_FILE_DIR:magnum-bullet>/magnum-bullet.html)

install(FILES bullet.html DESTINATION ${MAGNUM_DEPLOY_PREFIX}/bullet RENAME index.html)
install(TARGETS magnum-bullet DESTINATION ${MAGNUM_DEPLOY_PREFIX}/bullet)
install(FILES
Expand Down
12 changes: 11 additions & 1 deletion src/imgui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,18 @@ target_link_libraries(magnum-imgui PRIVATE
Magnum::Magnum
MagnumIntegration::ImGui)

# Installation for Emscripten
# For Emscripten copy the boilerplate next to the executable so it can be run
# directly from the build dir; provide an install target as well
if(CORRADE_TARGET_EMSCRIPTEN)
add_custom_command(TARGET magnum-imgui POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${MAGNUM_EMSCRIPTENAPPLICATION_JS}
${MAGNUM_WEBAPPLICATION_CSS}
$<TARGET_FILE_DIR:magnum-imgui>
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/imgui.html
$<TARGET_FILE_DIR:magnum-imgui>/magnum-imgui.html)

install(FILES imgui.html DESTINATION ${MAGNUM_DEPLOY_PREFIX}/imgui RENAME index.html)
install(TARGETS magnum-imgui DESTINATION ${MAGNUM_DEPLOY_PREFIX}/imgui)
install(FILES
Expand Down
12 changes: 11 additions & 1 deletion src/mouseinteraction/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,18 @@ target_link_libraries(magnum-mouseinteraction PRIVATE
Magnum::SceneGraph
Magnum::Shaders)

# Installation for Emscripten
# For Emscripten copy the boilerplate next to the executable so it can be run
# directly from the build dir; provide an install target as well
if(CORRADE_TARGET_EMSCRIPTEN)
add_custom_command(TARGET magnum-mouseinteraction POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${MAGNUM_EMSCRIPTENAPPLICATION_JS}
${MAGNUM_WEBAPPLICATION_CSS}
$<TARGET_FILE_DIR:magnum-mouseinteraction>
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/mouseinteraction.html
$<TARGET_FILE_DIR:magnum-mouseinteraction>/magnum-mouseinteraction.html)

install(FILES mouseinteraction.html DESTINATION ${MAGNUM_DEPLOY_PREFIX}/mouseinteraction RENAME index.html)
install(TARGETS magnum-mouseinteraction DESTINATION ${MAGNUM_DEPLOY_PREFIX}/mouseinteraction)
install(FILES
Expand Down
12 changes: 11 additions & 1 deletion src/picking/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,18 @@ target_link_libraries(magnum-picking PRIVATE
Magnum::SceneGraph
Magnum::Shaders)

# Installation for Emscripten
# For Emscripten copy the boilerplate next to the executable so it can be run
# directly from the build dir; provide an install target as well
if(CORRADE_TARGET_EMSCRIPTEN)
add_custom_command(TARGET magnum-picking POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${MAGNUM_EMSCRIPTENAPPLICATION_JS}
${MAGNUM_WEBAPPLICATION_CSS}
$<TARGET_FILE_DIR:magnum-picking>
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/picking.html
$<TARGET_FILE_DIR:magnum-picking>/magnum-picking.html)

install(FILES picking.html DESTINATION ${MAGNUM_DEPLOY_PREFIX}/picking RENAME index.html)
install(TARGETS magnum-picking DESTINATION ${MAGNUM_DEPLOY_PREFIX}/picking)
install(FILES
Expand Down
12 changes: 11 additions & 1 deletion src/primitives/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,18 @@ if(CORRADE_TARGET_IOS)
XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "YES")
endif()

# Installation for Emscripten
# For Emscripten copy the boilerplate next to the executable so it can be run
# directly from the build dir; provide an install target as well
if(CORRADE_TARGET_EMSCRIPTEN)
add_custom_command(TARGET magnum-primitives POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${MAGNUM_EMSCRIPTENAPPLICATION_JS}
${MAGNUM_WEBAPPLICATION_CSS}
$<TARGET_FILE_DIR:magnum-primitives>
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/primitives.html
$<TARGET_FILE_DIR:magnum-primitives>/magnum-primitives.html)

install(FILES primitives.html DESTINATION ${MAGNUM_DEPLOY_PREFIX}/primitives RENAME index.html)
install(TARGETS magnum-primitives DESTINATION ${MAGNUM_DEPLOY_PREFIX}/primitives)
install(FILES
Expand Down
12 changes: 11 additions & 1 deletion src/text/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,18 @@ if(MAGNUM_BUILD_STATIC)
Magnum::MagnumFont)
endif()

# Installation for Emscripten
# For Emscripten copy the boilerplate next to the executable so it can be run
# directly from the build dir; provide an install target as well
if(CORRADE_TARGET_EMSCRIPTEN)
add_custom_command(TARGET magnum-text POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${MAGNUM_EMSCRIPTENAPPLICATION_JS}
${MAGNUM_WEBAPPLICATION_CSS}
$<TARGET_FILE_DIR:magnum-text>
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/text.html
$<TARGET_FILE_DIR:magnum-text>/magnum-text.html)

install(FILES text.html DESTINATION ${MAGNUM_DEPLOY_PREFIX}/text RENAME index.html)
install(TARGETS magnum-text DESTINATION ${MAGNUM_DEPLOY_PREFIX}/text)
install(FILES
Expand Down
12 changes: 11 additions & 1 deletion src/textured-triangle/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,18 @@ if(CORRADE_TARGET_EMSCRIPTEN OR CORRADE_TARGET_ANDROID OR CORRADE_TARGET_IOS)
target_link_libraries(magnum-textured-triangle PRIVATE Magnum::TgaImporter)
endif()

# Installation for Emscripten
# For Emscripten copy the boilerplate next to the executable so it can be run
# directly from the build dir; provide an install target as well
if(CORRADE_TARGET_EMSCRIPTEN)
add_custom_command(TARGET magnum-textured-triangle POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${MAGNUM_EMSCRIPTENAPPLICATION_JS}
${MAGNUM_WEBAPPLICATION_CSS}
$<TARGET_FILE_DIR:magnum-textured-triangle>
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/textured-triangle.html
$<TARGET_FILE_DIR:magnum-textured-triangle>/magnum-textured-triangle.html)

install(FILES textured-triangle.html DESTINATION ${MAGNUM_DEPLOY_PREFIX}/textured-triangle RENAME index.html)
install(TARGETS magnum-textured-triangle DESTINATION ${MAGNUM_DEPLOY_PREFIX}/textured-triangle)
install(FILES
Expand Down
12 changes: 11 additions & 1 deletion src/triangle/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,18 @@ if(CORRADE_TARGET_IOS)
XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "YES")
endif()

# Installation for Emscripten
# For Emscripten copy the boilerplate next to the executable so it can be run
# directly from the build dir; provide an install target as well
if(CORRADE_TARGET_EMSCRIPTEN)
add_custom_command(TARGET magnum-triangle POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${MAGNUM_EMSCRIPTENAPPLICATION_JS}
${MAGNUM_WEBAPPLICATION_CSS}
$<TARGET_FILE_DIR:magnum-triangle>
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/triangle.html
$<TARGET_FILE_DIR:magnum-triangle>/magnum-triangle.html)

install(FILES triangle.html DESTINATION ${MAGNUM_DEPLOY_PREFIX}/triangle RENAME index.html)
install(TARGETS magnum-triangle DESTINATION ${MAGNUM_DEPLOY_PREFIX}/triangle)
install(FILES
Expand Down
12 changes: 11 additions & 1 deletion src/viewer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,18 @@ if(CORRADE_TARGET_ANDROID AND CMAKE_ANDROID_NDK)
android_create_apk(magnum-viewer src/main/AndroidManifest.xml)
endif()

# Installation for Emscripten
# For Emscripten copy the boilerplate next to the executable so it can be run
# directly from the build dir; provide an install target as well
if(CORRADE_TARGET_EMSCRIPTEN)
add_custom_command(TARGET magnum-viewer POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${MAGNUM_EMSCRIPTENAPPLICATION_JS}
${MAGNUM_WEBAPPLICATION_CSS}
$<TARGET_FILE_DIR:magnum-viewer>
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/viewer.html
$<TARGET_FILE_DIR:magnum-viewer>/magnum-viewer.html)

install(FILES viewer.html DESTINATION ${MAGNUM_DEPLOY_PREFIX}/viewer RENAME index.html)
install(TARGETS magnum-viewer DESTINATION ${MAGNUM_DEPLOY_PREFIX}/viewer)
install(FILES
Expand Down

0 comments on commit 09d5e01

Please sign in to comment.