-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
89 lines (79 loc) · 3.11 KB
/
Copy pathCMakeLists.txt
File metadata and controls
89 lines (79 loc) · 3.11 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
cmake_minimum_required(VERSION 3.6)
project(McBopomofoLMLib)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
add_subdirectory(gramambular2)
add_subdirectory(Mandarin)
add_library(McBopomofoLMLib
AssociatedPhrasesV2.h
AssociatedPhrasesV2.cpp
ByteBlockBackedDictionary.h
ByteBlockBackedDictionary.cpp
McBopomofoLM.h
McBopomofoLM.cpp
MemoryMappedFile.h
MemoryMappedFile.cpp
ParselessLM.h
ParselessLM.cpp
ParselessPhraseDB.h
ParselessPhraseDB.cpp
PhraseReplacementMap.h
PhraseReplacementMap.cpp
UTF8Helper.h
UTF8Helper.cpp
UserOverrideModel.h
UserOverrideModel.cpp
UserPhrasesLM.h
UserPhrasesLM.cpp)
if (ENABLE_CLANG_TIDY)
set_target_properties(McBopomofoLMLib PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}")
endif ()
if (ENABLE_TEST)
enable_testing()
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
cmake_policy(SET CMP0135 NEW)
endif()
if (NOT GTest_FOUND)
# Specify release version from https://github.com/google/googletest/releases
set(GTEST_VERSION "v1.14.0")
MESSAGE(STATUS "Fetching GoogleTest ${GTEST_VERSION} from GitHub")
# Let CMake fetch Google Test for us.
# https://github.com/google/googletest/tree/main/googletest#incorporating-into-an-existing-cmake-project
include(FetchContent)
FetchContent_Declare(
googletest
URL "https://github.com/google/googletest/archive/refs/tags/${GTEST_VERSION}.zip"
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
endif()
# Test target declarations.
add_executable(McBopomofoLMLibTest
AssociatedPhrasesV2Test.cpp
ByteBlockBackedDictionaryTest.cpp
McBopomofoLMTest.cpp
MemoryMappedFileTest.cpp
ParselessLMTest.cpp
ParselessPhraseDBTest.cpp
PhraseReplacementMapTest.cpp
UTF8HelperTest.cpp
UserOverrideModelTest.cpp
UserPhrasesLMTest.cpp)
target_link_libraries(McBopomofoLMLibTest GTest::gtest_main McBopomofoLMLib gramambular2_lib)
include(GoogleTest)
gtest_discover_tests(McBopomofoLMLibTest)
add_custom_target(
runMcBopomofoLMLibTest
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/McBopomofoLMLibTest
)
add_dependencies(runMcBopomofoLMLibTest McBopomofoLMLibTest)
# Benchmark target; to run, manually uncomment the lines below.
#
# find_package(benchmark)
# add_executable(ParselessLMBenchmark
# ParselessLMBenchmark.cpp)
# target_link_libraries(ParselessLMBenchmark McBopomofoLMLib benchmark::benchmark)
endif ()