CMakeLists.txt 3.3 KB
Newer Older
1
2
3
# Global options.
cmake_minimum_required(VERSION 2.8.12)
project(connectors CXX)
4
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
5
6
add_definitions("-D_GLIBCXX_USE_CXX11_ABI=0")

7
8

set(CONNECTOR_MAJOR 20)
9
set(CONNECTOR_MINOR 10)
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
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 ()

41
# We will use pkg-config if available.
42
include_directories(${CMAKE_SOURCE_DIR}/common/inc)
43
44

add_subdirectory(perl)
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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
64
    ${CMAKE_SOURCE_DIR}/common/src/log.cc
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
92
    ${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)