GetColumnar.cmake 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. include ( update_bundle )
  2. # How to perform version update (check-list):
  3. #
  4. # Say, you want to upgrade secondary headers to v.13
  5. # --------- On columnar side ------------
  6. # 1. Change value of constant LIB_VERSION in secondary/secondary.h to 13
  7. # 2. Commit and publish the changes.
  8. # 3. Wait until changes are mirrored to github. Ensure it is tagged as 'c16-s13' (mirroring script should do it)
  9. # 4. If the tag wasn't appear, push it manually, as:
  10. # git tag c16-s13
  11. # git push origin c16-s13 # here you must write your alias of github (NOT gitlab) repo instead of 'origin'
  12. # --------- On manticore side ------------
  13. # 1. Fix the numbers NEED_COLUMNAR_API and NEED_SECONDARY_API according to your upgrade
  14. # 2. Reconfigure build.
  15. #
  16. # Notice, with tagged revision in columnar repo you don't need to touch `columnar_src.txt` file anymore, however you
  17. # still can do it for any specific requirements.
  18. # Versions of API headers we are need to build with.
  19. set ( NEED_COLUMNAR_API 27 )
  20. set ( NEED_SECONDARY_API 19 )
  21. set ( NEED_KNN_API 9 )
  22. # Note: we don't build, neither link with columnar. Only thing we expect to get is a few interface headers, aka 'columnar_api'.
  23. # Actual usage of columnar is solely defined by availability of the module named below. That module is build (or not built)
  24. # separately outside the manticore.
  25. # In order to debug columnar, you should, namely, debug columnar. Open columnar's source, provide MANTICORE_LOCATOR there and configure.
  26. # It will be 'inverted' project with columnar as main code and manticore as helper aside.
  27. # If you provide locator as 'SOURCE_DIR /path/to/manticore/sources', they will be used inplace, without any copying, and will be available
  28. # to edit in IDE.
  29. if (WIN32)
  30. set ( EXTENSION dll )
  31. else()
  32. set ( EXTENSION so )
  33. endif()
  34. set ( LIB_MANTICORE_COLUMNAR "lib_manticore_columnar.${EXTENSION}" )
  35. set ( LIB_MANTICORE_SECONDARY "lib_manticore_secondary.${EXTENSION}" )
  36. set ( LIB_MANTICORE_KNN "lib_manticore_knn.${EXTENSION}" )
  37. set ( LIB_MANTICORE_KNN_EMBEDDINGS "lib_manticore_knn_embeddings.${EXTENSION}" )
  38. macro ( backup_paths )
  39. set ( _CMAKE_FIND_ROOT_PATH "${CMAKE_FIND_ROOT_PATH}" )
  40. set ( _CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}" )
  41. endmacro()
  42. macro ( restore_paths )
  43. set ( CMAKE_FIND_ROOT_PATH "${_CMAKE_FIND_ROOT_PATH}" )
  44. set ( CMAKE_PREFIX_PATH "${_CMAKE_PREFIX_PATH}" )
  45. endmacro ()
  46. macro ( return_if_all_api_found )
  47. if (TARGET columnar::columnar_api)
  48. set ( _HAS_COLUMNAR ON )
  49. endif ()
  50. if (TARGET columnar::secondary_api)
  51. set ( _HAS_SECONDARY ON )
  52. endif ()
  53. if (TARGET columnar::knn_api)
  54. set ( _HAS_KNN ON )
  55. endif ()
  56. if (_HAS_COLUMNAR AND _HAS_SECONDARY AND _HAS_KNN)
  57. include ( FeatureSummary )
  58. set_package_properties ( columnar PROPERTIES TYPE RUNTIME
  59. DESCRIPTION "a column-oriented storage library with a low memory footprint, designed to handle large volumes of data, a secondary index library, and a k-nearest neighbor search library"
  60. URL "https://github.com/manticoresoftware/columnar/"
  61. )
  62. trace ( columnar::columnar_api )
  63. trace ( columnar::secondary_api )
  64. trace ( columnar::knn_api )
  65. # restore prev find paths to avoid polishing global scope
  66. restore_paths()
  67. return ()
  68. endif ()
  69. endmacro ()
  70. # Columnar might be already provided by inverted inclusion - i.e. when sources of manticore included as testing tool into columnar's sources
  71. if (TARGET columnar::columnar_api)
  72. message ( STATUS "Columnar is already defined, skip." )
  73. return ()
  74. endif ()
  75. # expected version
  76. set ( NEED_API_NUMERIC_VERSION "${NEED_COLUMNAR_API}.${NEED_SECONDARY_API}.${NEED_KNN_API}" )
  77. set ( AUTO_TAG "c${NEED_COLUMNAR_API}-s${NEED_SECONDARY_API}-k${NEED_KNN_API}" )
  78. # set current path to modules in local usr
  79. get_build ( COLUMNAR_BUILD "mcl/${AUTO_TAG}" )
  80. # store prev find paths to avoid polishing global scope
  81. backup_paths()
  82. prepend_prefix ( "${COLUMNAR_BUILD}" )
  83. find_package ( columnar "${NEED_API_NUMERIC_VERSION}" EXACT COMPONENTS columnar_api secondary_api knn_api CONFIG )
  84. return_if_all_api_found ()
  85. # Not found. get columnar src, extract columnar_api.
  86. if (DEFINED ENV{COLUMNAR_LOCATOR} AND NOT "$ENV{COLUMNAR_LOCATOR}" STREQUAL "")
  87. set ( COLUMNAR_LOCATOR $ENV{COLUMNAR_LOCATOR} )
  88. message(STATUS "Using COLUMNAR_LOCATOR from environment variable: ${COLUMNAR_LOCATOR}")
  89. elseif (EXISTS "${MANTICORE_SOURCE_DIR}/local_columnar_src.txt")
  90. file ( STRINGS "${MANTICORE_SOURCE_DIR}/local_columnar_src.txt" COLUMNAR_LOCATOR LIMIT_COUNT 1 )
  91. message(STATUS "Using COLUMNAR_LOCATOR from local_columnar_src.txt: ${COLUMNAR_LOCATOR}")
  92. else ()
  93. file ( STRINGS "${MANTICORE_SOURCE_DIR}/columnar_src.txt" COLUMNAR_LOCATOR LIMIT_COUNT 1)
  94. message(STATUS "Using COLUMNAR_LOCATOR from columnar_src.txt: ${COLUMNAR_LOCATOR}")
  95. endif ()
  96. string ( CONFIGURE "${COLUMNAR_LOCATOR}" COLUMNAR_LOCATOR ) # that is to expand possible inside variables
  97. configure_file ( ${MANTICORE_SOURCE_DIR}/cmake/columnar-imported.cmake.in columnar-build/CMakeLists.txt )
  98. execute_process ( COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/columnar-build )
  99. execute_process ( COMMAND ${CMAKE_COMMAND} --build . WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/columnar-build )
  100. find_package ( columnar ${NEED_API_NUMERIC_VERSION} EXACT REQUIRED COMPONENTS columnar_api secondary_api knn_api CONFIG )
  101. return_if_all_api_found ()
  102. # restore prev find paths to avoid polishing global scope
  103. restore_paths()