attempt to build web version out of emscripten legacy gl wrapper
This commit is contained in:
@@ -30,15 +30,15 @@ option(TWN_USE_AMALGAM "Enable use of twn_amalgam.c as a single compilation unit
|
||||
option(TWN_FEATURE_DYNLIB_GAME "Enable dynamic library loading support" ON)
|
||||
set(TWN_OUT_DIR ${CMAKE_SOURCE_DIR} CACHE PATH "Artifact destination")
|
||||
|
||||
# todo: figure out how to compile for dynamic linking instead
|
||||
if(EMSCRIPTEN)
|
||||
# todo: figure out how to compile for dynamic linking instead?
|
||||
if(HAIKU OR EMSCRIPTEN)
|
||||
if(TWN_FEATURE_DYNLIB_GAME)
|
||||
message(WARNING "TWN_FEATURE_DYNLIB_GAME is set, but not supported - it is turned off")
|
||||
set(TWN_FEATURE_DYNLIB_GAME OFF CACHE INTERNAL "")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(HAIKU)
|
||||
if(HAIKU OR EMSCRIPTEN)
|
||||
if(TWN_SANITIZE)
|
||||
message(WARNING "TWN_SANITIZE is set, but not supported - it is turned off")
|
||||
set(TWN_SANITIZE OFF CACHE INTERNAL "")
|
||||
@@ -64,11 +64,7 @@ set(PHYSFS_ARCHIVE_7Z OFF CACHE INTERNAL "")
|
||||
add_subdirectory(third-party/physfs ${CMAKE_CURRENT_BINARY_DIR}/third-party/physfs SYSTEM)
|
||||
add_subdirectory(third-party/libxm ${CMAKE_CURRENT_BINARY_DIR}/third-party/libxm SYSTEM)
|
||||
|
||||
if(EMSCRIPTEN)
|
||||
set(TWN_RENDERING_API WEBGL1)
|
||||
else()
|
||||
set(TWN_RENDERING_API OPENGL_15)
|
||||
endif()
|
||||
set(TWN_RENDERING_API OPENGL_15)
|
||||
|
||||
if(TWN_RENDERING_API MATCHES OPENGL_15)
|
||||
set(SYSTEM_SOURCE_FILES ${SYSTEM_SOURCE_FILES}
|
||||
@@ -140,7 +136,7 @@ set_target_properties(${TWN_TARGET} PROPERTIES
|
||||
# precompile commonly used not-so-small headers
|
||||
target_precompile_headers(${TWN_TARGET} PRIVATE
|
||||
$<$<NOT:$<BOOL:${EMSCRIPTEN}>>:third-party/glad/include/glad/glad.h>
|
||||
${SDL2_INCLUDE_DIR}/SDL.h
|
||||
$<$<NOT:$<BOOL:${EMSCRIPTEN}>>:${SDL2_INCLUDE_DIR}/SDL.h>
|
||||
third-party/physfs/src/physfs.h)
|
||||
|
||||
|
||||
@@ -170,6 +166,13 @@ function(give_options_without_warnings target)
|
||||
$<$<BOOL:${TWN_SANITIZE}>:-fstack-protector-all -fsanitize=undefined -fsanitize=address>
|
||||
$<$<BOOL:${EMSCRIPTEN}>:-gsource-map>)
|
||||
|
||||
set(LINK_FLAGS
|
||||
-Bsymbolic-functions
|
||||
|
||||
$<$<BOOL:${EMSCRIPTEN}>:-sLEGACY_GL_EMULATION -sGL_FFP_ONLY -sGL_UNSAFE_OPTS>
|
||||
$<$<NOT:$<BOOL:${EMSCRIPTEN}>>:-Wl,--as-needed>
|
||||
$<$<BOOL:${LINUX}>:-Wl,--hash-style=gnu>)
|
||||
|
||||
set(LINK_FLAGS_RELEASE
|
||||
$<$<STREQUAL:${CMAKE_C_COMPILER_ID},Clang>:-Wl,--strip-all>
|
||||
${BUILD_FLAGS_RELEASE})
|
||||
@@ -194,12 +197,10 @@ function(give_options_without_warnings target)
|
||||
|
||||
target_link_options(${target} PUBLIC
|
||||
${BUILD_FLAGS}
|
||||
${LINK_FLAGS}
|
||||
# -Wl,--no-undefined # TODO: use later for implementing no-libc
|
||||
$<$<CONFIG:Release>:${LINK_FLAGS_RELEASE}>
|
||||
$<$<CONFIG:Debug>:${BUILD_FLAGS_DEBUG}>
|
||||
-Bsymbolic-functions
|
||||
-Wl,--as-needed
|
||||
$<$<BOOL:${LINUX}>:-Wl,--hash-style=gnu>)
|
||||
$<$<CONFIG:Debug>:${BUILD_FLAGS_DEBUG}>)
|
||||
|
||||
get_target_property(target_type ${target} TYPE)
|
||||
if (target_type MATCHES SHARED_LIBRARY)
|
||||
@@ -274,7 +275,7 @@ endfunction()
|
||||
function(link_deps target)
|
||||
target_link_libraries(${target} PUBLIC
|
||||
$<$<NOT:$<BOOL:${EMSCRIPTEN}>>:SDL2::SDL2>
|
||||
$<$<NOT:$<BOOL:${TWN_FEATURE_DYNLIB_GAME}>>:SDL2::SDL2main>
|
||||
$<$<NOT:$<OR:$<BOOL:${TWN_FEATURE_DYNLIB_GAME}>,$<BOOL:${EMSCRIPTEN}>>>:SDL2::SDL2main>
|
||||
physfs-static
|
||||
xms)
|
||||
target_include_directories(${target} PUBLIC ${SDL2_INCLUDE_DIRS})
|
||||
|
||||
Reference in New Issue
Block a user