]> git.saurik.com Git - apt.git/blame - CMakeLists.txt
debian: make autopkgtest run with CMake build dir
[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)
6cmake_minimum_required(VERSION 3.3.0)
7
06c2b40b
JAK
8enable_testing()
9
f3de2dba
JAK
10option(WITH_DOC "Build documentation." OFF)
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)
7def2482 22include(Translations)
f3de2dba
JAK
23include(CheckIncludeFiles)
24include(CheckFunctionExists)
25include(CheckStructHasMember)
26include(GNUInstallDirs)
27include(TestBigEndian)
28find_package(Threads)
29find_package(PkgConfig)
30
31# Set compiler flags
32set(CMAKE_CXX_STANDARD 11)
33set(CMAKE_CXX_STANDARD_REQUIRED ON)
34set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
35
36add_optional_compile_options(Wall)
37add_optional_compile_options(Wextra)
38add_optional_compile_options(Wcast-align)
39add_optional_compile_options(Wlogical-op)
40add_optional_compile_options(Wredundant-decls)
41add_optional_compile_options(Wmissing-declarations)
42add_optional_compile_options(Wunsafe-loop-optimizations)
43add_optional_compile_options(Wctor-dtor-privacy)
44add_optional_compile_options(Wdisabled-optimization)
45add_optional_compile_options(Winit-self)
46add_optional_compile_options(Wmissing-include-dirs)
47add_optional_compile_options(Wnoexcept)
48add_optional_compile_options(Wsign-promo)
49add_optional_compile_options(Wundef)
50
51# apt-ftparchive dependencies
52find_package(BerkeleyDB REQUIRED)
53if (BERKELEY_DB_FOUND)
54 set(HAVE_BDB 1)
55endif()
56
57
58# apt-transport-https dependencies
1ed5f979 59find_package(CURL REQUIRED)
f3de2dba
JAK
60if (CURL_FOUND)
61 set(HAVE_CURL 1)
62endif()
63
64# (De)Compressor libraries
65find_package(ZLIB REQUIRED)
66if (ZLIB_FOUND)
67 set(HAVE_ZLIB 1)
68endif()
69
70
71find_package(BZip2)
72if (BZIP2_FOUND)
73 set(HAVE_BZ2 1)
74endif()
75
76pkg_check_modules(LZMA liblzma)
77if (LZMA_FOUND)
78 set(HAVE_LZMA 1)
79endif()
80
81pkg_check_modules(LZ4 liblz4)
82if (LZ4_FOUND)
83 set(HAVE_LZ4 1)
84endif()
85
86# Mount()ing and stat()ing and friends
87
88check_function_exists(statvfs HAVE_STATVFS)
89if (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()
95 configure_file(buildlib/statvfs.h.in ${PROJECT_BINARY_DIR}/include/statvfs.h @ONLY)
96endif()
97
98CHECK_STRUCT_HAS_MEMBER("struct statfs" f_type sys/vfs.h HAVE_STRUCT_STATFS_F_TYPE)
99
100# Other checks
101check_function_exists(getresuid HAVE_GETRESUID)
102check_function_exists(getresgid HAVE_GETRESGID)
103check_function_exists(setresuid HAVE_SETRESUID)
104check_function_exists(setresgid HAVE_SETRESGID)
105check_function_exists(timegm HAVE_TIMEGM)
106test_big_endian(WORDS_BIGENDIAN)
107
108if (CMAKE_USE_PTHREADS_INIT)
109 set(HAVE_PTHREAD 1)
110endif()
111
112# Configure some variables like package, version and architecture.
33ee08e4
JAK
113set(PACKAGE ${PROJECT_NAME})
114set(PACKAGE_MAIL "APT Development Team <deity@lists.debian.org>")
f3de2dba
JAK
115
116execute_process(COMMAND dpkg-parsechangelog -SVersion -l${PROJECT_SOURCE_DIR}/debian/changelog
117 OUTPUT_VARIABLE PACKAGE_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
118execute_process(COMMAND dpkg-architecture -qDEB_HOST_ARCH
119 OUTPUT_VARIABLE COMMON_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
120
121# Configure our configuration headers (config.h and apti18n.h)
122configure_file(CMake/config.h.in ${PROJECT_BINARY_DIR}/include/config.h)
123configure_file(CMake/apti18n.h.in ${PROJECT_BINARY_DIR}/include/apti18n.h)
124
125# Generic header locations
126include_directories(${PROJECT_BINARY_DIR}/include)
127
128# Add our subdirectories
129add_subdirectory(vendor)
130add_subdirectory(apt-pkg)
131add_subdirectory(apt-private)
132add_subdirectory(apt-inst)
133add_subdirectory(cmdline)
9a2aa0e7 134add_subdirectory(doc)
f3de2dba
JAK
135add_subdirectory(dselect)
136add_subdirectory(ftparchive)
137add_subdirectory(methods)
7def2482 138add_subdirectory(po)
dfd863ea 139add_subdirectory(test)