GetJIEBA.cmake 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. set ( JIEBA_REPO "https://github.com/manticoresoftware/cppjieba" )
  12. set ( JIEBA_REV "0fa3cb07" )
  13. set ( JIEBA_SRC_MD5 "19b78cf80eef0c6289a6163674bfa869" )
  14. set ( JIEBA_GITHUB "${JIEBA_REPO}/archive/${JIEBA_REV}.zip" )
  15. set ( JIEBA_BUNDLE "${LIBS_BUNDLE}/cppjieba-${JIEBA_REV}.zip" )
  16. cmake_minimum_required ( VERSION 3.17 FATAL_ERROR )
  17. include ( update_bundle )
  18. # helpers
  19. function ( install_jiebadicts DEST )
  20. if (NOT TARGET jieba::jiebadict)
  21. return ()
  22. endif ()
  23. get_target_property ( JIEBA_DICTS jieba::jiebadict INTERFACE_SOURCES )
  24. diag ( JIEBA_DICTS )
  25. install ( DIRECTORY ${JIEBA_DICTS}/ DESTINATION "${DEST}" COMPONENT jiebadicts )
  26. endfunction ()
  27. # determine destination folder where we expect ready jieba and dict
  28. find_package ( jieba QUIET CONFIG )
  29. if (TARGET jieba::jieba AND TARGET jieba::jiebadict)
  30. diagst ( jieba::jieba "found ready (no need to build)" )
  31. return ()
  32. endif ()
  33. # not found. Populate and prepare sources
  34. select_nearest_url ( JIEBA_PLACE jieba ${JIEBA_BUNDLE} ${JIEBA_GITHUB} )
  35. fetch_and_check ( jieba ${JIEBA_PLACE} ${JIEBA_SRC_MD5} JIEBA_SRC )
  36. # build external project
  37. get_build ( JIEBA_BUILD jieba )
  38. external_build ( jieba JIEBA_SRC JIEBA_BUILD NO_BUILD=1 )
  39. # now it should find
  40. find_package ( jieba REQUIRED CONFIG )
  41. return_if_target_found ( jieba::jieba "was built and saved" )