add_library(mean_field_extension_example)

target_sources(
        mean_field_extension_example
        PUBLIC
        FILE_SET CXX_MODULES FILES
        ideal_gas_radiation.cppm
        rotating_stellar_model.cppm
)

target_link_libraries(mean_field_extension_example PUBLIC mean_field)

add_executable(extension_example_demo demo.cpp)
target_link_libraries(extension_example_demo PRIVATE mean_field_extension_example)

add_executable(
        extension_example_tests
        tests/ideal_gas_radiation.cpp
        tests/rotating_stellar_model.cpp
)
target_link_libraries(
        extension_example_tests
        PRIVATE
        mean_field_extension_example
        Catch2::Catch2WithMain
)

catch_discover_tests(
        extension_example_tests
        TEST_PREFIX "extension_example::"
        PROPERTIES LABELS "extension-example"
)

find_program(LATEXMK_EXECUTABLE latexmk)
if (LATEXMK_EXECUTABLE)
    add_custom_target(
            extension_example_manual
            COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/manual"
            COMMAND
            ${LATEXMK_EXECUTABLE}
            -pdf
            -interaction=nonstopmode
            -halt-on-error
            -outdir=${CMAKE_CURRENT_BINARY_DIR}/manual
            "${CMAKE_CURRENT_SOURCE_DIR}/manual/physics_developer_manual.tex"
            WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/manual"
            COMMENT "Compiling the MeanField physics developer manual"
            VERBATIM
    )
endif ()
