Skip to content

Commit

Permalink
Emscripten build works and produces a static library
Browse files Browse the repository at this point in the history
  • Loading branch information
vijaiaeroastro committed Oct 20, 2024
1 parent cc589ce commit f8e2ea2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
22 changes: 18 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ cmake_policy(SET CMP0048 NEW)

set_property(GLOBAL PROPERTY USE_FOLDERS ON)

if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
set(CMAKE_CXX_COMPILER_WORKS TRUE)
set(CMAKE_C_COMPILER_WORKS TRUE)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
set(VCPKG_TARGET_TRIPLET wasm32-emscripten)
endif()

# Automatically set the vcpkg toolchain file if vcpkg exists as a submodule
if (EXISTS "${CMAKE_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake")
message("Using VCPKG Toolchain")
Expand Down Expand Up @@ -116,10 +123,17 @@ endif()

#########################################################
# Shared library
add_library(${PROJECT_NAME} SHARED ${SRCS_COMMON} ${HDRS_COMMON}
${ACT_GENERATED_SOURCE}
${VERSION_FILES_OUTPUTLOCATION}
)
if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
add_library(${PROJECT_NAME} STATIC ${SRCS_COMMON} ${HDRS_COMMON}
${ACT_GENERATED_SOURCE}
${VERSION_FILES_OUTPUTLOCATION}
)
else()
add_library(${PROJECT_NAME} SHARED ${SRCS_COMMON} ${HDRS_COMMON}
${ACT_GENERATED_SOURCE}
${VERSION_FILES_OUTPUTLOCATION}
)
endif ()
SOURCE_GROUP("Source Files\\Autogenerated" FILES ${ACT_GENERATED_SOURCE})


Expand Down
3 changes: 3 additions & 0 deletions emscripten_build_notes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Building a static library using emscripten compiler

cmake .. -DCMAKE_SYSTEM_NAME=Emscripten

0 comments on commit f8e2ea2

Please sign in to comment.