summaryrefslogtreecommitdiffstats
path: root/data/CMakeLists.txt
blob: 90375e64e7fbeeee871e35f47f7779ff71b393e1 (plain)
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
62
63
64
65
66
67
68
69
70
71
72
set(
    BINARY_MODEL_DATA
    gb_char.bin
    gbk_char.bin
    phrase_index.bin
    pinyin_index.bin
    bigram.db
)

set(
    BINARY_MODEL_DATA_FILES
    ${CMAKE_BINARY_DIR}/data/gb_char.bin
    ${CMAKE_BINARY_DIR}/data/gbk_char.bin
    ${CMAKE_BINARY_DIR}/data/phrase_index.bin
    ${CMAKE_BINARY_DIR}/data/pinyin_index.bin
    ${CMAKE_BINARY_DIR}/data/bigram.db
)

set(
    gen_binary_files_BIN
    ${CMAKE_BINARY_DIR}/utils/storage/gen_binary_files
)

set(
    import_interpolation_BIN
    ${CMAKE_BINARY_DIR}/utils/storage/import_interpolation
)

add_custom_target(
    data
    ALL
    DEPENDS
        ${BINARY_MODEL_DATA}
)

add_custom_command(
    OUTPUT
        gb_char.bin
        gbk_char.bin
        phrase_index.bin
        pinyin_index.bin
    COMMENT
        "Building binary model data..."
    COMMAND
        ${gen_binary_files_BIN} --table-dir ${CMAKE_SOURCE_DIR}/data
    DEPENDS
        gen_binary_files
)

add_custom_command(
    OUTPUT
        bigram.db
    COMMENT
        "Building binary bigram data..."
    COMMAND
        ${import_interpolation_BIN} < ${CMAKE_SOURCE_DIR}/data/interpolation.text
    DEPENDS
        import_interpolation
)

install(
    FILES
        ${BINARY_MODEL_DATA_FILES}
    DESTINATION
        ${DIR_SHARE_LIBPINYIN}/data
)

set_directory_properties(
    PROPERTIES
        ADDITIONAL_MAKE_CLEAN_FILES
            ${BINARY_MODEL_DATA_FILES}
)