]> git.saurik.com Git - apt.git/blame - CMakeLists.txt
methods/connect.cc: Only use AI_IDN if defined
[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)
f3de2dba 7
06c2b40b
JAK
8enable_testing()
9
10ec2d23 10option(WITH_DOC "Build documentation." ON)
f3de2dba
JAK
11option(USE_NLS "Localisation support." ON)
12
13set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMake")
14
15# Work around bug in GNUInstallDirs
16if (EXISTS "/etc/debian_version")
17 set(CMAKE_INSTALL_LIBEXECDIR "lib")
18endif()
19
20# Include stuff
21include(Misc)
22include(CheckIncludeFiles)
23include(CheckFunctionExists)
24include(CheckStructHasMember)
25include(GNUInstallDirs)
26include(TestBigEndian)
27find_package(Threads)
3fbd6746
JAK
28find_package(LFS REQUIRED)
29
30# Add large file support
31add_compile_options(${LFS_COMPILE_OPTIONS})
32add_definitions(${LFS_DEFINITIONS})
33link_libraries(${LFS_LIBRARIES})
f3de2dba
JAK
34
35# Set compiler flags
36set(CMAKE_CXX_STANDARD 11)
37set(CMAKE_CXX_STANDARD_REQUIRED ON)
38set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
39
40add_optional_compile_options(Wall)
41add_optional_compile_options(Wextra)
42add_optional_compile_options(Wcast-align)
43add_optional_compile_options(Wlogical-op)
44add_optional_compile_options(Wredundant-decls)
45add_optional_compile_options(Wmissing-declarations)
46add_optional_compile_options(Wunsafe-loop-optimizations)
47add_optional_compile_options(Wctor-dtor-privacy)
48add_optional_compile_options(Wdisabled-optimization)
49add_optional_compile_options(Winit-self)
50add_optional_compile_options(Wmissing-include-dirs)
51add_optional_compile_options(Wnoexcept)
52add_optional_compile_options(Wsign-promo)
53add_optional_compile_options(Wundef)
54
55# apt-ftparchive dependencies
56find_package(BerkeleyDB REQUIRED)
57if (BERKELEY_DB_FOUND)
58 set(HAVE_BDB 1)
59endif()
60
61
62# apt-transport-https dependencies
1ed5f979 63find_package(CURL REQUIRED)
f3de2dba
JAK
64if (CURL_FOUND)
65 set(HAVE_CURL 1)
66endif()
67
68# (De)Compressor libraries
69find_package(ZLIB REQUIRED)
70if (ZLIB_FOUND)
71 set(HAVE_ZLIB 1)
72endif()
73
74
75find_package(BZip2)
76if (BZIP2_FOUND)
77 set(HAVE_BZ2 1)
78endif()
79
c799c3ef 80find_package(LZMA)
f3de2dba
JAK
81if (LZMA_FOUND)
82 set(HAVE_LZMA 1)
83endif()
84
c799c3ef
JAK
85
86find_package(LZ4)
f3de2dba
JAK
87if (LZ4_FOUND)
88 set(HAVE_LZ4 1)
89endif()
90
91# Mount()ing and stat()ing and friends
2c391d85
JAK
92check_symbol_exists(statfs sys/vfs.h HAVE_VFS_H)
93check_include_files(sys/params.h HAVE_PARAMS_H)
94check_symbol_exists(statfs sys/mount.h HAVE_MOUNT_H)
95if (NOT HAVE_VFS_H AND NOT HAVE_MOUNT_H)
96 message(FATAL_ERROR "Can find neither statvfs() nor statfs()")
97endif()
f3de2dba
JAK
98
99check_function_exists(statvfs HAVE_STATVFS)
100if (NOT HAVE_STATVFS)
389e8322 101 configure_file(CMake/statvfs.h.in ${PROJECT_BINARY_DIR}/include/statvfs.h COPYONLY)
f3de2dba
JAK
102endif()
103
104CHECK_STRUCT_HAS_MEMBER("struct statfs" f_type sys/vfs.h HAVE_STRUCT_STATFS_F_TYPE)
105
106# Other checks
107check_function_exists(getresuid HAVE_GETRESUID)
108check_function_exists(getresgid HAVE_GETRESGID)
109check_function_exists(setresuid HAVE_SETRESUID)
110check_function_exists(setresgid HAVE_SETRESGID)
8c1dbbef 111check_function_exists(ptsname_r HAVE_PTSNAME_R)
f3de2dba
JAK
112check_function_exists(timegm HAVE_TIMEGM)
113test_big_endian(WORDS_BIGENDIAN)
114
bb9fdfe4
JAK
115# FreeBSD
116add_definitions(-D_WITH_GETLINE=1)
117
f3de2dba
JAK
118if (CMAKE_USE_PTHREADS_INIT)
119 set(HAVE_PTHREAD 1)
120endif()
121
b10ec8cc
JAK
122CHECK_INCLUDE_FILES(machine/endian.h HAVE_MACHINE_ENDIAN_H)
123CHECK_INCLUDE_FILES(sys/endian.h HAVE_SYS_ENDIAN_H)
124CHECK_INCLUDE_FILES(endian.h HAVE_ENDIAN_H)
125if (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()
131endif()
132
133
0fa5d862
JAK
134include(CheckTypeSize)
135set(CMAKE_EXTRA_INCLUDE_FILES "signal.h")
136check_type_size("sig_t" SIG_T LANGUAGE "CXX")
137check_type_size("sighandler_t" SIGHANDLER_T LANGUAGE "CXX")
138set(CMAKE_EXTRA_INCLUDE_FILES)
139if (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()
145endif()
146
ad5282bb
JAK
147# Handle resolving
148check_function_exists(res_init HAVE_LIBC_RESOLV)
149if(HAVE_LIBC_RESOLV)
150 set(RESOLV_LIBRARIES)
151else()
152 set(RESOLV_LIBRARIES -lresolv)
153endif()
154
f3de2dba 155# Configure some variables like package, version and architecture.
33ee08e4
JAK
156set(PACKAGE ${PROJECT_NAME})
157set(PACKAGE_MAIL "APT Development Team <deity@lists.debian.org>")
43670e2e 158set(PACKAGE_VERSION "1.3~rc2")
f3de2dba 159
3093c60f
JAK
160if (NOT DEFINED COMMON_ARCH)
161 execute_process(COMMAND dpkg-architecture -qDEB_HOST_ARCH
162 OUTPUT_VARIABLE COMMON_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
163endif()
f3de2dba
JAK
164
165# Configure our configuration headers (config.h and apti18n.h)
166configure_file(CMake/config.h.in ${PROJECT_BINARY_DIR}/include/config.h)
167configure_file(CMake/apti18n.h.in ${PROJECT_BINARY_DIR}/include/apti18n.h)
168
169# Generic header locations
170include_directories(${PROJECT_BINARY_DIR}/include)
171
172# Add our subdirectories
173add_subdirectory(vendor)
174add_subdirectory(apt-pkg)
175add_subdirectory(apt-private)
176add_subdirectory(apt-inst)
177add_subdirectory(cmdline)
1bb40ea6 178add_subdirectory(completions)
9a2aa0e7 179add_subdirectory(doc)
f3de2dba
JAK
180add_subdirectory(dselect)
181add_subdirectory(ftparchive)
182add_subdirectory(methods)
dfd863ea 183add_subdirectory(test)
10ec2d23 184
ac103d45
JAK
185if (USE_NLS)
186add_subdirectory(po)
187
10ec2d23
JAK
188# Link update-po4a into the update-po target
189add_dependencies(update-po update-po4a)
ac103d45 190endif()
35d74be5
JAK
191
192# Create our directories.
193install_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)