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.
6 cmake_minimum_required(VERSION 3.3.0)
8 option(WITH_DOC "Build documentation." OFF)
9 option(USE_NLS "Localisation support." ON)
11 set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMake")
13 # Work around bug in GNUInstallDirs
14 if (EXISTS "/etc/debian_version")
15 set(CMAKE_INSTALL_LIBEXECDIR "lib")
21 include(CheckIncludeFiles)
22 include(CheckFunctionExists)
23 include(CheckStructHasMember)
24 include(GNUInstallDirs)
25 include(TestBigEndian)
27 find_package(PkgConfig)
30 set(CMAKE_CXX_STANDARD 11)
31 set(CMAKE_CXX_STANDARD_REQUIRED ON)
32 set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
34 add_optional_compile_options(Wall)
35 add_optional_compile_options(Wextra)
36 add_optional_compile_options(Wcast-align)
37 add_optional_compile_options(Wlogical-op)
38 add_optional_compile_options(Wredundant-decls)
39 add_optional_compile_options(Wmissing-declarations)
40 add_optional_compile_options(Wunsafe-loop-optimizations)
41 add_optional_compile_options(Wctor-dtor-privacy)
42 add_optional_compile_options(Wdisabled-optimization)
43 add_optional_compile_options(Winit-self)
44 add_optional_compile_options(Wmissing-include-dirs)
45 add_optional_compile_options(Wnoexcept)
46 add_optional_compile_options(Wsign-promo)
47 add_optional_compile_options(Wundef)
49 # apt-ftparchive dependencies
50 find_package(BerkeleyDB REQUIRED)
51 if (BERKELEY_DB_FOUND)
56 # apt-transport-https dependencies
57 find_package(CURL REQUIRED)
62 # (De)Compressor libraries
63 find_package(ZLIB REQUIRED)
74 pkg_check_modules(LZMA liblzma)
79 pkg_check_modules(LZ4 liblz4)
84 # Mount()ing and stat()ing and friends
86 check_function_exists(statvfs HAVE_STATVFS)
88 check_symbol_exists(statfs sys/vfs.h HAVE_VFS_H)
89 check_symbol_exists(statfs sys/mount.h HAVE_MOUNT_H)
90 if (NOT HAVE_VFS_H AND NOT HAVE_MOUNT_H)
91 message(FATAL_ERROR "Can find neither statvfs() nor statfs()")
93 configure_file(buildlib/statvfs.h.in ${PROJECT_BINARY_DIR}/include/statvfs.h @ONLY)
96 CHECK_STRUCT_HAS_MEMBER("struct statfs" f_type sys/vfs.h HAVE_STRUCT_STATFS_F_TYPE)
99 check_function_exists(getresuid HAVE_GETRESUID)
100 check_function_exists(getresgid HAVE_GETRESGID)
101 check_function_exists(setresuid HAVE_SETRESUID)
102 check_function_exists(setresgid HAVE_SETRESGID)
103 check_function_exists(timegm HAVE_TIMEGM)
104 test_big_endian(WORDS_BIGENDIAN)
106 if (CMAKE_USE_PTHREADS_INIT)
110 # Configure some variables like package, version and architecture.
111 set(PACKAGE ${PROJECT_NAME})
112 set(PACKAGE_MAIL "APT Development Team <deity@lists.debian.org>")
114 execute_process(COMMAND dpkg-parsechangelog -SVersion -l${PROJECT_SOURCE_DIR}/debian/changelog
115 OUTPUT_VARIABLE PACKAGE_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
116 execute_process(COMMAND dpkg-architecture -qDEB_HOST_ARCH
117 OUTPUT_VARIABLE COMMON_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
119 # Configure our configuration headers (config.h and apti18n.h)
120 configure_file(CMake/config.h.in ${PROJECT_BINARY_DIR}/include/config.h)
121 configure_file(CMake/apti18n.h.in ${PROJECT_BINARY_DIR}/include/apti18n.h)
123 # Generic header locations
124 include_directories(${PROJECT_BINARY_DIR}/include)
126 # Add our subdirectories
127 add_subdirectory(vendor)
128 add_subdirectory(apt-pkg)
129 add_subdirectory(apt-private)
130 add_subdirectory(apt-inst)
131 add_subdirectory(cmdline)
132 add_subdirectory(doc)
133 add_subdirectory(dselect)
134 add_subdirectory(ftparchive)
135 add_subdirectory(methods)
137 add_subdirectory(test)