From e7fbf378f9786c92b9e241767d10685f465876fe Mon Sep 17 00:00:00 2001 From: Kamil Cukrowski Date: Tue, 18 May 2021 16:14:14 +0200 Subject: cmake: Add examples as tests --- CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 1787154f..e7510343 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,4 +3,14 @@ project(stc) add_library(stc INTERFACE) target_include_directories(stc INTERFACE include) +include(CTest) +if(BUILD_TESTING) + file(GLOB examples examples/*.c) + foreach(file IN LISTS examples) + get_filename_component(name "${file}" NAME_WE) + add_executable(${name} ${file}) + target_link_libraries(${name} PRIVATE stc m) + add_test(NAME ${name} COMMAND ${name}) + endforeach() +endif() -- cgit v1.2.3