From 6b0fa8ceb6de2332a97f5628c5279b2b3ec9cb9f Mon Sep 17 00:00:00 2001 From: songkq Date: Mon, 22 May 2023 08:30:38 +0800 Subject: [PATCH 1/2] Update CMakeLists.txt Add ${TOKENIZERS_C_LINK_LIBS} and append ${CMAKE_DL_LIBS} for Linux platform (https://github.com/mlc-ai/tokenizers-cpp/issues/1#issuecomment-1556206254) --- CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 49b4933..fe8728e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,10 +7,13 @@ set(TOKENIZERS_CPP_CARGO_TARGET "") # extra link libraries set(TOKENIZERS_CPP_LINK_LIBS "") +set(TOKENIZERS_C_LINK_LIBS "") set(CARGO_EXTRA_ENVS "") message(STATUS "system-name" ${CMAKE_SYSTEM_NAME}) -if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten") +if (CMAKE_SYSTEM_NAME STREQUAL "Linux") + list(APPEND TOKENIZERS_C_LINK_LIBS ${CMAKE_DL_LIBS}) +elseif (CMAKE_SYSTEM_NAME STREQUAL "Emscripten") set(TOKENIZERS_CPP_CARGO_TARGET wasm32-unknown-emscripten) elseif (CMAKE_SYSTEM_NAME STREQUAL "iOS") set(TOKENIZERS_CPP_CARGO_TARGET aarch64-apple-ios) @@ -107,7 +110,7 @@ endif() add_subdirectory(sentencepiece sentencepiece EXCLUDE_FROM_ALL) add_library(tokenizers_c INTERFACE ${TOKENIZERS_RUST_LIB}) -target_link_libraries(tokenizers_c INTERFACE ${TOKENIZERS_RUST_LIB}) +target_link_libraries(tokenizers_c INTERFACE ${TOKENIZERS_RUST_LIB} ${TOKENIZERS_C_LINK_LIBS}) add_library(tokenizers_cpp STATIC $) target_link_libraries(tokenizers_cpp PRIVATE tokenizers_c sentencepiece-static ${TOKENIZERS_CPP_LINK_LIBS}) From 64aefe3c5e509dd67ede1c0e9163497df95c131c Mon Sep 17 00:00:00 2001 From: songkq Date: Mon, 22 May 2023 22:17:10 +0800 Subject: [PATCH 2/2] Update CMakeLists.txt move some of the TOKENIZERS_CPP_LINK_LIBS deps to TOKENIZERS_C_LINK_LIBS. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fe8728e..f34c81c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ elseif (CMAKE_SYSTEM_NAME STREQUAL "iOS") # add extra dependency needed for rust tokenizer in iOS find_library(FOUNDATION_LIB Foundation) find_library(SECURITY_LIB Security) - list(APPEND TOKENIZERS_CPP_LINK_LIBS ${FOUNDATION_LIB} ${SECURITY_LIB}) + list(APPEND TOKENIZERS_C_LINK_LIBS ${FOUNDATION_LIB} ${SECURITY_LIB}) elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin") if (CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64") set(TOKENIZERS_CPP_CARGO_TARGET aarch64-apple-darwin) @@ -37,7 +37,7 @@ elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows") endif() if(WIN32) - list(APPEND TOKENIZERS_CPP_LINK_LIBS + list(APPEND TOKENIZERS_C_LINK_LIBS wsock32 ws2_32 Bcrypt iphlpapi userenv psapi )