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