cmake_minimum_required( VERSION 3.13.4 ) project(auditd-plugin-clickhouse LANGUAGES CXX) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") set(SYSCONF_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/etc CACHE PATH "Installation prefix for configuration files") set(BIN_INSTALL_LIBEXEC ${CMAKE_INSTALL_PREFIX}/libexec CACHE PATH "Installation prefix for user executables") set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) find_package(Boost REQUIRED COMPONENTS filesystem) find_package(ClickhouseCpp REQUIRED) pkg_check_modules(AUPARSE auparse REQUIRED) include(GoogleTest) include_directories(${Boost_INCLUDE_DIRS} ${AUPARSE_INCLUDE_DIRS}) set(SOURCES auditd-datatypes.cpp auditd-plugin-clickhouse.cpp auditd-record.cpp logging.cpp utils.cpp ) set(HEADERS auditd-datatypes.hpp auditd-record.hpp logging.hpp utils.hpp ) enable_testing() add_executable( auditd-plugin-clickhouse ${SOURCES} ${HEADERS} ) target_link_libraries( auditd-plugin-clickhouse ${CLICKHOUSECPP_LIBRARIES} ${AUPARSE_LIBRARIES} Threads::Threads Boost::filesystem ) add_executable( test-audit-record test_audit_record.cpp auditd-record.cpp logging.cpp utils.cpp auditd-record.hpp logging.hpp utils.hpp ) target_link_libraries( test-audit-record ${CLICKHOUSECPP_LIBRARIES} ${AUPARSE_LIBRARIES} gtest gtest_main ) add_test( NAME test-audit-record COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-audit-record ) install(TARGETS auditd-plugin-clickhouse RUNTIME DESTINATION ${BIN_INSTALL_LIBEXEC} ) install(FILES auditd-plugin-clickhouse.conf DESTINATION ${SYSCONF_INSTALL_DIR}/audisp/plugins.d ) install(FILES auditd-clickhouse.conf auditd-clickhouse-datatypes.json DESTINATION ${SYSCONF_INSTALL_DIR}/audisp ) install(FILES auditd-plugin-clickhouse-logrotate.conf DESTINATION ${SYSCONF_INSTALL_DIR}/logrotate.d )