# Copyright (c) 2025 The YAC Authors
#
# SPDX-License-Identifier: BSD-3-Clause

set(YAC_TEST_DEFAULT_LABELS "core")
set(YAC_TEST_DEFAULT_LINK yac_core)

add_library(test_cxc OBJECT test_cxc.c)
target_link_libraries(test_cxc tests_common yac_core)

yac_add_test(NAME "test_angle")
yac_add_test(NAME "test_area")
yac_add_test(NAME "test_bnd_sphere_part")
yac_add_test(NAME "test_cell_bnd_circle")
yac_add_test(NAME "test_circle")
yac_add_test(NAME "test_clipping")
yac_add_test(NAME "test_collection_selection")
yac_add_test(NAME "test_expect_abort" MPI_PROCS 2)
yac_add_test(NAME "test_compute_overlap_area")
yac_add_test(
  NAME "test_fortran_api"
  LINK MPI::MPI_Fortran
  MPI_PROCS 3
)
yac_add_test(NAME "test_gcxgc" LINK test_cxc)
yac_add_test(NAME "test_gcxlatc" LINK test_cxc)
yac_add_test(NAME "test_geometry")
yac_add_test(NAME "test_group_comm" MPI_PROCS 9)
yac_add_test(NAME "test_instrument")
yac_add_test(NAME "test_interval_tree")
yac_add_test(NAME "test_io_utils")
yac_add_test(NAME "test_lapack" LINK LAPACK::LAPACK)
yac_add_test(NAME "test_io_config" MPI_PROCS 12)
yac_add_test(NAME "test_utils_common" MPI_PROCS 4)
yac_add_test(NAME "test_lat_clipping")
yac_add_test(NAME "test_latcxlatc" LINK test_cxc)
yac_add_test(NAME "test_loncxlatc" LINK test_cxc)
yac_add_test(NAME "test_loncxlonc" LINK test_cxc)
yac_add_test(NAME "test_mergesort")
yac_add_test(NAME "test_partial_areas")
yac_add_test(NAME "test_point_in_cell")
yac_add_test(NAME "test_point_selection")
yac_add_test(NAME "test_point_sphere_part")
yac_add_test(NAME "test_proc_sphere_part_parallel" MPI_PROCS 5)
yac_add_test(NAME "test_pxgc" LINK test_cxc)
yac_add_test(NAME "test_quicksort")
yac_add_test(NAME "test_yac_mpi" MPI_PROCS 3)
yac_add_test(
  NAME "test_yac_xmap"
  MPI_PROCS 3
  LINK yaxt::yaxt_c
)

yac_add_test(NAME "test_mpi_error")
set_tests_properties(test_mpi_error PROPERTIES WILL_FAIL TRUE)

yac_add_test(NAME "test_openmp") # runs also without OpenMP
if(YAC_ENABLE_OPENMP)
  target_link_libraries(test_openmp.x OpenMP::OpenMP_C)
endif()

yac_add_test(NAME "test_core_version")
yac_add_test(NAME "test_param")
yac_add_test(NAME "test_param_utils" MPI_PROCS 1)

add_subdirectory(grids)
add_subdirectory(interpolation)
