# Compiled safe=False broadcast Chebyshev kernel (libaa_fastpath.so).
# Standalone on purpose: does not touch the nrhjkokkos module build.
#   cmake -S cpp/fastpath -B cpp/fastpath/build \
#         -DKokkos_DIR=$HOME/soft/kokkos/4.6.0-pic/lib64/cmake/Kokkos \
#         -DCMAKE_BUILD_TYPE=Release
#   cmake --build cpp/fastpath/build
cmake_minimum_required(VERSION 3.19)
project(aa_fastpath CXX)

if(NOT CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE Release)
endif()

find_package(Kokkos REQUIRED)

# Both execution-space arms are ALWAYS compiled (contract R7,
# nrhjsurrogate/dispatch.py): chebyshev_evaluate_stacked_f64 (host) and
# chebyshev_evaluate_stacked_f64_device (default space).  Routing between them
# is dispatch.space_for -- a config edit, never a rebuild.  CUDA builds
# need --extended-lambda in CMAKE_CXX_FLAGS.
add_library(aa_fastpath SHARED fastpath.cpp)
target_link_libraries(aa_fastpath PRIVATE Kokkos::kokkos)
set_target_properties(aa_fastpath PROPERTIES POSITION_INDEPENDENT_CODE ON)
