forked from leducp/KickCAT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
66 lines (59 loc) · 2.07 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
cmake_minimum_required(VERSION 3.16.3)
project(KickCAT)
# custom CMake modules
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
set(WARNINGS_FLAGS "-Wall -Wextra -pedantic -Wcast-qual -Wcast-align -Wduplicated-cond -Wshadow -Wmissing-noreturn")
add_library(kickcat src/Bus.cc
src/CoE.cc
src/Frame.cc
src/Link.cc
src/LinuxSocket.cc
src/Mailbox.cc
src/protocol.cc
src/Slave.cc
src/Time.cc
)
target_include_directories(kickcat PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_include_directories(kickcat PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/kickcat)
set_target_properties(kickcat PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
POSITION_INDEPENDENT_CODE ON
COMPILE_FLAGS ${WARNINGS_FLAGS}
)
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.10.0
)
FetchContent_MakeAvailable(googletest)
add_executable(kickcat_unit unit/bus-t.cc
unit/frame-t.cc
unit/link-t.cc
unit/mailbox-t.cc
unit/protocol-t.cc
unit/slave-t.cc
)
target_link_libraries(kickcat_unit kickcat gtest gtest_main gmock)
set_target_properties(kickcat_unit PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
POSITION_INDEPENDENT_CODE ON
COMPILE_FLAGS ${WARNINGS_FLAGS}
)
add_test(NAME kickcat COMMAND kickcat_unit WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
option(CODE_COVERAGE "Enable code coverage - gcovr shall be in the PATH" FALSE)
if (${CODE_COVERAGE})
include(CodeCoverage)
append_coverage_compiler_flags()
set(GCOVR_ADDITIONAL_ARGS "--exclude-unreachable-branches")
setup_target_for_coverage_gcovr_html(
NAME coverage
EXECUTABLE kickcat_unit
EXCLUDE "unit/*" ".*gtest.*" "example" ".*gmock.*" ".*LinuxSocket*"
)
endif()
add_subdirectory(example)