blob: 267c4e0b36d9e7cb834794cd2b219b26a573cdf6 [file] [log] [blame]
James Feist6579c762019-06-13 10:45:00 -07001cmake_minimum_required (VERSION 3.5 FATAL_ERROR)
Ed Tanous383fb7b2019-02-11 11:22:30 -08002
Sumanth Bhatcfeaef82021-06-23 11:32:53 +05303option(DEV "Option for developer testing" OFF)
4
5if(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 ")
17endif()
18
19
James Feist6579c762019-06-13 10:45:00 -070020add_definitions (-DMCTP_LOG_STDERR)
James Feistcc0edda2019-12-09 15:03:25 -080021add_definitions (-DMCTP_HAVE_FILEIO)
Andrew Jeffery682232e2020-01-13 16:17:45 +103022add_definitions (-DMCTP_HAVE_STDIO)
James Feist9c99af22020-01-28 11:45:34 -080023add_definitions (-DMCTP_DEFAULT_ALLOC)
Ed Tanous383fb7b2019-02-11 11:22:30 -080024
Andrew Jefferyeba19a32021-03-09 23:09:40 +103025add_library (mctp STATIC alloc.c astlpc.c crc32.c core.c log.c libmctp.h serial.c)
Ed Tanous383fb7b2019-02-11 11:22:30 -080026
Andrew Jeffery8e436af2020-02-28 14:33:42 +103027target_include_directories (mctp PUBLIC
James Feist6579c762019-06-13 10:45:00 -070028 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
29 $<INSTALL_INTERFACE:include/libmctp)
Ed Tanous383fb7b2019-02-11 11:22:30 -080030
James Feist6579c762019-06-13 10:45:00 -070031enable_testing ()
Ed Tanous383fb7b2019-02-11 11:22:30 -080032
James Feist6579c762019-06-13 10:45:00 -070033add_executable (test_eid tests/test_eid.c tests/test-utils.c)
Andrew Jeffery8e436af2020-02-28 14:33:42 +103034target_link_libraries (test_eid mctp)
Andrew Jeffery56c6ff12020-02-28 14:43:42 +103035add_test (NAME eid COMMAND test_eid)
Ed Tanous383fb7b2019-02-11 11:22:30 -080036
James Feist6579c762019-06-13 10:45:00 -070037add_executable (test_seq tests/test_seq.c tests/test-utils.c)
Andrew Jeffery8e436af2020-02-28 14:33:42 +103038target_link_libraries (test_seq mctp)
Andrew Jeffery56c6ff12020-02-28 14:43:42 +103039add_test (NAME seq COMMAND test_seq)
Ed Tanous383fb7b2019-02-11 11:22:30 -080040
Andrew Jeffery2cda40f2020-02-28 15:26:20 +103041add_executable (test_bridge tests/test_bridge.c tests/test-utils.c)
42target_link_libraries (test_bridge mctp)
43add_test (NAME bridge COMMAND test_bridge)
44
45add_executable (test_astlpc tests/test_astlpc.c tests/test-utils.c)
46target_link_libraries (test_astlpc mctp)
47add_test (NAME astlpc COMMAND test_astlpc)
48
49add_executable (test_serial tests/test_serial.c tests/test-utils.c)
50target_link_libraries (test_serial mctp)
51add_test (NAME serial COMMAND test_serial)
52
Wiktor GoĊ‚gowskiba6727e2020-03-13 18:25:01 +010053add_executable (test_cmds tests/test_cmds.c tests/test-utils.c)
54target_link_libraries (test_cmds mctp)
55add_test (NAME control_commands COMMAND test_cmds)
56
Sumanth Bhat69f545f2021-05-18 09:16:43 +000057add_executable (test_core tests/test_core.c tests/test-utils.c)
58target_link_libraries (test_core mctp)
59add_test (NAME core COMMAND test_core)
60
Andrew Jeffery8e436af2020-02-28 14:33:42 +103061install (TARGETS mctp DESTINATION lib)
James Feist6579c762019-06-13 10:45:00 -070062install (FILES libmctp.h DESTINATION include)
63