]> git.saurik.com Git - apt.git/blob - CMakeLists.txt
debian: Pass -O to make to get readable build logs
[apt.git] / CMakeLists.txt
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)
6 cmake_minimum_required(VERSION 3.4.0)
7 # Generic header locations
8 include_directories(${PROJECT_BINARY_DIR}/include)
9
10
11 enable_testing()
12
13 option(WITH_DOC "Build documentation." ON)
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)
31 find_package(LFS REQUIRED)
32 find_package(Iconv REQUIRED)
33
34 if(USE_NLS)
35 find_package(Intl REQUIRED)
36 link_libraries(${Intl_LIBRARIES})
37 include_directories(${Intl_INCLUDE_DIRS})
38 endif()
39
40 # Add large file support
41 add_compile_options(${LFS_COMPILE_OPTIONS})
42 add_definitions(${LFS_DEFINITIONS})
43 link_libraries(${LFS_LIBRARIES})
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
73 find_package(CURL REQUIRED)
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
90 find_package(LZMA)
91 if (LZMA_FOUND)
92 set(HAVE_LZMA 1)
93 endif()
94
95
96 find_package(LZ4)
97 if (LZ4_FOUND)
98 set(HAVE_LZ4 1)
99 endif()
100
101 # Mount()ing and stat()ing and friends
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()
108
109 check_function_exists(statvfs HAVE_STATVFS)
110 if (NOT HAVE_STATVFS)
111 configure_file(CMake/statvfs.h.in ${PROJECT_BINARY_DIR}/include/statvfs.h COPYONLY)
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)
121 check_function_exists(ptsname_r HAVE_PTSNAME_R)
122 check_function_exists(timegm HAVE_TIMEGM)
123 test_big_endian(WORDS_BIGENDIAN)
124
125 # FreeBSD
126 add_definitions(-D_WITH_GETLINE=1)
127
128 if (CMAKE_USE_PTHREADS_INIT)
129 set(HAVE_PTHREAD 1)
130 endif()
131
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
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
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
165 # Configure some variables like package, version and architecture.
166 set(PACKAGE ${PROJECT_NAME})
167 set(PACKAGE_MAIL "APT Development Team <deity@lists.debian.org>")
168 set(PACKAGE_VERSION "1.3~rc3")
169
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()
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)")
180
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
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
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)
200 add_subdirectory(completions)
201 add_subdirectory(doc)
202 add_subdirectory(dselect)
203 add_subdirectory(ftparchive)
204 add_subdirectory(methods)
205 add_subdirectory(test)
206
207 if (USE_NLS)
208 add_subdirectory(po)
209
210 # Link update-po4a into the update-po target
211 add_dependencies(update-po update-po4a)
212 endif()
213
214 # Create our directories.
215 install_empty_directories(
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}
225 )