"Fossies" - the Fresh Open Source Software Archive

Member "apt-2.2.4/CMakeLists.txt" (10 Jun 2021, 7663 Bytes) of package /linux/misc/apt-2.2.4.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "CMakeLists.txt": 2.2.3_vs_2.2.4.

    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.4.0)
    7 # Generic header locations
    8 include_directories(${PROJECT_BINARY_DIR}/include)
    9 
   10 
   11 enable_testing()
   12 
   13 option(WITH_DOC "Build documentation." ON)
   14 option(WITH_TESTS "Build tests" ON)
   15 option(USE_NLS "Localisation support." ON)
   16 
   17 set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMake")
   18 
   19 # Add coverage target
   20 set(CMAKE_CXX_FLAGS_COVERAGE "-g -fprofile-arcs -ftest-coverage")
   21 set(CMAKE_EXE_LINKER_FLAGS_COVERAGE "-lgcov")
   22 set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE "-lgcov")
   23 
   24 # Work around bug in GNUInstallDirs
   25 if (EXISTS "/etc/debian_version")
   26   set(CMAKE_INSTALL_LIBEXECDIR "lib")
   27 endif()
   28 
   29 # Include stuff
   30 include(Misc)
   31 include(CheckIncludeFiles)
   32 include(CheckFunctionExists)
   33 include(CheckStructHasMember)
   34 include(GNUInstallDirs)
   35 include(TestBigEndian)
   36 find_package(Threads REQUIRED)
   37 find_package(LFS REQUIRED)
   38 find_package(Iconv REQUIRED)
   39 
   40 find_package(Perl REQUIRED)
   41 
   42 find_program(TRIEHASH_EXECUTABLE NAMES triehash)
   43 
   44 if (NOT TRIEHASH_EXECUTABLE)
   45   message(FATAL_ERROR "Could not find triehash executable")
   46 endif()
   47 
   48 if(USE_NLS)
   49   find_package(Intl REQUIRED)
   50   link_libraries(${Intl_LIBRARIES})
   51   include_directories(${Intl_INCLUDE_DIRS})
   52 endif()
   53 
   54 # Add large file support
   55 add_compile_options(${LFS_COMPILE_OPTIONS})
   56 add_definitions(${LFS_DEFINITIONS})
   57 link_libraries(${LFS_LIBRARIES})
   58 
   59 # Set compiler flags
   60 set(CMAKE_CXX_STANDARD 14)
   61 set(CMAKE_CXX_STANDARD_REQUIRED ON)
   62 set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
   63 
   64 add_optional_compile_options(Wall)
   65 add_optional_compile_options(Wextra)
   66 add_optional_compile_options(Wcast-align)
   67 add_optional_compile_options(Wlogical-op)
   68 add_optional_compile_options(Wredundant-decls)
   69 add_optional_compile_options(Wmissing-declarations)
   70 add_optional_compile_options(Wunsafe-loop-optimizations)
   71 add_optional_compile_options(Wctor-dtor-privacy)
   72 add_optional_compile_options(Wdisabled-optimization)
   73 add_optional_compile_options(Winit-self)
   74 add_optional_compile_options(Wmissing-include-dirs)
   75 add_optional_compile_options(Wnoexcept)
   76 add_optional_compile_options(Wsign-promo)
   77 add_optional_compile_options(Wundef)
   78 add_optional_compile_options(Wdouble-promotion)
   79 add_optional_compile_options(Wsuggest-override)
   80 add_optional_compile_options(Werror=suggest-override)
   81 add_optional_compile_options(Werror=return-type)
   82 # apt-ftparchive dependencies
   83 find_package(Berkeley REQUIRED)
   84 if (BERKELEY_FOUND)
   85   set(HAVE_BDB 1)
   86 endif()
   87 
   88 find_package(GnuTLS REQUIRED)
   89 if (GNUTLS_FOUND)
   90   set(HAVE_GNUTLS 1)
   91 endif()
   92 
   93 # (De)Compressor libraries
   94 find_package(ZLIB REQUIRED)
   95 if (ZLIB_FOUND)
   96   set(HAVE_ZLIB 1)
   97 endif()
   98 
   99 
  100 find_package(BZip2 REQUIRED)
  101 if (BZIP2_FOUND)
  102   set(HAVE_BZ2 1)
  103 endif()
  104 
  105 find_package(LZMA REQUIRED)
  106 if (LZMA_FOUND)
  107   set(HAVE_LZMA 1)
  108 endif()
  109 
  110 
  111 find_package(LZ4 REQUIRED)
  112 if (LZ4_FOUND)
  113   set(HAVE_LZ4 1)
  114 endif()
  115 
  116 find_package(ZSTD)
  117 if (ZSTD_FOUND)
  118   set(HAVE_ZSTD 1)
  119 endif()
  120 
  121 
  122 find_package(Udev)
  123 if (UDEV_FOUND)
  124   set(HAVE_UDEV 1)
  125 endif()
  126 
  127 find_package(Systemd)
  128 if (SYSTEMD_FOUND)
  129   set(HAVE_SYSTEMD 1)
  130 endif()
  131 
  132 find_package(SECCOMP)
  133 if (SECCOMP_FOUND)
  134   set(HAVE_SECCOMP 1)
  135 endif()
  136 
  137 find_package(GCRYPT REQUIRED)
  138 find_package(XXHASH REQUIRED)
  139 
  140 # Mount()ing and stat()ing and friends
  141 check_symbol_exists(statfs sys/vfs.h HAVE_VFS_H)
  142 check_include_files(sys/params.h HAVE_PARAMS_H)
  143 check_symbol_exists(statfs sys/mount.h HAVE_MOUNT_H)
  144 if (NOT HAVE_VFS_H AND NOT HAVE_MOUNT_H)
  145   message(FATAL_ERROR "Can find neither statvfs() nor statfs()")
  146 endif()
  147 
  148 check_function_exists(statvfs HAVE_STATVFS)
  149 if (NOT HAVE_STATVFS)
  150   configure_file(CMake/statvfs.h.in ${PROJECT_BINARY_DIR}/include/sys/statvfs.h COPYONLY)
  151 endif()
  152 
  153 CHECK_STRUCT_HAS_MEMBER("struct statfs" f_type sys/vfs.h HAVE_STRUCT_STATFS_F_TYPE)
  154 
  155 # Other checks
  156 check_function_exists(getresuid HAVE_GETRESUID)
  157 check_function_exists(getresgid HAVE_GETRESGID)
  158 check_function_exists(setresuid HAVE_SETRESUID)
  159 check_function_exists(setresgid HAVE_SETRESGID)
  160 check_function_exists(ptsname_r HAVE_PTSNAME_R)
  161 check_function_exists(timegm HAVE_TIMEGM)
  162 test_big_endian(WORDS_BIGENDIAN)
  163 
  164 # FreeBSD
  165 add_definitions(-D_WITH_GETLINE=1)
  166 
  167 CHECK_INCLUDE_FILES(machine/endian.h HAVE_MACHINE_ENDIAN_H)
  168 CHECK_INCLUDE_FILES(sys/endian.h HAVE_SYS_ENDIAN_H)
  169 CHECK_INCLUDE_FILES(endian.h HAVE_ENDIAN_H)
  170 if (NOT HAVE_ENDIAN_H)
  171   if (HAVE_MACHINE_ENDIAN_H OR HAVE_SYS_ENDIAN_H)
  172     configure_file(CMake/endian.h.in ${PROJECT_BINARY_DIR}/include/endian.h)
  173   else()
  174     message(FATAL_ERROR "Cannot find endian.h")
  175   endif()
  176 endif()
  177 
  178 
  179 include(CheckTypeSize)
  180 set(CMAKE_EXTRA_INCLUDE_FILES "signal.h")
  181 check_type_size("sig_t" SIG_T LANGUAGE "CXX")
  182 check_type_size("sighandler_t" SIGHANDLER_T LANGUAGE "CXX")
  183 set(CMAKE_EXTRA_INCLUDE_FILES)
  184 if (NOT HAVE_SIGHANDLER_T)
  185   if (HAVE_SIG_T)
  186     add_definitions(-Dsighandler_t=sig_t)
  187   else()
  188     message(FATAL_ERROR "Platform defines neither sig_t nor sighandler_t")
  189   endif()
  190 endif()
  191 
  192 # Handle resolving
  193 check_function_exists(res_ninit HAVE_LIBC_RESOLV)
  194 if(HAVE_LIBC_RESOLV)
  195     set(RESOLV_LIBRARIES)
  196 else()
  197     set(RESOLV_LIBRARIES -lresolv)
  198 endif()
  199 
  200 # Configure some variables like package, version and architecture.
  201 set(PACKAGE ${PROJECT_NAME})
  202 set(PACKAGE_MAIL "APT Development Team <deity@lists.debian.org>")
  203 set(PACKAGE_VERSION "2.2.4")
  204 string(REGEX MATCH "^[0-9.]+" PROJECT_VERSION ${PACKAGE_VERSION})
  205 
  206 if (NOT DEFINED DPKG_DATADIR)
  207   execute_process(COMMAND ${PERL_EXECUTABLE} -MDpkg -e "print $Dpkg::DATADIR;"
  208                   OUTPUT_VARIABLE DPKG_DATADIR_CMD OUTPUT_STRIP_TRAILING_WHITESPACE)
  209   message(STATUS "Found dpkg data dir: ${DPKG_DATADIR_CMD}")
  210   set(DPKG_DATADIR "${DPKG_DATADIR_CMD}" CACHE PATH "dpkg data directory")
  211 endif()
  212 if (NOT DEFINED COMMON_ARCH)
  213   execute_process(COMMAND dpkg-architecture -qDEB_HOST_ARCH
  214                   OUTPUT_VARIABLE COMMON_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
  215 endif()
  216 if (NOT DEFINED ROOT_GROUP)
  217   execute_process(COMMAND id -gn root
  218                   OUTPUT_VARIABLE ROOT_GROUP OUTPUT_STRIP_TRAILING_WHITESPACE)
  219   message(STATUS "Found root group: ${ROOT_GROUP}")
  220 endif()
  221 set(ROOT_GROUP "${ROOT_GROUP}" CACHE STRING "Group of root (e.g.: wheel or root)")
  222 
  223 # Set various directories
  224 set(STATE_DIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/apt" CACHE PATH "Your /var/lib/apt")
  225 set(CACHE_DIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/cache/apt" CACHE PATH "Your /var/cache/apt")
  226 set(LOG_DIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/log/apt" CACHE PATH "Your /var/log/apt")
  227 set(CONF_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/apt" CACHE PATH "Your /etc/apt")
  228 set(LIBEXEC_DIR "${CMAKE_INSTALL_FULL_LIBEXECDIR}/apt" CACHE PATH "Your /usr/libexec/apt")
  229 set(BIN_DIR "${CMAKE_INSTALL_FULL_BINDIR}")
  230 
  231 
  232 # Configure our configuration headers (config.h and apti18n.h)
  233 configure_file(CMake/config.h.in ${PROJECT_BINARY_DIR}/include/config.h)
  234 configure_file(CMake/apti18n.h.in ${PROJECT_BINARY_DIR}/include/apti18n.h)
  235 
  236 # Add our subdirectories
  237 add_subdirectory(vendor)
  238 add_subdirectory(apt-pkg)
  239 add_subdirectory(apt-private)
  240 add_subdirectory(cmdline)
  241 add_subdirectory(completions)
  242 add_subdirectory(doc)
  243 add_subdirectory(dselect)
  244 add_subdirectory(ftparchive)
  245 add_subdirectory(methods)
  246 add_subdirectory(test)
  247 
  248 if (USE_NLS)
  249 add_subdirectory(po)
  250 
  251 # Link update-po4a into the update-po target
  252 add_dependencies(update-po update-po4a)
  253 endif()
  254 
  255 # Create our directories.
  256 install_empty_directories(
  257   ${CONF_DIR}/apt.conf.d
  258   ${CONF_DIR}/auth.conf.d
  259   ${CONF_DIR}/preferences.d
  260   ${CONF_DIR}/sources.list.d
  261   ${CONF_DIR}/trusted.gpg.d
  262   ${CACHE_DIR}/archives/partial
  263   ${STATE_DIR}/lists/partial
  264   ${STATE_DIR}/mirrors/partial
  265   ${STATE_DIR}/periodic
  266   ${LOG_DIR}
  267 )