-
Notifications
You must be signed in to change notification settings - Fork 22
/
CMakeLists.txt
140 lines (117 loc) · 3.99 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
project(small C CXX)
cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
include(CheckFunctionExists)
include(CheckSymbolExists)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
if(NOT DEFINED SMALL_EMBEDDED)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -Wall -Wextra")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -Werror")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -Werror")
endif()
# Enable GNU glibc extentions.
add_definitions("-D_GNU_SOURCE")
set(CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE")
check_symbol_exists(MAP_ANON sys/mman.h TARANTOOL_SMALL_HAVE_MAP_ANON)
check_symbol_exists(MAP_ANONYMOUS sys/mman.h TARANTOOL_SMALL_HAVE_MAP_ANONYMOUS)
check_function_exists(madvise TARANTOOL_SMALL_HAVE_MADVISE)
check_symbol_exists(MADV_DONTDUMP sys/mman.h TARANTOOL_SMALL_HAVE_MADV_DONTDUMP)
set(config_h "${CMAKE_CURRENT_BINARY_DIR}/small/include/small_config.h")
configure_file(
"small/small_config.h.cmake"
"${config_h}"
)
message (STATUS "")
include_directories("${CMAKE_CURRENT_BINARY_DIR}/small/include")
include_directories("${PROJECT_SOURCE_DIR}/include/small")
# Valgrind
include_directories(third_party)
set(lib_headers
"${config_h}"
include/small/util.h
include/small/small_features.h
include/small/ibuf.h
include/small/lf_lifo.h
include/small/lifo.h
include/small/matras.h
include/small/mempool.h
include/small/obuf.h
include/small/quota.h
include/small/rb.h
include/small/region.h
include/small/rlist.h
include/small/slab_arena.h
include/small/slab_cache.h
include/small/slab_list.h
include/small/small_class.h
include/small/small.h
include/small/lsregion.h
include/small/static.h)
# ASAN implementation has extra headers that are included from regular headers.
if(ENABLE_ASAN)
list(APPEND lib_headers
include/small/slab_arena_asan.h
include/small/slab_cache_asan.h
include/small/mempool_asan.h
include/small/obuf_asan.h
include/small/lsregion_asan.h
include/small/region_asan.h
include/small/small_asan.h)
endif()
set(lib_sources
small/util.c
small/small_features.c
small/matras.c
small/ibuf.c
small/static.c)
if(ENABLE_ASAN)
list(APPEND lib_sources
small/slab_arena_asan.c
small/slab_cache_asan.c
small/mempool_asan.c
small/obuf_asan.c
small/lsregion_asan.c
small/region_asan.c
small/small_asan.c)
else()
list(APPEND lib_sources
small/slab_arena.c
small/slab_cache.c
small/mempool.c
small/obuf.c
small/lsregion.c
small/region.c
small/small_class.c
small/small.c)
endif()
add_library(${PROJECT_NAME} STATIC ${lib_sources})
target_link_libraries(${PROJECT_NAME} m)
enable_testing()
add_subdirectory(test)
add_subdirectory(perf)
if(DEFINED SMALL_EMBEDDED)
# Don't build shared library and skip INSTALL() targets if this
# library is used as submodule in other project.
return()
endif()
option(ENABLE_VALGRIND "Enable integration with valgrind, a memory analyzing tool" OFF)
if (NOT ENABLE_VALGRIND)
add_definitions(-DNVALGRIND=1)
endif()
add_library(${PROJECT_NAME}_shared SHARED ${lib_sources})
target_link_libraries(${PROJECT_NAME}_shared m)
set_target_properties(${PROJECT_NAME}_shared PROPERTIES VERSION 1.0 SOVERSION 1)
set_target_properties(${PROJECT_NAME}_shared PROPERTIES OUTPUT_NAME ${PROJECT_NAME})
include(GNUInstallDirs)
install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT library)
install(TARGETS ${PROJECT_NAME}_shared
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT library)
install(FILES ${lib_headers} DESTINATION include/${PROJECT_NAME})
install(DIRECTORY third_party DESTINATION include/${PROJECT_NAME} FILES_MATCHING PATTERN "*.h")