CMakeLists.txt 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. # This file is part of Desktop App Toolkit,
  2. # a set of libraries for developing nice desktop applications.
  3. #
  4. # For license and copyright information please follow this link:
  5. # https://github.com/desktop-app/legal/blob/master/LEGAL
  6. add_library(external_cld3 INTERFACE IMPORTED GLOBAL)
  7. add_library(desktop-app::external_cld3 ALIAS external_cld3)
  8. add_library(external_cld3_bundled STATIC)
  9. init_target(external_cld3_bundled "(external)")
  10. set(cld3_loc ${third_party_loc}/cld3)
  11. set(cld3_src ${cld3_loc}/src)
  12. set(gen_loc ${CMAKE_CURRENT_BINARY_DIR}/gen)
  13. set(gen_dst ${gen_loc}/cld_3/protos)
  14. if (DESKTOP_APP_USE_PACKAGED OR LINUX)
  15. find_package(protobuf CONFIG)
  16. if (NOT protobuf_FOUND)
  17. find_package(Protobuf MODULE REQUIRED)
  18. endif()
  19. set(protoc_executable protobuf::protoc)
  20. set(protobuf_lib protobuf::libprotobuf-lite)
  21. elseif (WIN32)
  22. set(build_loc ${libs_loc}/protobuf/build/$<IF:$<CONFIG:Debug>,Debug,Release>)
  23. set(protoc_executable ${build_loc}/protoc.exe)
  24. set(protobuf_lib ${build_loc}/libprotobuf-lite.lib)
  25. else()
  26. set(protoc_executable ${libs_loc}/protobuf/build/protoc)
  27. set(protobuf_lib ${libs_loc}/protobuf/build/libprotobuf-lite.a)
  28. endif()
  29. if (PROTOBUF_PROTOC_EXECUTABLE)
  30. set(protoc_executable ${PROTOBUF_PROTOC_EXECUTABLE})
  31. endif()
  32. include(generate_protobuf.cmake)
  33. function(generate protobuf_name)
  34. generate_single_protobuf(
  35. external_cld3_bundled
  36. ${gen_dst}
  37. ${protobuf_name}
  38. ${protoc_executable})
  39. endfunction()
  40. generate(feature_extractor.proto)
  41. generate(sentence.proto)
  42. generate(task_spec.proto)
  43. nice_target_sources(external_cld3_bundled ${cld3_src}
  44. PRIVATE
  45. feature_extractor.proto
  46. sentence.proto
  47. task_spec.proto
  48. base.cc
  49. embedding_feature_extractor.cc
  50. embedding_network.cc
  51. feature_extractor.cc
  52. feature_extractor.h
  53. feature_types.cc
  54. fml_parser.cc
  55. language_identifier_features.cc
  56. lang_id_nn_params.cc
  57. nnet_language_identifier.cc
  58. registry.cc
  59. relevant_script_feature.cc
  60. sentence_features.cc
  61. task_context.cc
  62. task_context_params.cc
  63. unicodetext.cc
  64. utils.cc
  65. workspace.cc
  66. script_span/generated_entities.cc
  67. script_span/getonescriptspan.cc
  68. script_span/getonescriptspan.h
  69. script_span/utf8statetable.cc
  70. script_span/offsetmap.cc
  71. script_span/text_processing.cc
  72. script_span/text_processing.h
  73. script_span/fixunicodevalue.cc
  74. )
  75. target_compile_definitions(external_cld3_bundled
  76. PUBLIC
  77. $<$<NOT:$<CONFIG:Debug>>:NDEBUG>
  78. )
  79. target_compile_options_if_exists(external_cld3_bundled
  80. PRIVATE
  81. -Wno-implicit-fallthrough
  82. )
  83. target_include_directories(external_cld3_bundled
  84. PUBLIC
  85. ${cld3_src}
  86. ${gen_loc}
  87. )
  88. if (NOT DESKTOP_APP_USE_PACKAGED AND NOT LINUX)
  89. target_include_directories(external_cld3_bundled
  90. PUBLIC
  91. ${libs_loc}/protobuf/src
  92. ${libs_loc}/protobuf/third_party/abseil-cpp
  93. )
  94. endif()
  95. target_link_libraries(external_cld3_bundled
  96. PRIVATE
  97. ${protobuf_lib}
  98. )
  99. target_link_libraries(external_cld3
  100. INTERFACE
  101. external_cld3_bundled
  102. )