Unverified Commit ac9fee4b authored by syl's avatar syl Committed by GitHub
Browse files

enh(chore): use one root cmake for both connectors (#16)

parent e932e21d
ssh/build
**/.*.swp
perl/src/xs_init.cc
perl/test/connector/paths.hh
ssh/test/connector/binary.hh
build/*
.idea/*
# Global options.
cmake_minimum_required(VERSION 2.8.12)
project(connectors CXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O3")
add_definitions("-D_GLIBCXX_USE_CXX11_ABI=0")
# We will use pkg-config if available.
add_subdirectory(perl)
add_subdirectory(ssh)
\ No newline at end of file
# We will use pkg-config if available.
include(FindPkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(LIBSSH2 QUIET "libssh2") # Will be used below.
pkg_check_modules(LIBGCRYPT QUIET "libgcrypt") # Will be used below.
endif ()
# Find libssh2's headers.
if (WITH_LIBSSH2_INCLUDE_DIR)
find_file(
LIBSSH2_HEADER_FOUND
"libssh2.h"
PATHS "${WITH_LIBSSH2_INCLUDE_DIR}"
NO_DEFAULT_PATH)
if (NOT LIBSSH2_HEADER_FOUND)
message(FATAL_ERROR "Could not find libssh2's headers in ${WITH_LIBSSH2_INCLUDE_DIR}.")
endif ()
include_directories("${WITH_LIBSSH2_INCLUDE_DIR}")
elseif (LIBSSH2_FOUND) # Was libssh2 detected with pkg-config ?
if (CMAKE_CXX_FLAGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBSSH2_CFLAGS}")
else ()
set(CMAKE_CXX_FLAGS "${LIBSSH2_CFLAGS}")
endif ()
else ()
find_path(LIBSSH2_INCLUDE_DIR "libssh2.h")
if (NOT LIBSSH2_INCLUDE_DIR)
message(FATAL_ERROR "Could not find libssh2's headers (try WITH_LIBSSH2_INCLUDE_DIR).")
endif ()
include_directories("${LIBSSH2_INCLUDE_DIR}")
endif ()
# Find libssh2's library.
if (WITH_LIBSSH2_LIBRARIES)
set(LIBSSH2_LIBRARIES "${WITH_LIBSSH2_LIBRARIES}")
elseif (WITH_LIBSSH2_LIBRARY_DIR)
find_library(
LIBSSH2_LIBRARIES
"ssh2"
PATHS "${WITH_LIBSSH2_LIBRARY_DIR}"
NO_DEFAULT_PATH)
if (NOT LIBSSH2_LIBRARIES)
message(FATAL_ERROR "Could not find libssh2's library in ${WITH_LIBSSH2_LIBRARY_DIR}.")
endif ()
elseif (LIBSSH2_FOUND) # Was libssh2 detected with pkg-config ?
set(LIBSSH2_LIBRARIES "${LIBSSH2_LDFLAGS}")
else ()
find_library(LIBSSH2_LIBRARIES "ssh2")
if (NOT LIBSSH2_LIBRARIES)
message(FATAL_ERROR "Could not find libssh2's library (try WITH_LIBSSH2_LIBRARY_DIR or WITH_LIBSSH2_LIBRARIES).")
endif ()
endif ()
# Check if libssh2 is using libgcrypt or OpenSSL.
if (WITH_LIBSSH2_WITH_LIBGCRYPT)
set(LIBSSH2_WITH_LIBGCRYPT "${WITH_LIBSSH2_WITH_LIBGCRYPT}")
else ()
set(LIBSSH2_WITH_LIBGCRYPT 1)
endif ()
if (LIBSSH2_WITH_LIBGCRYPT)
# Find libgcrypt's required header.
if (WITH_LIBGCRYPT_INCLUDE_DIR)
find_file(
LIBGCRYPT_HEADER_FOUND
"gcrypt.h"
PATHS "${WITH_LIBGCRYPT_INCLUDE_DIR}"
NO_DEFAULT_PATH)
if (NOT LIBGCRYPT_HEADER_FOUND)
message(FATAL_ERROR "Could not find libgcrypt's headers in ${WITH_LIBGCRYPT_INCLUDE_DIR}.")
endif ()
include_directories("${WITH_LIBGCRYPT_INCLUDE_DIR}")
else ()
find_file(LIBGCRYPT_HEADER_FOUND "gcrypt.h")
if (NOT LIBGCRYPT_HEADER_FOUND)
message(FATAL_ERROR "Could not find libgcrypt's headers (try WITH_LIBGCRYPT_INCLUDE_DIR).")
endif ()
endif ()
# Find libgcrypt's library.
if (WITH_LIBGCRYPT_LIBRARIES)
set(LIBGCRYPT_LIBRARIES "${WITH_LIBGCRYPT_LIBRARIES}")
elseif (WITH_LIBGCRYPT_LIBRARY_DIR)
find_library(
LIBGCRYPT_LIBRARIES
"gcrypt"
PATHS "${WITH_LIBGCRYPT_LIBRARY_DIR}"
NO_DEFAULT_PATH)
if (NOT LIBGCRYPT_LIBRARIES)
message(FATAL_ERROR "Could not find libgcrypt's library in ${WITH_LIBGCRYPT_LIBRARY_DIR}.")
endif ()
elseif (LIBGCRYPT_FOUND) # Was libgcrypt detected with pkg-config ?
set(LIBGCRYPT_LIBRARIES "${LIBGCRYPT_LDFLAGS}")
else ()
find_library(LIBGCRYPT_LIBRARIES "gcrypt")
if (NOT LIBGCRYPT_LIBRARIES)
message(FATAL_ERROR "Could not find libgcrypt's library (try WITH_LIBGCRYPT_LIBRARY_DIR).")
endif ()
endif ()
# Add macro.
add_definitions(-DLIBSSH2_WITH_LIBGCRYPT)
endif ()
# Find Centreon Clib's headers.
include(FindPkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(CLIB QUIET "centreon-clib") # Will be used below.
endif (PKG_CONFIG_FOUND)
if (WITH_CENTREON_CLIB_INCLUDE_DIR)
find_file(
CLIB_HEADER_FOUND
"com/centreon/clib/version.hh"
PATHS "${WITH_CENTREON_CLIB_INCLUDE_DIR}"
NO_DEFAULT_PATH)
if (NOT CLIB_HEADER_FOUND)
message(FATAL_ERROR "Could not find Centreon Clib's headers in ${WITH_CENTREON_CLIB_INCLUDE_DIR}.")
endif ()
include_directories("${WITH_CENTREON_CLIB_INCLUDE_DIR}")
set(CLIB_INCLUDE_DIR "${WITH_CENTREON_CLIB_INCLUDE_DIR}")
elseif (CLIB_FOUND) # Was Centreon Clib detected with pkg-config ?
if (CMAKE_CXX_FLAGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CLIB_CFLAGS}")
else ()
set(CMAKE_CXX_FLAGS "${CLIB_CFLAGS}")
endif ()
else ()
find_path(CLIB_INCLUDE_DIR "com/centreon/clib/version.hh" PATH_SUFFIXES "centreon-clib")
if (NOT CLIB_INCLUDE_DIR)
message(FATAL_ERROR "Could not find Centreon Clib's headers (try WITH_CENTREON_CLIB_INCLUDE_DIR).")
endif ()
include_directories("${CLIB_INCLUDE_DIR}")
endif ()
# Find Centreon Clib's library.
if (WITH_CENTREON_CLIB_LIBRARIES)
set(CLIB_LIBRARIES "${WITH_CENTREON_CLIB_LIBRARIES}")
elseif (WITH_CENTREON_CLIB_LIBRARY_DIR)
find_library(
CLIB_LIBRARIES
"centreon_clib"
PATHS "${WITH_CENTREON_CLIB_LIBRARY_DIR}"
NO_DEFAULT_PATH)
if (NOT CLIB_LIBRARIES)
message(FATAL_ERROR "Could not find Centreon Clib's library in ${WITH_CENTREON_CLIB_LIBRARY_DIR}.")
endif ()
elseif (CLIB_FOUND) # Was Centreon Clib detected with pkg-config ?
set(CLIB_LIBRARIES "${CLIB_LDFLAGS}")
else ()
find_library(CLIB_LIBRARIES "centreon_clib")
if (NOT CLIB_LIBRARIES)
message(FATAL_ERROR "Could not find Centreon Clib's library (try WITH_CENTREON_CLIB_LIBRARY_DIR or WITH_CENTREON_CLIB_LIBRARIES).")
endif ()
endif ()
\ No newline at end of file
# Find Perl.
include(FindPerlLibs)
if (NOT PERLLIBS_FOUND)
message(FATAL_ERROR "Could not find Perl libraries.")
endif ()
execute_process(COMMAND "${PERL_EXECUTABLE}" "-MExtUtils::Embed" "-e" "ldopts"
RESULT_VARIABLE PERL_LDFLAGS_ERROR
OUTPUT_VARIABLE PERL_LIBRARIES)
string(STRIP "${PERL_LIBRARIES}" PERL_LIBRARIES)
if (PERL_LDFLAGS_ERROR)
set(PERL_LIBRARIES ${PERL_LIBRARY})
endif ()
execute_process(COMMAND "${PERL_EXECUTABLE}" "-MExtUtils::Embed" "-e" "ccopts"
RESULT_VARIABLE PERL_CFLAGS_ERROR
OUTPUT_VARIABLE PERL_CFLAGS)
if (NOT PERL_CFLAGS_ERROR)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PERL_CFLAGS}")
endif ()
message(INFO ${PERL_CFLAGS})
\ No newline at end of file
......@@ -17,13 +17,9 @@
##
# Global options.
cmake_minimum_required(VERSION 2.8)
project("Centreon Perl Connector" C CXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(PROJECT_SOURCE_DIR "${PROJECT_SOURCE_DIR}/..")
set(INC_DIR "${PROJECT_SOURCE_DIR}/inc/com/centreon/connector/perl")
set(SRC_DIR "${PROJECT_SOURCE_DIR}/src")
set(TEST_DIR "${PROJECT_SOURCE_DIR}/test")
include(${CMAKE_SOURCE_DIR}/cmake/Findclib.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/Findperl.cmake)
include_directories("${PROJECT_SOURCE_DIR}/inc" "/usr/lib64/perl5/CORE")
# Project version.
......@@ -33,85 +29,13 @@ set(CONNECTOR_PERL_PATCH 0)
set(CONNECTOR_PERL_VERSION "${CONNECTOR_PERL_MAJOR}.${CONNECTOR_PERL_MINOR}.${CONNECTOR_PERL_PATCH}")
add_definitions(-DCENTREON_CONNECTOR_PERL_VERSION=\"${CONNECTOR_PERL_VERSION}\")
# We will use pkg-config if available.
include(FindPkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(CLIB QUIET "centreon-clib") # Will be used below.
endif ()
# Find Centreon Clib's headers.
if (WITH_CENTREON_CLIB_INCLUDE_DIR)
find_file(
CLIB_HEADER_FOUND
"com/centreon/clib/version.hh"
PATHS "${WITH_CENTREON_CLIB_INCLUDE_DIR}"
NO_DEFAULT_PATH)
if (NOT CLIB_HEADER_FOUND)
message(FATAL_ERROR "Could not find Centreon Clib's headers in ${WITH_CENTREON_CLIB_INCLUDE_DIR}.")
endif ()
include_directories("${WITH_CENTREON_CLIB_INCLUDE_DIR}")
set(CLIB_INCLUDE_DIR "${WITH_CENTREON_CLIB_INCLUDE_DIR}")
elseif (CLIB_FOUND) # Was Centreon Clib detected with pkg-config ?
if (CMAKE_CXX_FLAGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CLIB_CFLAGS}")
else ()
set(CMAKE_CXX_FLAGS "${CLIB_CFLAGS}")
endif ()
else ()
find_path(CLIB_INCLUDE_DIR "com/centreon/clib/version.hh" PATH_SUFFIXES "centreon-clib")
if (NOT CLIB_INCLUDE_DIR)
message(FATAL_ERROR "Could not find Centreon Clib's headers (try WITH_CENTREON_CLIB_INCLUDE_DIR).")
endif ()
include_directories("${CLIB_INCLUDE_DIR}")
endif ()
# Find Centreon Clib's library.
if (WITH_CENTREON_CLIB_LIBRARIES)
set(CLIB_LIBRARIES "${WITH_CENTREON_CLIB_LIBRARIES}")
elseif (WITH_CENTREON_CLIB_LIBRARY_DIR)
find_library(
CLIB_LIBRARIES
"centreon_clib"
PATHS "${WITH_CENTREON_CLIB_LIBRARY_DIR}"
NO_DEFAULT_PATH)
if (NOT CLIB_LIBRARIES)
message(FATAL_ERROR "Could not find Centreon Clib's library in ${WITH_CENTREON_CLIB_LIBRARY_DIR}.")
endif ()
elseif (CLIB_FOUND) # Was Centreon Clib detected with pkg-config ?
set(CLIB_LIBRARIES "${CLIB_LDFLAGS}")
else ()
find_library(CLIB_LIBRARIES "centreon_clib")
if (NOT CLIB_LIBRARIES)
message(FATAL_ERROR "Could not find Centreon Clib's library (try WITH_CENTREON_CLIB_LIBRARY_DIR or WITH_CENTREON_CLIB_LIBRARIES).")
endif ()
endif ()
# Find Perl.
include(FindPerlLibs)
if (NOT PERLLIBS_FOUND)
message(FATAL_ERROR "Could not find Perl libraries.")
endif ()
execute_process(COMMAND "${PERL_EXECUTABLE}" "-MExtUtils::Embed" "-e" "ldopts"
RESULT_VARIABLE PERL_LDFLAGS_ERROR
OUTPUT_VARIABLE PERL_LIBRARIES)
string(STRIP "${PERL_LIBRARIES}" PERL_LIBRARIES)
if (PERL_LDFLAGS_ERROR)
set(PERL_LIBRARIES ${PERL_LIBRARY})
endif ()
execute_process(COMMAND "${PERL_EXECUTABLE}" "-MExtUtils::Embed" "-e" "ccopts"
RESULT_VARIABLE PERL_CFLAGS_ERROR
OUTPUT_VARIABLE PERL_CFLAGS)
if (NOT PERL_CFLAGS_ERROR)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PERL_CFLAGS}")
endif ()
# Generate code to dynamically load modules.
add_custom_command(OUTPUT "${SRC_DIR}/xs_init.cc"
COMMAND "${PERL_EXECUTABLE}" "-MExtUtils::Embed" "-e" "xsinit" "--" "-o" "${SRC_DIR}/xs_init.cc")
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 "${SRC_DIR}/embedded_perl.cc"
get_property(EMBEDDED_PERL_CXXFLAGS SOURCE ${SRC_DIR}/embedded_perl.cc
PROPERTY COMPILE_FLAGS)
if (EMBEDDED_PERL_CXXFLAGS)
string(REGEX REPLACE "-pedantic *"
......@@ -120,48 +44,41 @@ if (EMBEDDED_PERL_CXXFLAGS)
PROPERTY COMPILE_FLAGS "${EMBEDDED_PERL_CXXFLAGS}")
endif ()
# Perl connector library.
set(CONNECTORLIB "centreonconnectorperl")
add_library("${CONNECTORLIB}" STATIC
include_directories(${CMAKE_SOURCE_DIR}/perl/inc/)
# Perl connector.
add_executable(centreon_connector_perl
# Sources.
${CMAKE_SOURCE_DIR}/perl/src/main.cc
# Sources.
"${SRC_DIR}/checks/check.cc"
"${SRC_DIR}/checks/result.cc"
"${SRC_DIR}/checks/timeout.cc"
"${SRC_DIR}/embedded_perl.cc"
"${SRC_DIR}/multiplexer.cc"
"${SRC_DIR}/options.cc"
"${SRC_DIR}/orders/parser.cc"
"${SRC_DIR}/pipe_handle.cc"
"${SRC_DIR}/policy.cc"
"${SRC_DIR}/reporter.cc"
"${SRC_DIR}/script.cc"
"${SRC_DIR}/xs_init.cc"
${CMAKE_SOURCE_DIR}/perl/src/checks/check.cc
${CMAKE_SOURCE_DIR}/perl/src/checks/result.cc
${CMAKE_SOURCE_DIR}/perl/src/checks/timeout.cc
${CMAKE_SOURCE_DIR}/perl/src/embedded_perl.cc
${CMAKE_SOURCE_DIR}/perl/src/multiplexer.cc
${CMAKE_SOURCE_DIR}/perl/src/options.cc
${CMAKE_SOURCE_DIR}/perl/src/orders/parser.cc
${CMAKE_SOURCE_DIR}/perl/src/pipe_handle.cc
${CMAKE_SOURCE_DIR}/perl/src/policy.cc
${CMAKE_SOURCE_DIR}/perl/src/reporter.cc
${CMAKE_SOURCE_DIR}/perl/src/script.cc
${CMAKE_SOURCE_DIR}/perl/src/xs_init.cc
# Headers.
"${INC_DIR}/checks/check.hh"
"${INC_DIR}/checks/listener.hh"
"${INC_DIR}/checks/result.hh"
"${INC_DIR}/checks/timeout.hh"
"${INC_DIR}/embedded_perl.hh"
"${INC_DIR}/multiplexer.hh"
"${INC_DIR}/namespace.hh"
"${INC_DIR}/options.hh"
"${INC_DIR}/orders/listener.hh"
"${INC_DIR}/orders/parser.hh"
"${INC_DIR}/pipe_handle.hh"
"${INC_DIR}/policy.hh"
"${INC_DIR}/reporter.hh"
)
target_link_libraries(
"${CONNECTORLIB}"
${PERL_LIBRARIES}
${CLIB_LIBRARIES})
${CMAKE_SOURCE_DIR}/perl/inc/com/centreon/connector/perl/checks/check.hh
${CMAKE_SOURCE_DIR}/perl/inc/com/centreon/connector/perl/checks/listener.hh
${CMAKE_SOURCE_DIR}/perl/inc/com/centreon/connector/perl/checks/result.hh
${CMAKE_SOURCE_DIR}/perl/inc/com/centreon/connector/perl/checks/timeout.hh
${CMAKE_SOURCE_DIR}/perl/inc/com/centreon/connector/perl/embedded_perl.hh
${CMAKE_SOURCE_DIR}/perl/inc/com/centreon/connector/perl/multiplexer.hh
${CMAKE_SOURCE_DIR}/perl/inc/com/centreon/connector/perl/namespace.hh
${CMAKE_SOURCE_DIR}/perl/inc/com/centreon/connector/perl/options.hh
${CMAKE_SOURCE_DIR}/perl/inc/com/centreon/connector/perl/orders/listener.hh
${CMAKE_SOURCE_DIR}/perl/inc/com/centreon/connector/perl/orders/parser.hh
${CMAKE_SOURCE_DIR}/perl/inc/com/centreon/connector/perl/pipe_handle.hh
${CMAKE_SOURCE_DIR}/perl/inc/com/centreon/connector/perl/policy.hh
${CMAKE_SOURCE_DIR}/perl/inc/com/centreon/connector/perl/reporter.hh
)
# Perl connector.
set(CONNECTOR "centreon_connector_perl")
add_executable("${CONNECTOR}"
# Sources.
"${SRC_DIR}/main.cc")
target_link_libraries("${CONNECTOR}" ${CONNECTORLIB})
target_link_libraries(centreon_connector_perl ${CLIB_LIBRARIES} ${PERL_LIBRARIES} pthread)
# Installation path.
if (WITH_PREFIX)
......@@ -174,11 +91,7 @@ else ()
endif ()
# Install rules.
install(TARGETS "${CONNECTOR}"
RUNTIME DESTINATION "${PREFIX_BINARY}")
# Packaging.
include("package.cmake")
install(TARGETS centreon_connector_perl RUNTIME DESTINATION ${PREFIX_BINARY})
# Code coverage on unit tests
option(WITH_COVERAGE "Add code coverage on unit tests." OFF)
......@@ -284,35 +197,3 @@ if (WITH_TESTING)
endif ()
endif ()
# Summary.
message(STATUS "")
message(STATUS "Configuration Summary")
message(STATUS "---------------------")
message(STATUS "")
message(STATUS " Project")
message(STATUS " - Name Centreon Perl Connector")
message(STATUS " - Version ${CONNECTOR_PERL_VERSION}")
message(STATUS "")
message(STATUS " System")
message(STATUS " - Name ${CMAKE_SYSTEM_NAME}")
message(STATUS " - Version ${CMAKE_SYSTEM_VERSION}")
message(STATUS " - Processor ${CMAKE_SYSTEM_PROCESSOR}")
message(STATUS "")
message(STATUS " Build")
message(STATUS " - Compiler ${CMAKE_CXX_COMPILER} (${CMAKE_CXX_COMPILER_ID})")
message(STATUS " - Extra compilation flags ${CMAKE_CXX_FLAGS}")
if (WITH_TESTING)
message(STATUS " - Unit tests enabled")
else()
message(STATUS " - Unit tests disabled")
endif ()
message(STATUS "")
message(STATUS " Install")
message(STATUS " - Prefix ${CMAKE_INSTALL_PREFIX}")
message(STATUS " - Binary prefix ${PREFIX_BINARY}")
message(STATUS " - Package ${PACKAGE_LIST}")
message(STATUS "")
message(STATUS " Libraries")
message(STATUS " - clib include directory ${CLIB_INCLUDE_DIR}")
message(STATUS " - clib library directory ${CLIB_LIBRARIES}")
##
## Copyright 2011-2013,2015 Centreon
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##
## For more information : contact@centreon.com
##
# Packaging.
option(WITH_PACKAGE_SH "Build shell-installable package." OFF)
option(WITH_PACKAGE_TGZ "Build gziped tarball package." OFF)
option(WITH_PACKAGE_TBZ2 "Build bzip2'd tarball package." OFF)
option(WITH_PACKAGE_DEB "Build DEB package." OFF)
option(WITH_PACKAGE_RPM "Build RPM package." OFF)
option(WITH_PACKAGE_NSIS "Build NSIS package." OFF)
if (WITH_PACKAGE_SH
OR WITH_PACKAGE_TGZ
OR WITH_PACKAGE_TBZ2
OR WITH_PACKAGE_DEB
OR WITH_PACKAGE_RPM
OR WITH_PACKAGE_NSIS)
# Default settings.
set(CPACK_PACKAGE_VENDOR "Centreon")
set(CPACK_PACKAGE_VERSION_MAJOR "${CONNECTOR_PERL_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${CONNECTOR_PERL_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${CONNECTOR_PERL_PATCH}")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
"Perl connector for Centreon Engine.")
set(CPACK_PACKAGE_FILE_NAME
"centreon-connector-perl-${CONNECTOR_PERL_VERSION}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "centreon-connector-perl")
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_CONTACT
"Matthieu Kermagoret <mkermagoret@centreon.com>")
# Generators.
unset(PACKAGE_LIST)
if (WITH_PACKAGE_SH)
list(APPEND CPACK_GENERATOR "STGZ")
list(APPEND PACKAGE_LIST "Shell-installable package (.sh)")
endif ()
if (WITH_PACKAGE_TGZ)
list(APPEND CPACK_GENERATOR "TGZ")
list(APPEND PACKAGE_LIST "gziped tarball (.tar.gz)")
endif ()
if (WITH_PACKAGE_TBZ2)
list(APPEND CPACK_GENERATOR "TBZ2")
list(APPEND PACKAGE_LIST "bzip2'd tarball (.tar.bz2)")
endif ()
if (WITH_PACKAGE_DEB)
list(APPEND CPACK_GENERATOR "DEB")
list(APPEND PACKAGE_LIST "DEB package (.deb)")
set(CPACK_DEBIAN_PACKAGE_SECTION "net")
endif ()
if (WITH_PACKAGE_RPM)
list(APPEND CPACK_GENERATOR "RPM")
list(APPEND PACKAGE_LIST "RPM package (.rpm)")
set(CPACK_RPM_PACKAGE_RELEASE 1)
set(CPACK_RPM_PACKAGE_LICENSE "ASL 2.0")
endif ()
if (WITH_PACKAGE_NSIS)
list(APPEND CPACK_GENERATOR "NSIS")
list(APPEND PACKAGE_LIST "NSIS package (.exe)")
endif ()
string(REPLACE ";" ", " PACKAGE_LIST "${PACKAGE_LIST}")
# CPack module.
include(CPack)
else ()
set(PACKAGE_LIST "None")
endif ()
......@@ -16,17 +16,8 @@
## For more information : contact@centreon.com
##
# Global options.
cmake_minimum_required(VERSION 2.8)
project("Centreon SSH Connector" CXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(PROJECT_SOURCE_DIR "${PROJECT_SOURCE_DIR}/..")
set(INC_DIR "${PROJECT_SOURCE_DIR}/inc/com/centreon/connector/ssh")
set(SRC_DIR "${PROJECT_SOURCE_DIR}/src")
set(TEST_DIR "${PROJECT_SOURCE_DIR}/test")
include_directories("${PROJECT_SOURCE_DIR}/inc")
include(${CMAKE_SOURCE_DIR}/cmake/Findclib.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/FindSSH.cmake)
# Project version.
set(CONNECTOR_SSH_MAJOR 20)
set(CONNECTOR_SSH_MINOR 04)
......@@ -34,156 +25,6 @@ set(CONNECTOR_SSH_PATCH 0)
set(CONNECTOR_SSH_VERSION "${CONNECTOR_SSH_MAJOR}.${CONNECTOR_SSH_MINOR}.${CONNECTOR_SSH_PATCH}")
add_definitions(-DCENTREON_CONNECTOR_SSH_VERSION=\"${CONNECTOR_SSH_VERSION}\")
# We will use pkg-config if available.
include(FindPkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(CLIB QUIET "centreon-clib") # Will be used below.
pkg_check_modules(LIBSSH2 QUIET "libssh2") # Will be used below.
pkg_check_modules(LIBGCRYPT QUIET "libgcrypt") # Will be used below.
endif ()
# Find libssh2's headers.
if (WITH_LIBSSH2_INCLUDE_DIR)
find_file(
LIBSSH2_HEADER_FOUND
"libssh2.h"
PATHS "${WITH_LIBSSH2_INCLUDE_DIR}"
NO_DEFAULT_PATH)
if (NOT LIBSSH2_HEADER_FOUND)
message(FATAL_ERROR "Could not find libssh2's headers in ${WITH_LIBSSH2_INCLUDE_DIR}.")
endif ()
include_directories("${WITH_LIBSSH2_INCLUDE_DIR}")
elseif (LIBSSH2_FOUND) # Was libssh2 detected with pkg-config ?
if (CMAKE_CXX_FLAGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBSSH2_CFLAGS}")
else ()
set(CMAKE_CXX_FLAGS "${LIBSSH2_CFLAGS}")
endif ()
else ()
find_path(LIBSSH2_INCLUDE_DIR "libssh2.h")
if (NOT LIBSSH2_INCLUDE_DIR)
message(FATAL_ERROR "Could not find libssh2's headers (try WITH_LIBSSH2_INCLUDE_DIR).")
endif ()
include_directories("${LIBSSH2_INCLUDE_DIR}")
endif ()
# Find libssh2's library.
if (WITH_LIBSSH2_LIBRARIES)
set(LIBSSH2_LIBRARIES "${WITH_LIBSSH2_LIBRARIES}")
elseif (WITH_LIBSSH2_LIBRARY_DIR)
find_library(
LIBSSH2_LIBRARIES
"ssh2"
PATHS "${WITH_LIBSSH2_LIBRARY_DIR}"
NO_DEFAULT_PATH)
if (NOT LIBSSH2_LIBRARIES)
message(FATAL_ERROR "Could not find libssh2's library in ${WITH_LIBSSH2_LIBRARY_DIR}.")
endif ()
elseif (LIBSSH2_FOUND) # Was libssh2 detected with pkg-config ?
set(LIBSSH2_LIBRARIES "${LIBSSH2_LDFLAGS}")
else ()
find_library(LIBSSH2_LIBRARIES "ssh2")
if (NOT LIBSSH2_LIBRARIES)
message(FATAL_ERROR "Could not find libssh2's library (try WITH_LIBSSH2_LIBRARY_DIR or WITH_LIBSSH2_LIBRARIES).")
endif ()
endif ()
# Check if libssh2 is using libgcrypt or OpenSSL.
if (WITH_LIBSSH2_WITH_LIBGCRYPT)
set(LIBSSH2_WITH_LIBGCRYPT "${WITH_LIBSSH2_WITH_LIBGCRYPT}")
else ()
set(LIBSSH2_WITH_LIBGCRYPT 1)
endif ()
if (LIBSSH2_WITH_LIBGCRYPT)
# Find libgcrypt's required header.
if (WITH_LIBGCRYPT_INCLUDE_DIR)
find_file(
LIBGCRYPT_HEADER_FOUND
"gcrypt.h"
PATHS "${WITH_LIBGCRYPT_INCLUDE_DIR}"
NO_DEFAULT_PATH)
if (NOT LIBGCRYPT_HEADER_FOUND)
message(FATAL_ERROR "Could not find libgcrypt's headers in ${WITH_LIBGCRYPT_INCLUDE_DIR}.")
endif ()
include_directories("${WITH_LIBGCRYPT_INCLUDE_DIR}")
else ()
find_file(LIBGCRYPT_HEADER_FOUND "gcrypt.h")
if (NOT LIBGCRYPT_HEADER_FOUND)
message(FATAL_ERROR "Could not find libgcrypt's headers (try WITH_LIBGCRYPT_INCLUDE_DIR).")
endif ()
endif ()
# Find libgcrypt's library.
if (WITH_LIBGCRYPT_LIBRARIES)
set(LIBGCRYPT_LIBRARIES "${WITH_LIBGCRYPT_LIBRARIES}")
elseif (WITH_LIBGCRYPT_LIBRARY_DIR)
find_library(
LIBGCRYPT_LIBRARIES