]> git.saurik.com Git - apt.git/blame - CMakeLists.txt
ensure all configures are reported to hook scripts
[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)
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()
fa1b5d86 95 configure_file(CMake/statvfs.h.in ${PROJECT_BINARY_DIR}/include/statvfs.h @ONLY)
f3de2dba
JAK
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)
8c1dbbef 105check_function_exists(ptsname_r HAVE_PTSNAME_R)
f3de2dba
JAK
106check_function_exists(timegm HAVE_TIMEGM)
107test_big_endian(WORDS_BIGENDIAN)
108
109if (CMAKE_USE_PTHREADS_INIT)
110 set(HAVE_PTHREAD 1)
111endif()
112
113# Configure some variables like package, version and architecture.
33ee08e4
JAK
114set(PACKAGE ${PROJECT_NAME})
115set(PACKAGE_MAIL "APT Development Team <deity@lists.debian.org>")
66eae024 116set(PACKAGE_VERSION "1.3~pre3+cmake2")
f3de2dba 117
3093c60f
JAK
118if (NOT DEFINED COMMON_ARCH)
119 execute_process(COMMAND dpkg-architecture -qDEB_HOST_ARCH
120 OUTPUT_VARIABLE COMMON_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
121endif()
f3de2dba
JAK
122
123# Configure our configuration headers (config.h and apti18n.h)
124configure_file(CMake/config.h.in ${PROJECT_BINARY_DIR}/include/config.h)
125configure_file(CMake/apti18n.h.in ${PROJECT_BINARY_DIR}/include/apti18n.h)
126
127# Generic header locations
128include_directories(${PROJECT_BINARY_DIR}/include)
129
130# Add our subdirectories
131add_subdirectory(vendor)
132add_subdirectory(apt-pkg)
133add_subdirectory(apt-private)
134add_subdirectory(apt-inst)
135add_subdirectory(cmdline)
9a2aa0e7 136add_subdirectory(doc)
f3de2dba
JAK
137add_subdirectory(dselect)
138add_subdirectory(ftparchive)
139add_subdirectory(methods)
7def2482 140add_subdirectory(po)
dfd863ea 141add_subdirectory(test)
10ec2d23
JAK
142
143# Link update-po4a into the update-po target
144add_dependencies(update-po update-po4a)