codecbench.patch 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. diff --git a/CMakeLists.txt b/CMakeLists.txt
  2. index eccc49e..dac126c 100644
  3. --- a/CMakeLists.txt
  4. +++ b/CMakeLists.txt
  5. @@ -127,3 +127,42 @@ install(FILES
  6. ${CMAKE_CURRENT_BINARY_DIR}/meshoptimizerConfig.cmake
  7. ${CMAKE_CURRENT_BINARY_DIR}/meshoptimizerConfigVersion.cmake
  8. DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/meshoptimizer)
  9. +
  10. +##################################################
  11. +# codecbench
  12. +##################################################
  13. +add_executable(codecbench tools/codecbench.cpp ${SOURCES})
  14. +
  15. +set_target_properties(codecbench PROPERTIES OUTPUT_NAME codecbench.wasm)
  16. +
  17. +target_compile_options(codecbench
  18. + PUBLIC
  19. + -std=c++11
  20. + -Wno-unused-function
  21. + -Wno-unused-variable
  22. +)
  23. +
  24. +target_link_options(codecbench
  25. + PUBLIC
  26. + LINKER:-allow-undefined,--demangle
  27. +)
  28. +
  29. +find_program(WASM_OPT
  30. + NAMES wasm-opt
  31. + PATHS /opt/binaryen-version_97/bin /opt/binaryen/bin
  32. +)
  33. +
  34. +if (NOT WASM_OPT)
  35. + message(WARNING "can not find wasm-opt and will not optimize any wasm module")
  36. +endif()
  37. +
  38. +add_custom_target(codecbench.opt ALL
  39. + COMMAND
  40. + ${WASM_OPT} -Oz --enable-simd -o codecbench.opt.wasm codecbench.wasm
  41. + BYPRODUCTS
  42. + ${CMAKE_CURRENT_BINARY_DIR}/codecbench.opt.wasm
  43. + WORKING_DIRECTORY
  44. + ${CMAKE_CURRENT_BINARY_DIR}
  45. +)
  46. +
  47. +add_dependencies(codecbench.opt codecbench)