-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
88 lines (77 loc) · 1.91 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
cmake_minimum_required(VERSION 3.10)
project(Decimal VERSION 1.0 LANGUAGES C)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_C_STANDARD_REQUIRED ON)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include
)
set(HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/include/decimal.h
)
set(SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/source/decimal.c
${CMAKE_CURRENT_SOURCE_DIR}/source/service_fun_arithmetic.c
${CMAKE_CURRENT_SOURCE_DIR}/source/service_fun_cast.c
${CMAKE_CURRENT_SOURCE_DIR}/source/service_fun_common.c
${CMAKE_CURRENT_SOURCE_DIR}/source/service_fun_comp.c
)
set(BUILD_FILES
${HEADERS}
${SOURCES}
)
add_library(${PROJECT_NAME}
STATIC
${BUILD_FILES}
)
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${CMAKE_PROJECT_NAME})
set_target_properties(${PROJECT_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib)
target_compile_options(
${PROJECT_NAME}
PRIVATE
-Wall
-Werror
-Wextra
-Wpedantic
-fsanitize=address
)
target_link_libraries(
${PROJECT_NAME}
PRIVATE
-fsanitize=address
)
# Add cppcheck
find_program(CPPCHECK cppcheck)
if(CPPCHECK)
message(STATUS "cppcheck found: ${CPPCHECK}")
list(
APPEND CPPCHECK_ARGS
"--enable=all"
"--inconclusive"
"--quiet"
"--std=c11"
"--suppress=missingIncludeSystem"
"--suppress=unusedFunction"
"--suppress=missingInclude"
"--suppress=unusedStructMember"
"--suppress=variableScope"
)
add_custom_target(
cppcheck
COMMAND ${CPPCHECK} ${CPPCHECK_ARGS} ${BUILD_FILES}
)
else()
message(STATUS "cppcheck not found")
endif()
# Add clang-format
find_program(CLANG_FORMAT clang-format)
if(CLANG_FORMAT)
message(STATUS "clang-format found: ${CLANG_FORMAT}")
add_custom_target(
clang-format
COMMAND ${CLANG_FORMAT} -i -style=Google ${BUILD_FILES}
)
else()
message(STATUS "clang-format not found")
endif()