forked from centreon-deb/centreon-connectors
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
91 lines (76 loc) · 3.3 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# Global options.
cmake_minimum_required(VERSION 2.8.12)
project(connectors CXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
add_definitions("-D_GLIBCXX_USE_CXX11_ABI=1")
set(CONNECTOR_MAJOR 21)
set(CONNECTOR_MINOR 10)
set(CONNECTOR_PATCH 0)
set(CONNECTOR_VERSION "${CONNECTOR_MAJOR}.${CONNECTOR_MINOR}.${CONNECTOR_PATCH}")
add_definitions(-DCENTREON_CONNECTOR_VERSION=\"${CONNECTOR_VERSION}\")
include(${CMAKE_SOURCE_DIR}/cmake/Findclib.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/FindSSH.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/Findperl.cmake)
include(${CMAKE_BINARY_DIR}/conan_paths.cmake)
find_package(fmt REQUIRED)
find_package(spdlog REQUIRED)
add_definitions(${spdlog_DEFINITIONS})
include_directories(${fmt_INCLUDE_DIRS})
include_directories(${spdlog_INCLUDE_DIRS})
# Generate code to dynamically load modules.
add_custom_command(OUTPUT "${CMAKE_SOURCE_DIR}/perl/src/xs_init.cc"
COMMAND "${PERL_EXECUTABLE}" "-MExtUtils::Embed" "-e" "xsinit" "--" "-o" "${CMAKE_SOURCE_DIR}/perl/src/xs_init.cc")
# Disable some warnings generated by Embedded Perl.
get_property(EMBEDDED_PERL_CXXFLAGS SOURCE ${CMAKE_SOURCE_DIR}/perl/src/embedded_perl.cc
PROPERTY COMPILE_FLAGS)
if (EMBEDDED_PERL_CXXFLAGS)
string(REGEX REPLACE "-pedantic *"
EMBEDDED_PERL_CXXFLAGS "${EMBEDDED_PERL_CXXFLAGS}")
set_property(SOURCE "${CMAKE_SOURCE_DIR}/perl/src/embedded_perl.cc"
PROPERTY COMPILE_FLAGS "${EMBEDDED_PERL_CXXFLAGS}")
endif ()
# We will use pkg-config if available.
include_directories(${CMAKE_SOURCE_DIR}/common/inc)
add_subdirectory(perl)
add_subdirectory(ssh)
# Testing.
option(WITH_TESTING "Build unit tests." OFF)
if (WITH_TESTING)
find_package(GTest REQUIRED)
include_directories(${GTest_INCLUDE_DIRS})
include_directories(/usr/lib64/perl5/CORE)
link_directories(${GTest_LIB_DIRS})
include_directories(${CMAKE_SOURCE_DIR}/perl/inc)
include_directories(${CMAKE_SOURCE_DIR}/ssh/inc)
add_definitions(-DBUILD_PATH="${CMAKE_BINARY_DIR}")
add_executable(ut
# Core sources
${CMAKE_SOURCE_DIR}/perl/src/embedded_perl.cc
${CMAKE_SOURCE_DIR}/common/src/log.cc
${CMAKE_SOURCE_DIR}/perl/src/pipe_handle.cc
${CMAKE_SOURCE_DIR}/perl/src/script.cc
${CMAKE_SOURCE_DIR}/perl/src/xs_init.cc
${CMAKE_SOURCE_DIR}/ssh/src/checks/check.cc
${CMAKE_SOURCE_DIR}/ssh/src/checks/result.cc
${CMAKE_SOURCE_DIR}/ssh/src/checks/timeout.cc
${CMAKE_SOURCE_DIR}/ssh/src/multiplexer.cc
${CMAKE_SOURCE_DIR}/ssh/src/orders/options.cc
${CMAKE_SOURCE_DIR}/ssh/src/orders/parser.cc
${CMAKE_SOURCE_DIR}/ssh/src/sessions/credentials.cc
${CMAKE_SOURCE_DIR}/ssh/src/sessions/session.cc
${CMAKE_SOURCE_DIR}/ssh/src/sessions/socket_handle.cc
${CMAKE_SOURCE_DIR}/ssh/src/reporter.cc
# Test sources.
${CMAKE_SOURCE_DIR}/perl/test/main.cc
${CMAKE_SOURCE_DIR}/perl/test/connector.cc
${CMAKE_SOURCE_DIR}/perl/test/embedded_perl.cc
${CMAKE_SOURCE_DIR}/ssh/test/buffer_handle.cc
${CMAKE_SOURCE_DIR}/ssh/test/checks.cc
${CMAKE_SOURCE_DIR}/ssh/test/connector.cc
${CMAKE_SOURCE_DIR}/ssh/test/fake_listener.cc
${CMAKE_SOURCE_DIR}/ssh/test/orders.cc
${CMAKE_SOURCE_DIR}/ssh/test/reporter.cc
${CMAKE_SOURCE_DIR}/ssh/test/sessions.cc
)
target_link_libraries(ut ${GTest_LIBS} ${CLIB_LIBRARIES} ${PERL_LIBRARIES} ${fmt_LIBS} ${spdlog_LIBS} ${LIBSSH2_LIBRARIES})
endif (WITH_TESTING)