Radek Krejci | ce24ab8 | 2015-10-08 15:37:02 +0200 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 2.6) |
Radek Krejci | 6c11eda | 2015-10-08 16:35:19 +0200 | [diff] [blame] | 2 | find_package(CMocka 1.0.0 REQUIRED) |
Radek Krejci | ce24ab8 | 2015-10-08 15:37:02 +0200 | [diff] [blame] | 3 | |
Michal Vasko | 294d4c6 | 2016-02-01 10:10:27 +0100 | [diff] [blame^] | 4 | # list of all the tests |
| 5 | set(tests test_io test_fd_comm) |
| 6 | |
| 7 | foreach(test_name IN LISTS tests) |
| 8 | add_executable(${test_name} ${test_name}.c) |
| 9 | target_link_libraries(${test_name} ${CMOCKA_LIBRARIES} ${LIBYANG_LIBRARIES} netconf2) |
| 10 | add_test(${test_name} ${test_name}) |
| 11 | endforeach(test_name) |
Radek Krejci | ce24ab8 | 2015-10-08 15:37:02 +0200 | [diff] [blame] | 12 | |
| 13 | if(ENABLE_VALGRIND_TESTS) |
Michal Vasko | 294d4c6 | 2016-02-01 10:10:27 +0100 | [diff] [blame^] | 14 | find_program(valgrind_FOUND valgrind) |
| 15 | if(valgrind_FOUND) |
| 16 | foreach(test_name IN LISTS tests) |
| 17 | add_test(${test_name}_valgrind valgrind --leak-check=full ${CMAKE_BINARY_DIR}/tests/${test_name}) |
| 18 | endforeach(test_name) |
| 19 | else(valgrind_FOUND) |
| 20 | Message("-- valgrind executable not found! Disabling memory leaks tests") |
| 21 | endif(valgrind_FOUND) |
Radek Krejci | ce24ab8 | 2015-10-08 15:37:02 +0200 | [diff] [blame] | 22 | endif() |
| 23 | |
| 24 | include_directories(${CMAKE_SOURCE_DIR}/src) |
Radek Krejci | e1a5867 | 2016-01-19 14:12:31 +0100 | [diff] [blame] | 25 | configure_file("${PROJECT_SOURCE_DIR}/tests/config.h.in" "${PROJECT_SOURCE_DIR}/tests/config.h" ESCAPE_QUOTES @ONLY) |