CMakeLists.txt 3.8 KB

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