Implement cmake build system
This commit is contained in:
parent
9b2b7ccf0a
commit
400777aaee
16 changed files with 2057 additions and 916 deletions
13
.travis.yml
13
.travis.yml
|
@ -18,13 +18,20 @@ addons:
|
||||||
apt:
|
apt:
|
||||||
packages:
|
packages:
|
||||||
- libspf2-dev
|
- libspf2-dev
|
||||||
|
- doxygen
|
||||||
|
- graphviz
|
||||||
homebrew:
|
homebrew:
|
||||||
packages:
|
packages:
|
||||||
|
- libintl
|
||||||
- gettext
|
- gettext
|
||||||
- openssl
|
- openssl
|
||||||
|
- doxygen
|
||||||
|
- graphviz
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- ./bootstrap
|
- mkdir build
|
||||||
- ./configure
|
- pushd build
|
||||||
- make install prefix=$PWD/install-dir
|
- cmake .. -DCMAKE_INSTALL_PREFIX=$PWD/install-dir
|
||||||
|
- make install
|
||||||
- find $PWD/install-dir
|
- find $PWD/install-dir
|
||||||
|
- popd
|
||||||
|
|
86
CMakeLists.txt
Normal file
86
CMakeLists.txt
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
cmake_minimum_required(VERSION 3.12)
|
||||||
|
|
||||||
|
project (hermes)
|
||||||
|
set(LOGGER_CLASS UnixLogger CACHE STRING "One of UnixLogger, FileLogger or NullLogger")
|
||||||
|
|
||||||
|
|
||||||
|
add_executable (hermes
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/Configfile.cpp
|
||||||
|
src/Exception.cpp
|
||||||
|
src/hermes.cpp
|
||||||
|
src/ServerSocket.cpp
|
||||||
|
src/Utils.cpp
|
||||||
|
src/Database.cpp
|
||||||
|
src/Proxy.cpp
|
||||||
|
src/Socket.cpp)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
set(SOURCES ${SOURCES}
|
||||||
|
src/FileLogger.cpp
|
||||||
|
src/win32-service.cpp)
|
||||||
|
target_compile_definitions(hermes PRIVATE WIN32)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_compile_definitions(hermes PRIVATE LOGGER_CLASS=${LOGGER_CLASS})
|
||||||
|
target_sources(hermes PRIVATE src/${LOGGER_CLASS}.cpp)
|
||||||
|
|
||||||
|
# required dependency sqlite3
|
||||||
|
find_library (SQLITE3_LIBRARY NAMES libsqlite3 sqlite3)
|
||||||
|
|
||||||
|
# optional dependency libspf2
|
||||||
|
find_library (SPF2_LIBRARY NAMES spf2 libspf2)
|
||||||
|
if(SPF2_LIB)
|
||||||
|
target_compile_definitions(hermes PRIVATE HAVE_SPF2)
|
||||||
|
target_sources(hermes PRIVATE src/Spf.cpp)
|
||||||
|
set(OPT_DEFS ${OPT_DEFS} -DHAVE_SPF2)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# optional dependency openssl
|
||||||
|
find_package (OpenSSL)
|
||||||
|
if(OPENSSL_FOUND)
|
||||||
|
target_compile_definitions(hermes PRIVATE HAVE_SSL)
|
||||||
|
set(OPT_DEFS ${OPT_DEFS} -DHAVE_SSL)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
src)
|
||||||
|
|
||||||
|
# generation of various files
|
||||||
|
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Configfile.cpp
|
||||||
|
COMMAND cpp ${OPT_DEFS} ${CMAKE_CURRENT_SOURCE_DIR}/src/Configfile.tmpl -I
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR} |
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_config.pl
|
||||||
|
DEPENDS src/Configfile.cpp.in src/Configfile.h.in src/Configfile.tmpl
|
||||||
|
docs/hermes-options.html.in scripts/generate_config.pl)
|
||||||
|
|
||||||
|
|
||||||
|
# doxygen
|
||||||
|
find_package (Doxygen REQUIRED dot)
|
||||||
|
if(DOXYGEN_FOUND)
|
||||||
|
add_custom_target(doc ALL
|
||||||
|
doxygen
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/docs)
|
||||||
|
install(
|
||||||
|
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/docs/html
|
||||||
|
DESTINATION usr/share/doc/hermes/html)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_link_libraries(hermes
|
||||||
|
${SQLITE3_LIBRARY}
|
||||||
|
${OPENSSL_LIBRARIES}
|
||||||
|
${SPF2_LIBRARY}
|
||||||
|
pthread)
|
||||||
|
|
||||||
|
install(TARGETS hermes
|
||||||
|
RUNTIME DESTINATION bin)
|
||||||
|
|
||||||
|
install(FILES dists/hermesrc.example
|
||||||
|
DESTINATION etc)
|
||||||
|
|
||||||
|
install(FILES
|
||||||
|
dists/hermesrc.example
|
||||||
|
docs/gpl.txt
|
||||||
|
docs/installing-hermes.txt
|
||||||
|
docs/hermes-options.html
|
||||||
|
DESTINATION usr/share/doc/hermes)
|
|
@ -1,3 +0,0 @@
|
||||||
EXTRA_DIST = scripts/generate_config.pl ChangeLog TODO
|
|
||||||
|
|
||||||
SUBDIRS = src docs dists
|
|
|
@ -1,3 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
aclocal && autoconf && autoheader && automake --add-missing
|
|
134
configure.in
134
configure.in
|
@ -1,134 +0,0 @@
|
||||||
dnl Process this file with autoconf to produce a configure script.
|
|
||||||
|
|
||||||
AC_PREREQ(2.57)
|
|
||||||
|
|
||||||
AC_INIT([hermes], [1.9], [juanjo@gutierrezdequevedo.com])
|
|
||||||
|
|
||||||
dnl AC_CONFIG_AUX_DIR=([./config])
|
|
||||||
|
|
||||||
AM_CONFIG_HEADER([config.h])
|
|
||||||
|
|
||||||
AM_INIT_AUTOMAKE([1.7.8 foreign])
|
|
||||||
|
|
||||||
AC_PROG_CXX
|
|
||||||
AC_PROG_INSTALL
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl check libraries and functions
|
|
||||||
dnl
|
|
||||||
|
|
||||||
AC_CHECK_FUNCS(getaddrinfo gai_strerror)
|
|
||||||
PKG_CHECK_MODULES(SQLite3, sqlite3, [], AC_MSG_ERROR("sqlite3 is required"))
|
|
||||||
PKG_CHECK_MODULES(OpenSSL, openssl, have_ssl=yes, have_ssl=no)
|
|
||||||
AC_CHECK_LIB(spf2,SPF_server_new, have_spf=yes, have_spf=no)
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl end of libraries and functions
|
|
||||||
dnl
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl check parameters
|
|
||||||
dnl
|
|
||||||
|
|
||||||
AC_ARG_WITH(logger-module,
|
|
||||||
[ --with-logger-module=module Module to log errors with. module is one of unix, file or null. default=unix],
|
|
||||||
[loggermodule=$withval],
|
|
||||||
[loggermodule=unix]
|
|
||||||
)
|
|
||||||
|
|
||||||
if test "$loggermodule" = unix; then
|
|
||||||
AC_DEFINE(LOGGER_CLASS,UnixLogger)
|
|
||||||
fi
|
|
||||||
if test "$loggermodule" = file; then
|
|
||||||
AC_DEFINE(LOGGER_CLASS,FileLogger)
|
|
||||||
fi
|
|
||||||
if test "$loggermodule" = null; then
|
|
||||||
AC_DEFINE(LOGGER_CLASS,NullLogger,[Define what logger we are using])
|
|
||||||
fi
|
|
||||||
|
|
||||||
AC_ARG_ENABLE(openssl,
|
|
||||||
[ --enable-openssl Enable OpenSSL support ],
|
|
||||||
[
|
|
||||||
if test x$enableval = xyes; then
|
|
||||||
if test x$have_ssl = xno; then
|
|
||||||
AC_MSG_ERROR("OpenSSL support requested but not detected")
|
|
||||||
fi
|
|
||||||
have_ssl=yes
|
|
||||||
else
|
|
||||||
have_ssl=no
|
|
||||||
fi
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
AC_ARG_ENABLE(spf,
|
|
||||||
[ --enable-spf Enable SPF support ],
|
|
||||||
[
|
|
||||||
if test x$enableval = xyes; then
|
|
||||||
if test x$have_spf = xno; then
|
|
||||||
AC_MSG_ERROR("SPF support requested but not detected")
|
|
||||||
fi
|
|
||||||
have_spf=yes
|
|
||||||
else
|
|
||||||
have_spf=no
|
|
||||||
fi
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
win32_service=no
|
|
||||||
AC_ARG_ENABLE(win32-service,
|
|
||||||
[ --enable-win32-service Enable win32 service support ],
|
|
||||||
[
|
|
||||||
if test x$enableval = xyes; then
|
|
||||||
win32_service=yes
|
|
||||||
fi
|
|
||||||
]
|
|
||||||
)
|
|
||||||
dnl
|
|
||||||
dnl end of parameters check
|
|
||||||
dnl
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl config.h variables
|
|
||||||
dnl
|
|
||||||
|
|
||||||
if test x$have_ssl = xyes; then
|
|
||||||
AC_DEFINE(HAVE_SSL,1,[Defined if using openssl for SSL support])
|
|
||||||
fi
|
|
||||||
if test x$have_spf = xyes; then
|
|
||||||
AC_DEFINE(HAVE_SPF,1,[Defined if system has libspf2])
|
|
||||||
fi
|
|
||||||
if test x$win32_service = xyes; then
|
|
||||||
AC_DEFINE(WIN32_SERVICE,1,[Defined if we want to compile win32 service support])
|
|
||||||
fi
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl end of config.h variables
|
|
||||||
dnl
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl conditionals for makefiles
|
|
||||||
dnl
|
|
||||||
|
|
||||||
AM_CONDITIONAL(HAVE_SPF, test "$have_spf" = yes)
|
|
||||||
AM_CONDITIONAL(LOGGER_UNIX, test "$loggermodule" = unix)
|
|
||||||
AM_CONDITIONAL(LOGGER_NULL, test "$loggermodule" = null)
|
|
||||||
AM_CONDITIONAL(LOGGER_FILE, test "$loggermodule" = file)
|
|
||||||
AM_CONDITIONAL(WIN32_SERVICE, test "$win32_service" = yes)
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl end of conditionals for makefiles
|
|
||||||
dnl
|
|
||||||
|
|
||||||
|
|
||||||
AC_CONFIG_FILES([Makefile src/Makefile docs/Makefile dists/Makefile dists/hermes.spec])
|
|
||||||
AC_OUTPUT
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo
|
|
||||||
echo "Configuration for $PACKAGE_STRING"
|
|
||||||
echo
|
|
||||||
echo " SSL: $have_ssl"
|
|
||||||
echo " SPF: $have_spf"
|
|
||||||
echo " Logger: $loggermodule"
|
|
||||||
echo " Win32: $win32_service"
|
|
||||||
echo
|
|
|
@ -1,2 +0,0 @@
|
||||||
doc_DATA = hermesrc.example
|
|
||||||
EXTRA_DIST = fc_init hermes.spec hermes.spec.in
|
|
2682
docs/Doxyfile
2682
docs/Doxyfile
File diff suppressed because it is too large
Load diff
|
@ -1,6 +0,0 @@
|
||||||
EXTRA_DIST = Doxyfile gpl.txt installing-hermes.txt hermes-options.html hermes-options.html.in
|
|
||||||
|
|
||||||
doc_DATA = gpl.txt installing-hermes.txt hermes-options.html hermes-options.html.in
|
|
||||||
|
|
||||||
docs:
|
|
||||||
doxygen
|
|
|
@ -74,7 +74,7 @@ chomp $hvar1;
|
||||||
chomp $hvar2;
|
chomp $hvar2;
|
||||||
chomp $conf_example;
|
chomp $conf_example;
|
||||||
|
|
||||||
open CPPIN, "<Configfile.cpp.in";
|
open CPPIN, "<../src/Configfile.cpp.in";
|
||||||
$cppstr=join("",<CPPIN>);
|
$cppstr=join("",<CPPIN>);
|
||||||
close CPPIN;
|
close CPPIN;
|
||||||
open CPPOUT, ">Configfile.cpp";
|
open CPPOUT, ">Configfile.cpp";
|
||||||
|
@ -84,7 +84,7 @@ $cppstr =~ s/%templ_getmethods%/$cppvar3/;
|
||||||
print CPPOUT $cppstr;
|
print CPPOUT $cppstr;
|
||||||
close CPPOUT;
|
close CPPOUT;
|
||||||
|
|
||||||
open HIN, "<Configfile.h.in";
|
open HIN, "<../src/Configfile.h.in";
|
||||||
$hstr=join("",<HIN>);
|
$hstr=join("",<HIN>);
|
||||||
close HIN;
|
close HIN;
|
||||||
open HOUT, ">Configfile.h";
|
open HOUT, ">Configfile.h";
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#include "../config.h"
|
|
||||||
|
|
||||||
* comments MUST begin with a #.
|
* comments MUST begin with a #.
|
||||||
*
|
*
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
*/
|
*/
|
||||||
#include "FileLogger.h"
|
#include "FileLogger.h"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
extern Configfile cfg;
|
extern Configfile cfg;
|
||||||
extern __thread unsigned long connection_id;
|
extern __thread unsigned long connection_id;
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
#ifndef FILELOGGER_H
|
#ifndef FILELOGGER_H
|
||||||
#define FILELOGGER_H
|
#define FILELOGGER_H
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
INCLUDES = $(OpenSSL_CFLAGS) $(SQLite3_CFLAGS)
|
|
||||||
LIBS = $(OpenSSL_LIBS) $(SQLite3_LIBS)
|
|
||||||
CXXFLAGS += -Wall -pedantic -Wshadow -pthread -Werror --std=c++11
|
|
||||||
|
|
||||||
bin_PROGRAMS = hermes
|
|
||||||
nodist_hermes_SOURCES = Configfile.cpp
|
|
||||||
hermes_SOURCES = Proxy.cpp ServerSocket.cpp Socket.cpp Database.cpp Utils.cpp Exception.cpp hermes.cpp
|
|
||||||
noinst_HEADERS = Proxy.h ServerSocket.h Socket.h Database.h UnixLogger.cpp FileLogger.h NullLogger.h Logger.h Utils.h Exception.h hermes.h Spf.h
|
|
||||||
EXTRA_DIST = Configfile.cpp.in Configfile.h.in Configfile.tmpl UnixLogger.cpp UnixLogger.h FileLogger.cpp FileLogger.h
|
|
||||||
|
|
||||||
if LOGGER_UNIX
|
|
||||||
hermes_SOURCES += UnixLogger.cpp
|
|
||||||
endif
|
|
||||||
|
|
||||||
if LOGGER_FILE
|
|
||||||
hermes_SOURCES += FileLogger.cpp
|
|
||||||
endif
|
|
||||||
|
|
||||||
if HAVE_SPF
|
|
||||||
hermes_SOURCES += Spf.cpp
|
|
||||||
LIBS += -lspf2
|
|
||||||
endif
|
|
||||||
|
|
||||||
if WIN32_SERVICE
|
|
||||||
hermes_SOURCES += win32-service.cpp
|
|
||||||
endif
|
|
||||||
|
|
||||||
Configfile.h: Configfile.cpp.in Configfile.h.in Configfile.tmpl ../docs/hermes-options.html.in ../scripts/generate_config.pl ../config.h
|
|
||||||
cpp Configfile.tmpl|../scripts/generate_config.pl
|
|
||||||
|
|
||||||
Configfile.cpp: Configfile.h Configfile.cpp.in Configfile.h.in Configfile.tmpl ../docs/hermes-options.html.in ../scripts/generate_config.pl ../config.h
|
|
||||||
|
|
||||||
*.cpp: Configfile.h
|
|
|
@ -20,7 +20,6 @@
|
||||||
#ifndef SERVERSOCKET_H
|
#ifndef SERVERSOCKET_H
|
||||||
#define SERVERSOCKET_H
|
#define SERVERSOCKET_H
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
*
|
*
|
||||||
* @author Juan José Gutiérrez de Quevedo <juanjo@gutierrezdequevedo.com>
|
* @author Juan José Gutiérrez de Quevedo <juanjo@gutierrezdequevedo.com>
|
||||||
*/
|
*/
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
#ifndef SMTPPROXY_H
|
#ifndef SMTPPROXY_H
|
||||||
#define SMTPPROXY_H
|
#define SMTPPROXY_H
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
#include "Exception.h"
|
#include "Exception.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
Loading…
Add table
Reference in a new issue