|
| 1 | +# This cmake scripts only builds a static cld3 lib and the unittests. |
| 2 | +project(cld3) |
| 3 | + |
| 4 | +# Old versions of cmake dont search/find protobuf lite |
| 5 | +cmake_minimum_required(VERSION 3.9) |
| 6 | + |
| 7 | +find_package(Protobuf REQUIRED) |
| 8 | +message(STATUS "Protobuf_FOUND= ${Protobuf_FOUND}") |
| 9 | +message(STATUS "Protobuf_VERSION= ${Protobuf_VERSION}") |
| 10 | +message(WARNING "Protobuf 2.5 and CLD3 seems happy together. This script does NOT check if your verison of protobuf is compatible.") |
| 11 | +message(STATUS "Protobuf_LIBRARIES= ${Protobuf_LIBRARIES}") |
| 12 | +message(STATUS "Protobuf_LITE_LIBRARIES= ${Protobuf_LITE_LIBRARIES}") # Usually /usr/lib64/libprotobuf-lite.so |
| 13 | + |
| 14 | +# By default, protobuf_generate_cpp generates pb.* files directy in the cmake build dir. |
| 15 | +# But CLD3 sources have been coded using hard coded pathes to cld_3/protos/*.pb.h. |
| 16 | +# So *.pb.h must be output to cld_3/protos. |
| 17 | +# For that, let's use a custom my_protobuf_generate_cpp: |
| 18 | +include(${CMAKE_CURRENT_SOURCE_DIR}/misc/myprotobuf.cmake) |
| 19 | +my_protobuf_generate_cpp(cld_3/protos PROTO_SRCS PROTO_HDRS src/feature_extractor.proto src/sentence.proto src/task_spec.proto) |
| 20 | +message(STATUS "PROTO_HDRS= ${PROTO_HDRS}") |
| 21 | + |
| 22 | +add_definitions(-fPIC) # Position Independant Code |
| 23 | +add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0) |
| 24 | +add_definitions(-std=c++11) # Needed for std::to_string(), ... |
| 25 | + |
| 26 | +include_directories(${CMAKE_CURRENT_BINARY_DIR}) # needed to include generated pb headers |
| 27 | + |
| 28 | +add_library(${PROJECT_NAME} |
| 29 | + ${PROTO_SRCS} ${PROTO_HDRS} |
| 30 | + src/base.cc |
| 31 | + src/embedding_feature_extractor.cc |
| 32 | + src/embedding_network.cc |
| 33 | + src/feature_extractor.cc |
| 34 | + src/feature_extractor.h |
| 35 | + src/feature_types.cc |
| 36 | + src/fml_parser.cc |
| 37 | + src/language_identifier_features.cc |
| 38 | + src/lang_id_nn_params.cc |
| 39 | + src/nnet_language_identifier.cc |
| 40 | + src/registry.cc |
| 41 | + src/relevant_script_feature.cc |
| 42 | + src/sentence_features.cc |
| 43 | + src/task_context.cc |
| 44 | + src/task_context_params.cc |
| 45 | + src/unicodetext.cc |
| 46 | + src/utils.cc |
| 47 | + src/workspace.cc |
| 48 | + |
| 49 | + src/script_span/generated_entities.cc |
| 50 | + src/script_span/getonescriptspan.cc |
| 51 | + src/script_span/getonescriptspan.h |
| 52 | + src/script_span/getonescriptspan_test.cc |
| 53 | + src/script_span/utf8statetable.cc |
| 54 | + src/script_span/offsetmap.cc |
| 55 | + src/script_span/text_processing.cc |
| 56 | + src/script_span/text_processing.h |
| 57 | + src/script_span/fixunicodevalue.cc |
| 58 | + ) |
| 59 | + |
| 60 | +# unit tests exec: |
| 61 | +add_executable(language_identifier_main src/language_identifier_main.cc) |
| 62 | +target_link_libraries(language_identifier_main cld3 ${Protobuf_LITE_LIBRARIES}) |
| 63 | + |
| 64 | +add_executable(getonescriptspan_test src/script_span/getonescriptspan_test.cc) |
| 65 | +target_link_libraries(getonescriptspan_test cld3 ${Protobuf_LITE_LIBRARIES}) |
| 66 | + |
| 67 | +add_executable(language_identifier_features_test src/language_identifier_features_test.cc) |
| 68 | +target_link_libraries(language_identifier_features_test cld3 ${Protobuf_LITE_LIBRARIES}) |
0 commit comments