SHARE
TWEET

Untitled

a guest Mar 7th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. set(EMSCRIPTEN_PREFIX "${PROJECT_SOURCE_DIR}/emscripten/emsdk/emscripten/1.38.28/")
  2. set(_WEBAPPLICATION_HTML "${PROJECT_SOURCE_DIR}/platforms/web/Application.html")
  3. set(MAGNUM_EMSCRIPTENAPPLICATION_JS "${PROJECT_SOURCE_DIR}/platforms/web/EmscriptenApplication.js")
  4. set(MAGNUM_WINDOWLESSEMSCRIPTENAPPLICATION_JS ${MAGNUM_EMSCRIPTENAPPLICATION_JS})
  5. set(MAGNUM_WEBAPPLICATION_CSS "${PROJECT_SOURCE_DIR}/platforms/web/WebApplication.css")
  6. set(_DEPLOY_DIR "${PROJECT_SOURCE_DIR}/deploy/")
  7.  
  8.  
  9. set(CMAKE_SYSTEM_NAME Emscripten)
  10.  
  11. # Help CMake find the platform file
  12. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR}/../modules)
  13.  
  14. if(NOT EMSCRIPTEN_PREFIX)
  15.     if(DEFINED ENV{EMSCRIPTEN})
  16.         file(TO_CMAKE_PATH "$ENV{EMSCRIPTEN}" EMSCRIPTEN_PREFIX)
  17.     else()
  18.         set(EMSCRIPTEN_PREFIX "/usr/lib/emscripten")
  19.     endif()
  20. endif()
  21.  
  22. set(EMSCRIPTEN_TOOLCHAIN_PATH "${EMSCRIPTEN_PREFIX}/system")
  23.  
  24. if(CMAKE_HOST_WIN32)
  25.     set(EMCC_SUFFIX ".bat")
  26. else()
  27.     set(EMCC_SUFFIX "")
  28. endif()
  29. set(CMAKE_C_COMPILER "${EMSCRIPTEN_PREFIX}/emcc${EMCC_SUFFIX}")
  30. set(CMAKE_CXX_COMPILER "${EMSCRIPTEN_PREFIX}/em++${EMCC_SUFFIX}")
  31. set(CMAKE_AR "${EMSCRIPTEN_PREFIX}/emar${EMCC_SUFFIX}" CACHE FILEPATH "Emscripten ar")
  32. set(CMAKE_RANLIB "${EMSCRIPTEN_PREFIX}/emranlib${EMCC_SUFFIX}" CACHE FILEPATH "Emscripten ranlib")
  33.  
  34. set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH}
  35.     "${EMSCRIPTEN_TOOLCHAIN_PATH}"
  36.     "${EMSCRIPTEN_PREFIX}")
  37.  
  38. set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
  39. set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
  40. set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
  41.  
  42. # Otherwise FindCorrade fails to find _CORRADE_MODULE_DIR. Why the heck is this
  43. # not implicit is beyond me.
  44. set(CMAKE_SYSTEM_PREFIX_PATH ${CMAKE_FIND_ROOT_PATH})
  45.  
  46. # Since some unspecified release, -s WASM=1 is the default, so we need to
  47. # explicitly say -s WASM=0 to use asm.js. The *_INIT variables are available
  48. # since CMake 3.7, so it won't work in earlier versions. Sorry.
  49. cmake_minimum_required(VERSION 3.7)
  50. set(CMAKE_CXX_FLAGS_INIT "-s WASM=0")
  51. set(CMAKE_EXE_LINKER_FLAGS_INIT "-s WASM=0")
  52. set(CMAKE_CXX_FLAGS_RELEASE_INIT "-DNDEBUG -O3")
  53. set(CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT "-O3 --llvm-lto 1")
  54.  
  55. find_package(MagnumIntegration REQUIRED ImGui)
  56. set(CORRADE_TARGET_EMSCRIPTEN 1)
  57. find_package(Magnum REQUIRED GL Sdl2Application)
  58.  
  59.  
  60. #set(CMAKE_TOOLCHAIN_FILE "${PROJECT_SOURCE_DIR}/toolchains/generic/Emscripten.cmake")
  61. #set(CMAKE_INSTALL_PREFIX "${EMSCRIPTEN_PREFIX}/system/")
  62. #set(CMAKE_PREFIX_PATH "${EMSCRIPTEN_PREFIX}/system/")
  63.  
  64. set_directory_properties(PROPERTIES CORRADE_USE_PEDANTIC_FLAGS ON)
  65.  
  66.  
  67. add_executable(MyApplication main.cpp)
  68. target_link_libraries(MyApplication PRIVATE
  69.     Magnum::Application
  70.     Magnum::GL
  71.     MagnumIntegration::ImGui)
  72.  
  73. if(CORRADE_TARGET_EMSCRIPTEN)
  74.     install(TARGETS MyApplication DESTINATION ${_DEPLOY_DIR})
  75.     install(FILES
  76.         ${_WEBAPPLICATION_HTML}
  77.         ${_EMSCRIPTENAPPLICATION_JS}
  78.         ${_WEBAPPLICATION_CSS}
  79.         DESTINATION ${_DEPLOY_DIR})
  80. endif()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top