forked from tarantool/small
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
112 lines (91 loc) · 3.19 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
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/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/small_class.h
include/small/small.h
include/small/lsregion.h
include/small/static.h)
set(lib_sources
small/small_features.c
small/slab_cache.c
small/region.c
small/mempool.c
small/slab_arena.c
small/small_class.c
small/small.c
small/matras.c
small/ibuf.c
small/obuf.c
small/lsregion.c
small/static.c)
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")