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

Kevin Duret's avatar
Kevin Duret committed
7
8
set(CONNECTOR_MAJOR 21)
set(CONNECTOR_MINOR 04)
9
set(CONNECTOR_PATCH 2)
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
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 ()

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

add_subdirectory(perl)
44
45
46
47
48
add_subdirectory(ssh)

# Testing.
option(WITH_TESTING "Build unit tests." OFF)
if (WITH_TESTING)
49
  find_package(GTest REQUIRED)
50

51
  include_directories(${GTest_INCLUDE_DIRS})
52
53
  include_directories(/usr/lib64/perl5/CORE)

54
  link_directories(${GTest_LIB_DIRS})
55
56
57
58
59
60
61
62

  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
63
    ${CMAKE_SOURCE_DIR}/common/src/log.cc
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
    ${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
    )

90
  target_link_libraries(ut ${GTest_LIBS} ${CLIB_LIBRARIES} ${PERL_LIBRARIES} ${fmt_LIBS} ${spdlog_LIBS} ${LIBSSH2_LIBRARIES})
91
endif (WITH_TESTING)