FindWasmtime.cmake 913 B

1234567891011121314151617181920212223
  1. find_path2(WASMTIME_INCLUDE_DIR wasmtime.h)
  2. find_library2(WASMTIME_LIBRARY wasmtime)
  3. if(WASMTIME_INCLUDE_DIR AND EXISTS "${WASMTIME_INCLUDE_DIR}/wasmtime.h")
  4. file(STRINGS ${WASMTIME_INCLUDE_DIR}/wasmtime.h WASMTIME_VERSION REGEX "#define WASMTIME_VERSION")
  5. string(REGEX MATCH "[0-9]+\.[0-9]\.[0-9]" WASMTIME_VERSION ${WASMTIME_VERSION})
  6. endif()
  7. find_package_handle_standard_args(Wasmtime
  8. REQUIRED_VARS WASMTIME_INCLUDE_DIR WASMTIME_LIBRARY
  9. VERSION_VAR WASMTIME_VERSION)
  10. add_library(wasmtime INTERFACE)
  11. target_include_directories(wasmtime SYSTEM BEFORE INTERFACE ${WASMTIME_INCLUDE_DIR})
  12. target_link_libraries(wasmtime INTERFACE ${WASMTIME_LIBRARY})
  13. if(MSVC)
  14. target_compile_options(wasmtime INTERFACE -DWASM_API_EXTERN= -DWASI_API_EXTERN=)
  15. target_link_libraries(wasmtime INTERFACE ws2_32 advapi32 userenv ntdll shell32 ole32 bcrypt)
  16. endif()
  17. mark_as_advanced(WASMTIME_INCLUDE_DIR WASMTIME_LIBRARY)