# One file per line, sorted: parallel PRs then add lines at different places and do not
# conflict in these lists.
add_library(rtt_analysis
  src/chromatic.cpp
  src/fft.cpp
  src/field.cpp
  src/ghosts.cpp
  src/irradiance.cpp
  src/jones.cpp
  src/nominal_reference.cpp
  src/opd.cpp
  src/paths.cpp
  src/psf.cpp
  src/pupil.cpp
  src/reference.cpp
  src/reports.cpp
  src/spot.cpp
  src/stokes.cpp
  src/zernike.cpp)
add_library(rtt::analysis ALIAS rtt_analysis)
target_include_directories(rtt_analysis PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
target_link_libraries(rtt_analysis PUBLIC rtt::trace rtt::paraxial rtt::compile rtt::math
  PRIVATE rtt::diagnostics rtt::pocketfft rtt::polar)
rtt_target_defaults(rtt_analysis LIBRARY)

if(RTT_BUILD_TESTS)
  # rtt::io only loads the reference systems in the tests; TBB limits the threads in the
  # determinism test; rtt::polar (Stokes, diattenuation) and rtt::coating (catalogues) only for
  # the M3 acceptance (#63).
  rtt_add_test(rtt_analysis_tests
    SOURCES
      tests/test_annular.cpp
      tests/test_centre_thickness.cpp
      tests/test_chromatic.cpp
      tests/test_error_context.cpp
      tests/test_fans.cpp
      tests/test_fft.cpp
      tests/test_field.cpp
      tests/test_focus_shift.cpp
      tests/test_gauss_rejected.cpp
      tests/test_ghost_ranking.cpp
      tests/test_surface_stop_ghosts.cpp
      tests/test_ideal_lens_analysis.cpp
      tests/test_interferogram.cpp
      tests/test_irradiance.cpp
      tests/test_jones_pupil.cpp
      tests/test_loss_counter.cpp
      tests/test_losses.cpp
      tests/test_m2_acceptance.cpp
      tests/test_m3_acceptance.cpp
      tests/test_m4_acceptance.cpp
      tests/test_m6_acceptance.cpp
      tests/test_m8_acceptance.cpp
      tests/test_mapping_limit.cpp
      tests/test_mtf_ee.cpp
      tests/test_no_stop.cpp
      tests/test_nominal_reference.cpp
      tests/test_obscured.cpp tests/test_obscuration_stop.cpp tests/test_zernike_surface.cpp tests/test_grid_sag_surface.cpp
      tests/test_opd.cpp
      tests/test_opd_points.cpp
      tests/test_paths.cpp
      tests/test_point_list_pupil.cpp
      tests/test_psf.cpp
      tests/test_pupil_cells.cpp
      tests/test_pupil_function.cpp
      tests/test_relative_ghosts.cpp
      tests/test_reports.cpp
      tests/test_run_control.cpp
      tests/test_spot.cpp
      tests/test_stokes_pupil.cpp
      tests/test_warnings.cpp
      tests/test_zernike.cpp
    LIBS rtt::analysis rtt::io rtt::polar rtt::coating rtt::model_test_support TBB::tbb)
  target_compile_definitions(rtt_analysis_tests PRIVATE
    RTT_CATALOG_DIR="${PROJECT_SOURCE_DIR}/tests/catalogs")
endif()
