@@ -19,7 +19,8 @@ project(Tokenizers)
19
19
option (TOKENIZERS_BUILD_TEST "Build tests" OFF )
20
20
option (TOKENIZERS_BUILD_TOOLS "Build tools" OFF )
21
21
option (SUPPORT_REGEX_LOOKAHEAD
22
- "Support regex lookahead patterns (requires PCRE2)" OFF )
22
+ "Support regex lookahead patterns (requires PCRE2)" OFF
23
+ )
23
24
24
25
# Include CMakePackageConfigHelpers for configure_package_config_file
25
26
include (CMakePackageConfigHelpers )
@@ -50,22 +51,27 @@ set(tokenizers_source_files
50
51
${CMAKE_CURRENT_SOURCE_DIR} /src/regex.cpp
51
52
${CMAKE_CURRENT_SOURCE_DIR} /src/sentencepiece.cpp
52
53
${CMAKE_CURRENT_SOURCE_DIR} /src/tiktoken.cpp
53
- ${CMAKE_CURRENT_SOURCE_DIR} /src/token_decoder.cpp )
54
+ ${CMAKE_CURRENT_SOURCE_DIR} /src/token_decoder.cpp
55
+ )
54
56
55
57
file (GLOB unicode_source_files
56
- ${CMAKE_CURRENT_SOURCE_DIR} /third-party/llama.cpp-unicode/src/*.cpp )
57
- add_library (tokenizers STATIC ${tokenizers_source_files}
58
- ${unicode_source_files} )
58
+ ${CMAKE_CURRENT_SOURCE_DIR} /third-party/llama.cpp-unicode/src/*.cpp
59
+ )
60
+ add_library (
61
+ tokenizers STATIC ${tokenizers_source_files} ${unicode_source_files}
62
+ )
59
63
60
64
# Using abseil from sentencepiece/third_party
61
65
target_include_directories (
62
66
tokenizers
63
- PUBLIC $< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /include>
64
- $< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /third-party/sentencepiece>
65
- $< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /third-party/sentencepiece/src>
66
- $< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /third-party/re2>
67
- $< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /third-party/json/single_include>
68
- $< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /third-party/llama.cpp-unicode/include> )
67
+ PUBLIC
68
+ $< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /include>
69
+ $< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /third-party/sentencepiece>
70
+ $< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /third-party/sentencepiece/src>
71
+ $< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /third-party/re2>
72
+ $< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /third-party/json/single_include>
73
+ $< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /third-party/llama.cpp-unicode/include>
74
+ )
69
75
target_link_libraries (tokenizers PUBLIC sentencepiece-static re2::re2 )
70
76
71
77
if (SUPPORT_REGEX_LOOKAHEAD )
@@ -82,18 +88,24 @@ if(SUPPORT_REGEX_LOOKAHEAD)
82
88
add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /third-party/pcre2 )
83
89
84
90
# Set the INTERFACE_INCLUDE_DIRECTORIES property for pcre2-8-static
85
- set_target_properties (pcre2-8-static PROPERTIES
86
- INTERFACE_INCLUDE_DIRECTORIES $< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /third-party/pcre2/src>
91
+ set_target_properties (
92
+ pcre2-8-static
93
+ PROPERTIES
94
+ INTERFACE_INCLUDE_DIRECTORIES
95
+ $< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /third-party/pcre2/src>
87
96
)
88
97
add_library (
89
98
regex_lookahead STATIC
90
99
${CMAKE_CURRENT_SOURCE_DIR} /src/pcre2_regex.cpp
91
100
${CMAKE_CURRENT_SOURCE_DIR} /src/regex_lookahead.cpp
92
- ${CMAKE_CURRENT_SOURCE_DIR} /src/std_regex.cpp )
101
+ ${CMAKE_CURRENT_SOURCE_DIR} /src/std_regex.cpp
102
+ )
93
103
target_link_libraries (regex_lookahead PUBLIC pcre2-8 )
94
104
target_include_directories (
95
- regex_lookahead PUBLIC $< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /include>
96
- $< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /third-party/pcre2/src> )
105
+ regex_lookahead
106
+ PUBLIC $< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /include>
107
+ $< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /third-party/pcre2/src>
108
+ )
97
109
target_link_options_shared_lib (regex_lookahead )
98
110
target_link_libraries (tokenizers PUBLIC regex_lookahead )
99
111
install (
@@ -126,13 +138,15 @@ install(
126
138
install (
127
139
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} /include/
128
140
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
129
- FILES_MATCHING PATTERN "*.h"
141
+ FILES_MATCHING
142
+ PATTERN "*.h"
130
143
)
131
144
132
145
install (
133
146
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} /third-party/json/single_include/
134
147
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
135
- FILES_MATCHING PATTERN "*.hpp"
148
+ FILES_MATCHING
149
+ PATTERN "*.hpp"
136
150
)
137
151
138
152
# Install the CMake config files
@@ -151,7 +165,6 @@ configure_package_config_file(
151
165
PATH_VARS CMAKE_INSTALL_INCLUDEDIR
152
166
)
153
167
154
- install (
155
- FILES ${CMAKE_CURRENT_BINARY_DIR} /tokenizers-config.cmake
156
- DESTINATION ${CMAKE_INSTALL_LIBDIR} /cmake/tokenizers
168
+ install (FILES ${CMAKE_CURRENT_BINARY_DIR} /tokenizers-config.cmake
169
+ DESTINATION ${CMAKE_INSTALL_LIBDIR} /cmake/tokenizers
157
170
)
0 commit comments