CMakeLists.txt 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. # Set compiler flags
  25. set(CMAKE_CXX_STANDARD 11)
  26. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  27. set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
  28. add_optional_compile_options(Wall)
  29. add_optional_compile_options(Wextra)
  30. add_optional_compile_options(Wcast-align)
  31. add_optional_compile_options(Wlogical-op)
  32. add_optional_compile_options(Wredundant-decls)
  33. add_optional_compile_options(Wmissing-declarations)
  34. add_optional_compile_options(Wunsafe-loop-optimizations)
  35. add_optional_compile_options(Wctor-dtor-privacy)
  36. add_optional_compile_options(Wdisabled-optimization)
  37. add_optional_compile_options(Winit-self)
  38. add_optional_compile_options(Wmissing-include-dirs)
  39. add_optional_compile_options(Wnoexcept)
  40. add_optional_compile_options(Wsign-promo)
  41. add_optional_compile_options(Wundef)
  42. # apt-ftparchive dependencies
  43. find_package(BerkeleyDB REQUIRED)
  44. if (BERKELEY_DB_FOUND)
  45. set(HAVE_BDB 1)
  46. endif()
  47. # apt-transport-https dependencies
  48. find_package(CURL REQUIRED)
  49. if (CURL_FOUND)
  50. set(HAVE_CURL 1)
  51. endif()
  52. # (De)Compressor libraries
  53. find_package(ZLIB REQUIRED)
  54. if (ZLIB_FOUND)
  55. set(HAVE_ZLIB 1)
  56. endif()
  57. find_package(BZip2)
  58. if (BZIP2_FOUND)
  59. set(HAVE_BZ2 1)
  60. endif()
  61. pkg_check_modules(LZMA liblzma)
  62. if (LZMA_FOUND)
  63. set(HAVE_LZMA 1)
  64. endif()
  65. pkg_check_modules(LZ4 liblz4)
  66. if (LZ4_FOUND)
  67. set(HAVE_LZ4 1)
  68. endif()
  69. # Mount()ing and stat()ing and friends
  70. check_function_exists(statvfs HAVE_STATVFS)
  71. if (NOT HAVE_STATVFS)
  72. check_symbol_exists(statfs sys/vfs.h HAVE_VFS_H)
  73. check_symbol_exists(statfs sys/mount.h HAVE_MOUNT_H)
  74. if (NOT HAVE_VFS_H AND NOT HAVE_MOUNT_H)
  75. message(FATAL_ERROR "Can find neither statvfs() nor statfs()")
  76. endif()
  77. configure_file(buildlib/statvfs.h.in ${PROJECT_BINARY_DIR}/include/statvfs.h @ONLY)
  78. endif()
  79. CHECK_STRUCT_HAS_MEMBER("struct statfs" f_type sys/vfs.h HAVE_STRUCT_STATFS_F_TYPE)
  80. # Other checks
  81. check_function_exists(getresuid HAVE_GETRESUID)
  82. check_function_exists(getresgid HAVE_GETRESGID)
  83. check_function_exists(setresuid HAVE_SETRESUID)
  84. check_function_exists(setresgid HAVE_SETRESGID)
  85. check_function_exists(ptsname_r HAVE_PTSNAME_R)
  86. check_function_exists(timegm HAVE_TIMEGM)
  87. test_big_endian(WORDS_BIGENDIAN)
  88. if (CMAKE_USE_PTHREADS_INIT)
  89. set(HAVE_PTHREAD 1)
  90. endif()
  91. # Configure some variables like package, version and architecture.
  92. set(PACKAGE ${PROJECT_NAME})
  93. set(PACKAGE_MAIL "APT Development Team <deity@lists.debian.org>")
  94. if (NOT DEFINED PACKAGE_VERSION)
  95. execute_process(COMMAND dpkg-parsechangelog -SVersion -l${PROJECT_SOURCE_DIR}/debian/changelog
  96. OUTPUT_VARIABLE PACKAGE_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
  97. endif()
  98. if (NOT DEFINED COMMON_ARCH)
  99. execute_process(COMMAND dpkg-architecture -qDEB_HOST_ARCH
  100. OUTPUT_VARIABLE COMMON_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
  101. endif()
  102. # Configure our configuration headers (config.h and apti18n.h)
  103. configure_file(CMake/config.h.in ${PROJECT_BINARY_DIR}/include/config.h)
  104. configure_file(CMake/apti18n.h.in ${PROJECT_BINARY_DIR}/include/apti18n.h)
  105. # Generic header locations
  106. include_directories(${PROJECT_BINARY_DIR}/include)
  107. # Add our subdirectories
  108. add_subdirectory(vendor)
  109. add_subdirectory(apt-pkg)
  110. add_subdirectory(apt-private)
  111. add_subdirectory(apt-inst)
  112. add_subdirectory(cmdline)
  113. add_subdirectory(doc)
  114. add_subdirectory(dselect)
  115. add_subdirectory(ftparchive)
  116. add_subdirectory(methods)
  117. add_subdirectory(po)
  118. add_subdirectory(test)
  119. # Link update-po4a into the update-po target
  120. add_dependencies(update-po update-po4a)