Skip to content

Commit

Permalink
CraterCrashGH-609 Create Emscripten .so file
Browse files Browse the repository at this point in the history
  • Loading branch information
Naros committed Aug 24, 2024
1 parent 4d54146 commit c0ae889
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
21 changes: 15 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,26 @@ endif()
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src")

IF (NOT APPLE)
# Linker options for the GDExtension library
TARGET_LINK_OPTIONS(${PROJECT_NAME} PRIVATE
$<$<NOT:${compiler_is_msvc}>:
# Check if we are using Emscripten
IF (CMAKE_CXX_COMPILER MATCHES "em\\+\\+|emcc")
# Emscripten-specific linker options (empty or specific to Emscripten)
# Do not add -R or $$ORIGIN here since Emscripten does not support them
TARGET_LINK_OPTIONS(${PROJECT_NAME} PRIVATE
# Emscripten does not need these options
)
ELSE()
# Linker options for non-Emscripten platforms
TARGET_LINK_OPTIONS(${PROJECT_NAME} PRIVATE
$<$<NOT:${compiler_is_msvc}>:
-static-libgcc
-static-libstdc++
-Wl,-R,'$$ORIGIN'
$<$<CONFIG:Release>:
$<$<PLATFORM_ID:Android>:-s>
$<$<PLATFORM_ID:Android>:-s>
>
>
)
>
)
ENDIF()
ENDIF ()

if (AUTOFORMAT_SRC_ON_CONFIGURE MATCHES ON)
Expand Down
2 changes: 1 addition & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"CMAKE_CXX_COMPILER": "em++",
"CMAKE_TOOLCHAIN_FILE": "$env{EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake",
"BUILD_SHARED_LIBS": "ON",
"CMAKE_CXX_FLAGS": "-s SIDE_MODULE=1 -shared"
"CMAKE_CXX_FLAGS": "-s SIDE_MODULE=1"
}
}
]
Expand Down

0 comments on commit c0ae889

Please sign in to comment.