]>
Commit | Line | Data |
---|---|---|
f3de2dba JAK |
1 | # Copyright (C) 2009, 2016 Julian Andres Klode <jak@debian.org>. |
2 | # Licensed under the same terms as APT; i.e. GPL 2 or later. | |
3 | ||
4 | # set minimum version | |
5 | project(apt) | |
4924e468 | 6 | cmake_minimum_required(VERSION 3.4.0) |
cede4eda JAK |
7 | # Generic header locations |
8 | include_directories(${PROJECT_BINARY_DIR}/include) | |
9 | ||
f3de2dba | 10 | |
06c2b40b JAK |
11 | enable_testing() |
12 | ||
10ec2d23 | 13 | option(WITH_DOC "Build documentation." ON) |
f3de2dba JAK |
14 | option(USE_NLS "Localisation support." ON) |
15 | ||
16 | set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMake") | |
17 | ||
18 | # Work around bug in GNUInstallDirs | |
19 | if (EXISTS "/etc/debian_version") | |
20 | set(CMAKE_INSTALL_LIBEXECDIR "lib") | |
21 | endif() | |
22 | ||
23 | # Include stuff | |
24 | include(Misc) | |
25 | include(CheckIncludeFiles) | |
26 | include(CheckFunctionExists) | |
27 | include(CheckStructHasMember) | |
28 | include(GNUInstallDirs) | |
29 | include(TestBigEndian) | |
30 | find_package(Threads) | |
3fbd6746 JAK |
31 | find_package(LFS REQUIRED) |
32 | ||
cede4eda JAK |
33 | if(USE_NLS) |
34 | find_package(Intl REQUIRED) | |
35 | link_libraries(${Intl_LIBRARIES}) | |
36 | include_directories(${Intl_INCLUDE_DIRS}) | |
37 | endif() | |
38 | ||
3fbd6746 JAK |
39 | # Add large file support |
40 | add_compile_options(${LFS_COMPILE_OPTIONS}) | |
41 | add_definitions(${LFS_DEFINITIONS}) | |
42 | link_libraries(${LFS_LIBRARIES}) | |
f3de2dba JAK |
43 | |
44 | # Set compiler flags | |
45 | set(CMAKE_CXX_STANDARD 11) | |
46 | set(CMAKE_CXX_STANDARD_REQUIRED ON) | |
47 | set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) | |
48 | ||
49 | add_optional_compile_options(Wall) | |
50 | add_optional_compile_options(Wextra) | |
51 | add_optional_compile_options(Wcast-align) | |
52 | add_optional_compile_options(Wlogical-op) | |
53 | add_optional_compile_options(Wredundant-decls) | |
54 | add_optional_compile_options(Wmissing-declarations) | |
55 | add_optional_compile_options(Wunsafe-loop-optimizations) | |
56 | add_optional_compile_options(Wctor-dtor-privacy) | |
57 | add_optional_compile_options(Wdisabled-optimization) | |
58 | add_optional_compile_options(Winit-self) | |
59 | add_optional_compile_options(Wmissing-include-dirs) | |
60 | add_optional_compile_options(Wnoexcept) | |
61 | add_optional_compile_options(Wsign-promo) | |
62 | add_optional_compile_options(Wundef) | |
63 | ||
64 | # apt-ftparchive dependencies | |
65 | find_package(BerkeleyDB REQUIRED) | |
66 | if (BERKELEY_DB_FOUND) | |
67 | set(HAVE_BDB 1) | |
68 | endif() | |
69 | ||
70 | ||
71 | # apt-transport-https dependencies | |
1ed5f979 | 72 | find_package(CURL REQUIRED) |
f3de2dba JAK |
73 | if (CURL_FOUND) |
74 | set(HAVE_CURL 1) | |
75 | endif() | |
76 | ||
77 | # (De)Compressor libraries | |
78 | find_package(ZLIB REQUIRED) | |
79 | if (ZLIB_FOUND) | |
80 | set(HAVE_ZLIB 1) | |
81 | endif() | |
82 | ||
83 | ||
84 | find_package(BZip2) | |
85 | if (BZIP2_FOUND) | |
86 | set(HAVE_BZ2 1) | |
87 | endif() | |
88 | ||
c799c3ef | 89 | find_package(LZMA) |
f3de2dba JAK |
90 | if (LZMA_FOUND) |
91 | set(HAVE_LZMA 1) | |
92 | endif() | |
93 | ||
c799c3ef JAK |
94 | |
95 | find_package(LZ4) | |
f3de2dba JAK |
96 | if (LZ4_FOUND) |
97 | set(HAVE_LZ4 1) | |
98 | endif() | |
99 | ||
100 | # Mount()ing and stat()ing and friends | |
2c391d85 JAK |
101 | check_symbol_exists(statfs sys/vfs.h HAVE_VFS_H) |
102 | check_include_files(sys/params.h HAVE_PARAMS_H) | |
103 | check_symbol_exists(statfs sys/mount.h HAVE_MOUNT_H) | |
104 | if (NOT HAVE_VFS_H AND NOT HAVE_MOUNT_H) | |
105 | message(FATAL_ERROR "Can find neither statvfs() nor statfs()") | |
106 | endif() | |
f3de2dba JAK |
107 | |
108 | check_function_exists(statvfs HAVE_STATVFS) | |
109 | if (NOT HAVE_STATVFS) | |
389e8322 | 110 | configure_file(CMake/statvfs.h.in ${PROJECT_BINARY_DIR}/include/statvfs.h COPYONLY) |
f3de2dba JAK |
111 | endif() |
112 | ||
113 | CHECK_STRUCT_HAS_MEMBER("struct statfs" f_type sys/vfs.h HAVE_STRUCT_STATFS_F_TYPE) | |
114 | ||
115 | # Other checks | |
116 | check_function_exists(getresuid HAVE_GETRESUID) | |
117 | check_function_exists(getresgid HAVE_GETRESGID) | |
118 | check_function_exists(setresuid HAVE_SETRESUID) | |
119 | check_function_exists(setresgid HAVE_SETRESGID) | |
8c1dbbef | 120 | check_function_exists(ptsname_r HAVE_PTSNAME_R) |
f3de2dba JAK |
121 | check_function_exists(timegm HAVE_TIMEGM) |
122 | test_big_endian(WORDS_BIGENDIAN) | |
123 | ||
bb9fdfe4 JAK |
124 | # FreeBSD |
125 | add_definitions(-D_WITH_GETLINE=1) | |
126 | ||
f3de2dba JAK |
127 | if (CMAKE_USE_PTHREADS_INIT) |
128 | set(HAVE_PTHREAD 1) | |
129 | endif() | |
130 | ||
b10ec8cc JAK |
131 | CHECK_INCLUDE_FILES(machine/endian.h HAVE_MACHINE_ENDIAN_H) |
132 | CHECK_INCLUDE_FILES(sys/endian.h HAVE_SYS_ENDIAN_H) | |
133 | CHECK_INCLUDE_FILES(endian.h HAVE_ENDIAN_H) | |
134 | if (NOT HAVE_ENDIAN_H) | |
135 | if (HAVE_MACHINE_ENDIAN_H OR HAVE_SYS_ENDIAN_H) | |
136 | configure_file(CMake/endian.h.in ${PROJECT_BINARY_DIR}/include/endian.h) | |
137 | else() | |
138 | message(FATAL_ERROR "Cannot find endian.h") | |
139 | endif() | |
140 | endif() | |
141 | ||
142 | ||
0fa5d862 JAK |
143 | include(CheckTypeSize) |
144 | set(CMAKE_EXTRA_INCLUDE_FILES "signal.h") | |
145 | check_type_size("sig_t" SIG_T LANGUAGE "CXX") | |
146 | check_type_size("sighandler_t" SIGHANDLER_T LANGUAGE "CXX") | |
147 | set(CMAKE_EXTRA_INCLUDE_FILES) | |
148 | if (NOT HAVE_SIGHANDLER_T) | |
149 | if (HAVE_SIG_T) | |
150 | add_definitions(-Dsighandler_t=sig_t) | |
151 | else() | |
152 | message(FATAL_ERROR "Platform defines neither sig_t nor sighandler_t") | |
153 | endif() | |
154 | endif() | |
155 | ||
ad5282bb JAK |
156 | # Handle resolving |
157 | check_function_exists(res_init HAVE_LIBC_RESOLV) | |
158 | if(HAVE_LIBC_RESOLV) | |
159 | set(RESOLV_LIBRARIES) | |
160 | else() | |
161 | set(RESOLV_LIBRARIES -lresolv) | |
162 | endif() | |
163 | ||
f3de2dba | 164 | # Configure some variables like package, version and architecture. |
33ee08e4 JAK |
165 | set(PACKAGE ${PROJECT_NAME}) |
166 | set(PACKAGE_MAIL "APT Development Team <deity@lists.debian.org>") | |
43670e2e | 167 | set(PACKAGE_VERSION "1.3~rc2") |
f3de2dba | 168 | |
3093c60f JAK |
169 | if (NOT DEFINED COMMON_ARCH) |
170 | execute_process(COMMAND dpkg-architecture -qDEB_HOST_ARCH | |
171 | OUTPUT_VARIABLE COMMON_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE) | |
172 | endif() | |
6f1f3c9a JAK |
173 | if (NOT DEFINED ROOT_GROUP) |
174 | execute_process(COMMAND id -gn root | |
175 | OUTPUT_VARIABLE ROOT_GROUP OUTPUT_STRIP_TRAILING_WHITESPACE) | |
176 | message(STATUS "Found root group: ${ROOT_GROUP}") | |
177 | endif() | |
178 | set(ROOT_GROUP "${ROOT_GROUP}" CACHE STRING "Group of root (e.g.: wheel or root)") | |
f3de2dba | 179 | |
8757a0fd JAK |
180 | # Set various directories |
181 | set(STATE_DIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/apt" CACHE PATH "Your /var/lib/apt") | |
182 | set(CACHE_DIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/cache/apt" CACHE PATH "Your /var/cache/apt") | |
183 | set(LOG_DIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/log/apt" CACHE PATH "Your /var/log/apt") | |
184 | set(CONF_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/apt" CACHE PATH "Your /etc/apt") | |
185 | set(LIBEXEC_DIR "${CMAKE_INSTALL_FULL_LIBEXECDIR}/apt" CACHE PATH "Your /usr/libexec/apt") | |
186 | set(BIN_DIR "${CMAKE_INSTALL_FULL_BINDIR}") | |
187 | ||
188 | ||
f3de2dba JAK |
189 | # Configure our configuration headers (config.h and apti18n.h) |
190 | configure_file(CMake/config.h.in ${PROJECT_BINARY_DIR}/include/config.h) | |
191 | configure_file(CMake/apti18n.h.in ${PROJECT_BINARY_DIR}/include/apti18n.h) | |
192 | ||
f3de2dba JAK |
193 | # Add our subdirectories |
194 | add_subdirectory(vendor) | |
195 | add_subdirectory(apt-pkg) | |
196 | add_subdirectory(apt-private) | |
197 | add_subdirectory(apt-inst) | |
198 | add_subdirectory(cmdline) | |
1bb40ea6 | 199 | add_subdirectory(completions) |
9a2aa0e7 | 200 | add_subdirectory(doc) |
f3de2dba JAK |
201 | add_subdirectory(dselect) |
202 | add_subdirectory(ftparchive) | |
203 | add_subdirectory(methods) | |
dfd863ea | 204 | add_subdirectory(test) |
10ec2d23 | 205 | |
ac103d45 JAK |
206 | if (USE_NLS) |
207 | add_subdirectory(po) | |
208 | ||
10ec2d23 JAK |
209 | # Link update-po4a into the update-po target |
210 | add_dependencies(update-po update-po4a) | |
ac103d45 | 211 | endif() |
35d74be5 JAK |
212 | |
213 | # Create our directories. | |
214 | install_empty_directories( | |
8757a0fd JAK |
215 | ${CONF_DIR}/apt.conf.d |
216 | ${CONF_DIR}/preferences.d | |
217 | ${CONF_DIR}/sources.list.d | |
218 | ${CONF_DIR}/trusted.gpg.d | |
219 | ${CACHE_DIR}/archives/partial | |
220 | ${STATE_DIR}/lists/partial | |
221 | ${STATE_DIR}/mirrors/partial | |
222 | ${STATE_DIR}/periodic | |
223 | ${LOG_DIR} | |
35d74be5 | 224 | ) |