-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
152 lines (121 loc) · 4.2 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
141
142
143
144
145
146
147
148
149
150
151
cmake_minimum_required(VERSION 3.10)
project(
passgen
VERSION 1.0.0
DESCRIPTION "Regex-based password generator"
LANGUAGES C)
# project build options.
option(BUILD_TOOLS "Build utility binaries." YES)
option(BUILD_BENCH "Build benchmark utilities." YES)
option(BUILD_GIT_INFO "Bake git commit information into the binaries." ON)
option(BUILD_TESTING "Build unit tests" ON)
option(BUILD_DATA "Build data" ON)
option(LIBPASSGEN_STATIC "Build Passgen static library (libpassgen.a)" ON)
option(LIBPASSGEN_SHARED "Build Passgen dynamic library (libpassgen.so)" ON)
option(PASSGEN_STATIC "Link Passgen CLI statically" OFF)
option(USE_BACKTRACE "Enable backtrace() for debug builds (not always available)." ON)
option(USE_LIBEXECINFO
"Use libexecinfo. For systems that don't have backtrace in libc." OFF)
# TODO: disable when not building for linux
option(PASSGEN_MLOCK "Use mlock() to lock memory on startup, preventing leaks through swapping" ON)
option(PASSGEN_MEMORY "Build with option to override memory management" ON)
option(PASSGEN_SECCOMP "Build with seccomp filters" OFF)
option(PASSGEN_MONOCYPHER "Build with monocypher" ON)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
option(PASSGEN_DEBUG "Include debugging features for passgen" ON)
else()
option(PASSGEN_DEBUG "Include debugging features for passgen" OFF)
endif()
# against what do we link tools?
if(PASSGEN_STATIC OR NOT LIBPASSGEN_SHARED)
set(PASSGEN_LIB passgen-static)
else()
set(PASSGEN_LIB passgen-shared)
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(FindPkgConfig)
include(ClangFormat)
include(CMakeFormat)
include(Passgen)
include(Sanitizers)
include(CodeCoverage)
include(IWYU)
clangformat_setup()
cmakeformat_setup(CMakeLists.txt libpassgen/CMakeLists.txt tests/CMakeLists.txt
tools/CMakeLists.txt bin/CMakeLists.txt)
passgen_check_symbols_setup()
iwyu_setup()
passgen_metrics_setup()
# get commit info, if git is available.
if(BUILD_GIT_INFO)
include(GitInfo)
git_info()
endif()
# dependency (only on alpine): libexecinfo-dev
if(USE_LIBEXECINFO)
find_library(libexecinfo execinfo)
endif(USE_LIBEXECINFO)
# dependency: secconf, if requested.
if(PASSGEN_SECCOMP)
if(PASSGEN_STATIC)
find_library(libseccomp NAMES libseccomp.a seccomp)
else()
find_library(libseccomp seccomp)
endif()
endif()
# build libpassgen
add_subdirectory(src)
if(BUILD_DATA)
add_subdirectory(data)
endif()
if(BUILD_BENCH)
add_subdirectory(src/bench)
endif()
# build passgen binary and perhaps utils
add_subdirectory(src/cli)
if(BUILD_TOOLS)
add_subdirectory(src/tools)
endif()
# unit tests
if(BUILD_TESTING)
add_subdirectory(src/tests)
endif()
# setup and install man page
configure_file(man/passgen.1.in passgen.1)
install(
FILES ${PROJECT_BINARY_DIR}/passgen.1
DESTINATION share/man/man1
COMPONENT runtime)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Passgen")
set(CPACK_PACKAGE_VENDOR "xfbs")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_PACKAGE_CONTACT "Patrick Elsen <[email protected]>")
set(CPACK_PACKAGE_VERSION ${CMAKE_PROJECT_VERSION})
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md")
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
set(CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS ON)
set(CPACK_DEB_COMPONENT_INSTALL OFF)
if(PASSGEN_SECCOMP)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6, libseccomp2 (>= 2.5.1)")
else()
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6")
endif()
# development package
set(CPACK_COMPONENT_DEVELOPMENT_DEPENDS "runtime")
set(CPACK_DEBIAN_DEVELOPMENT_PACKAGE_NAME "passgen-dev")
set(CPACK_DEBIAN_DEVELOPMENT_PACKAGE_ARCHITECTURE "all")
set(CPACK_DEBIAN_DEVELOPMENT_PACKAGE_DEPENDS "libc6-dev | libc-dev")
# data package
set(CPACK_COMPONENT_DATA_DEPENDS "runtime")
set(CPACK_DEBIAN_DATA_PACKAGE_NAME "passgen-data")
set(CPACK_DEBIAN_DATA_PACKAGE_ARCHITECTURE "all")
set(CPACK_DEBIAN_DATA_PACKAGE_DEPENDS "")
# runtime package
set(CPACK_DEBIAN_RUNTIME_PACKAGE_NAME "passgen")
set(CPACK_DEBIAN_RUNTIME_PACKAGE_SECTION "utils")
if(PASSGEN_SECCOMP)
set(CPACK_DEBIAN_RUNTIME_PACKAGE_DEPENDS "libc6, libseccomp2 (>= 2.5.1)")
else()
set(CPACK_DEBIAN_RUNTIME_PACKAGE_DEPENDS "libc6")
endif()
include(CPack)