You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

flatbuffers.cmake 2.2 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. set(flatbuffers_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2")
  2. set(flatbuffers_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
  3. mindspore_add_pkg(flatbuffers
  4. VER 1.11.0
  5. LIBS flatbuffers
  6. EXE flatc
  7. URL https://github.com/google/flatbuffers/archive/v1.11.0.tar.gz
  8. MD5 02c64880acb89dbd57eebacfd67200d8
  9. CMAKE_OPTION -DFLATBUFFERS_BUILD_TESTS=OFF )
  10. include_directories(${flatbuffers_INC})
  11. add_library(mindspore::flatbuffers ALIAS flatbuffers::flatbuffers)
  12. add_executable(mindspore::flatc ALIAS flatbuffers::flatc)
  13. include_directories(${flatbuffers_INC})
  14. function(ms_build_flatbuffers source_schema_files
  15. source_schema_dirs
  16. custom_target_name
  17. generated_output_dir)
  18. set(total_schema_dirs "")
  19. set(total_generated_files "")
  20. set(FLATC mindspore::flatc)
  21. foreach (schema_dir ${source_schema_dirs})
  22. set(total_schema_dirs -I ${schema_dir} ${total_schema_dirs})
  23. endforeach()
  24. foreach(schema ${source_schema_files})
  25. get_filename_component(filename ${schema} NAME_WE)
  26. if (NOT ${generated_output_dir} STREQUAL "")
  27. set(generated_file ${generated_output_dir}/${filename}_generated.h)
  28. add_custom_command(
  29. OUTPUT ${generated_file}
  30. COMMAND ${FLATC} --gen-mutable
  31. --reflect-names --gen-object-api -o ${generated_output_dir}
  32. ${total_schema_dirs}
  33. -c -b --reflect-types ${schema}
  34. DEPENDS ${FLATC} ${schema}
  35. WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
  36. COMMENT "Running C++ flatbuffers compiler on ${schema}" VERBATIM)
  37. list(APPEND total_generated_files ${generated_file})
  38. endif()
  39. endforeach()
  40. add_custom_target(${custom_target_name} ALL
  41. DEPENDS ${total_generated_files})
  42. if (NOT ${generated_output_dir} STREQUAL "")
  43. include_directories(${generated_output_dir})
  44. set_property(TARGET ${custom_target_name}
  45. PROPERTY GENERATED_OUTPUT_DIR
  46. ${generated_output_dir})
  47. endif()
  48. endfunction()

MindSpore is a new open source deep learning training/inference framework that could be used for mobile, edge and cloud scenarios.

Contributors (1)