add_executable(conformallab_tests
    # ── Pure-math test suite (no CGAL, no mesh — runs on every branch) ─────
    test_clausen.cpp
    test_hyper_ideal_utility.cpp
    test_matrix_utility.cpp
    test_surface_curve_utility.cpp
    test_discrete_elliptic_utility.cpp
    test_p2_utility.cpp
    test_hyper_ideal_visualization_utility.cpp
    #
    # Stale stub files were removed in v0.9.0:
    #   test_hyper_ideal_functional.cpp
    #   test_hyper_ideal_hyperelliptic_utility.cpp
    #   test_spherical_functional.cpp
    # They referenced a "HDS port (Phase 4)" that never happened —
    # CoHDS was intentionally replaced by CGAL::Surface_mesh, and the
    # functionals + tests live in code/tests/cgal/test_*_functional.cpp.
)

target_include_directories(conformallab_tests SYSTEM PRIVATE
    ${CMAKE_SOURCE_DIR}/deps/eigen-3.4.0
)

target_include_directories(conformallab_tests PRIVATE
    ${CMAKE_SOURCE_DIR}/include
)

target_link_libraries(conformallab_tests PRIVATE GTest::gtest_main)

# Fast test-build mode (lever #10): -O0 -g overrides the inherited
# Release-mode -O3 + -DNDEBUG.  Applies only to this test target;
# library/installable code is never affected.
if(CONFORMALLAB_FAST_TEST_BUILD)
    target_compile_options(conformallab_tests PRIVATE
        $<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:-O0 -g -UNDEBUG>
    )
endif()

include(GoogleTest)
gtest_discover_tests(conformallab_tests DISCOVERY_TIMEOUT 60)

# ── CGAL test suite ──────────────────────────────────────────────────────────
# Built with -DWITH_CGAL_TESTS=ON (headless CI, no viewer) or
#            -DWITH_CGAL=ON       (full build with viewer + CLI).
if(WITH_CGAL OR WITH_CGAL_TESTS)
    add_subdirectory(cgal)
endif()
