]> git.saurik.com Git - apt.git/blob - CMakeLists.txt
CMake: Use find_package() for curl instead of pkg_check_modules()
[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.3.0)
7
8 option(WITH_DOC "Build documentation." OFF)
9 option(USE_NLS "Localisation support." ON)
10
11 set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMake")
12
13 # Work around bug in GNUInstallDirs
14 if (EXISTS "/etc/debian_version")
15 set(CMAKE_INSTALL_LIBEXECDIR "lib")
16 endif()
17
18 # Include stuff
19 include(Misc)
20 include(Translations)
21 include(CheckIncludeFiles)
22 include(CheckFunctionExists)
23 include(CheckStructHasMember)
24 include(GNUInstallDirs)
25 include(TestBigEndian)
26 find_package(Threads)
27 find_package(PkgConfig)
28
29 # Set compiler flags
30 set(CMAKE_CXX_STANDARD 11)
31 set(CMAKE_CXX_STANDARD_REQUIRED ON)
32 set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
33
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)
48
49 # apt-ftparchive dependencies
50 find_package(BerkeleyDB REQUIRED)
51 if (BERKELEY_DB_FOUND)
52 set(HAVE_BDB 1)
53 endif()
54
55
56 # apt-transport-https dependencies
57 find_package(CURL REQUIRED)
58 if (CURL_FOUND)
59 set(HAVE_CURL 1)
60 endif()
61
62 # (De)Compressor libraries
63 find_package(ZLIB REQUIRED)
64 if (ZLIB_FOUND)
65 set(HAVE_ZLIB 1)
66 endif()
67
68
69 find_package(BZip2)
70 if (BZIP2_FOUND)
71 set(HAVE_BZ2 1)
72 endif()
73
74 pkg_check_modules(LZMA liblzma)
75 if (LZMA_FOUND)
76 set(HAVE_LZMA 1)
77 endif()
78
79 pkg_check_modules(LZ4 liblz4)
80 if (LZ4_FOUND)
81 set(HAVE_LZ4 1)
82 endif()
83
84 # Mount()ing and stat()ing and friends
85
86 check_function_exists(statvfs HAVE_STATVFS)
87 if (NOT 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()")
92 endif()
93 configure_file(buildlib/statvfs.h.in ${PROJECT_BINARY_DIR}/include/statvfs.h @ONLY)
94 endif()
95
96 CHECK_STRUCT_HAS_MEMBER("struct statfs" f_type sys/vfs.h HAVE_STRUCT_STATFS_F_TYPE)
97
98 # Other checks
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)
105
106 if (CMAKE_USE_PTHREADS_INIT)
107 set(HAVE_PTHREAD 1)
108 endif()
109
110 # Configure some variables like package, version and architecture.
111 set(PACKAGE "apt")
112
113 execute_process(COMMAND dpkg-parsechangelog -SVersion -l${PROJECT_SOURCE_DIR}/debian/changelog
114 OUTPUT_VARIABLE PACKAGE_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
115 execute_process(COMMAND dpkg-architecture -qDEB_HOST_ARCH
116 OUTPUT_VARIABLE COMMON_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
117
118 # Configure our configuration headers (config.h and apti18n.h)
119 configure_file(CMake/config.h.in ${PROJECT_BINARY_DIR}/include/config.h)
120 configure_file(CMake/apti18n.h.in ${PROJECT_BINARY_DIR}/include/apti18n.h)
121
122 # Generic header locations
123 include_directories(${PROJECT_BINARY_DIR}/include)
124
125 # Add our subdirectories
126 add_subdirectory(vendor)
127 add_subdirectory(apt-pkg)
128 add_subdirectory(apt-private)
129 add_subdirectory(apt-inst)
130 add_subdirectory(cmdline)
131 add_subdirectory(doc)
132 add_subdirectory(dselect)
133 add_subdirectory(ftparchive)
134 add_subdirectory(methods)
135 add_subdirectory(po)
136 add_subdirectory(test)