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