include(FetchContent)

FetchContent_Declare(
    Unity
        GIT_REPOSITORY https://github.com/ThrowTheSwitch/Unity.git
        GIT_TAG v2.6.1
)
FetchContent_MakeAvailable(Unity)

list(
    APPEND JSON_TESTS
        json_tests_simple
        json_tests_array
        json_tests_object
        json_tests_complex
)
foreach(JSON_TEST IN LISTS JSON_TESTS)
    add_executable(
        ${JSON_TEST}
        ${JSON_TEST}.c
    )
    set_target_properties(
        ${JSON_TEST}
        PROPERTIES
            C_STANDARD 23
            C_STANDARD_REQUIRED ON
            C_EXTENSIONS OFF
    )
    target_link_libraries(
        ${JSON_TEST}
        PRIVATE
            json
            unity::framework
    )
    target_include_directories(
        ${JSON_TEST}
        PRIVATE
            ${CMAKE_SOURCE_DIR}
    )

    add_test(NAME ${JSON_TEST} COMMAND ${JSON_TEST})
endforeach()

