-
Timm Fitschen authoredTimm Fitschen authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
CMakeLists.txt 1.32 KiB
# append all the test cases here (file name without the ".c" suffix)
set(test_cases
test_connection
)
find_library(cmocka-static cmocka)
if (cmocka-static)
message(STATUS "Found pre-installed cmocka: ${cmocka-static}")
elseif (${CMAKE_VERSION} VERSION_LESS "3.14.0")
message(FATAL_ERROR
"Failed to run tests. A pre-installed cmocka could not be found and
your cmake version is prior to 3.14. Please consider to upgrade you
cmake (>=3.14) or install cmocka.")
else ()
include(FetchCMocka)
endif ()
list(LENGTH test_cases len_test_cases)
math(EXPR len_test_cases "${len_test_cases} - 1")
foreach (i RANGE "${len_test_cases}")
list(GET test_cases ${i} test_case_name)
add_executable(${test_case_name} ${test_case_name}.c)
target_compile_features(${test_case_name} PRIVATE c_std_99)
target_link_libraries(${test_case_name} PRIVATE cmocka-static libcaosdb)
add_test(${test_case_name} ${test_case_name})
endforeach ()
# code coverage report
include(CodeCoverage)
if (LCOV_PATH)
setup_target_for_coverage_lcov(
NAME unit_test_coverage
EXECUTABLE ctest
DEPEDENCIES libcaosdb
LCOV_ARGS --rc lcov_branch_coverage=1
GENHTML_ARGS --rc lcov_branch_coverage=1
)
else ()
message(WARNING "Could not generate code coverage report. Please install lcov.")
endif ()