add_library(rtt_compile src/compile.cpp src/layout.cpp src/ghosts.cpp src/perturbation.cpp)
add_library(rtt::compile ALIAS rtt_compile)
target_include_directories(rtt_compile PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
target_link_libraries(rtt_compile PUBLIC rtt::diagnostics rtt::model rtt::geom rtt::material
  rtt::coating rtt::math)
rtt_target_defaults(rtt_compile LIBRARY)

if(RTT_BUILD_TESTS)
  # rtt::io only loads the reference systems in the tests; the library does not depend on it.
  rtt_add_test(rtt_compile_tests
    SOURCES tests/test_compile.cpp tests/test_media.cpp tests/test_coatings.cpp tests/test_layout.cpp
            tests/test_diagnostic_codes.cpp tests/test_errors.cpp tests/test_ghosts.cpp
            tests/test_migration.cpp tests/test_crystal.cpp tests/test_object_medium.cpp
            tests/test_relative_placement.cpp tests/test_configurations.cpp
            tests/test_node_frames.cpp tests/test_ideal_lens.cpp tests/test_perturbation.cpp
            tests/test_zernike_perturbation.cpp
            tests/test_object_z.cpp tests/test_stop.cpp tests/test_surface_stop.cpp
            tests/test_anamorphic_compile.cpp tests/test_rotational_compile.cpp
            tests/test_forbes_compile.cpp tests/test_active.cpp tests/test_bound_ranges.cpp
            tests/test_object_at_infinity.cpp
    LIBS rtt::compile rtt::io rtt::model_test_support)
  target_compile_definitions(rtt_compile_tests PRIVATE
    RTT_CATALOG_DIR="${PROJECT_SOURCE_DIR}/tests/catalogs")
endif()
