-
Notifications
You must be signed in to change notification settings - Fork 145
/
CMakeLists.txt
100 lines (71 loc) · 2.22 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
cmake_minimum_required(VERSION 2.8)
project(csptr C)
# Project setup & environment variables
enable_testing()
set(PROJECT_VERSION "2.0.5-7")
set(MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/.cmake/Modules")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${MODULE_DIR})
if (NOT MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror -g -std=gnu99 -Wno-unused-result -Wno-missing-field-initializers")
endif ()
if (WIN32 AND NOT MSVC)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-no-undefined")
endif()
# Setup coveralls
option(COVERALLS "Turn on coveralls support" OFF)
option(COVERALLS_UPLOAD "Upload the generated coveralls json" ON)
if (COVERALLS AND NOT LIBCSPTR_DISABLE_COVERALLS)
include(Coveralls)
coveralls_turn_on_coverage()
endif()
# Find dependencies
option(LIBCSPTR_TESTS "Turn on tests" ON)
find_package(Check)
if (CHECK_FOUND AND LIBCSPTR_TESTS AND NOT LIBCSPTR_DISABLE_TESTS)
add_subdirectory(check)
endif()
# Setup options
option(SENTINEL "Use a sentinel for the variadic function arguments" ON)
option(FIXED_ALLOCATOR "Define if malloc should always be used" OFF)
# Generate the configure file
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in"
"${CMAKE_CURRENT_SOURCE_DIR}/include/csptr/config.h"
)
# List sources and headers
set(SOURCE_FILES
src/array.c
src/mman.c
src/mman.h
)
set(INTERFACE_FILES
include/csptr/config.h
include/csptr/smalloc.h
include/csptr/array.h
include/csptr/smart_ptr.h
include/csptr/common.h
)
set(MAN_FILES doc/csptr.3)
if (NOT WIN32)
add_definitions("-fPIC")
endif ()
include_directories(include/csptr src)
add_library(csptr STATIC ${SOURCE_FILES} ${INTERFACE_FILES})
if (COVERALLS AND NOT LIBCSPTR_DISABLE_COVERALLS)
coveralls_setup("${SOURCE_FILES}" ${COVERALLS_UPLOAD})
endif()
install(FILES ${INTERFACE_FILES} DESTINATION include/csptr)
install(FILES ${MAN_FILES} DESTINATION share/man/man3)
install(TARGETS csptr
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
add_custom_target(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_MODULE_PATH}/uninstall.cmake"
)
include (PackageConfig)
option(UPLOAD_DEB "Upload package to launchpad" OFF)
if (UNIX AND UPLOAD_DEB)
include (DebConfig)
endif ()