Support basic build with Emscripten
The result doesn't necessarily work yet, but at least the build is not failing.
This commit is contained in:
parent
08d77d6e93
commit
4204022390
5 changed files with 25 additions and 4 deletions
1
3rdparty/CMakeLists.txt
vendored
1
3rdparty/CMakeLists.txt
vendored
|
|
@ -1,6 +1,7 @@
|
|||
if(CMAKE_SYSTEM_NAME STREQUAL Emscripten)
|
||||
set(BOOST_INCLUDE_LIBRARIES random stacktrace math)
|
||||
set(BOOST_ENABLE_COMPATIBILITY_TARGETS 1)
|
||||
add_compile_options(-fdeclspec) # math doesn't build otherwise
|
||||
add_subdirectory(boost EXCLUDE_FROM_ALL)
|
||||
|
||||
# TODO: make this available via find_package so we wouldn't have to
|
||||
|
|
|
|||
|
|
@ -52,6 +52,18 @@ if(PSEMEK_BACKEND STREQUAL "ANDROID")
|
|||
set(PSEMEK_GL_LIBRARIES GLESv3 EGL)
|
||||
set(PSEMEK_PACKAGE_AS_LIBRARY ON CACHE INTERNAL "Build applications as shared libraries")
|
||||
list(APPEND PSEMEK_CXX_FLAGS -fPIC)
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL Emscripten)
|
||||
set(PSEMEK_GL_API gles32)
|
||||
set(PSEMEK_GL_LIBRARIES EGL)
|
||||
set(PSEMEK_PACKAGE_AS_LIBRARY OFF CACHE INTERNAL "Build applications as shared libraries")
|
||||
list(APPEND PSEMEK_DEFINITIONS "-DPSEMEK_GLES=1")
|
||||
list(APPEND PSEMEK_CXX_FLAGS -sUSE_SDL=2)
|
||||
# by default emcc doesn't produce catch clauses, but psemek is designed around exceptions
|
||||
list(APPEND PSEMEK_CXX_FLAGS -sDISABLE_EXCEPTION_CATCHING=0)
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
list(APPEND PSEMEK_CXX_FLAGS -g)
|
||||
endif()
|
||||
set(CMAKE_EXECUTABLE_SUFFIX ".html" PARENT_SCOPE) # we want to build html, not js
|
||||
else()
|
||||
find_package(Threads REQUIRED)
|
||||
set(OpenGL_GL_PREFERENCE LEGACY)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#include <stdio.h>
|
||||
#elif defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#elif defined(__ANDROID__)
|
||||
#elif defined(__ANDROID__) || defined(__EMSCRIPTEN__)
|
||||
#include <EGL/egl.h>
|
||||
#else
|
||||
#include <GL/glx.h>
|
||||
|
|
@ -80,7 +80,7 @@ namespace gl
|
|||
return reinterpret_cast<void*>(GetProcAddress(image, reinterpret_cast<LPCSTR>(name)));
|
||||
}
|
||||
|
||||
#elif defined(__ANDROID__)
|
||||
#elif defined(__ANDROID__) || defined(__EMSCRIPTEN__)
|
||||
|
||||
static void * get_proc_address(const char *func)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -149,9 +149,11 @@ namespace psemek::log
|
|||
#if __APPLE__
|
||||
::pthread_setname_np(name.data());
|
||||
#else
|
||||
#if !(defined __EMSCRIPTEN__) || (defined __EMSCRIPTEN_PTHREADS__)
|
||||
::pthread_setname_np(::pthread_self(), name.data());
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
auto id = std::this_thread::get_id();
|
||||
|
|
|
|||
|
|
@ -17,7 +17,13 @@ if(PSEMEK_PACKAGE_MODE)
|
|||
set(PSEMEK_PACKAGE_SUFFIX ${PSEMEK_PACKAGE_SUFFIX_RAW} CACHE INTERNAL "Packaging suffix" FORCE)
|
||||
|
||||
set(PSEMEK_PACKAGE_LINK_FLAGS_RAW)
|
||||
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL Emscripten)
|
||||
list(APPEND PSEMEK_PACKAGE_LINK_FLAGS_RAW "-sMIN_WEBGL_VERSION=2" "-sNO_DISABLE_EXCEPTION_CATCHING")
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
list(APPEND PSEMEK_PACKAGE_LINK_FLAGS_RAW "-g")
|
||||
endif()
|
||||
elseif((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
|
||||
list(APPEND PSEMEK_PACKAGE_LINK_FLAGS_RAW "-static-libgcc" "-static-libstdc++")
|
||||
endif()
|
||||
set(PSEMEK_PACKAGE_LINK_FLAGS ${PSEMEK_PACKAGE_LINK_FLAGS_RAW} CACHE INTERNAL "Packaging CXX flags" FORCE)
|
||||
|
|
@ -67,7 +73,7 @@ function(psemek_add_executable_impl target is_application)
|
|||
)
|
||||
endif()
|
||||
|
||||
if(UNIX AND (NOT APPLE) AND (NOT ANDROID))
|
||||
if(UNIX AND (NOT APPLE) AND (NOT ANDROID) AND (NOT (CMAKE_SYSTEM_NAME STREQUAL Emscripten)))
|
||||
add_custom_command(TARGET ${target} POST_BUILD
|
||||
COMMAND chrpath -r . $<TARGET_FILE:${target}>
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue