diff --git a/CMakeLists.txt b/CMakeLists.txt index fb6da74..120d349 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,6 +75,7 @@ file(GLOB unicode_source_files add_library( tokenizers STATIC ${tokenizers_source_files} ${unicode_source_files} ) +add_library(tokenizers::tokenizers ALIAS tokenizers) # Using abseil from sentencepiece/third_party target_include_directories( @@ -115,6 +116,7 @@ if(SUPPORT_REGEX_LOOKAHEAD) ${CMAKE_CURRENT_SOURCE_DIR}/src/regex_lookahead.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/std_regex.cpp ) + add_library(tokenizers::regex_lookahead ALIAS regex_lookahead) target_link_libraries(regex_lookahead PUBLIC pcre2-8-static) target_include_directories( regex_lookahead diff --git a/Utils.cmake b/Utils.cmake index 698323b..3ab31a1 100644 --- a/Utils.cmake +++ b/Utils.cmake @@ -20,21 +20,21 @@ function(kernel_link_options target_name) # "$") target_link_options( ${target_name} INTERFACE "SHELL:LINKER:--whole-archive \ - $ \ + $ \ LINKER:--no-whole-archive") endfunction() # Same as kernel_link_options but it's for MacOS linker function(macos_kernel_link_options target_name) target_link_options(${target_name} INTERFACE - "SHELL:LINKER:-force_load,$") + "SHELL:LINKER:-force_load,$") endfunction() # Same as kernel_link_options but it's for MSVC linker function(msvc_kernel_link_options target_name) target_link_options( ${target_name} INTERFACE - "SHELL:LINKER:/WHOLEARCHIVE:$") + "SHELL:LINKER:/WHOLEARCHIVE:$") endfunction() # Ensure that the load-time constructor functions run. By default, the linker diff --git a/cmake/tokenizers-config.cmake.in b/cmake/tokenizers-config.cmake.in index f0a9bb7..460fd75 100644 --- a/cmake/tokenizers-config.cmake.in +++ b/cmake/tokenizers-config.cmake.in @@ -7,12 +7,12 @@ @PACKAGE_INIT@ include(CMakeFindDependencyMacro) - +include(GNUInstallDirs) # Find dependencies find_dependency(re2 REQUIRED) find_dependency(absl REQUIRED) # Directly include sentencepiece library -set(SENTENCEPIECE_LIBRARY "${CMAKE_INSTALL_PREFIX}/lib64/libsentencepiece.a") +set(SENTENCEPIECE_LIBRARY "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libsentencepiece.a") if(NOT EXISTS "${SENTENCEPIECE_LIBRARY}") message( FATAL_ERROR @@ -26,21 +26,6 @@ include("${CMAKE_CURRENT_LIST_DIR}/tokenizers-targets.cmake") # Set the include directories set_and_check(TOKENIZERS_INCLUDE_DIRS "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@") -# Add --whole-archive linker flag for tokenizers library -if(APPLE) - set(TOKENIZERS_LINK_OPTIONS - "SHELL:-force_load,$" - ) -elseif(MSVC) - set(TOKENIZERS_LINK_OPTIONS - "SHELL:/WHOLEARCHIVE:$" - ) -else() - set(TOKENIZERS_LINK_OPTIONS - "SHELL:LINKER:--whole-archive $ LINKER:--no-whole-archive" - ) -endif() - # Set the libraries and link options set(TOKENIZERS_LIBRARIES tokenizers::tokenizers) set_property(