Files
bongo/cmake/Requirements.cmake
T
2026-07-16 19:04:19 +02:00

121 lines
4.1 KiB
CMake

# include here the requirements to build Bongo
# anything which isn't necessary should be marked [optional]
include(CheckIncludeFile)
# look for header files we need first
check_include_file(inttypes.h HAVE_INTTYPES_H)
check_include_file(sys/kstat.h HAVE_KSTAT_H)
check_include_file(sys/vfs.h HAVE_SYS_VFS_H)
check_include_file(sys/stat.h HAVE_SYS_STAT_H)
check_include_file(sys/statvfs.h HAVE_SYS_STATVFS_H)
check_include_file(time.h HAVE_TIME_H)
check_include_file(semaphore.h HAVE_SEMAPHORE_H)
# look for PThreads
include(FindThreads)
if (NOT CMAKE_USE_PTHREADS_INIT)
message(FATAL_ERROR "Bongo requires a platform with PThreads")
endif (NOT CMAKE_USE_PTHREADS_INIT)
# check for gettext
check_include_file(libintl.h HAVE_LIBINTL_H)
include (FindGettext)
if (NOT GETTEXT_FOUND)
message(FATAL_ERROR "Bongo needs Gettext developer support available")
endif (NOT GETTEXT_FOUND)
check_include_file(kstat.h HAVE_KSTAT_H)
# check for glib
find_package(GLib2 2.10 REQUIRED)
# memmgr.h is a public legacy header and includes glib.h directly.
include_directories(AFTER ${GLib2_INCLUDE_DIRS})
# check for GMime
find_package(GMime 2.6 REQUIRED)
# check for gcrypt
find_package(LibGcrypt 1.6 REQUIRED)
# connio.h and xplhash.h are public legacy headers and include gcrypt.h.
include_directories(AFTER ${LibGcrypt_INCLUDE_DIR})
# check for gnutls
find_package(GnuTLS REQUIRED)
# check for sqlite3
find_package(SQLite3 REQUIRED)
if(NOT TARGET SQLite3::SQLite3)
add_library(SQLite3::SQLite3 ALIAS SQLite::SQLite3)
endif()
# Secure IMAP, POP3 and SMTP client transport.
find_package(CURL 7.61 REQUIRED)
# RFC 5228 Sieve parser and validator used by the filter UI and ManageSieve.
find_package(Mailutils REQUIRED COMPONENTS Sieve)
# Shared SASL implementation for SMTP, IMAP, POP3 and ManageSieve.
find_package(CyrusSASL 2.1.28 REQUIRED)
# Native mail authentication. Bongo links to the protocol libraries directly;
# it does not require the corresponding milter daemons at runtime.
find_package(SPF2 REQUIRED)
find_package(OpenDKIM REQUIRED)
find_package(OpenDMARC REQUIRED)
find_package(SRS2 REQUIRED)
find_package(LibPSL 0.21 REQUIRED)
# check for libical
find_package(LibIcal REQUIRED)
if(EXISTS "${LibIcal_INCLUDE_DIR}/libical/ical.h")
set(HAVE_ICAL_H 1)
else()
set(HAVE_OLD_ICAL_H 1)
endif()
# check for Python
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
set(PYTHON_EXECUTABLE "${Python3_EXECUTABLE}")
set(PYTHON_LIBRARIES "${Python3_LIBRARIES}")
set(PYTHON_INCLUDE_DIRS "${Python3_INCLUDE_DIRS}")
set(PYTHON_INCLUDE_PATH "${Python3_INCLUDE_DIRS}")
function(python_add_module target)
add_library(${target} MODULE ${ARGN})
endfunction()
if (NOT Python3_Development_FOUND)
message(FATAL_ERROR "Bongo requires Python development libraries installed")
endif ()
execute_process(
COMMAND "${Python3_EXECUTABLE}" -c "import dateutil, nh3, vobject"
RESULT_VARIABLE PYTHON_NH3_FOUND
)
if (NOT PYTHON_NH3_FOUND EQUAL 0)
message(FATAL_ERROR "Bongo requires the Python dateutil, nh3, and vobject modules")
endif ()
execute_process(COMMAND "${Python3_EXECUTABLE}" -c "import sysconfig; print(sysconfig.get_path('purelib', vars={'base':'', 'platbase':''}))"
RESULT_VARIABLE PYTHON_SITEPACKAGES_FOUND
OUTPUT_VARIABLE PYTHON_SITEPACKAGES_PATH_RAW
)
string(STRIP "${PYTHON_SITEPACKAGES_PATH_RAW}" PYTHON_SITEPACKAGES_PATH_RAW)
execute_process(COMMAND "${Python3_EXECUTABLE}" -c "import sysconfig; print(sysconfig.get_path('platlib', vars={'base':'', 'platbase':''}))"
RESULT_VARIABLE PYTHON_SITELIB_FOUND
OUTPUT_VARIABLE PYTHON_SITELIB_PATH_RAW
)
string(STRIP "${PYTHON_SITELIB_PATH_RAW}" PYTHON_SITELIB_PATH_RAW)
if (PYTHON_SITEPACKAGES_FOUND EQUAL 0)
# sysconfig returns paths relative to an empty base with a leading slash.
# Prefix them exactly once so /usr/local never becomes /usr/local/usr.
set(PYTHON_SITEPACKAGES_PATH "${CMAKE_INSTALL_PREFIX}${PYTHON_SITEPACKAGES_PATH_RAW}")
set(PYTHON_SITELIB_PATH "${CMAKE_INSTALL_PREFIX}${PYTHON_SITELIB_PATH_RAW}")
else (PYTHON_SITEPACKAGES_FOUND EQUAL 0)
message(FATAL_ERROR "Couldn't determine where to install Python modules")
endif (PYTHON_SITEPACKAGES_FOUND EQUAL 0)
# check for Doxygen [optional]
include(FindDoxygen)