]> git.saurik.com Git - apt.git/blob - CMakeLists.txt
methods/connect.cc: Only use AI_IDN if defined
[apt.git] / CMakeLists.txt
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.4.0)
7
8 enable_testing()
9
10 option(WITH_DOC "Build documentation." ON)
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(LFS REQUIRED)
29
30 # Add large file support
31 add_compile_options(${LFS_COMPILE_OPTIONS})
32 add_definitions(${LFS_DEFINITIONS})
33 link_libraries(${LFS_LIBRARIES})
34
35 # Set compiler flags
36 set(CMAKE_CXX_STANDARD 11)
37 set(CMAKE_CXX_STANDARD_REQUIRED ON)
38 set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
39
40 add_optional_compile_options(Wall)
41 add_optional_compile_options(Wextra)
42 add_optional_compile_options(Wcast-align)
43 add_optional_compile_options(Wlogical-op)
44 add_optional_compile_options(Wredundant-decls)
45 add_optional_compile_options(Wmissing-declarations)
46 add_optional_compile_options(Wunsafe-loop-optimizations)
47 add_optional_compile_options(Wctor-dtor-privacy)
48 add_optional_compile_options(Wdisabled-optimization)
49 add_optional_compile_options(Winit-self)
50 add_optional_compile_options(Wmissing-include-dirs)
51 add_optional_compile_options(Wnoexcept)
52 add_optional_compile_options(Wsign-promo)
53 add_optional_compile_options(Wundef)
54
55 # apt-ftparchive dependencies
56 find_package(BerkeleyDB REQUIRED)
57 if (BERKELEY_DB_FOUND)
58 set(HAVE_BDB 1)
59 endif()
60
61
62 # apt-transport-https dependencies
63 find_package(CURL REQUIRED)
64 if (CURL_FOUND)
65 set(HAVE_CURL 1)
66 endif()
67
68 # (De)Compressor libraries
69 find_package(ZLIB REQUIRED)
70 if (ZLIB_FOUND)
71 set(HAVE_ZLIB 1)
72 endif()
73
74
75 find_package(BZip2)
76 if (BZIP2_FOUND)
77 set(HAVE_BZ2 1)
78 endif()
79
80 find_package(LZMA)
81 if (LZMA_FOUND)
82 set(HAVE_LZMA 1)
83 endif()
84
85
86 find_package(LZ4)
87 if (LZ4_FOUND)
88 set(HAVE_LZ4 1)
89 endif()
90
91 # Mount()ing and stat()ing and friends
92 check_symbol_exists(statfs sys/vfs.h HAVE_VFS_H)
93 check_include_files(sys/params.h HAVE_PARAMS_H)
94 check_symbol_exists(statfs sys/mount.h HAVE_MOUNT_H)
95 if (NOT HAVE_VFS_H AND NOT HAVE_MOUNT_H)
96 message(FATAL_ERROR "Can find neither statvfs() nor statfs()")
97 endif()
98
99 check_function_exists(statvfs HAVE_STATVFS)
100 if (NOT HAVE_STATVFS)
101 configure_file(CMake/statvfs.h.in ${PROJECT_BINARY_DIR}/include/statvfs.h COPYONLY)
102 endif()
103
104 CHECK_STRUCT_HAS_MEMBER("struct statfs" f_type sys/vfs.h HAVE_STRUCT_STATFS_F_TYPE)
105
106 # Other checks
107 check_function_exists(getresuid HAVE_GETRESUID)
108 check_function_exists(getresgid HAVE_GETRESGID)
109 check_function_exists(setresuid HAVE_SETRESUID)
110 check_function_exists(setresgid HAVE_SETRESGID)
111 check_function_exists(ptsname_r HAVE_PTSNAME_R)
112 check_function_exists(timegm HAVE_TIMEGM)
113 test_big_endian(WORDS_BIGENDIAN)
114
115 # FreeBSD
116 add_definitions(-D_WITH_GETLINE=1)
117
118 if (CMAKE_USE_PTHREADS_INIT)
119 set(HAVE_PTHREAD 1)
120 endif()
121
122 CHECK_INCLUDE_FILES(machine/endian.h HAVE_MACHINE_ENDIAN_H)
123 CHECK_INCLUDE_FILES(sys/endian.h HAVE_SYS_ENDIAN_H)
124 CHECK_INCLUDE_FILES(endian.h HAVE_ENDIAN_H)
125 if (NOT HAVE_ENDIAN_H)
126 if (HAVE_MACHINE_ENDIAN_H OR HAVE_SYS_ENDIAN_H)
127 configure_file(CMake/endian.h.in ${PROJECT_BINARY_DIR}/include/endian.h)
128 else()
129 message(FATAL_ERROR "Cannot find endian.h")
130 endif()
131 endif()
132
133
134 include(CheckTypeSize)
135 set(CMAKE_EXTRA_INCLUDE_FILES "signal.h")
136 check_type_size("sig_t" SIG_T LANGUAGE "CXX")
137 check_type_size("sighandler_t" SIGHANDLER_T LANGUAGE "CXX")
138 set(CMAKE_EXTRA_INCLUDE_FILES)
139 if (NOT HAVE_SIGHANDLER_T)
140 if (HAVE_SIG_T)
141 add_definitions(-Dsighandler_t=sig_t)
142 else()
143 message(FATAL_ERROR "Platform defines neither sig_t nor sighandler_t")
144 endif()
145 endif()
146
147 # Handle resolving
148 check_function_exists(res_init HAVE_LIBC_RESOLV)
149 if(HAVE_LIBC_RESOLV)
150 set(RESOLV_LIBRARIES)
151 else()
152 set(RESOLV_LIBRARIES -lresolv)
153 endif()
154
155 # Configure some variables like package, version and architecture.
156 set(PACKAGE ${PROJECT_NAME})
157 set(PACKAGE_MAIL "APT Development Team <deity@lists.debian.org>")
158 set(PACKAGE_VERSION "1.3~rc2")
159
160 if (NOT DEFINED COMMON_ARCH)
161 execute_process(COMMAND dpkg-architecture -qDEB_HOST_ARCH
162 OUTPUT_VARIABLE COMMON_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
163 endif()
164
165 # Configure our configuration headers (config.h and apti18n.h)
166 configure_file(CMake/config.h.in ${PROJECT_BINARY_DIR}/include/config.h)
167 configure_file(CMake/apti18n.h.in ${PROJECT_BINARY_DIR}/include/apti18n.h)
168
169 # Generic header locations
170 include_directories(${PROJECT_BINARY_DIR}/include)
171
172 # Add our subdirectories
173 add_subdirectory(vendor)
174 add_subdirectory(apt-pkg)
175 add_subdirectory(apt-private)
176 add_subdirectory(apt-inst)
177 add_subdirectory(cmdline)
178 add_subdirectory(completions)
179 add_subdirectory(doc)
180 add_subdirectory(dselect)
181 add_subdirectory(ftparchive)
182 add_subdirectory(methods)
183 add_subdirectory(test)
184
185 if (USE_NLS)
186 add_subdirectory(po)
187
188 # Link update-po4a into the update-po target
189 add_dependencies(update-po update-po4a)
190 endif()
191
192 # Create our directories.
193 install_empty_directories(
194 ${CMAKE_INSTALL_FULL_SYSCONFDIR}/apt/apt.conf.d
195 ${CMAKE_INSTALL_FULL_SYSCONFDIR}/apt/preferences.d
196 ${CMAKE_INSTALL_FULL_SYSCONFDIR}/apt/sources.list.d
197 ${CMAKE_INSTALL_FULL_SYSCONFDIR}/apt/trusted.gpg.d
198 ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/cache/apt/archives/partial
199 ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/apt/lists/partial
200 ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/apt/mirrors/partial
201 ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/apt/periodic
202 ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/log/apt
203 )