File size: 1,774 Bytes
1ce325b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Eigen3 less than 3.1.0 has a race condition: http://eigen.tuxfamily.org/bz/show_bug.cgi?id=466

if(ENABLE_INTERPOLATE)
  find_package(Eigen3 3.1.0 CONFIG REQUIRED)
  include_directories(${EIGEN3_INCLUDE_DIR})

  set(KENLM_INTERPOLATE_SOURCE
    backoff_reunification.cc
    bounded_sequence_encoding.cc
    merge_probabilities.cc
    merge_vocab.cc
    normalize.cc
    pipeline.cc
    split_worker.cc
    tune_derivatives.cc
    tune_instances.cc
    tune_weights.cc
    universal_vocab.cc)

  add_library(kenlm_interpolate ${KENLM_INTERPOLATE_SOURCE})
  target_link_libraries(kenlm_interpolate PUBLIC kenlm Eigen3::Eigen)
  # Since headers are relative to `include/kenlm` at install time, not just `include`
  target_include_directories(kenlm_interpolate PUBLIC $<INSTALL_INTERFACE:include/kenlm>)


  find_package(OpenMP)
  if (OPENMP_CXX_FOUND)
    target_link_libraries(kenlm_interpolate PUBLIC OpenMP::OpenMP_CXX)
  endif()


  set(KENLM_INTERPOLATE_EXES
    interpolate
    streaming_example)

  set(KENLM_INTERPOLATE_LIBS
    kenlm_interpolate)

  AddExes(EXES ${KENLM_INTERPOLATE_EXES}
    LIBRARIES ${KENLM_INTERPOLATE_LIBS})

  install(
    TARGETS kenlm_interpolate
    EXPORT kenlmTargets
    RUNTIME DESTINATION bin
    LIBRARY DESTINATION lib
    ARCHIVE DESTINATION lib
    INCLUDES DESTINATION include
  )
  
  if(BUILD_TESTING)
    AddTests(TESTS backoff_reunification_test bounded_sequence_encoding_test merge_vocab_test normalize_test tune_derivatives_test
      LIBRARIES ${KENLM_INTERPOLATE_LIBS} Threads::Threads)

    # tune_instances_test needs an extra command line parameter
    KenLMAddTest(TEST tune_instances_test
      LIBRARIES ${KENLM_INTERPOLATE_LIBS}
      TEST_ARGS -- ${CMAKE_CURRENT_SOURCE_DIR}/../common/test_data)
  endif()
endif()