James Feist | 6579c76 | 2019-06-13 10:45:00 -0700 | [diff] [blame] | 1 | cmake_minimum_required (VERSION 3.5 FATAL_ERROR) |
Ed Tanous | 383fb7b | 2019-02-11 11:22:30 -0800 | [diff] [blame] | 2 | |
Sumanth Bhat | cfeaef8 | 2021-06-23 11:32:53 +0530 | [diff] [blame] | 3 | option(DEV "Option for developer testing" OFF) |
| 4 | |
| 5 | if(DEV) |
| 6 | set(CMAKE_C_FLAGS |
| 7 | "${CMAKE_C_FLAGS} \ |
| 8 | -Werror \ |
| 9 | -Wall \ |
| 10 | -Wextra \ |
| 11 | -Wnull-dereference \ |
| 12 | -Wformat-security \ |
| 13 | -Wno-type-limits \ |
| 14 | -fsanitize=address,leak,undefined \ |
| 15 | -ggdb \ |
| 16 | ") |
| 17 | endif() |
| 18 | |
| 19 | |
James Feist | 6579c76 | 2019-06-13 10:45:00 -0700 | [diff] [blame] | 20 | add_definitions (-DMCTP_LOG_STDERR) |
James Feist | cc0edda | 2019-12-09 15:03:25 -0800 | [diff] [blame] | 21 | add_definitions (-DMCTP_HAVE_FILEIO) |
Andrew Jeffery | 682232e | 2020-01-13 16:17:45 +1030 | [diff] [blame] | 22 | add_definitions (-DMCTP_HAVE_STDIO) |
James Feist | 9c99af2 | 2020-01-28 11:45:34 -0800 | [diff] [blame] | 23 | add_definitions (-DMCTP_DEFAULT_ALLOC) |
Ed Tanous | 383fb7b | 2019-02-11 11:22:30 -0800 | [diff] [blame] | 24 | |
Andrew Jeffery | eba19a3 | 2021-03-09 23:09:40 +1030 | [diff] [blame] | 25 | add_library (mctp STATIC alloc.c astlpc.c crc32.c core.c log.c libmctp.h serial.c) |
Ed Tanous | 383fb7b | 2019-02-11 11:22:30 -0800 | [diff] [blame] | 26 | |
Andrew Jeffery | 8e436af | 2020-02-28 14:33:42 +1030 | [diff] [blame] | 27 | target_include_directories (mctp PUBLIC |
James Feist | 6579c76 | 2019-06-13 10:45:00 -0700 | [diff] [blame] | 28 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> |
| 29 | $<INSTALL_INTERFACE:include/libmctp) |
Ed Tanous | 383fb7b | 2019-02-11 11:22:30 -0800 | [diff] [blame] | 30 | |
James Feist | 6579c76 | 2019-06-13 10:45:00 -0700 | [diff] [blame] | 31 | enable_testing () |
Ed Tanous | 383fb7b | 2019-02-11 11:22:30 -0800 | [diff] [blame] | 32 | |
James Feist | 6579c76 | 2019-06-13 10:45:00 -0700 | [diff] [blame] | 33 | add_executable (test_eid tests/test_eid.c tests/test-utils.c) |
Andrew Jeffery | 8e436af | 2020-02-28 14:33:42 +1030 | [diff] [blame] | 34 | target_link_libraries (test_eid mctp) |
Andrew Jeffery | 56c6ff1 | 2020-02-28 14:43:42 +1030 | [diff] [blame] | 35 | add_test (NAME eid COMMAND test_eid) |
Ed Tanous | 383fb7b | 2019-02-11 11:22:30 -0800 | [diff] [blame] | 36 | |
James Feist | 6579c76 | 2019-06-13 10:45:00 -0700 | [diff] [blame] | 37 | add_executable (test_seq tests/test_seq.c tests/test-utils.c) |
Andrew Jeffery | 8e436af | 2020-02-28 14:33:42 +1030 | [diff] [blame] | 38 | target_link_libraries (test_seq mctp) |
Andrew Jeffery | 56c6ff1 | 2020-02-28 14:43:42 +1030 | [diff] [blame] | 39 | add_test (NAME seq COMMAND test_seq) |
Ed Tanous | 383fb7b | 2019-02-11 11:22:30 -0800 | [diff] [blame] | 40 | |
Andrew Jeffery | 2cda40f | 2020-02-28 15:26:20 +1030 | [diff] [blame] | 41 | add_executable (test_bridge tests/test_bridge.c tests/test-utils.c) |
| 42 | target_link_libraries (test_bridge mctp) |
| 43 | add_test (NAME bridge COMMAND test_bridge) |
| 44 | |
| 45 | add_executable (test_astlpc tests/test_astlpc.c tests/test-utils.c) |
| 46 | target_link_libraries (test_astlpc mctp) |
| 47 | add_test (NAME astlpc COMMAND test_astlpc) |
| 48 | |
| 49 | add_executable (test_serial tests/test_serial.c tests/test-utils.c) |
| 50 | target_link_libraries (test_serial mctp) |
| 51 | add_test (NAME serial COMMAND test_serial) |
| 52 | |
Wiktor GoĊgowski | ba6727e | 2020-03-13 18:25:01 +0100 | [diff] [blame] | 53 | add_executable (test_cmds tests/test_cmds.c tests/test-utils.c) |
| 54 | target_link_libraries (test_cmds mctp) |
| 55 | add_test (NAME control_commands COMMAND test_cmds) |
| 56 | |
Sumanth Bhat | 69f545f | 2021-05-18 09:16:43 +0000 | [diff] [blame] | 57 | add_executable (test_core tests/test_core.c tests/test-utils.c) |
| 58 | target_link_libraries (test_core mctp) |
| 59 | add_test (NAME core COMMAND test_core) |
| 60 | |
Andrew Jeffery | 8e436af | 2020-02-28 14:33:42 +1030 | [diff] [blame] | 61 | install (TARGETS mctp DESTINATION lib) |
James Feist | 6579c76 | 2019-06-13 10:45:00 -0700 | [diff] [blame] | 62 | install (FILES libmctp.h DESTINATION include) |
| 63 | |