Radek Krejci | e84f12f | 2018-09-18 14:11:50 +0200 | [diff] [blame] | 1 | # Correct RPATH usage on OS X |
| 2 | set(CMAKE_MACOSX_RPATH TRUE) |
| 3 | |
Radek Krejci | ef5f767 | 2021-04-01 17:04:12 +0200 | [diff] [blame] | 4 | configure_file("${PROJECT_SOURCE_DIR}/tests/tests_config.h.in" "${PROJECT_BINARY_DIR}/tests/tests_config.h" ESCAPE_QUOTES @ONLY) |
Radek Krejci | e84f12f | 2018-09-18 14:11:50 +0200 | [diff] [blame] | 5 | include_directories(SYSTEM ${CMOCKA_INCLUDE_DIR}) |
Radek Krejci | ef5f767 | 2021-04-01 17:04:12 +0200 | [diff] [blame] | 6 | include_directories(${PROJECT_BINARY_DIR}/tests/) |
Radek Krejci | e84f12f | 2018-09-18 14:11:50 +0200 | [diff] [blame] | 7 | |
Radek Krejci | 18abde4 | 2020-06-13 20:04:39 +0200 | [diff] [blame] | 8 | function(ly_add_utest) |
| 9 | cmake_parse_arguments(ADDTEST "" "NAME;WRAP" "SOURCES" ${ARGN}) |
| 10 | set(TEST_NAME utest_${ADDTEST_NAME}) |
Radek Krejci | e84f12f | 2018-09-18 14:11:50 +0200 | [diff] [blame] | 11 | |
Radek Krejci | 18abde4 | 2020-06-13 20:04:39 +0200 | [diff] [blame] | 12 | foreach(TEST_SOURCE ${ADDTEST_SOURCES}) |
Michal Vasko | 0666d05 | 2021-05-21 11:12:13 +0200 | [diff] [blame] | 13 | list(APPEND TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/${TEST_SOURCE}) |
Radek Krejci | 18abde4 | 2020-06-13 20:04:39 +0200 | [diff] [blame] | 14 | endforeach() |
Radek Krejci | e84f12f | 2018-09-18 14:11:50 +0200 | [diff] [blame] | 15 | |
Michal Vasko | 0666d05 | 2021-05-21 11:12:13 +0200 | [diff] [blame] | 16 | add_executable(${TEST_NAME} ${TEST_SOURCES} $<TARGET_OBJECTS:yangobj>) |
| 17 | |
Radek Krejci | 18abde4 | 2020-06-13 20:04:39 +0200 | [diff] [blame] | 18 | # Set common attributes of all tests |
| 19 | set_target_properties(${TEST_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests") |
Radek Krejci | bf940f9 | 2021-03-24 21:04:13 +0100 | [diff] [blame] | 20 | target_link_libraries(${TEST_NAME} ${CMOCKA_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${PCRE2_LIBRARIES} ${CMAKE_DL_LIBS} m) |
Radek Krejci | 1b5ef9d | 2018-11-27 12:49:59 +0100 | [diff] [blame] | 21 | if (NOT APPLE) |
Radek Krejci | 18abde4 | 2020-06-13 20:04:39 +0200 | [diff] [blame] | 22 | if (ADDTEST_WRAP) |
| 23 | set_target_properties(${TEST_NAME} PROPERTIES LINK_FLAGS "${ADDTEST_WRAP}") |
| 24 | endif() |
Radek Krejci | 1b5ef9d | 2018-11-27 12:49:59 +0100 | [diff] [blame] | 25 | endif() |
Radek Krejci | 18abde4 | 2020-06-13 20:04:39 +0200 | [diff] [blame] | 26 | |
| 27 | add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME}) |
Radek Krejci | 18abde4 | 2020-06-13 20:04:39 +0200 | [diff] [blame] | 28 | set_property(TEST ${TEST_NAME} APPEND PROPERTY ENVIRONMENT "MALLOC_CHECK_=3") |
Radek Krejci | e84f12f | 2018-09-18 14:11:50 +0200 | [diff] [blame] | 29 | |
Radek Krejci | 1fd5ad6 | 2020-05-15 15:48:42 +0200 | [diff] [blame] | 30 | if(ENABLE_VALGRIND_TESTS) |
Michal Vasko | f74be50 | 2021-06-04 08:52:26 +0200 | [diff] [blame] | 31 | add_test(${TEST_NAME}_valgrind valgrind --leak-check=full --show-leak-kinds=all --suppressions=${PROJECT_SOURCE_DIR}/tests/ld.supp --error-exitcode=1 ${CMAKE_BINARY_DIR}/tests/${TEST_NAME}) |
| 32 | endif() |
| 33 | endfunction() |
Radek Krejci | 18abde4 | 2020-06-13 20:04:39 +0200 | [diff] [blame] | 34 | |
Michal Vasko | 99544ca | 2021-06-29 10:45:19 +0200 | [diff] [blame^] | 35 | if(ENABLE_TESTS) |
| 36 | add_subdirectory(style) |
| 37 | add_subdirectory(plugins) |
| 38 | add_subdirectory(utests) |
| 39 | add_subdirectory(fuzz) |
| 40 | endif() |
| 41 | if(ENABLE_PERF_TESTS) |
| 42 | add_subdirectory(perf) |
| 43 | endif() |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 44 | |
| 45 | set(format_sources ${format_sources} PARENT_SCOPE) |