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