CMakeLists.txt 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. # set minimum version
  4. project(apt)
  5. cmake_minimum_required(VERSION 3.4.0)
  6. enable_testing()
  7. option(WITH_DOC "Build documentation." ON)
  8. option(USE_NLS "Localisation support." ON)
  9. set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMake")
  10. # Work around bug in GNUInstallDirs
  11. if (EXISTS "/etc/debian_version")
  12. set(CMAKE_INSTALL_LIBEXECDIR "lib")
  13. endif()
  14. # Include stuff
  15. include(Misc)
  16. include(Translations)
  17. include(CheckIncludeFiles)
  18. include(CheckFunctionExists)
  19. include(CheckStructHasMember)
  20. include(GNUInstallDirs)
  21. include(TestBigEndian)
  22. find_package(Threads)
  23. find_package(PkgConfig)
  24. find_package(LFS REQUIRED)
  25. # Add large file support
  26. add_compile_options(${LFS_COMPILE_OPTIONS})
  27. add_definitions(${LFS_DEFINITIONS})
  28. link_libraries(${LFS_LIBRARIES})
  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. add_optional_compile_options(Wall)
  34. add_optional_compile_options(Wextra)
  35. add_optional_compile_options(Wcast-align)
  36. add_optional_compile_options(Wlogical-op)
  37. add_optional_compile_options(Wredundant-decls)
  38. add_optional_compile_options(Wmissing-declarations)
  39. add_optional_compile_options(Wunsafe-loop-optimizations)
  40. add_optional_compile_options(Wctor-dtor-privacy)
  41. add_optional_compile_options(Wdisabled-optimization)
  42. add_optional_compile_options(Winit-self)
  43. add_optional_compile_options(Wmissing-include-dirs)
  44. add_optional_compile_options(Wnoexcept)
  45. add_optional_compile_options(Wsign-promo)
  46. add_optional_compile_options(Wundef)
  47. # apt-ftparchive dependencies
  48. find_package(BerkeleyDB REQUIRED)
  49. if (BERKELEY_DB_FOUND)
  50. set(HAVE_BDB 1)
  51. endif()
  52. # apt-transport-https dependencies
  53. find_package(CURL REQUIRED)
  54. if (CURL_FOUND)
  55. set(HAVE_CURL 1)
  56. endif()
  57. # (De)Compressor libraries
  58. find_package(ZLIB REQUIRED)
  59. if (ZLIB_FOUND)
  60. set(HAVE_ZLIB 1)
  61. endif()
  62. find_package(BZip2)
  63. if (BZIP2_FOUND)
  64. set(HAVE_BZ2 1)
  65. endif()
  66. pkg_check_modules(LZMA liblzma)
  67. if (LZMA_FOUND)
  68. set(HAVE_LZMA 1)
  69. endif()
  70. pkg_check_modules(LZ4 liblz4)
  71. if (LZ4_FOUND)
  72. set(HAVE_LZ4 1)
  73. endif()
  74. # Mount()ing and stat()ing and friends
  75. check_function_exists(statvfs HAVE_STATVFS)
  76. if (NOT HAVE_STATVFS)
  77. check_symbol_exists(statfs sys/vfs.h HAVE_VFS_H)
  78. check_symbol_exists(statfs sys/mount.h HAVE_MOUNT_H)
  79. if (NOT HAVE_VFS_H AND NOT HAVE_MOUNT_H)
  80. message(FATAL_ERROR "Can find neither statvfs() nor statfs()")
  81. endif()
  82. configure_file(CMake/statvfs.h.in ${PROJECT_BINARY_DIR}/include/statvfs.h COPYONLY)
  83. endif()
  84. CHECK_STRUCT_HAS_MEMBER("struct statfs" f_type sys/vfs.h HAVE_STRUCT_STATFS_F_TYPE)
  85. # Other checks
  86. check_function_exists(getresuid HAVE_GETRESUID)
  87. check_function_exists(getresgid HAVE_GETRESGID)
  88. check_function_exists(setresuid HAVE_SETRESUID)
  89. check_function_exists(setresgid HAVE_SETRESGID)
  90. check_function_exists(ptsname_r HAVE_PTSNAME_R)
  91. check_function_exists(timegm HAVE_TIMEGM)
  92. test_big_endian(WORDS_BIGENDIAN)
  93. if (CMAKE_USE_PTHREADS_INIT)
  94. set(HAVE_PTHREAD 1)
  95. endif()
  96. # Configure some variables like package, version and architecture.
  97. set(PACKAGE ${PROJECT_NAME})
  98. set(PACKAGE_MAIL "APT Development Team <deity@lists.debian.org>")
  99. set(PACKAGE_VERSION "1.3~rc2")
  100. if (NOT DEFINED COMMON_ARCH)
  101. execute_process(COMMAND dpkg-architecture -qDEB_HOST_ARCH
  102. OUTPUT_VARIABLE COMMON_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
  103. endif()
  104. # Configure our configuration headers (config.h and apti18n.h)
  105. configure_file(CMake/config.h.in ${PROJECT_BINARY_DIR}/include/config.h)
  106. configure_file(CMake/apti18n.h.in ${PROJECT_BINARY_DIR}/include/apti18n.h)
  107. # Generic header locations
  108. include_directories(${PROJECT_BINARY_DIR}/include)
  109. # Add our subdirectories
  110. add_subdirectory(vendor)
  111. add_subdirectory(apt-pkg)
  112. add_subdirectory(apt-private)
  113. add_subdirectory(apt-inst)
  114. add_subdirectory(cmdline)
  115. add_subdirectory(completions)
  116. add_subdirectory(doc)
  117. add_subdirectory(dselect)
  118. add_subdirectory(ftparchive)
  119. add_subdirectory(methods)
  120. add_subdirectory(po)
  121. add_subdirectory(test)
  122. # Link update-po4a into the update-po target
  123. add_dependencies(update-po update-po4a)
  124. # Create our directories.
  125. install_empty_directories(
  126. ${CMAKE_INSTALL_FULL_SYSCONFDIR}/apt/apt.conf.d
  127. ${CMAKE_INSTALL_FULL_SYSCONFDIR}/apt/preferences.d
  128. ${CMAKE_INSTALL_FULL_SYSCONFDIR}/apt/sources.list.d
  129. ${CMAKE_INSTALL_FULL_SYSCONFDIR}/apt/trusted.gpg.d
  130. ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/cache/apt/archives/partial
  131. ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/apt/lists/partial
  132. ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/apt/mirrors/partial
  133. ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/apt/periodic
  134. ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/log/apt
  135. )