# NOTE: This file is generated by yotta: changes will be overwritten!

enable_testing()

include_directories("{{ source_directory | replaceBackslashes }}")

{% for file_names, object_name, languages in tests %}
add_executable({{ object_name }}
    {{ file_names | join('\n    ') | replaceBackslashes }}
)
{% if 'objc' in languages %}
# no proper CMake support for objective-c flags :(
set_target_properties({{ object_name }} PROPERTIES
    COMPILE_FLAGS "${CMAKE_OBJC_FLAGS}"
)
{% endif %}
target_link_libraries({{ object_name }}
    {{ link_dependencies | join('\n    ') }}
)
# if the target has defined a post-processing step, perform it:
if(YOTTA_POSTPROCESS_COMMAND)
    string(REPLACE YOTTA_CURRENT_EXE_NAME "{{ object_name }}" LOCAL_POSTPROCESS_COMMAND "${YOTTA_POSTPROCESS_COMMAND}")
    separate_arguments(LOCAL_POSTPROCESS_COMMAND_SEPARATED UNIX_COMMAND ${LOCAL_POSTPROCESS_COMMAND})
    add_custom_command(
        TARGET {{ object_name }}
        POST_BUILD
        COMMAND ${LOCAL_POSTPROCESS_COMMAND_SEPARATED}
    )
endif()
add_test({{ object_name }} {{ object_name }})

{% endfor %}

{% for include in cmake_files %}
include("{{ include | replaceBackslashes }}")
{% endfor %}
