codecbench.patch 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. diff --git a/CMakeLists.txt b/CMakeLists.txt
  2. index ffdb4da..a397427 100644
  3. --- a/CMakeLists.txt
  4. +++ b/CMakeLists.txt
  5. @@ -127,3 +127,43 @@ 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. + -O3 -msimd128
  20. + -std=c++11
  21. + -Wno-unused-function
  22. + -Wno-unused-variable
  23. +)
  24. +
  25. +target_link_options(codecbench
  26. + PUBLIC
  27. + LINKER:-allow-undefined,--demangle,--export=malloc,--export=free
  28. +)
  29. +
  30. +find_program(WASM_OPT
  31. + NAMES wasm-opt
  32. + PATHS /opt/binaryen-version_97/bin /opt/binaryen/bin
  33. +)
  34. +
  35. +if (NOT WASM_OPT)
  36. + message(WARNING "can not find wasm-opt and will not optimize any wasm module")
  37. +endif()
  38. +
  39. +add_custom_target(codecbench.opt ALL
  40. + COMMAND
  41. + ${WASM_OPT} -Oz --enable-simd -o codecbench.opt.wasm codecbench.wasm
  42. + BYPRODUCTS
  43. + ${CMAKE_CURRENT_BINARY_DIR}/codecbench.opt.wasm
  44. + WORKING_DIRECTORY
  45. + ${CMAKE_CURRENT_BINARY_DIR}
  46. +)
  47. +
  48. +add_dependencies(codecbench.opt codecbench)