]> git.saurik.com Git - apt.git/blame - CMakeLists.txt
CMake: Add basic CMake build system
[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
8option(WITH_DOC "Build documentation." OFF)
9option(USE_NLS "Localisation support." ON)
10
11set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMake")
12
13# Work around bug in GNUInstallDirs
14if (EXISTS "/etc/debian_version")
15 set(CMAKE_INSTALL_LIBEXECDIR "lib")
16endif()
17
18# Include stuff
19include(Misc)
20include(CheckIncludeFiles)
21include(CheckFunctionExists)
22include(CheckStructHasMember)
23include(GNUInstallDirs)
24include(TestBigEndian)
25find_package(Threads)
26find_package(PkgConfig)
27
28# Set compiler flags
29set(CMAKE_CXX_STANDARD 11)
30set(CMAKE_CXX_STANDARD_REQUIRED ON)
31set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
32
33add_optional_compile_options(Wall)
34add_optional_compile_options(Wextra)
35add_optional_compile_options(Wcast-align)
36add_optional_compile_options(Wlogical-op)
37add_optional_compile_options(Wredundant-decls)
38add_optional_compile_options(Wmissing-declarations)
39add_optional_compile_options(Wunsafe-loop-optimizations)
40add_optional_compile_options(Wctor-dtor-privacy)
41add_optional_compile_options(Wdisabled-optimization)
42add_optional_compile_options(Winit-self)
43add_optional_compile_options(Wmissing-include-dirs)
44add_optional_compile_options(Wnoexcept)
45add_optional_compile_options(Wsign-promo)
46add_optional_compile_options(Wundef)
47
48# apt-ftparchive dependencies
49find_package(BerkeleyDB REQUIRED)
50if (BERKELEY_DB_FOUND)
51 set(HAVE_BDB 1)
52endif()
53
54
55# apt-transport-https dependencies
56pkg_check_modules(CURL libcurl REQUIRED)
57if (CURL_FOUND)
58 set(HAVE_CURL 1)
59endif()
60
61# (De)Compressor libraries
62find_package(ZLIB REQUIRED)
63if (ZLIB_FOUND)
64 set(HAVE_ZLIB 1)
65endif()
66
67
68find_package(BZip2)
69if (BZIP2_FOUND)
70 set(HAVE_BZ2 1)
71endif()
72
73pkg_check_modules(LZMA liblzma)
74if (LZMA_FOUND)
75 set(HAVE_LZMA 1)
76endif()
77
78pkg_check_modules(LZ4 liblz4)
79if (LZ4_FOUND)
80 set(HAVE_LZ4 1)
81endif()
82
83# Mount()ing and stat()ing and friends
84
85check_function_exists(statvfs HAVE_STATVFS)
86if (NOT HAVE_STATVFS)
87 check_symbol_exists(statfs sys/vfs.h HAVE_VFS_H)
88 check_symbol_exists(statfs sys/mount.h HAVE_MOUNT_H)
89 if (NOT HAVE_VFS_H AND NOT HAVE_MOUNT_H)
90 message(FATAL_ERROR "Can find neither statvfs() nor statfs()")
91 endif()
92 configure_file(buildlib/statvfs.h.in ${PROJECT_BINARY_DIR}/include/statvfs.h @ONLY)
93endif()
94
95CHECK_STRUCT_HAS_MEMBER("struct statfs" f_type sys/vfs.h HAVE_STRUCT_STATFS_F_TYPE)
96
97# Other checks
98check_function_exists(getresuid HAVE_GETRESUID)
99check_function_exists(getresgid HAVE_GETRESGID)
100check_function_exists(setresuid HAVE_SETRESUID)
101check_function_exists(setresgid HAVE_SETRESGID)
102check_function_exists(timegm HAVE_TIMEGM)
103test_big_endian(WORDS_BIGENDIAN)
104
105if (CMAKE_USE_PTHREADS_INIT)
106 set(HAVE_PTHREAD 1)
107endif()
108
109# Configure some variables like package, version and architecture.
110set(PACKAGE "apt")
111
112execute_process(COMMAND dpkg-parsechangelog -SVersion -l${PROJECT_SOURCE_DIR}/debian/changelog
113 OUTPUT_VARIABLE PACKAGE_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
114execute_process(COMMAND dpkg-architecture -qDEB_HOST_ARCH
115 OUTPUT_VARIABLE COMMON_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
116
117# Configure our configuration headers (config.h and apti18n.h)
118configure_file(CMake/config.h.in ${PROJECT_BINARY_DIR}/include/config.h)
119configure_file(CMake/apti18n.h.in ${PROJECT_BINARY_DIR}/include/apti18n.h)
120
121# Generic header locations
122include_directories(${PROJECT_BINARY_DIR}/include)
123
124# Add our subdirectories
125add_subdirectory(vendor)
126add_subdirectory(apt-pkg)
127add_subdirectory(apt-private)
128add_subdirectory(apt-inst)
129add_subdirectory(cmdline)
130add_subdirectory(dselect)
131add_subdirectory(ftparchive)
132add_subdirectory(methods)