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