-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
94 lines (75 loc) · 1.84 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
cmake_minimum_required(VERSION 3.7)
project(carrow
VERSION 5.4.2
LANGUAGES C
)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fms-extensions -D_GNU_SOURCE=1")
configure_file(manifest.h.in manifest.h)
include_directories(
${PROJECT_SOURCE_DIR}
${PROJECT_BINARY_DIR}
)
add_library(carrow STATIC carrow.c carrow.h)
# Install
install(TARGETS carrow DESTINATION "lib")
install(FILES carrow.h DESTINATION "include")
install(FILES carrow_generic.h DESTINATION "include")
install(FILES carrow_generic.c DESTINATION "include")
# Lint
set(PRETTYC_FLAGS
--recursive
--verbose=0
--repository=.
--extensions=c,h,in
--linelength=80
--headers=h,in
--includeorder=standardcfirst
--root=.
#--quiet
${PROJECT_SOURCE_DIR}
)
add_custom_target(lint
COMMAND prettyc
${PRETTYC_FLAGS}
)
# CPack
set(CPACK_PACKAGE_FILE_NAME "libcarrow-${PROJECT_VERSION}")
set(CPACK_SET_DESTDIR true)
set(CPACK_PACKAGE_NAME libcarrow)
set(CPACK_PACKAGE_CONTACT "Vahid Mardani <vahid.mardani@gmail.com>")
set(CPACK_GENERATOR DEB)
include(CPack)
# Testing
if (NOT DEFINED ENV{SKIP_TESTS})
include(CTest)
list(APPEND CMAKE_CTEST_ARGUMENTS "--output-on-failure")
# Valgrind, Profiling
set(VALGRIND_FLAGS
-s
--tool=memcheck
--leak-check=yes
--show-reachable=yes
--num-callers=20
--track-fds=yes
)
add_custom_target(profile
DEPENDS
profile_test_carrow
)
# Test carrow
add_executable(test_carrow
$<TARGET_OBJECTS:carrow>
test_carrow.c)
target_include_directories(test_carrow PUBLIC "${PROJECT_BINARY_DIR}")
target_link_libraries(test_carrow PUBLIC clog)
add_test(NAME test_carrow COMMAND test_carrow)
add_custom_target(profile_test_carrow
COMMAND "valgrind"
${VALGRIND_FLAGS}
$<TARGET_FILE:test_carrow>
)
endif()
# Examples
if (NOT DEFINED ENV{SKIP_EXAMPLES})
add_subdirectory(examples)
endif()