src/platform/test/CMakeLists.txt (view raw)
1if(BUILD_PERF)
2 set(PERF_SRC ${CMAKE_CURRENT_SOURCE_DIR}/perf-main.c)
3 if(UNIX AND NOT APPLE)
4 list(APPEND PERF_LIB rt)
5 endif()
6
7 add_executable(${BINARY_NAME}-perf ${PERF_SRC})
8 target_link_libraries(${BINARY_NAME}-perf ${BINARY_NAME} ${PERF_LIB} ${OS_LIB})
9 set_target_properties(${BINARY_NAME}-perf PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
10 install(TARGETS ${BINARY_NAME}-perf DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${BINARY_NAME}-perf)
11 install(FILES "${CMAKE_SOURCE_DIR}/tools/perf.py" DESTINATION "${LIBDIR}/${BINARY_NAME}" COMPONENT ${BINARY_NAME}-perf)
12endif()
13
14if(BUILD_TEST)
15 add_executable(${BINARY_NAME}-fuzz ${CMAKE_CURRENT_SOURCE_DIR}/fuzz-main.c)
16 target_link_libraries(${BINARY_NAME}-fuzz ${BINARY_NAME})
17 set_target_properties(${BINARY_NAME}-fuzz PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}")
18 add_executable(tbl-fuzz ${CMAKE_CURRENT_SOURCE_DIR}/tbl-fuzz-main.c)
19 target_link_libraries(tbl-fuzz ${BINARY_NAME})
20 set_target_properties(tbl-fuzz PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}")
21 install(TARGETS ${BINARY_NAME}-fuzz tbl-fuzz DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${BINARY_NAME}-test)
22endif()
23
24if(BUILD_SUITE)
25 enable_testing()
26 include_directories(AFTER ${CMOCKA_INCLUDE_DIRS})
27 link_directories(${CMOCKA_LIBRARY_DIRS})
28
29 foreach(TEST IN LISTS TEST_SRC)
30 string(REPLACE "${CMAKE_SOURCE_DIR}/src/" "" TEST_NAME "${TEST}")
31 string(REPLACE "/" "-" TEST_NAME "${TEST_NAME}")
32 string(REPLACE "-test" "" TEST_NAME "${TEST_NAME}")
33 string(REPLACE ".c" "" TEST_NAME "${TEST_NAME}")
34 add_executable(test-${TEST_NAME} ${TEST})
35 target_link_libraries(test-${TEST_NAME} ${BINARY_NAME} ${PLATFORM_LIBRARY} cmocka)
36 set_target_properties(test-${TEST_NAME} PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}")
37 add_test(${TEST_NAME} test-${TEST_NAME})
38 endforeach()
39endif()
40
41if(BUILD_CINEMA)
42 enable_testing()
43 add_executable(${BINARY_NAME}-cinema ${CMAKE_CURRENT_SOURCE_DIR}/cinema-main.c)
44 target_link_libraries(${BINARY_NAME}-cinema ${BINARY_NAME} ${PLATFORM_LIBRARY})
45 set_target_properties(${BINARY_NAME}-cinema PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}")
46 add_test(cinema ${BINARY_NAME}-cinema -v)
47 install(TARGETS ${BINARY_NAME}-cinema DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${BINARY_NAME}-test)
48endif()