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

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


# add include path definitions needed only for tests (from testDependencies):
{% for component in test_dependencies %}
    include_directories("{{ component.path | replaceBackslashes }}")
{% endfor %}

{% for component in test_dependencies %}
    {% for d in component.getExtraSysIncludes() %}
        include_directories(SYSTEM "{{ pathJoin(component.path, d) | replaceBackslashes }}")
    {% endfor %}
{% endfor %}

{% for component in test_dependencies %}
    {% for d in component.getExtraIncludes() %}
        include_directories("{{ pathJoin(component.path, d) | replaceBackslashes }}")
    {% endfor %}
{% endfor %}


# define the tests themselves:

{% for file_names, object_name, languages in tests %}
add_executable({{ object_name }} {{ 'EXCLUDE_FROM_ALL' if exclude_from_all else '' }}
    {% for filename in file_names %}
        "{{ filename | replaceBackslashes }}"
    {% endfor %}
)
{% 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    ') }}
)
yotta_postprocess_target(EXECUTABLE {{ object_name }})
add_test({{ object_name }} {{ object_name }})
add_dependencies(all_tests {{ object_name }})

{% endfor %}

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