Skip to content

Commit a628b57

Browse files
committed
CMake: Fix web export issue godotengine#1830
- cache emscripten variables to make them available in consumers - add -sUSE_PTHREADS=1 to link flags - add =1 to sSIDE_MODULE=1 in compile flags to match scons.
1 parent 5910c0e commit a628b57

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

cmake/emsdkHack.cmake

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ Overwrite Shared Library Properties to allow shared libs to be generated.
2525
]=======================================================================]
2626
if(EMSCRIPTEN)
2727
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
28-
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-sSIDE_MODULE=1")
29-
set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-sSIDE_MODULE=1")
30-
set(CMAKE_SHARED_LIBRARY_SUFFIX) # remove the suffix from the shared lib
31-
set(CMAKE_STRIP FALSE) # used by default in pybind11 on .so modules
28+
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-sSIDE_MODULE=1" CACHE INTERNAL "")
29+
set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-sSIDE_MODULE=1" CACHE INTERNAL "")
30+
set(CMAKE_SHARED_LIBRARY_SUFFIX "" CACHE INTERNAL "") # remove the suffix from the shared lib
31+
set(CMAKE_STRIP FALSE "" CACHE INTERNAL "") # used by default in pybind11 on .so modules
3232

3333
# The Emscripten toolchain sets the default value for EMSCRIPTEN_SYSTEM_PROCESSOR to x86
3434
# and copies that to CMAKE_SYSTEM_PROCESSOR. We don't want that.
35-
set(CMAKE_SYSTEM_PROCESSOR "wasm32")
35+
set(CMAKE_SYSTEM_PROCESSOR "wasm32" CACHE INTERNAL "")
3636
# the above prevents the need for logic like:
3737
#if( ${CMAKE_SYSTEM_NAME} STREQUAL Emscripten )
3838
# set( SYSTEM_ARCH wasm32 )

cmake/web.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function(web_generate)
2121
target_compile_options(
2222
godot-cpp
2323
PUBLIC #
24-
-sSIDE_MODULE
24+
-sSIDE_MODULE=1
2525
-sSUPPORT_LONGJMP=wasm
2626
$<${THREADS_ENABLED}:-sUSE_PTHREADS=1>
2727
)
@@ -33,6 +33,7 @@ function(web_generate)
3333
-sSUPPORT_LONGJMP=wasm
3434
-fvisibility=hidden
3535
-shared
36+
$<${THREADS_ENABLED}:-sUSE_PTHREADS=1>
3637
)
3738

3839
common_compiler_flags()

0 commit comments

Comments
 (0)