]> git.saurik.com Git - apt.git/blame - CMakeLists.txt
Make root group configurable via ROOT_GROUP
[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()
6f1f3c9a
JAK
173if (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}")
177endif()
178set(ROOT_GROUP "${ROOT_GROUP}" CACHE STRING "Group of root (e.g.: wheel or root)")
f3de2dba 179
8757a0fd
JAK
180# Set various directories
181set(STATE_DIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/apt" CACHE PATH "Your /var/lib/apt")
182set(CACHE_DIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/cache/apt" CACHE PATH "Your /var/cache/apt")
183set(LOG_DIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/log/apt" CACHE PATH "Your /var/log/apt")
184set(CONF_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/apt" CACHE PATH "Your /etc/apt")
185set(LIBEXEC_DIR "${CMAKE_INSTALL_FULL_LIBEXECDIR}/apt" CACHE PATH "Your /usr/libexec/apt")
186set(BIN_DIR "${CMAKE_INSTALL_FULL_BINDIR}")
187
188
f3de2dba
JAK
189# Configure our configuration headers (config.h and apti18n.h)
190configure_file(CMake/config.h.in ${PROJECT_BINARY_DIR}/include/config.h)
191configure_file(CMake/apti18n.h.in ${PROJECT_BINARY_DIR}/include/apti18n.h)
192
f3de2dba
JAK
193# Add our subdirectories
194add_subdirectory(vendor)
195add_subdirectory(apt-pkg)
196add_subdirectory(apt-private)
197add_subdirectory(apt-inst)
198add_subdirectory(cmdline)
1bb40ea6 199add_subdirectory(completions)
9a2aa0e7 200add_subdirectory(doc)
f3de2dba
JAK
201add_subdirectory(dselect)
202add_subdirectory(ftparchive)
203add_subdirectory(methods)
dfd863ea 204add_subdirectory(test)
10ec2d23 205
ac103d45
JAK
206if (USE_NLS)
207add_subdirectory(po)
208
10ec2d23
JAK
209# Link update-po4a into the update-po target
210add_dependencies(update-po update-po4a)
ac103d45 211endif()
35d74be5
JAK
212
213# Create our directories.
214install_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)