1cmake_minimum_required (VERSION 3.5 FATAL_ERROR) 2 3option(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 20add_definitions (-DMCTP_LOG_STDERR) 21add_definitions (-DMCTP_HAVE_FILEIO) 22add_definitions (-DMCTP_HAVE_STDIO) 23add_definitions (-DMCTP_DEFAULT_ALLOC) 24 25add_library (mctp STATIC alloc.c astlpc.c crc32.c core.c log.c libmctp.h serial.c crc-16-ccitt.c control.c) 26 27target_include_directories (mctp PUBLIC 28 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> 29 $<INSTALL_INTERFACE:include/libmctp) 30 31enable_testing () 32 33add_executable (test_eid tests/test_eid.c tests/test-utils.c) 34target_link_libraries (test_eid mctp) 35add_test (NAME eid COMMAND test_eid) 36 37add_executable (test_seq tests/test_seq.c tests/test-utils.c) 38target_link_libraries (test_seq mctp) 39add_test (NAME seq COMMAND test_seq) 40 41add_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 53add_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 57add_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 61install (TARGETS mctp DESTINATION lib) 62install (FILES libmctp.h DESTINATION include) 63 64