# This file was generated by the YaTool build system (https://github.com/yandex/yatool),
# from a source YaTool build configuration provided in ya.make files.
#
# If the repository supports both CMake and ya build configurations, please modify both of them.
#
# If only CMake build configuration is supported then modify only CMake files and note that only
# simple modifications are allowed like adding source-files to targets or adding simple properties
# like target_include_directories. These modifications will be ported to original ya.make files
# by maintainers. Any complex modifications which can't be easily ported back to the ya build
# system may be rejected.
#
# Please refer to the build instructions in the repository for more information about manual
# changes in this file.

# Unfortunately, standard FindPython3 CMake module does not support Interpreter and NumPy COMPONENTS
# from different Python installations that prevents CI building for multiple Python versions and
# Cross-compilation, so we'll handle these special cases by setting ${Python3_NumPy_INCLUDE_DIRS} explicitly
if(Python3_NumPy_INCLUDE_DIR)
  if(EXISTS "${Python3_NumPy_INCLUDE_DIR}" AND IS_DIRECTORY "${Python3_NumPy_INCLUDE_DIR}")
    set(Python3_NumPy_INCLUDE_DIRS ${Python3_NumPy_INCLUDE_DIR})
  else()
    message(FATAL_ERROR "Python3_NumPy_INCLUDE_DIR=\"${Python3_NumPy_INCLUDE_DIR}\" does not exist.")
  endif()
else()
  find_package(Python3 REQUIRED COMPONENTS
    Development NumPy
  )
endif()

if (NOT USE_INTERNAL_CYTHON)
  find_package(Cython 3.0.10...<4.0 REQUIRED)
endif()

find_package(Python3 REQUIRED COMPONENTS
  Development
)

add_shared_library(_hnsw)


target_compile_options(_hnsw PRIVATE
  $<IF:$<CXX_COMPILER_ID:MSVC>,,-Wno-everything>
)

target_link_libraries(_hnsw PUBLIC
  contrib-libs-linux-headers
  contrib-libs-cxxsupp
  yutil
  build-cow-on
  Python3::Module
  cpp-hnsw-helpers
  cpp-hnsw-index
  cpp-hnsw-index_builder
  cpp-hnsw-logging
  cpp-online_hnsw-base
  cpp-online_hnsw-dense_vectors
  library-cpp-pair_vector_distance
)

target_link_options(_hnsw PRIVATE
  -ldl
  -lrt
  -Wl,--no-as-needed
  -fPIC
  -Wl,-z,notext
  -Wl,-Bsymbolic
  -fPIC
  -lpthread
  -lrt
  -ldl
)

target_cython_sources(_hnsw PRIVATE
  ${PROJECT_SOURCE_DIR}/library/python/hnsw/hnsw/_hnsw.pyx
)

target_sources(_hnsw PRIVATE
  ${PROJECT_SOURCE_DIR}/library/python/hnsw/hnsw/helpers.cpp
)


use_export_script(_hnsw
  ${PROJECT_SOURCE_DIR}/library/python/hnsw/hnsw/hnsw3.exports
)

target_cython_options(_hnsw
  -X
  legacy_implicit_noexcept=True
  -E
  UNAME_SYSNAME=Linux
  --module-name
  _hnsw
  --cplus
)

target_cython_include_directories(_hnsw
  ${PROJECT_BINARY_DIR}
  ${PROJECT_SOURCE_DIR}
)

set_python_type_for_cython(_hnsw
  PY3
)

vcs_info(_hnsw)

target_include_directories(_hnsw PRIVATE
  ${Python3_NumPy_INCLUDE_DIRS}
)

target_cython_include_directories(_hnsw
  ${Python3_NumPy_INCLUDE_DIRS}
)
