Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CMakeLists.txt to handle WebAssembly #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ghdalsrl326
Copy link

Hi, I would like to suggest adding a script to build tetgen with webassembly so that it can be used in web projects.
Here’s a summary of the changes made to the CMakeLists.txt file:

  1. Build Options Adjustment:
  • Original: The BUILD_EXECUTABLE option was set to OFF by default.
  • Modified: I changed the BUILD_EXECUTABLE option to ON by default, since static tetgen.js, tetgen.wasm files needed for web projects. If this modification is improper for standard tetgen users, update readme for web users is required.
  1. Emscripten-Specific Enhancements:

New Condition Added:
I added a condition to check if the build system is Emscripten. This lets us apply specific settings when targeting WebAssembly.

HTML Output for Emscripten:

  • Original: There was no specific handling for Emscripten.
  • Modified: When building with Emscripten, the output file for the tetgen executable now gets a .html suffix instead of the usual executable format.

Emscripten Compiler Flags:
New Flags: I included several flags to improve the WebAssembly build:
EXPORTED_RUNTIME_METHODS=['callMain']: This makes sure the callMain method is available in the runtime, so we can call the main function from JavaScript.
-sSTACK_SIZE=131072: I increased the stack size to 131072 bytes to avoid stack overflow issues during complex operations.
-s TOTAL_MEMORY=64MB: I set the total memory allocation to 64MB to prevent out-of-memory errors while running the WebAssembly module.

Best Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant