-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
64 lines (55 loc) · 1.68 KB
/
CMakeLists.txt
File metadata and controls
64 lines (55 loc) · 1.68 KB
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
cmake_minimum_required(VERSION 3.11)
project(tests LANGUAGES C CXX)
# General settings
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
cmake_policy(SET CMP0076 NEW)
# Enable testing and code coverage
enable_testing()
include_directories(src src/include)
# Fetch Catch2 for testing
Include(FetchContent)
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.4.0
)
FetchContent_MakeAvailable(Catch2)
# Core library
add_library(uwlkv STATIC
src/uwlkv.c
src/map.c
src/entry.c
src/storage.c
)
# Test executable
add_executable(tests
tests/tests.cpp
tests/nvram_mock.cpp
)
target_link_libraries(tests PRIVATE Catch2::Catch2WithMain uwlkv)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options(uwlkv PRIVATE
-Wall -Wextra -Werror -pedantic
--coverage
)
target_compile_options(tests PRIVATE
-Wall -Wextra -Werror -pedantic
-fstrict-aliasing
-Wdouble-promotion -Wswitch-enum -Wfloat-equal -Wundef
-Wconversion -Wsign-promo -Wsign-conversion -Wcast-align
-Wtype-limits -Wzero-as-null-pointer-constant -Wnon-virtual-dtor
-Woverloaded-virtual
--coverage
-g -O0
)
target_link_options(tests PRIVATE --coverage)
set(LCOV_REMOVE_EXTRA "'test/*'")
add_custom_target(coverage COMMAND gcov ${CMAKE_BINARY_DIR}/CMakeFiles/uwlkv.dir/src/*.c.o)
elseif(MSVC)
# MSVC-specific warning levels
target_compile_options(uwlkv PRIVATE /W4 /WX)
target_compile_options(tests PRIVATE /W4 /WX)
endif()