Add cmake compatibility to c-api (#4369)

* Add cmake compatibility to c-api

* Add CMake documentation to wasmtime.h

* Add CMake instructions in examples

* Modify CI for CMake support

* Use correct rust in CI

* Trigger build

* Refactor run-examples

* Reintroduce example_to_run in run-examples

* Replace run-examples crate with cmake

* Fix markdown formatting in examples readme

* Fix cmake test quotes

* Build rust wasm before cmake tests

* Pass CTEST_OUTPUT_ON_FAILURE

* Another cmake test

* Handle os differences in cmake test

* Fix bugs in memory and multimemory examples
This commit is contained in:
TheGreatRambler
2022-07-22 11:22:36 -06:00
committed by GitHub
parent 35b750ab9a
commit 2ba3025e67
25 changed files with 244 additions and 161 deletions

View File

@@ -1,3 +1,27 @@
/*
Example of instantiating of the WebAssembly module and invoking its exported
function in a separate thread.
You can compile and run this example on Linux with:
cargo build --release -p wasmtime-c-api
cc examples/threads.c \
-I crates/c-api/include \
-I crates/c-api/wasm-c-api/include \
target/release/libwasmtime.a \
-lpthread -ldl -lm \
-o threads
./threads
Note that on Windows and macOS the command will be similar, but you'll need
to tweak the `-lpthread` and such annotations as well as the name of the
`libwasmtime.a` file on Windows.
You can also build using cmake:
mkdir build && cd build && cmake .. && cmake --build . --target wasmtime-threads
*/
#ifndef _WIN32
#include <inttypes.h>