Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
vijaiaeroastro committed Nov 4, 2024
1 parent 432171c commit 94c6e62
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,33 @@ endif()


#########################################################
# Add conditional compilation for Emscripten
if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
set(CMAKE_EXECUTABLE_SUFFIX ".js") # Set the output suffix to .js for WebAssembly

add_executable(${PROJECT_NAME} ${SRCS_COMMON} ${HDRS_COMMON} ${ACT_GENERATED_SOURCE} ${VERSION_FILES_OUTPUTLOCATION})

# Emscripten-specific linker options
target_link_options(${PROJECT_NAME} PRIVATE
"-s MODULARIZE=1" # Wrap the output in a module
"-s EXPORT_ALL=1" # Export all functions
"-s ALLOW_MEMORY_GROWTH=1" # Allow dynamic memory growth
"--bind" # Enables embind support (optional if you’re using embind)
"--whole-archive"
)
SOURCE_GROUP("Source Files\\Autogenerated" FILES ${ACT_GENERATED_SOURCE})
else()
# For non-Emscripten builds, keep the original library setup
add_library(${PROJECT_NAME} STATIC ${SRCS_COMMON} ${HDRS_COMMON} ${ACT_GENERATED_SOURCE} ${VERSION_FILES_OUTPUTLOCATION})
SOURCE_GROUP("Source Files\\Autogenerated" FILES ${ACT_GENERATED_SOURCE})
endif ()


# Shared library
add_library(${PROJECT_NAME} STATIC ${SRCS_COMMON} ${HDRS_COMMON}
${ACT_GENERATED_SOURCE}
${VERSION_FILES_OUTPUTLOCATION}
)
#add_library(${PROJECT_NAME} STATIC ${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}
Expand All @@ -143,7 +165,6 @@ add_library(${PROJECT_NAME} STATIC ${SRCS_COMMON} ${HDRS_COMMON}
# ${VERSION_FILES_OUTPUTLOCATION}
# )
#endif ()
SOURCE_GROUP("Source Files\\Autogenerated" FILES ${ACT_GENERATED_SOURCE})



Expand Down

0 comments on commit 94c6e62

Please sign in to comment.