Commit 0ab40dc1 authored by louiz’'s avatar louiz’

Refactoring louloulibs and cmake

Use OBJECT libraries
Remove the louloulibs directory
Write FOUND variables in the cache
parent 2d380615
......@@ -31,7 +31,7 @@ variables:
script:
- "echo Running cmake with the following parameters: -DCMAKE_CXX_COMPILER=${COMPILER} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} ${BOTAN} ${UDNS} ${SYSTEMD} ${LIBIDN} ${LITESQL}"
- cmake .. -DCMAKE_CXX_COMPILER=${COMPILER} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} ${BOTAN} ${UDNS} ${SYSTEMD} ${LIBIDN} ${LITESQL}
- make biboumi -j$(nproc || echo 1)
- make -j$(nproc || echo 1)
- make coverage_check -j$(nproc || echo 1)
artifacts:
expire_in: 8 hours
......@@ -140,7 +140,7 @@ test:freebsd:
stage: test
script:
- cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} ${BOTAN} ${UDNS} ${SYSTEMD} ${LIBIDN} ${LITESQL}
- make biboumi
- make
- make check
- make e2e
......@@ -226,7 +226,7 @@ coverity:
script:
- export PATH=$PATH:~/coverity/bin
- cmake .. -DWITHOUT_SYSTEMD=1
- cov-build --dir cov-int make biboumi test_suite -j$(nproc || echo 1)
- cov-build --dir cov-int make -j$(nproc || echo 1)
- tar czvf biboumi_coverity.tgz cov-int
- curl --form token=$COVERITY_TOKEN --form email=louiz@louiz.org --form file=@biboumi_coverity.tgz --form version="$(git rev-parse --short HEAD)" --form description="Automatic submission by gitlab-ci" https://scan.coverity.com/builds?project=louiz%2Fbiboumi
......
This diff is collapsed.
#cmakedefine USE_DATABASE
#cmakedefine ICONV_SECOND_ARGUMENT_IS_CONST
#cmakedefine LIBIDN_FOUND
#cmakedefine SYSTEMD_FOUND
#cmakedefine POLLER ${POLLER}
#cmakedefine BOTAN_FOUND
#cmakedefine GCRYPT_FOUND
#cmakedefine UDNS_FOUND
#cmakedefine SOFTWARE_VERSION "${SOFTWARE_VERSION}"
#cmakedefine PROJECT_NAME "${PROJECT_NAME}"
#cmakedefine HAS_GET_TIME
#cmakedefine HAS_PUT_TIME
......@@ -16,10 +16,9 @@
# This file is in the public domain
include(FindPkgConfig)
pkg_check_modules(BOTAN botan-2)
if(NOT BOTAN_FOUND)
pkg_check_modules(BOTAN botan-1.11)
endif()
pkg_check_modules(BOTAN botan-1.11)
if(NOT BOTAN_FOUND)
find_path(BOTAN_INCLUDE_DIRS NAMES botan/botan.h
......@@ -35,9 +34,9 @@ if(NOT BOTAN_FOUND)
find_package_handle_standard_args(BOTAN REQUIRED_VARS BOTAN_LIBRARIES BOTAN_INCLUDE_DIRS)
if(BOTAN_FOUND)
set(BOTAN_LIBRARY ${BOTAN_LIBRARIES} PARENT_SCOPE)
set(BOTAN_INCLUDE_DIR ${BOTAN_INCLUDE_DIRS} PARENT_SCOPE)
set(BOTAN_FOUND ${BOTAN_FOUND} PARENT_SCOPE)
set(BOTAN_LIBRARY ${BOTAN_LIBRARIES} CACHE INTERNAL "")
set(BOTAN_INCLUDE_DIR ${BOTAN_INCLUDE_DIRS} CACHE INTERNAL "")
set(BOTAN_FOUND ${BOTAN_FOUND} CACHE INTERNAL "")
endif()
endif()
......
......@@ -32,9 +32,9 @@ if(NOT GCRYPT_FOUND)
find_package_handle_standard_args(GCRYPT REQUIRED_VARS GCRYPT_LIBRARIES GCRYPT_INCLUDE_DIRS)
if(GCRYPT_FOUND)
set(GCRYPT_LIBRARY ${GCRYPT_LIBRARIES} PARENT_SCOPE)
set(GCRYPT_INCLUDE_DIR ${GCRYPT_INCLUDE_DIRS} PARENT_SCOPE)
set(GCRYPT_FOUND ${GCRYPT_FOUND} PARENT_SCOPE)
set(GCRYPT_LIBRARY ${GCRYPT_LIBRARIES} CACHE INTERNAL "")
set(GCRYPT_INCLUDE_DIR ${GCRYPT_INCLUDE_DIRS} CACHE INTERNAL "")
set(GCRYPT_FOUND ${GCRYPT_FOUND} CACHE INTERNAL "")
endif()
endif()
......
......@@ -53,9 +53,8 @@ if(ICONV_FOUND)
ICONV_SECOND_ARGUMENT_IS_CONST)
# Compatibility for all the ways of writing these variables
set(ICONV_LIBRARY ${ICONV_LIBRARIES} PARENT_SCOPE)
set(ICONV_INCLUDE_DIR ${ICONV_INCLUDE_DIRS} PARENT_SCOPE)
set(ICONV_FOUND ${ICONV_FOUND} PARENT_SCOPE)
set(ICONV_LIBRARY ${ICONV_LIBRARIES})
set(ICONV_INCLUDE_DIR ${ICONV_INCLUDE_DIRS})
endif()
mark_as_advanced(ICONV_INCLUDE_DIRS ICONV_LIBRARIES ICONV_SECOND_ARGUMENT_IS_CONST)
......@@ -33,9 +33,9 @@ if(NOT LIBIDN_FOUND)
# Compatibility for all the ways of writing these variables
if(LIBIDN_FOUND)
set(LIBIDN_INCLUDE_DIR ${LIBIDN_INCLUDE_DIRS} PARENT_SCOPE)
set(LIBIDN_LIBRARY ${LIBIDN_LIBRARIES} PARENT_SCOPE)
set(LIBIDN_FOUND ${LIBIDN_FOUND} PARENT_SCOPE)
set(LIBIDN_INCLUDE_DIR ${LIBIDN_INCLUDE_DIRS} CACHE INTERNAL "")
set(LIBIDN_LIBRARY ${LIBIDN_LIBRARIES} CACHE INTERNAL "")
set(LIBIDN_FOUN ${LIBIDN_FOUND} CACHE INTERNAL "")
endif()
endif()
......
......@@ -33,9 +33,9 @@ if(NOT LIBUUID_FOUND)
# Compatibility for all the ways of writing these variables
if(LIBUUID_FOUND)
set(LIBUUID_INCLUDE_DIR ${LIBUUID_INCLUDE_DIRS} PARENT_SCOPE)
set(LIBUUID_LIBRARY ${LIBUUID_LIBRARIES} PARENT_SCOPE)
set(LIBUUID_FOUND ${LIBUUID_FOUND} PARENT_SCOPE)
set(LIBUUID_INCLUDE_DIR ${LIBUUID_INCLUDE_DIRS} CACHE INTERNAL "")
set(LIBUUID_LIBRARY ${LIBUUID_LIBRARIES} CACHE INTERNAL "")
set(LIBUUID_FOUND ${LIBUUID_FOUND} CACHE INTERNAL "")
endif()
endif()
......
......@@ -64,7 +64,7 @@ function(LITESQL_GENERATE_CPP
set(${OUTPUT_SOURCES})
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_NAME}.cpp"
"${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_NAME}.hpp"
"${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_NAME}.hpp"
COMMAND ${LITESQLGEN_EXECUTABLE}
ARGS -t c++ --output-dir=${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE_FILE}
DEPENDS ${SOURCE_FILE}
......
......@@ -31,9 +31,9 @@ if(NOT SYSTEMD_FOUND)
find_package_handle_standard_args(SYSTEMD REQUIRED_VARS SYSTEMD_LIBRARIES SYSTEMD_INCLUDE_DIRS)
if(SYSTEMD_FOUND)
set(SYSTEMD_LIBRARY ${SYSTEMD_LIBRARIES} PARENT_SCOPE)
set(SYSTEMD_INCLUDE_DIR ${SYSTEMD_INCLUDE_DIRS} PARENT_SCOPE)
set(SYSTEMD_FOUND ${SYSTEMD_FOUND} PARENT_SCOPE)
set(SYSTEMD_LIBRARY ${SYSTEMD_LIBRARIES} CACHE INTERNAL "")
set(SYSTEMD_INCLUDE_DIR ${SYSTEMD_INCLUDE_DIRS} CACHE INTERNAL "")
set(SYSTEMD_FOUND ${SYSTEMD_FOUND} CACHE INTERNAL "")
endif()
endif()
......
......@@ -29,9 +29,9 @@ if(NOT UDNS_FOUND)
# Compatibility for all the ways of writing these variables
if(UDNS_FOUND)
set(UDNS_INCLUDE_DIR ${UDNS_INCLUDE_DIRS} PARENT_SCOPE)
set(UDNS_LIBRARY ${UDNS_LIBRARIES} PARENT_SCOPE)
set(UDNS_FOUND ${UDNS_FOUND} PARENT_SCOPE)
set(UDNS_INCLUDE_DIR ${UDNS_INCLUDE_DIRS} CACHE INTERNAL "")
set(UDNS_LIBRARY ${UDNS_LIBRARIES} CACHE INTERNAL "")
set(UDNS_FOUND ${UDNS_FOUND} CACHE INTERNAL "")
endif()
endif()
......
cmake_minimum_required(VERSION 3.0)
set(${PROJECT_NAME}_VERSION_MAJOR 1)
set(${PROJECT_NAME}_VERSION_MINOR 0)
set(${PROJECT_NAME}_VERSION_SUFFIX "~dev")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -pedantic -Wall -Wextra")
#
## Look for external libraries
#
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
find_package(ICONV REQUIRED)
find_package(LIBUUID REQUIRED)
find_package(EXPAT REQUIRED)
set(EXPAT_FOUND ${EXPAT_FOUND} PARENT_SCOPE)
if(WITH_LIBIDN)
find_package(LIBIDN REQUIRED)
elseif(NOT WITHOUT_LIBIDN)
find_package(LIBIDN)
endif()
if(WITH_SYSTEMD)
find_package(SYSTEMD REQUIRED)
elseif(NOT WITHOUT_SYSTEMD)
find_package(SYSTEMD)
endif()
if(WITH_BOTAN)
find_package(BOTAN REQUIRED)
elseif(NOT WITHOUT_BOTAN)
find_package(BOTAN)
endif()
if(NOT BOTAN_FOUND)
find_package(GCRYPT REQUIRED)
endif()
if(WITH_UDNS)
find_package(UDNS REQUIRED)
elseif(NOT WITHOUT_UDNS)
find_package(UDNS)
endif()
# To be able to include the config.h file generated by cmake
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${EXPAT_INCLUDE_DIRS})
include_directories(${ICONV_INCLUDE_DIRS})
include_directories(${LIBUUID_INCLUDE_DIRS})
set(POLLER_DOCSTRING "Choose the poller between POLL and EPOLL (Linux-only)")
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(POLLER "EPOLL" CACHE STRING ${POLLER_DOCSTRING})
else()
set(POLLER "POLL" CACHE STRING ${POLLER_DOCSTRING})
endif()
if((NOT ${POLLER} MATCHES "POLL") AND
(NOT ${POLLER} MATCHES "EPOLL"))
message(FATAL_ERROR "POLLER must be either POLL or EPOLL")
endif()
#
## utils
#
file(GLOB source_utils
utils/*.[hc]pp)
set(source_utils ${source_utils} PARENT_SCOPE)
#
## config
#
file(GLOB source_config
config/*.[hc]pp)
set(source_config ${source_config} PARENT_SCOPE)
#
## logger
#
file(GLOB source_logger
logger/*.[hc]pp)
set(source_logger ${source_logger} PARENT_SCOPE)
#
## network
#
file(GLOB source_network
network/*.[hc]pp)
set(source_network ${source_network} PARENT_SCOPE)
#
## xmpplib
#
file(GLOB source_xmpplib
xmpp/*.[hc]pp)
set(source_xmpplib ${source_xmpplib} PARENT_SCOPE)
# Define a __FILENAME__ macro with the relative path (from the base project directory)
# of each source file
file(GLOB_RECURSE source_all *.[hc]pp)
foreach(file ${source_all})
file(RELATIVE_PATH shorter_file ${CMAKE_CURRENT_SOURCE_DIR} ${file})
set_property(SOURCE ${file} APPEND PROPERTY COMPILE_DEFINITIONS __FILENAME__="${shorter_file}")
endforeach()
#
## Check if we have std::get_time
#
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("
#include <iomanip>
int main()
{ std::get_time(nullptr, \"\"); }"
HAS_GET_TIME)
mark_as_advanced(HAS_GET_TIME)
check_cxx_source_compiles("
#include <iomanip>
int main()
{ std::put_time(nullptr, \"\"); }"
HAS_PUT_TIME)
mark_as_advanced(HAS_PUT_TIME)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/louloulibs.h.cmake ${CMAKE_BINARY_DIR}/src/louloulibs.h)
#cmakedefine ICONV_SECOND_ARGUMENT_IS_CONST
#cmakedefine LIBIDN_FOUND
#cmakedefine SYSTEMD_FOUND
#cmakedefine POLLER ${POLLER}
#cmakedefine BOTAN_FOUND
#cmakedefine GCRYPT_FOUND
#cmakedefine UDNS_FOUND
#cmakedefine SOFTWARE_VERSION "${SOFTWARE_VERSION}"
#cmakedefine PROJECT_NAME "${PROJECT_NAME}"
#cmakedefine HAS_GET_TIME
#cmakedefine HAS_PUT_TIME
......@@ -21,7 +21,6 @@
#include <string>
#include "biboumi.h"
#include "louloulibs.h"
using namespace std::string_literals;
using namespace std::chrono_literals;
......
......@@ -17,7 +17,7 @@
#define warning_lvl 2
#define error_lvl 3
#include "louloulibs.h"
#include "biboumi.h"
#ifdef SYSTEMD_FOUND
# include <systemd/sd-daemon.h>
#else
......
#include "louloulibs.h"
#include "biboumi.h"
#ifdef BOTAN_FOUND
#include <network/tcp_socket_handler.hpp>
......
#pragma once
#include "louloulibs.h"
#include "biboumi.h"
#ifdef BOTAN_FOUND
......
#include <louloulibs.h>
#include <biboumi.h>
#ifdef UDNS_FOUND
#include <network/dns_socket_handler.hpp>
......
#pragma once
#include <louloulibs.h>
#include <biboumi.h>
#ifdef UDNS_FOUND
class Poller;
......
#include <louloulibs.h>
#include <biboumi.h>
#ifdef UDNS_FOUND
#include <network/dns_socket_handler.hpp>
......
#pragma once
#include <louloulibs.h>
#include <biboumi.h>
#ifdef UDNS_FOUND
#include <network/socket_handler.hpp>
......
......@@ -10,7 +10,7 @@
#define POLL 1
#define EPOLL 2
#define KQUEUE 3
#include <louloulibs.h>
#include <biboumi.h>
#ifndef POLLER
#define POLLER POLL
#endif
......
#pragma once
#include "louloulibs.h"
#include "biboumi.h"
#include <functional>
#include <vector>
......
#pragma once
#include <louloulibs.h>
#include <biboumi.h>
#include <memory>
class Poller;
......
#pragma once
#include "louloulibs.h"
#include "biboumi.h"
#include <network/socket_handler.hpp>
#include <network/resolver.hpp>
......
#include <utils/sha1.hpp>
#include <louloulibs.h>
#include <biboumi.h>
#ifdef BOTAN_FOUND
# include <botan/hash.h>
......
......@@ -5,7 +5,7 @@
#include <iomanip>
#include <locale>
#include "louloulibs.h"
#include "biboumi.h"
namespace utils
{
......
#include <utils/xdg.hpp>
#include <cstdlib>
#include "louloulibs.h"
#include "biboumi.h"
std::string xdg_path(const std::string& filename, const char* env_var)
{
......
......@@ -16,7 +16,6 @@
#include <cstdlib>
#include <louloulibs.h>
#include <biboumi.h>
#include <uuid/uuid.h>
......
......@@ -3,7 +3,7 @@
#include <cstring>
#include <map>
#include <louloulibs.h>
#include <biboumi.h>
#ifdef LIBIDN_FOUND
#include <stringprep.h>
#include <sys/types.h>
......
......@@ -19,7 +19,7 @@
#include <cstdlib>
#include <set>
#include <louloulibs.h>
#include <biboumi.h>
#ifdef SYSTEMD_FOUND
# include <systemd/sd-daemon.h>
#endif
......
#include "catch.hpp"
#include <xmpp/jid.hpp>
#include <louloulibs.h>
#include <biboumi.h>
TEST_CASE("Jid")
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment