diff --git a/recipe/build-lib.bat b/recipe/build-lib.bat index 02e3d6a..67e20e8 100644 --- a/recipe/build-lib.bat +++ b/recipe/build-lib.bat @@ -8,8 +8,6 @@ cmake -G "Ninja" ^ -DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX%;%LIBRARY_BIN%;%LIBRARY_LIB% ^ -DCMAKE_INCLUDE_PATH=%LIBRARY_INC% ^ -DCMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX% ^ - -DCMAKE_INSTALL_LIBDIR="lib" ^ - -DCMAKE_INSTALL_INCLUDEDIR="include" ^ -Dprotobuf_BUILD_SHARED_LIBS=OFF ^ -DSPM_ENABLE_SHARED=OFF ^ -DSPM_ABSL_PROVIDER="package" ^ diff --git a/recipe/build-lib.sh b/recipe/build-lib.sh index 4beeaea..de788b2 100644 --- a/recipe/build-lib.sh +++ b/recipe/build-lib.sh @@ -11,8 +11,6 @@ fi cmake -G "Ninja" \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=$PREFIX \ - -DCMAKE_INSTALL_LIBDIR="lib" \ - -DCMAKE_INSTALL_INCLUDEDIR="include" \ -DCMAKE_AR="${AR}" \ -DSPM_ENABLE_SHARED=ON \ -DSPM_ENABLE_TCMALLOC=OFF \ diff --git a/recipe/meta.yaml b/recipe/meta.yaml index a17df22..11bd263 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -10,16 +10,16 @@ source: patches: # trying to build both static & shared build seems to break on OSX - patches/0001-do-not-mix-static-shared-builds.patch - # unvendor abseil & protobuf-lite - - patches/0002-do-not-build-vendored-abseil-libprotobuf-lite.patch # ensure python bindings link to correct libs on windows - - patches/0003-point-to-our-libs-headers-for-windows-in-setup.py.patch + - patches/0002-point-to-our-libs-headers-for-windows-in-setup.py.patch # install pkg-config metadata also on windows - - patches/0004-also-install-pkg-config-files-on-windows.patch + - patches/0003-also-install-pkg-config-files-on-windows.patch # install CMake metadata - - patches/0005-create-and-install-CMake-metadata.patch + - patches/0004-create-and-install-CMake-metadata.patch # fix abseil setup on windows - - patches/0006-also-link-to-static-absl_flags_-on-windows.patch + - patches/0005-also-link-to-static-absl_flags_-on-windows.patch + # avoid having to specify CMAKE_INSTALL_{LIB,INCLUDE}DIR due to wrong order + - patches/0006-move-setting-of-default-CMAKE_INSTALL_-BIN-INCLUDE-L.patch build: number: 0 diff --git a/recipe/patches/0002-do-not-build-vendored-abseil-libprotobuf-lite.patch b/recipe/patches/0002-do-not-build-vendored-abseil-libprotobuf-lite.patch deleted file mode 100644 index d921105..0000000 --- a/recipe/patches/0002-do-not-build-vendored-abseil-libprotobuf-lite.patch +++ /dev/null @@ -1,37 +0,0 @@ -From ab5c20be4a987d1cd6d2e472634f5e1b9c11211f Mon Sep 17 00:00:00 2001 -From: "H. Vetinari" -Date: Thu, 2 Dec 2021 10:05:12 +1100 -Subject: [PATCH 2/6] do not build vendored abseil & libprotobuf-lite - -ensure we can use shared builds of libprotobuf also on windows ---- - src/CMakeLists.txt | 5 +++++ - third_party/CMakeLists.txt | 5 +---- - 2 files changed, 6 insertions(+), 4 deletions(-) - -diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt -index fbdf238..2b8aefa 100644 ---- a/src/CMakeLists.txt -+++ b/src/CMakeLists.txt -@@ -71,6 +71,11 @@ if (SPM_PROTOBUF_PROVIDER STREQUAL "internal") - include_directories(builtin_pb) - elseif (SPM_PROTOBUF_PROVIDER STREQUAL "package") - find_package(Protobuf REQUIRED) -+ if (MSVC) -+ add_definitions("/DPROTOBUF_USE_DLLS") -+ else() -+ add_definitions("-DPROTOBUF_USE_DLLS") -+ endif() - include_directories(${Protobuf_INCLUDE_DIRS}) - protobuf_generate_cpp(SPM_PROTO_SRCS SPM_PROTO_HDRS sentencepiece.proto) - protobuf_generate_cpp(SPM_MODEL_PROTO_SRCS SPM_MODEL_PROTO_HDRS sentencepiece_model.proto) -diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt -index d00ecba..3096702 100644 ---- a/third_party/CMakeLists.txt -+++ b/third_party/CMakeLists.txt -@@ -1,4 +1 @@ --include_directories(absl/strings darts_clone esaxx protobuf-lite) -- -- -- -+include_directories(darts_clone esaxx) diff --git a/recipe/patches/0003-point-to-our-libs-headers-for-windows-in-setup.py.patch b/recipe/patches/0002-point-to-our-libs-headers-for-windows-in-setup.py.patch similarity index 94% rename from recipe/patches/0003-point-to-our-libs-headers-for-windows-in-setup.py.patch rename to recipe/patches/0002-point-to-our-libs-headers-for-windows-in-setup.py.patch index 82499c7..b5f0589 100644 --- a/recipe/patches/0003-point-to-our-libs-headers-for-windows-in-setup.py.patch +++ b/recipe/patches/0002-point-to-our-libs-headers-for-windows-in-setup.py.patch @@ -1,7 +1,7 @@ -From 428ac3758e24b1aeedec8e0568d128e2097d1646 Mon Sep 17 00:00:00 2001 +From bf4bd0aa4b0c2c2669f761922b85870643568dfe Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Sun, 11 Dec 2022 01:09:03 +1100 -Subject: [PATCH 3/6] point to our libs / headers for windows in setup.py +Subject: [PATCH 2/6] point to our libs / headers for windows in setup.py also do not risk building against bundled libs, nor setting /MT for the MSVC static runtime libs diff --git a/recipe/patches/0004-also-install-pkg-config-files-on-windows.patch b/recipe/patches/0003-also-install-pkg-config-files-on-windows.patch similarity index 86% rename from recipe/patches/0004-also-install-pkg-config-files-on-windows.patch rename to recipe/patches/0003-also-install-pkg-config-files-on-windows.patch index af08f2c..27866cf 100644 --- a/recipe/patches/0004-also-install-pkg-config-files-on-windows.patch +++ b/recipe/patches/0003-also-install-pkg-config-files-on-windows.patch @@ -1,7 +1,7 @@ -From f6ec12fe46a666940007cb205e715ee6f3916e97 Mon Sep 17 00:00:00 2001 +From f3b6c5baf0d5bd4ba2bb31039ad05a939d9d14df Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Mon, 12 Dec 2022 14:36:45 +1100 -Subject: [PATCH 4/6] also install pkg-config files on windows +Subject: [PATCH 3/6] also install pkg-config files on windows --- CMakeLists.txt | 4 +--- diff --git a/recipe/patches/0005-create-and-install-CMake-metadata.patch b/recipe/patches/0004-create-and-install-CMake-metadata.patch similarity index 91% rename from recipe/patches/0005-create-and-install-CMake-metadata.patch rename to recipe/patches/0004-create-and-install-CMake-metadata.patch index e357c36..70d6988 100644 --- a/recipe/patches/0005-create-and-install-CMake-metadata.patch +++ b/recipe/patches/0004-create-and-install-CMake-metadata.patch @@ -1,7 +1,7 @@ -From 366a1080b048a43452bdfb43968c5f2a44acdcf4 Mon Sep 17 00:00:00 2001 +From bb6fce08448e4ba5aec0bbae6c2aa43959ecb054 Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Wed, 18 Jan 2023 19:44:15 +1100 -Subject: [PATCH 5/6] create and install CMake metadata +Subject: [PATCH 4/6] create and install CMake metadata --- CMakeLists.txt | 10 ++++++++++ @@ -46,10 +46,10 @@ index 0000000..b4c0474 +# Targets +include(${CMAKE_CURRENT_LIST_DIR}/sentencepieceTargets.cmake) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt -index 2b8aefa..eed204f 100644 +index fbdf238..6ff0a69 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt -@@ -244,7 +244,7 @@ endif() +@@ -239,7 +239,7 @@ endif() if (SPM_ENABLE_SHARED) target_link_libraries(sentencepiece ${SPM_LIBS}) target_link_libraries(sentencepiece_train ${SPM_LIBS} sentencepiece) @@ -58,7 +58,7 @@ index 2b8aefa..eed204f 100644 set_target_properties(sentencepiece sentencepiece_train PROPERTIES SOVERSION 0 VERSION 0.0.0) set_target_properties(sentencepiece PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS YES) set_target_properties(sentencepiece_train PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS YES) -@@ -258,7 +258,7 @@ if (SPM_ENABLE_SHARED) +@@ -253,7 +253,7 @@ if (SPM_ENABLE_SHARED) else() add_library(sentencepiece ALIAS sentencepiece-static) add_library(sentencepiece_train ALIAS sentencepiece_train-static) @@ -67,7 +67,7 @@ index 2b8aefa..eed204f 100644 set_target_properties(sentencepiece-static PROPERTIES OUTPUT_NAME "sentencepiece") set_target_properties(sentencepiece_train-static PROPERTIES OUTPUT_NAME "sentencepiece_train") -@@ -305,7 +305,7 @@ if (SPM_ENABLE_NFKC_COMPILE) +@@ -300,7 +300,7 @@ if (SPM_ENABLE_NFKC_COMPILE) target_link_libraries(compile_charsmap sentencepiece sentencepiece_train) endif() @@ -76,7 +76,7 @@ index 2b8aefa..eed204f 100644 spm_encode spm_decode spm_normalize spm_train spm_export_vocab) if (CMAKE_SYSTEM_NAME STREQUAL "iOS") -@@ -315,12 +315,21 @@ if (CMAKE_SYSTEM_NAME STREQUAL "iOS") +@@ -310,12 +310,21 @@ if (CMAKE_SYSTEM_NAME STREQUAL "iOS") LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) else() diff --git a/recipe/patches/0006-also-link-to-static-absl_flags_-on-windows.patch b/recipe/patches/0005-also-link-to-static-absl_flags_-on-windows.patch similarity index 92% rename from recipe/patches/0006-also-link-to-static-absl_flags_-on-windows.patch rename to recipe/patches/0005-also-link-to-static-absl_flags_-on-windows.patch index c7617bf..ba65d3f 100644 --- a/recipe/patches/0006-also-link-to-static-absl_flags_-on-windows.patch +++ b/recipe/patches/0005-also-link-to-static-absl_flags_-on-windows.patch @@ -1,7 +1,7 @@ -From 64f7608bd0757387cee221df7014c9bdbe78585b Mon Sep 17 00:00:00 2001 +From 1e169c989ce79a49c40b3e8c210005fdc013648e Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Tue, 20 Feb 2024 17:43:23 +1100 -Subject: [PATCH 6/6] also link to static absl_flags_* on windows +Subject: [PATCH 5/6] also link to static absl_flags_* on windows --- python/setup.py | 10 +++++++++- diff --git a/recipe/patches/0006-move-setting-of-default-CMAKE_INSTALL_-BIN-INCLUDE-L.patch b/recipe/patches/0006-move-setting-of-default-CMAKE_INSTALL_-BIN-INCLUDE-L.patch new file mode 100644 index 0000000..3be8a3b --- /dev/null +++ b/recipe/patches/0006-move-setting-of-default-CMAKE_INSTALL_-BIN-INCLUDE-L.patch @@ -0,0 +1,52 @@ +From f25582c062c1deb4d60302135443e7506972c6aa Mon Sep 17 00:00:00 2001 +From: "H. Vetinari" +Date: Tue, 20 Feb 2024 18:43:25 +1100 +Subject: [PATCH 6/6] move setting of default + CMAKE_INSTALL_{BIN,INCLUDE,LIB}DIR before first use + +--- + CMakeLists.txt | 24 ++++++++++++------------ + 1 file changed, 12 insertions(+), 12 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 56830cf..8633318 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -57,6 +57,18 @@ if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND + string(APPEND CMAKE_CXX_FLAGS " -fmacro-prefix-map=${CMAKE_SOURCE_DIR}/=''") + endif() + ++if (NOT DEFINED CMAKE_INSTALL_BINDIR) ++ set(CMAKE_INSTALL_BINDIR bin) ++endif() ++ ++if (NOT DEFINED CMAKE_INSTALL_LIBDIR) ++ set(CMAKE_INSTALL_LIBDIR lib) ++endif() ++ ++if (NOT DEFINED CMAKE_INSTALL_INCDIR) ++ set(CMAKE_INSTALL_INCDIR include) ++endif() ++ + if (UNIX) + include(GNUInstallDirs) + set(prefix ${CMAKE_INSTALL_PREFIX}) +@@ -103,18 +115,6 @@ if (APPLE) + endif() + endif() + +-if (NOT DEFINED CMAKE_INSTALL_BINDIR) +- set(CMAKE_INSTALL_BINDIR bin) +-endif() +- +-if (NOT DEFINED CMAKE_INSTALL_LIBDIR) +- set(CMAKE_INSTALL_LIBDIR lib) +-endif() +- +-if (NOT DEFINED CMAKE_INSTALL_INCDIR) +- set(CMAKE_INSTALL_INCDIR include) +-endif() +- + # SPDX-License-Identifier: (MIT OR CC0-1.0) + # Copyright 2020 Jan Tojnar + # https://github.com/jtojnar/cmake-snips