-
Notifications
You must be signed in to change notification settings - Fork 9
/
CMakeLists.txt
104 lines (84 loc) · 2.54 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# module téléinformation client
# rene-d 2020
cmake_minimum_required(VERSION 3.10)
project(tic)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_EXTENSIONS OFF)
option(DUMP_VARS "dump CMake variables" OFF)
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin)
find_package(gtest REQUIRED)
else()
set(GTEST_BOTH_LIBRARIES gtest gtest_main)
# debian/ubuntu
if(EXISTS /usr/src/googletest/CMakeLists.txt)
add_subdirectory(/usr/src/googletest external EXCLUDE_FROM_ALL)
endif()
endif()
# Code Coverage Configuration
add_library(coverage_config INTERFACE)
option(CODE_COVERAGE "Enable coverage reporting" OFF)
if(CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
# Add required flags (GCC & LLVM/Clang)
target_compile_options(coverage_config INTERFACE
-O0 # no optimization
-g # generate debug info
--coverage # sets all required flags
)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13)
target_link_options(coverage_config INTERFACE --coverage)
else()
target_link_libraries(coverage_config INTERFACE --coverage)
endif()
endif()
#
#
add_executable(tic
test/test_config.cpp
test/test_filesystem.cpp
test/test_led_enabled.cpp
test/test_led_disabled.cpp
test/test_sys.cpp
test/test_teleinfo.cpp
test/test_tic.cpp
test/test_support.cpp
test/mock_time.cpp
test/mock.cpp
test/mock_support.cpp)
target_include_directories(tic
PRIVATE ${GTEST_INCLUDE_DIRS}
PRIVATE src
PRIVATE test/support)
target_compile_options(tic PUBLIC -Wall -pedantic)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l)
# https://github.com/nlohmann/json/issues/658
target_compile_options(tic PUBLIC -Wno-psabi)
endif()
target_link_libraries(tic
PRIVATE ${GTEST_BOTH_LIBRARIES} pthread)
target_link_libraries(tic PUBLIC coverage_config)
target_compile_definitions(tic PRIVATE ENABLE_CLI ENABLE_DEBUG PLATFORMIO=1 WIFINFO_VERSION=\"test\")
#
#
add_executable(gen_eeprom
test/gen_eeprom.cpp test/mock_support.cpp)
target_include_directories(gen_eeprom
PRIVATE src
PRIVATE test/support)
target_compile_definitions(gen_eeprom PRIVATE PLATFORMIO=1 WIFINFO_VERSION=\"test\")
#
#
enable_testing()
add_test(NAME tic_test COMMAND tic --gtest_output=xml)
#
#
function(dump_cmake_variables)
get_cmake_property(_variableNames VARIABLES)
list(SORT _variableNames)
foreach (_variableName ${_variableNames})
message(STATUS "${_variableName}=${${_variableName}}")
endforeach()
endfunction()
if(DUMP_VARS)
dump_cmake_variables()
endif()