164 lines
5.7 KiB
CMake
164 lines
5.7 KiB
CMake
# include here the requirements to build Bongo
|
|
# anything which isn't necessary should be marked [optional]
|
|
|
|
include(CheckIncludeFile)
|
|
include(CheckCSourceCompiles)
|
|
|
|
# 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)
|
|
|
|
# GCC and Clang provide the __atomic builtins used by XplAtomic. Some older
|
|
# 32-bit targets (including ARM) need libatomic for the same operations, while
|
|
# others emit them inline. Detect that at link time instead of assuming the
|
|
# build host's behaviour.
|
|
set(_BONGO_ATOMIC_TEST_SOURCE "
|
|
int main(void)
|
|
{
|
|
int value = 0;
|
|
__atomic_fetch_add(&value, 1, __ATOMIC_SEQ_CST);
|
|
return __atomic_load_n(&value, __ATOMIC_SEQ_CST) != 1;
|
|
}")
|
|
check_c_source_compiles("${_BONGO_ATOMIC_TEST_SOURCE}"
|
|
BONGO_ATOMICS_LINK_WITHOUT_LIBRARY)
|
|
add_library(BongoAtomic INTERFACE)
|
|
add_library(Bongo::Atomic ALIAS BongoAtomic)
|
|
if(NOT BONGO_ATOMICS_LINK_WITHOUT_LIBRARY)
|
|
set(CMAKE_REQUIRED_LIBRARIES atomic)
|
|
check_c_source_compiles("${_BONGO_ATOMIC_TEST_SOURCE}"
|
|
BONGO_ATOMICS_LINK_WITH_LIBATOMIC)
|
|
unset(CMAKE_REQUIRED_LIBRARIES)
|
|
if(NOT BONGO_ATOMICS_LINK_WITH_LIBATOMIC)
|
|
message(FATAL_ERROR
|
|
"The compiler cannot link the atomic operations required by Bongo")
|
|
endif()
|
|
target_link_libraries(BongoAtomic INTERFACE atomic)
|
|
endif()
|
|
unset(_BONGO_ATOMIC_TEST_SOURCE)
|
|
|
|
# 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)
|
|
|
|
# Native DNS queries, authoritative propagation checks and RFC 2136 updates
|
|
# used by ACME DNS-01 providers.
|
|
find_package(LDNS 1.8 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(GSASL 2.2.0 REQUIRED)
|
|
|
|
# Primary directory authentication with a short-lived local offline cache.
|
|
find_package(OpenLDAP 2.4 REQUIRED)
|
|
|
|
# TOTP, recovery codes and service-scoped app passwords.
|
|
find_package(OATH 2.6 REQUIRED)
|
|
find_package(Argon2 REQUIRED)
|
|
|
|
# QR codes for enrolling authenticator applications in the web interface.
|
|
find_package(QRencode 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, dns.resolver, nh3, vobject"
|
|
RESULT_VARIABLE PYTHON_NH3_FOUND
|
|
)
|
|
if (NOT PYTHON_NH3_FOUND EQUAL 0)
|
|
message(FATAL_ERROR "Bongo requires the Python dateutil, dnspython, 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)
|