-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
85 lines (70 loc) · 2.55 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
cmake_minimum_required (VERSION 2.8)
project (tralloc C)
set (TRALLOC_VERSION "0.7.0")
set (TRALLOC_DEBUG true CACHE BOOL "debug features")
set (TRALLOC_LENGTH true CACHE BOOL "length feature")
set (TRALLOC_DESTRUCTOR true CACHE BOOL "destructor feature")
set (TRALLOC_REFERENCE true CACHE BOOL "reference feature")
set (TRALLOC_POOL true CACHE BOOL "pool feature")
set (TRALLOC_UTILS_BUFFER true CACHE BOOL "buffer util")
set (TRALLOC_SHARED true CACHE BOOL "build shared libs")
set (TRALLOC_STATIC true CACHE BOOL "build static libs")
set (TRALLOC_MAN true CACHE BOOL "create man")
set (TRALLOC_TEST true CACHE BOOL "build tests")
set (TRALLOC_EXAMPLES true CACHE BOOL "build examples")
if (NOT DEFINED CMAKE_INSTALL_LIBDIR)
set (CMAKE_INSTALL_LIBDIR "lib" CACHE PATH "Output directory for libraries")
endif ()
if (NOT DEFINED CMAKE_INSTALL_INCLUDEDIR)
set (CMAKE_INSTALL_INCLUDEDIR "include" CACHE PATH "Output directory for include files")
endif ()
if (NOT DEFINED CMAKE_INSTALL_MANDIR)
set (CMAKE_INSTALL_MANDIR "share/man/man3" CACHE PATH "Output directory for include files")
endif ()
if (${TRALLOC_UTILS_BUFFER})
set (TRALLOC_UTILS true)
endif ()
if (${TRALLOC_LENGTH} OR ${TRALLOC_DESTRUCTOR} OR ${TRALLOC_REFERENCE} OR ${TRALLOC_POOL})
set (TRALLOC_EXTENSIONS true)
endif ()
if (NOT ${TRALLOC_STATIC} AND NOT ${TRALLOC_SHARED})
message (FATAL_ERROR "Tralloc can not be compiled. Please enable building of shared or static libraries")
endif ()
if (NOT DEFINED TRALLOC_TARGET)
set (TRALLOC_TARGET ${PROJECT_NAME})
endif ()
if (NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
set (CMAKE_BUILD_TYPE DEBUG)
endif ()
set (CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
include (CheckBool)
check_bool ()
include (CheckFile)
check_file ()
include (CheckC99_inline)
check_c99_inline ()
include (CheckLTO)
check_lto ()
if (${TRALLOC_DESTRUCTOR} AND ${TRALLOC_HAVE_FILE})
set (TRALLOC_FILE true)
endif ()
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Winline ${C99_CFLAGS}")
set (CMAKE_C_FLAGS_DEBUG "-pipe -O0 -g")
set (CMAKE_C_FLAGS_RELEASE "-pipe -O2 ${LTO_CFLAGS}")
set (CMAKE_LD_FLAGS_RELEASE ${LTO_LDLAGS})
add_subdirectory ("src")
include_directories ("src")
if (${TRALLOC_TEST} OR ${TRALLOC_EXAMPLES})
enable_testing()
endif ()
if (${TRALLOC_TEST})
add_subdirectory ("tests")
endif ()
if (${TRALLOC_EXAMPLES})
add_subdirectory ("examples")
endif ()
if (${TRALLOC_MAN})
add_subdirectory ("man")
endif ()
include (CPackConfig.cmake)
include (CPack)