]>
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) |
f3de2dba | 7 | |
06c2b40b JAK |
8 | enable_testing() |
9 | ||
10ec2d23 | 10 | option(WITH_DOC "Build documentation." ON) |
f3de2dba JAK |
11 | option(USE_NLS "Localisation support." ON) |
12 | ||
13 | set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMake") | |
14 | ||
15 | # Work around bug in GNUInstallDirs | |
16 | if (EXISTS "/etc/debian_version") | |
17 | set(CMAKE_INSTALL_LIBEXECDIR "lib") | |
18 | endif() | |
19 | ||
20 | # Include stuff | |
21 | include(Misc) | |
22 | include(CheckIncludeFiles) | |
23 | include(CheckFunctionExists) | |
24 | include(CheckStructHasMember) | |
25 | include(GNUInstallDirs) | |
26 | include(TestBigEndian) | |
27 | find_package(Threads) | |
28 | find_package(PkgConfig) | |
3fbd6746 JAK |
29 | find_package(LFS REQUIRED) |
30 | ||
31 | # Add large file support | |
32 | add_compile_options(${LFS_COMPILE_OPTIONS}) | |
33 | add_definitions(${LFS_DEFINITIONS}) | |
34 | link_libraries(${LFS_LIBRARIES}) | |
f3de2dba JAK |
35 | |
36 | # Set compiler flags | |
37 | set(CMAKE_CXX_STANDARD 11) | |
38 | set(CMAKE_CXX_STANDARD_REQUIRED ON) | |
39 | set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) | |
40 | ||
41 | add_optional_compile_options(Wall) | |
42 | add_optional_compile_options(Wextra) | |
43 | add_optional_compile_options(Wcast-align) | |
44 | add_optional_compile_options(Wlogical-op) | |
45 | add_optional_compile_options(Wredundant-decls) | |
46 | add_optional_compile_options(Wmissing-declarations) | |
47 | add_optional_compile_options(Wunsafe-loop-optimizations) | |
48 | add_optional_compile_options(Wctor-dtor-privacy) | |
49 | add_optional_compile_options(Wdisabled-optimization) | |
50 | add_optional_compile_options(Winit-self) | |
51 | add_optional_compile_options(Wmissing-include-dirs) | |
52 | add_optional_compile_options(Wnoexcept) | |
53 | add_optional_compile_options(Wsign-promo) | |
54 | add_optional_compile_options(Wundef) | |
55 | ||
56 | # apt-ftparchive dependencies | |
57 | find_package(BerkeleyDB REQUIRED) | |
58 | if (BERKELEY_DB_FOUND) | |
59 | set(HAVE_BDB 1) | |
60 | endif() | |
61 | ||
62 | ||
63 | # apt-transport-https dependencies | |
1ed5f979 | 64 | find_package(CURL REQUIRED) |
f3de2dba JAK |
65 | if (CURL_FOUND) |
66 | set(HAVE_CURL 1) | |
67 | endif() | |
68 | ||
69 | # (De)Compressor libraries | |
70 | find_package(ZLIB REQUIRED) | |
71 | if (ZLIB_FOUND) | |
72 | set(HAVE_ZLIB 1) | |
73 | endif() | |
74 | ||
75 | ||
76 | find_package(BZip2) | |
77 | if (BZIP2_FOUND) | |
78 | set(HAVE_BZ2 1) | |
79 | endif() | |
80 | ||
81 | pkg_check_modules(LZMA liblzma) | |
82 | if (LZMA_FOUND) | |
83 | set(HAVE_LZMA 1) | |
84 | endif() | |
85 | ||
86 | pkg_check_modules(LZ4 liblz4) | |
87 | if (LZ4_FOUND) | |
88 | set(HAVE_LZ4 1) | |
89 | endif() | |
90 | ||
91 | # Mount()ing and stat()ing and friends | |
92 | ||
93 | check_function_exists(statvfs HAVE_STATVFS) | |
94 | if (NOT HAVE_STATVFS) | |
95 | check_symbol_exists(statfs sys/vfs.h HAVE_VFS_H) | |
96 | check_symbol_exists(statfs sys/mount.h HAVE_MOUNT_H) | |
97 | if (NOT HAVE_VFS_H AND NOT HAVE_MOUNT_H) | |
98 | message(FATAL_ERROR "Can find neither statvfs() nor statfs()") | |
99 | endif() | |
389e8322 | 100 | configure_file(CMake/statvfs.h.in ${PROJECT_BINARY_DIR}/include/statvfs.h COPYONLY) |
f3de2dba JAK |
101 | endif() |
102 | ||
103 | CHECK_STRUCT_HAS_MEMBER("struct statfs" f_type sys/vfs.h HAVE_STRUCT_STATFS_F_TYPE) | |
104 | ||
105 | # Other checks | |
106 | check_function_exists(getresuid HAVE_GETRESUID) | |
107 | check_function_exists(getresgid HAVE_GETRESGID) | |
108 | check_function_exists(setresuid HAVE_SETRESUID) | |
109 | check_function_exists(setresgid HAVE_SETRESGID) | |
8c1dbbef | 110 | check_function_exists(ptsname_r HAVE_PTSNAME_R) |
f3de2dba JAK |
111 | check_function_exists(timegm HAVE_TIMEGM) |
112 | test_big_endian(WORDS_BIGENDIAN) | |
113 | ||
114 | if (CMAKE_USE_PTHREADS_INIT) | |
115 | set(HAVE_PTHREAD 1) | |
116 | endif() | |
117 | ||
118 | # Configure some variables like package, version and architecture. | |
33ee08e4 JAK |
119 | set(PACKAGE ${PROJECT_NAME}) |
120 | set(PACKAGE_MAIL "APT Development Team <deity@lists.debian.org>") | |
43670e2e | 121 | set(PACKAGE_VERSION "1.3~rc2") |
f3de2dba | 122 | |
3093c60f JAK |
123 | if (NOT DEFINED COMMON_ARCH) |
124 | execute_process(COMMAND dpkg-architecture -qDEB_HOST_ARCH | |
125 | OUTPUT_VARIABLE COMMON_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE) | |
126 | endif() | |
f3de2dba JAK |
127 | |
128 | # Configure our configuration headers (config.h and apti18n.h) | |
129 | configure_file(CMake/config.h.in ${PROJECT_BINARY_DIR}/include/config.h) | |
130 | configure_file(CMake/apti18n.h.in ${PROJECT_BINARY_DIR}/include/apti18n.h) | |
131 | ||
132 | # Generic header locations | |
133 | include_directories(${PROJECT_BINARY_DIR}/include) | |
134 | ||
135 | # Add our subdirectories | |
136 | add_subdirectory(vendor) | |
137 | add_subdirectory(apt-pkg) | |
138 | add_subdirectory(apt-private) | |
139 | add_subdirectory(apt-inst) | |
140 | add_subdirectory(cmdline) | |
1bb40ea6 | 141 | add_subdirectory(completions) |
9a2aa0e7 | 142 | add_subdirectory(doc) |
f3de2dba JAK |
143 | add_subdirectory(dselect) |
144 | add_subdirectory(ftparchive) | |
145 | add_subdirectory(methods) | |
dfd863ea | 146 | add_subdirectory(test) |
10ec2d23 | 147 | |
ac103d45 JAK |
148 | if (USE_NLS) |
149 | add_subdirectory(po) | |
150 | ||
10ec2d23 JAK |
151 | # Link update-po4a into the update-po target |
152 | add_dependencies(update-po update-po4a) | |
ac103d45 | 153 | endif() |
35d74be5 JAK |
154 | |
155 | # Create our directories. | |
156 | install_empty_directories( | |
157 | ${CMAKE_INSTALL_FULL_SYSCONFDIR}/apt/apt.conf.d | |
158 | ${CMAKE_INSTALL_FULL_SYSCONFDIR}/apt/preferences.d | |
159 | ${CMAKE_INSTALL_FULL_SYSCONFDIR}/apt/sources.list.d | |
160 | ${CMAKE_INSTALL_FULL_SYSCONFDIR}/apt/trusted.gpg.d | |
161 | ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/cache/apt/archives/partial | |
162 | ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/apt/lists/partial | |
163 | ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/apt/mirrors/partial | |
164 | ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/apt/periodic | |
165 | ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/log/apt | |
166 | ) |