GetSTEMMER.cmake 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #=============================================================================
  2. # Copyright 2017-2026, Manticore Software LTD (https://manticoresearch.com)
  3. #
  4. # Distributed under the OSI-approved BSD License (the "License");
  5. # see accompanying file Copyright.txt for details.
  6. #
  7. # This software is distributed WITHOUT ANY WARRANTY; without even the
  8. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. # See the License for more information.
  10. #=============================================================================
  11. # This file need to get libstemmer sources
  12. # First it try 'traditional' way - find stemmer package.
  13. # Then (if it is not found) it try to look into ${LIBS_BUNDLE} for file named 'libstemmer_c.tgz'
  14. # It is supposed, that file (if any) contains archive from snowball with stemmer's sources.
  15. # If no file found, it will try to fetch it from
  16. # https://snowballstem.org/dist/libstemmer_c.tgz
  17. set ( STEMMER_REMOTE "https://github.com/manticoresoftware/snowball/archive/refs/tags/v3.0.3.tar.gz" )
  18. set ( STEMMER_BUNDLEZIP "${LIBS_BUNDLE}/libstemmer_c.tgz" )
  19. set ( STEMMER_SRC_MD5 "4fec9f845790b1758175bd16e06e4fe6" )
  20. cmake_minimum_required ( VERSION 3.17 FATAL_ERROR )
  21. include ( update_bundle )
  22. # if it is allowed to use system library - try to use it
  23. if (NOT WITH_STEMMER_FORCE_STATIC)
  24. find_package ( stemmer MODULE QUIET )
  25. return_if_target_found ( stemmer::stemmer "as default (sys or other)" )
  26. endif ()
  27. # determine destination folder where we expect pre-built stemmer
  28. find_package ( stemmer CONFIG )
  29. return_if_target_found ( stemmer::stemmer "ready (no need to build)" )
  30. # not found. Populate and prepare sources
  31. select_nearest_url ( STEMMER_PLACE stemmer ${STEMMER_BUNDLEZIP} ${STEMMER_REMOTE} )
  32. fetch_and_check ( stemmer ${STEMMER_PLACE} ${STEMMER_SRC_MD5} STEMMER_SRC )
  33. execute_process ( COMMAND ${CMAKE_COMMAND} -E copy_if_different "${MANTICORE_SOURCE_DIR}/libstemmer_c/CMakeLists.txt" "${STEMMER_SRC}/CMakeLists.txt" )
  34. # build external project
  35. get_build ( STEMMER_BUILD stemmer )
  36. external_build ( stemmer STEMMER_SRC STEMMER_BUILD )
  37. # now it should find
  38. find_package ( stemmer REQUIRED CONFIG )
  39. return_if_target_found ( stemmer::stemmer "was built and saved" )