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
......
......@@ -6,34 +6,28 @@ set(${PROJECT_NAME}_VERSION_MAJOR 5)
set(${PROJECT_NAME}_VERSION_MINOR 0)
set(${PROJECT_NAME}_VERSION_SUFFIX "~dev")
#
## Find optional instrumentation libraries that will be used in debug only
#
find_library(LIBASAN NAMES asan libasan.so.3 libasan.so.2 libasan.so.1)
find_library(LIBUBSAN NAMES ubsan libubsan.so.0)
#
## Set various debug flags (instrumentation libs, coverage, …)
#
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -pedantic -Wall -Wextra")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage --coverage")
endif()
if(LIBASAN)
message(STATUS "Libasan found.")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address")
else()
message(STATUS "Libasan NOT found.")
endif()
if(LIBUBSAN)
message(STATUS "Libubsan found.")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=undefined")
else()
message(STATUS "Libubsan NOT found.")
endif()
#
## Look for external libraries
#
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
#
## Get the software version
## Set the software version, archive name, RPM name etc
#
set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR})
set(RPM_VERSION ${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR})
......@@ -62,16 +56,8 @@ endif()
set(SOFTWARE_VERSION
${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}${${PROJECT_NAME}_VERSION_SUFFIX})
include(CheckFunctionExists)
check_function_exists(ppoll HAVE_PPOLL_FUNCTION)
# To be able to include the config.h and other files generated by cmake
include_directories("${CMAKE_CURRENT_BINARY_DIR}/src/")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src/")
include_directories("${CMAKE_CURRENT_BINARY_DIR}/")
#
## Documentation
## The rule that generates the documentation
#
execute_process(COMMAND "date" "+%Y-%m-%d" OUTPUT_VARIABLE DOC_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE)
......@@ -94,28 +80,57 @@ if (NOT PANDOC_EXECUTABLE)
endif()
mark_as_advanced(PANDOC_EXECUTABLE)
# Look for litesql and enable the database if found
if(WITH_LITESQL)
find_package(LITESQL REQUIRED)
elseif(NOT WITHOUT_LITESQL)
find_package(LITESQL)
#
## Set this search path for cmake, to find our custom search modules
#
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)
#
## Find all the libraries (optional or not)
#
if(WITH_LIBIDN)
find_package(LIBIDN REQUIRED)
elseif(NOT WITHOUT_LIBIDN)
find_package(LIBIDN)
endif()
if(LITESQL_FOUND)
LITESQL_GENERATE_CPP("database/database.xml"
"biboudb"
LITESQL_GENERATED_SOURCES)
if(WITH_SYSTEMD)
find_package(SYSTEMD REQUIRED)
elseif(NOT WITHOUT_SYSTEMD)
find_package(SYSTEMD)
endif()
set(source_database src/database/database.cpp ${LITESQL_GENERATED_SOURCES})
set(USE_DATABASE TRUE)
else()
set(source_database)
if(WITH_BOTAN)
find_package(BOTAN REQUIRED)
elseif(NOT WITHOUT_BOTAN)
find_package(BOTAN)
endif()
add_subdirectory("louloulibs")
include_directories("louloulibs")
if(NOT BOTAN_FOUND)
find_package(GCRYPT REQUIRED)
endif()
# If they are found in louloulibs CMakeLists.txt, we inherite these values
if(WITH_UDNS)
find_package(UDNS REQUIRED)
elseif(NOT WITHOUT_UDNS)
find_package(UDNS)
endif()
if(WITH_LITESQL)
find_package(LITESQL REQUIRED)
elseif(NOT WITHOUT_LITESQL)
find_package(LITESQL)
endif()
#
## Set all the include directories, depending on what libraries are used
#
include_directories(${EXPAT_INCLUDE_DIRS})
include_directories(${ICONV_INCLUDE_DIRS})
include_directories(${LIBUUID_INCLUDE_DIRS})
if(SYSTEMD_FOUND)
include_directories(${SYSTEMD_INCLUDE_DIRS})
endif()
......@@ -126,70 +141,92 @@ if(UDNS_FOUND)
include_directories(${UDNS_INCLUDE_DIRS})
endif()
#
## utils
#
file(GLOB source_src_utils
src/utils/*.[hc]pp)
# To be able to include the config.h and other files generated by cmake
include_directories("${CMAKE_CURRENT_BINARY_DIR}/src/")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src/")
include_directories("${CMAKE_CURRENT_BINARY_DIR}/")
#
## irclib
## Define all the modules
#
file(GLOB source_utils
src/utils/*.[hc]pp)
add_library(utils OBJECT ${source_utils})
file(GLOB source_irc
src/irc/*.[hc]pp)
src/irc/*.[hc]pp)
add_library(irc OBJECT ${source_irc})
#
## xmpp
#
file(GLOB source_xmpp
src/xmpp/*.[hc]pp)
src/xmpp/*.[hc]pp)
add_library(xmpp OBJECT ${source_xmpp})
#
## identd
#
file(GLOB source_identd
src/identd/*.[hc]pp)
src/identd/*.[hc]pp)
add_library(identd OBJECT ${source_identd})
#
## bridge
#
file(GLOB source_bridge
src/bridge/*.[hc]pp)
src/bridge/*.[hc]pp)
add_library(bridge OBJECT ${source_bridge})
#
## Main executable
#
add_executable(${PROJECT_NAME} src/main.cpp
${source_utils}
${source_config}
${source_logger}
${source_network}
${source_xmpplib}
${source_xmpp}
${source_src_utils}
${source_bridge}
${source_irc}
${source_identd}
${source_database})
file(GLOB source_config
src/config/*.[hc]pp)
add_library(config OBJECT ${source_config})
file(GLOB source_logger
src/logger/*.[hc]pp)
add_library(logger OBJECT ${source_logger})
file(GLOB source_network
src/network/*.[hc]pp)
add_library(network OBJECT ${source_network})
if(LITESQL_FOUND)
LITESQL_GENERATE_CPP("database/database.xml"
"biboudb"
LITESQL_GENERATED_SOURCES)
add_library(database OBJECT src/database/database.cpp
${LITESQL_GENERATED_SOURCES})
set(USE_DATABASE TRUE)
else()
add_library(database OBJECT "")
endif()
#
## Tests
## Define the executables
#
## main
add_executable(${PROJECT_NAME} src/main.cpp
$<TARGET_OBJECTS:utils>
$<TARGET_OBJECTS:config>
$<TARGET_OBJECTS:logger>
$<TARGET_OBJECTS:network>
$<TARGET_OBJECTS:xmpp>
$<TARGET_OBJECTS:bridge>
$<TARGET_OBJECTS:irc>
$<TARGET_OBJECTS:identd>
$<TARGET_OBJECTS:database>)
## test_suite
file(GLOB source_tests
tests/*.cpp)
add_executable(test_suite EXCLUDE_FROM_ALL ${source_tests}
${source_utils}
${source_config}
${source_logger}
${source_network}
${source_xmpplib}
${source_xmpp}
${source_src_utils}
${source_bridge}
${source_irc}
${source_identd}
${source_database})
add_executable(test_suite ${source_tests}
$<TARGET_OBJECTS:utils>
$<TARGET_OBJECTS:config>
$<TARGET_OBJECTS:logger>
$<TARGET_OBJECTS:network>
$<TARGET_OBJECTS:xmpp>
$<TARGET_OBJECTS:bridge>
$<TARGET_OBJECTS:irc>
$<TARGET_OBJECTS:identd>
$<TARGET_OBJECTS:database>)
#
## Link the executables with their libraries
#
target_link_libraries(${PROJECT_NAME}
${ICONV_LIBRARIES}
${LIBUUID_LIBRARIES}
......@@ -230,6 +267,9 @@ foreach(file ${source_all})
set_property(SOURCE ${file} APPEND PROPERTY COMPILE_DEFINITIONS __FILENAME__="${shorter_file}")
endforeach()
#
## Add a rule to download the catch unit test framework
#
include(ExternalProject)
ExternalProject_Add(catch
GIT_REPOSITORY "https://lab.louiz.org/louiz/Catch.git"
......@@ -247,17 +287,16 @@ if(NOT EXISTS ${CMAKE_SOURCE_DIR}/tests/catch.hpp)
)
add_dependencies(test_suite catch)
endif()
#
## Add some custom rules to launch the tests
#
add_custom_target(check COMMAND "test_suite"
DEPENDS test_suite biboumi)
add_custom_target(e2e COMMAND "python3" "${CMAKE_CURRENT_SOURCE_DIR}/tests/end_to_end/"
DEPENDS biboumi)
add_custom_target(e2e_valgrind COMMAND "E2E_BIBOUMI_SUPP_DIR=${CMAKE_CURRENT_SOURCE_DIR}/tests/end_to_end/" "E2E_BIBOUMI_VALGRIND=1" "python3" "${CMAKE_CURRENT_SOURCE_DIR}/tests/end_to_end/"
DEPENDS biboumi)
#
## Code coverage
#
if(CMAKE_BUILD_TYPE MATCHES Debug)
include(CodeCoverage)
SETUP_TARGET_FOR_COVERAGE(coverage_check
......@@ -278,7 +317,6 @@ if(CMAKE_BUILD_TYPE MATCHES Debug)
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
endif()
#
......@@ -315,8 +353,9 @@ add_custom_target(rpm
COMMAND rpmbuild --define "_topdir `pwd`/rpmbuild/" --define "_sourcedir `pwd`" -ba biboumi.spec
)
configure_file(biboumi.h.cmake src/biboumi.h)
#
## Set some variables that will be used in the cmake-generated files
#
set(SYSTEMD_SERVICE_TYPE_DOCSTRING "The value used as the Type= in the systemd unit file.")
set(WATCHDOG_SEC_DOCSTRING "The value used as WatchdogSec= in the systemd unit file.")
if(SYSTEMD_FOUND)
......@@ -334,7 +373,6 @@ set(SERVICE_GROUP_DOCSTRING "The value used as the Group= in the systemd unit fi
if(NOT DEFINED SERVICE_GROUP)
set(SERVICE_GROUP "nobody" CACHE STRING ${SERVICE_GROUP_DOCSTRING})
endif()
configure_file(unit/biboumi.service.cmake biboumi.service)
# Force the format of the date output
set(ENV{LANG} "C")
......@@ -342,4 +380,38 @@ execute_process(COMMAND "date" "+%a %b %d %Y" OUTPUT_VARIABLE RPM_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE)
unset(ENV{LANG})
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()
#
## Check if we have std::get_time and put_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(unit/biboumi.service.cmake biboumi.service)
configure_file(packaging/biboumi.spec.cmake biboumi.spec)
configure_file(biboumi.h.cmake src/biboumi.h)
#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)