]>
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) | |
6 | cmake_minimum_required(VERSION 3.3.0) | |
7 | ||
8 | option(WITH_DOC "Build documentation." OFF) | |
9 | option(USE_NLS "Localisation support." ON) | |
10 | ||
11 | set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMake") | |
12 | ||
13 | # Work around bug in GNUInstallDirs | |
14 | if (EXISTS "/etc/debian_version") | |
15 | set(CMAKE_INSTALL_LIBEXECDIR "lib") | |
16 | endif() | |
17 | ||
18 | # Include stuff | |
19 | include(Misc) | |
20 | include(CheckIncludeFiles) | |
21 | include(CheckFunctionExists) | |
22 | include(CheckStructHasMember) | |
23 | include(GNUInstallDirs) | |
24 | include(TestBigEndian) | |
25 | find_package(Threads) | |
26 | find_package(PkgConfig) | |
27 | ||
28 | # Set compiler flags | |
29 | set(CMAKE_CXX_STANDARD 11) | |
30 | set(CMAKE_CXX_STANDARD_REQUIRED ON) | |
31 | set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) | |
32 | ||
33 | add_optional_compile_options(Wall) | |
34 | add_optional_compile_options(Wextra) | |
35 | add_optional_compile_options(Wcast-align) | |
36 | add_optional_compile_options(Wlogical-op) | |
37 | add_optional_compile_options(Wredundant-decls) | |
38 | add_optional_compile_options(Wmissing-declarations) | |
39 | add_optional_compile_options(Wunsafe-loop-optimizations) | |
40 | add_optional_compile_options(Wctor-dtor-privacy) | |
41 | add_optional_compile_options(Wdisabled-optimization) | |
42 | add_optional_compile_options(Winit-self) | |
43 | add_optional_compile_options(Wmissing-include-dirs) | |
44 | add_optional_compile_options(Wnoexcept) | |
45 | add_optional_compile_options(Wsign-promo) | |
46 | add_optional_compile_options(Wundef) | |
47 | ||
48 | # apt-ftparchive dependencies | |
49 | find_package(BerkeleyDB REQUIRED) | |
50 | if (BERKELEY_DB_FOUND) | |
51 | set(HAVE_BDB 1) | |
52 | endif() | |
53 | ||
54 | ||
55 | # apt-transport-https dependencies | |
56 | pkg_check_modules(CURL libcurl REQUIRED) | |
57 | if (CURL_FOUND) | |
58 | set(HAVE_CURL 1) | |
59 | endif() | |
60 | ||
61 | # (De)Compressor libraries | |
62 | find_package(ZLIB REQUIRED) | |
63 | if (ZLIB_FOUND) | |
64 | set(HAVE_ZLIB 1) | |
65 | endif() | |
66 | ||
67 | ||
68 | find_package(BZip2) | |
69 | if (BZIP2_FOUND) | |
70 | set(HAVE_BZ2 1) | |
71 | endif() | |
72 | ||
73 | pkg_check_modules(LZMA liblzma) | |
74 | if (LZMA_FOUND) | |
75 | set(HAVE_LZMA 1) | |
76 | endif() | |
77 | ||
78 | pkg_check_modules(LZ4 liblz4) | |
79 | if (LZ4_FOUND) | |
80 | set(HAVE_LZ4 1) | |
81 | endif() | |
82 | ||
83 | # Mount()ing and stat()ing and friends | |
84 | ||
85 | check_function_exists(statvfs HAVE_STATVFS) | |
86 | if (NOT HAVE_STATVFS) | |
87 | check_symbol_exists(statfs sys/vfs.h HAVE_VFS_H) | |
88 | check_symbol_exists(statfs sys/mount.h HAVE_MOUNT_H) | |
89 | if (NOT HAVE_VFS_H AND NOT HAVE_MOUNT_H) | |
90 | message(FATAL_ERROR "Can find neither statvfs() nor statfs()") | |
91 | endif() | |
92 | configure_file(buildlib/statvfs.h.in ${PROJECT_BINARY_DIR}/include/statvfs.h @ONLY) | |
93 | endif() | |
94 | ||
95 | CHECK_STRUCT_HAS_MEMBER("struct statfs" f_type sys/vfs.h HAVE_STRUCT_STATFS_F_TYPE) | |
96 | ||
97 | # Other checks | |
98 | check_function_exists(getresuid HAVE_GETRESUID) | |
99 | check_function_exists(getresgid HAVE_GETRESGID) | |
100 | check_function_exists(setresuid HAVE_SETRESUID) | |
101 | check_function_exists(setresgid HAVE_SETRESGID) | |
102 | check_function_exists(timegm HAVE_TIMEGM) | |
103 | test_big_endian(WORDS_BIGENDIAN) | |
104 | ||
105 | if (CMAKE_USE_PTHREADS_INIT) | |
106 | set(HAVE_PTHREAD 1) | |
107 | endif() | |
108 | ||
109 | # Configure some variables like package, version and architecture. | |
110 | set(PACKAGE "apt") | |
111 | ||
112 | execute_process(COMMAND dpkg-parsechangelog -SVersion -l${PROJECT_SOURCE_DIR}/debian/changelog | |
113 | OUTPUT_VARIABLE PACKAGE_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) | |
114 | execute_process(COMMAND dpkg-architecture -qDEB_HOST_ARCH | |
115 | OUTPUT_VARIABLE COMMON_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE) | |
116 | ||
117 | # Configure our configuration headers (config.h and apti18n.h) | |
118 | configure_file(CMake/config.h.in ${PROJECT_BINARY_DIR}/include/config.h) | |
119 | configure_file(CMake/apti18n.h.in ${PROJECT_BINARY_DIR}/include/apti18n.h) | |
120 | ||
121 | # Generic header locations | |
122 | include_directories(${PROJECT_BINARY_DIR}/include) | |
123 | ||
124 | # Add our subdirectories | |
125 | add_subdirectory(vendor) | |
126 | add_subdirectory(apt-pkg) | |
127 | add_subdirectory(apt-private) | |
128 | add_subdirectory(apt-inst) | |
129 | add_subdirectory(cmdline) | |
130 | add_subdirectory(dselect) | |
131 | add_subdirectory(ftparchive) | |
132 | add_subdirectory(methods) |