Fix sample ref-types/wasm-c-api build error with wat2wasm low version (#1702)
Fix build error in sample ref-types and wasm-c-api caused by the version of wat2wasm: refine makefile to auto detect the wat2wasm version and add the compile flag accordingly.
This commit is contained in:
@ -104,8 +104,17 @@ find_program(WAT2WASM
|
||||
|
||||
if(NOT WAT2WASM)
|
||||
message(SEND_ERROR "can not find wat2wasm")
|
||||
else ()
|
||||
execute_process(COMMAND ${WAT2WASM} --version
|
||||
OUTPUT_VARIABLE WAT2WASM_VERSION_OUTPUT)
|
||||
string(STRIP ${WAT2WASM_VERSION_OUTPUT} WAT2WASM_VERSION)
|
||||
message("-- Found wat2wasm ${WAT2WASM_VERSION}")
|
||||
endif()
|
||||
|
||||
if (${WAT2WASM_VERSION} VERSION_LESS 1.0.26)
|
||||
set(WAT2WASM_FLAGS "--enable-reference-types")
|
||||
endif ()
|
||||
|
||||
if(${WAMR_BUILD_AOT} EQUAL 1)
|
||||
## locate wamrc
|
||||
find_program(WAMRC
|
||||
@ -161,7 +170,7 @@ foreach(EX ${EXAMPLES})
|
||||
set(WAT ${CMAKE_CURRENT_LIST_DIR}/src/${EX}.wat)
|
||||
|
||||
add_custom_target(${EX}_WASM
|
||||
COMMAND ${WAT2WASM} ${WAT} --enable-reference-types -o ${PROJECT_BINARY_DIR}/${EX}.wasm
|
||||
COMMAND ${WAT2WASM} ${WAT} ${WAT2WASM_FLAGS} -o ${PROJECT_BINARY_DIR}/${EX}.wasm
|
||||
DEPENDS ${WAT}
|
||||
BYPRODUCTS ${PROJECT_BINARY_DIR}/${EX}.wasm
|
||||
VERBATIM
|
||||
|
||||
Reference in New Issue
Block a user