|
| 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 | + |
| 7 | +add_library(external_cld3 INTERFACE IMPORTED GLOBAL) |
| 8 | +add_library(desktop-app::external_cld3 ALIAS external_cld3) |
| 9 | + |
| 10 | +add_library(external_cld3_bundled STATIC) |
| 11 | +init_target(external_cld3_bundled "(external)") |
| 12 | + |
| 13 | +set(cld3_loc ${third_party_loc}/cld3) |
| 14 | +set(cld3_src ${cld3_loc}/src) |
| 15 | + |
| 16 | +set(gen_loc ${cld3_loc}/build/gen) |
| 17 | +set(gen_dst ${gen_loc}/cld_3/protos) |
| 18 | + |
| 19 | +if (DESKTOP_APP_USE_PACKAGED) |
| 20 | + find_package(Protobuf) |
| 21 | + if (NOT Protobuf_FOUND) |
| 22 | + find_package(protobuf REQUIRED CONFIG) |
| 23 | + endif() |
| 24 | + set(protoc_executable protobuf::protoc) |
| 25 | + set(protobuf_lib protobuf::libprotobuf-lite) |
| 26 | +elseif (WIN32) |
| 27 | + set(build_loc ${libs_loc}/protobuf/build/$<IF:$<CONFIG:Debug>,Debug,Release>) |
| 28 | + set(protoc_executable ${build_loc}/protoc.exe) |
| 29 | + set(protobuf_lib ${build_loc}/libprotobuf-lite.lib) |
| 30 | +else() |
| 31 | + set(protoc_executable ${libs_loc}/protobuf/build/protoc) |
| 32 | + set(protobuf_lib ${libs_loc}/protobuf/build/libprotobuf-lite.a) |
| 33 | + if (LINUX) |
| 34 | + target_compile_options(external_cld3_bundled PRIVATE -Wno-implicit-fallthrough) |
| 35 | + endif() |
| 36 | +endif() |
| 37 | +if (PROTOBUF_PROTOC_EXECUTABLE) |
| 38 | + set(protoc_executable ${PROTOBUF_PROTOC_EXECUTABLE}) |
| 39 | +endif() |
| 40 | + |
| 41 | +include(generate_protobuf.cmake) |
| 42 | + |
| 43 | +function(generate protobuf_name) |
| 44 | + generate_single_protobuf( |
| 45 | + external_cld3_bundled |
| 46 | + ${gen_dst} |
| 47 | + ${protobuf_name} |
| 48 | + ${protoc_executable}) |
| 49 | +endfunction() |
| 50 | + |
| 51 | +generate(feature_extractor.proto) |
| 52 | +generate(sentence.proto) |
| 53 | +generate(task_spec.proto) |
| 54 | + |
| 55 | +nice_target_sources(external_cld3_bundled ${cld3_src} |
| 56 | +PRIVATE |
| 57 | + feature_extractor.proto |
| 58 | + sentence.proto |
| 59 | + task_spec.proto |
| 60 | + |
| 61 | + base.cc |
| 62 | + embedding_feature_extractor.cc |
| 63 | + embedding_network.cc |
| 64 | + feature_extractor.cc |
| 65 | + feature_extractor.h |
| 66 | + feature_types.cc |
| 67 | + fml_parser.cc |
| 68 | + language_identifier_features.cc |
| 69 | + lang_id_nn_params.cc |
| 70 | + nnet_language_identifier.cc |
| 71 | + registry.cc |
| 72 | + relevant_script_feature.cc |
| 73 | + sentence_features.cc |
| 74 | + task_context.cc |
| 75 | + task_context_params.cc |
| 76 | + unicodetext.cc |
| 77 | + utils.cc |
| 78 | + workspace.cc |
| 79 | + |
| 80 | + script_span/generated_entities.cc |
| 81 | + script_span/getonescriptspan.cc |
| 82 | + script_span/getonescriptspan.h |
| 83 | + script_span/utf8statetable.cc |
| 84 | + script_span/offsetmap.cc |
| 85 | + script_span/text_processing.cc |
| 86 | + script_span/text_processing.h |
| 87 | + script_span/fixunicodevalue.cc |
| 88 | +) |
| 89 | + |
| 90 | +target_include_directories(external_cld3_bundled |
| 91 | +PUBLIC |
| 92 | + ${cld3_src} |
| 93 | + ${gen_loc} |
| 94 | +) |
| 95 | + |
| 96 | +if (NOT DESKTOP_APP_USE_PACKAGED) |
| 97 | + target_include_directories(external_cld3_bundled |
| 98 | + PUBLIC |
| 99 | + ${libs_loc}/protobuf/src |
| 100 | + ${libs_loc}/protobuf/third_party/abseil-cpp |
| 101 | + ) |
| 102 | +endif() |
| 103 | + |
| 104 | +target_link_libraries(external_cld3_bundled |
| 105 | +PRIVATE |
| 106 | + ${protobuf_lib} |
| 107 | +) |
| 108 | + |
| 109 | +target_link_libraries(external_cld3 |
| 110 | +INTERFACE |
| 111 | + external_cld3_bundled |
| 112 | +) |
0 commit comments