]> git.saurik.com Git - apt.git/blame - CMakeLists.txt
CMake: Discover docbook stylesheet in other locations
[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)
3fbd6746
JAK
30find_package(LFS REQUIRED)
31
32# Add large file support
33add_compile_options(${LFS_COMPILE_OPTIONS})
34add_definitions(${LFS_DEFINITIONS})
35link_libraries(${LFS_LIBRARIES})
f3de2dba
JAK
36
37# Set compiler flags
38set(CMAKE_CXX_STANDARD 11)
39set(CMAKE_CXX_STANDARD_REQUIRED ON)
40set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
41
42add_optional_compile_options(Wall)
43add_optional_compile_options(Wextra)
44add_optional_compile_options(Wcast-align)
45add_optional_compile_options(Wlogical-op)
46add_optional_compile_options(Wredundant-decls)
47add_optional_compile_options(Wmissing-declarations)
48add_optional_compile_options(Wunsafe-loop-optimizations)
49add_optional_compile_options(Wctor-dtor-privacy)
50add_optional_compile_options(Wdisabled-optimization)
51add_optional_compile_options(Winit-self)
52add_optional_compile_options(Wmissing-include-dirs)
53add_optional_compile_options(Wnoexcept)
54add_optional_compile_options(Wsign-promo)
55add_optional_compile_options(Wundef)
56
57# apt-ftparchive dependencies
58find_package(BerkeleyDB REQUIRED)
59if (BERKELEY_DB_FOUND)
60 set(HAVE_BDB 1)
61endif()
62
63
64# apt-transport-https dependencies
1ed5f979 65find_package(CURL REQUIRED)
f3de2dba
JAK
66if (CURL_FOUND)
67 set(HAVE_CURL 1)
68endif()
69
70# (De)Compressor libraries
71find_package(ZLIB REQUIRED)
72if (ZLIB_FOUND)
73 set(HAVE_ZLIB 1)
74endif()
75
76
77find_package(BZip2)
78if (BZIP2_FOUND)
79 set(HAVE_BZ2 1)
80endif()
81
82pkg_check_modules(LZMA liblzma)
83if (LZMA_FOUND)
84 set(HAVE_LZMA 1)
85endif()
86
87pkg_check_modules(LZ4 liblz4)
88if (LZ4_FOUND)
89 set(HAVE_LZ4 1)
90endif()
91
92# Mount()ing and stat()ing and friends
93
94check_function_exists(statvfs HAVE_STATVFS)
95if (NOT HAVE_STATVFS)
96 check_symbol_exists(statfs sys/vfs.h HAVE_VFS_H)
97 check_symbol_exists(statfs sys/mount.h HAVE_MOUNT_H)
98 if (NOT HAVE_VFS_H AND NOT HAVE_MOUNT_H)
99 message(FATAL_ERROR "Can find neither statvfs() nor statfs()")
100 endif()
389e8322 101 configure_file(CMake/statvfs.h.in ${PROJECT_BINARY_DIR}/include/statvfs.h COPYONLY)
f3de2dba
JAK
102endif()
103
104CHECK_STRUCT_HAS_MEMBER("struct statfs" f_type sys/vfs.h HAVE_STRUCT_STATFS_F_TYPE)
105
106# Other checks
107check_function_exists(getresuid HAVE_GETRESUID)
108check_function_exists(getresgid HAVE_GETRESGID)
109check_function_exists(setresuid HAVE_SETRESUID)
110check_function_exists(setresgid HAVE_SETRESGID)
8c1dbbef 111check_function_exists(ptsname_r HAVE_PTSNAME_R)
f3de2dba
JAK
112check_function_exists(timegm HAVE_TIMEGM)
113test_big_endian(WORDS_BIGENDIAN)
114
115if (CMAKE_USE_PTHREADS_INIT)
116 set(HAVE_PTHREAD 1)
117endif()
118
119# Configure some variables like package, version and architecture.
33ee08e4
JAK
120set(PACKAGE ${PROJECT_NAME})
121set(PACKAGE_MAIL "APT Development Team <deity@lists.debian.org>")
43670e2e 122set(PACKAGE_VERSION "1.3~rc2")
f3de2dba 123
3093c60f
JAK
124if (NOT DEFINED COMMON_ARCH)
125 execute_process(COMMAND dpkg-architecture -qDEB_HOST_ARCH
126 OUTPUT_VARIABLE COMMON_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
127endif()
f3de2dba
JAK
128
129# Configure our configuration headers (config.h and apti18n.h)
130configure_file(CMake/config.h.in ${PROJECT_BINARY_DIR}/include/config.h)
131configure_file(CMake/apti18n.h.in ${PROJECT_BINARY_DIR}/include/apti18n.h)
132
133# Generic header locations
134include_directories(${PROJECT_BINARY_DIR}/include)
135
136# Add our subdirectories
137add_subdirectory(vendor)
138add_subdirectory(apt-pkg)
139add_subdirectory(apt-private)
140add_subdirectory(apt-inst)
141add_subdirectory(cmdline)
1bb40ea6 142add_subdirectory(completions)
9a2aa0e7 143add_subdirectory(doc)
f3de2dba
JAK
144add_subdirectory(dselect)
145add_subdirectory(ftparchive)
146add_subdirectory(methods)
7def2482 147add_subdirectory(po)
dfd863ea 148add_subdirectory(test)
10ec2d23
JAK
149
150# Link update-po4a into the update-po target
151add_dependencies(update-po update-po4a)
35d74be5
JAK
152
153# Create our directories.
154install_empty_directories(
155 ${CMAKE_INSTALL_FULL_SYSCONFDIR}/apt/apt.conf.d
156 ${CMAKE_INSTALL_FULL_SYSCONFDIR}/apt/preferences.d
157 ${CMAKE_INSTALL_FULL_SYSCONFDIR}/apt/sources.list.d
158 ${CMAKE_INSTALL_FULL_SYSCONFDIR}/apt/trusted.gpg.d
159 ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/cache/apt/archives/partial
160 ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/apt/lists/partial
161 ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/apt/mirrors/partial
162 ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/apt/periodic
163 ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/log/apt
164)