2013-11-03 13:45:26 +01:00
|
|
|
# Icinga 2
|
2014-03-19 01:02:29 +01:00
|
|
|
# Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org)
|
2013-11-03 13:45:26 +01:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software Foundation
|
|
|
|
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
cmake_minimum_required(VERSION 2.6)
|
2013-12-18 12:54:49 +01:00
|
|
|
set(BOOST_MIN_VERSION "1.41.0")
|
|
|
|
|
2013-11-03 13:45:26 +01:00
|
|
|
project(icinga2)
|
2014-06-23 10:56:12 +02:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
2014-06-15 02:17:01 +02:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/third-party/cmake")
|
2013-11-03 13:45:26 +01:00
|
|
|
|
2013-11-20 16:36:11 +01:00
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
2013-11-30 13:47:51 +01:00
|
|
|
set(CMAKE_BUILD_TYPE Release CACHE STRING
|
2013-11-20 16:36:11 +01:00
|
|
|
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
|
|
|
|
FORCE)
|
|
|
|
endif()
|
|
|
|
|
2013-11-03 13:45:26 +01:00
|
|
|
file(STRINGS icinga2.spec VERSION_LINE REGEX "^Version: ")
|
|
|
|
string(REPLACE "Version: " "" ICINGA2_VERSION ${VERSION_LINE})
|
|
|
|
|
2014-07-22 13:18:41 +02:00
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
2013-12-05 09:42:42 +01:00
|
|
|
set(ICINGA2_USER "icinga" CACHE STRING "Icinga 2 user")
|
|
|
|
set(ICINGA2_GROUP "icinga" CACHE STRING "Icinga 2 group")
|
|
|
|
set(ICINGA2_COMMAND_USER "icinga" CACHE STRING "Icinga 2 command user")
|
|
|
|
set(ICINGA2_COMMAND_GROUP "icingacmd" CACHE STRING "Icinga 2 command group")
|
2014-07-22 13:18:41 +02:00
|
|
|
set(ICINGA2_RUNDIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/run" CACHE STRING "/run directory")
|
2014-07-22 13:22:39 +02:00
|
|
|
set(ICINGA2_PLUGINDIR "/usr/lib/nagios/plugins" CACHE STRING "Path for the check plugins")
|
2014-05-18 14:33:38 +02:00
|
|
|
set(ICINGA2_GIT_VERSION_INFO ON CACHE BOOL "Whether to use git describe")
|
2014-08-30 18:08:28 +02:00
|
|
|
set(ICINGA2_UNITY_BUILD OFF CACHE BOOL "Whether to perform a unity build")
|
2013-11-03 13:45:26 +01:00
|
|
|
|
|
|
|
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/COPYING" ICINGA2_LICENSE_GPL)
|
|
|
|
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.Exceptions" ICINGA2_LICENSE_ADDITIONS)
|
|
|
|
set(ICINGA2_LICENSE "${ICINGA2_LICENSE_GPL}\n\n---\n\n${ICINGA2_LICENSE_ADDITIONS}")
|
|
|
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt" ${ICINGA2_LICENSE})
|
|
|
|
|
|
|
|
include(GetGitRevisionDescription)
|
|
|
|
git_describe(GIT_VERSION --tags)
|
2014-05-18 14:19:16 +02:00
|
|
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/icinga-version.h.force)
|
|
|
|
configure_file(icinga-version.h.force ${CMAKE_CURRENT_BINARY_DIR}/icinga-version.h COPYONLY)
|
2013-11-27 10:35:48 +01:00
|
|
|
else()
|
2014-05-18 14:33:38 +02:00
|
|
|
if(NOT ICINGA2_GIT_VERSION_INFO OR GIT_VERSION MATCHES "-NOTFOUND$")
|
2014-05-18 14:19:16 +02:00
|
|
|
file(STRINGS icinga2.spec SPEC_VERSION REGEX "^Version:")
|
2014-05-21 10:29:44 +02:00
|
|
|
string(LENGTH "${SPEC_VERSION}" SPEC_VERSION_LENGTH)
|
|
|
|
math(EXPR SPEC_VERSION_LENGTH "${SPEC_VERSION_LENGTH} - 9")
|
|
|
|
string(SUBSTRING ${SPEC_VERSION} 9 ${SPEC_VERSION_LENGTH} SPEC_VERSION)
|
|
|
|
|
|
|
|
file(STRINGS icinga2.spec SPEC_REVISION REGEX "^%define revision ")
|
|
|
|
string(LENGTH "${SPEC_REVISION}" SPEC_REVISION_LENGTH)
|
|
|
|
math(EXPR SPEC_REVISION_LENGTH "${SPEC_REVISION_LENGTH} - 17")
|
|
|
|
string(SUBSTRING ${SPEC_REVISION} 17 ${SPEC_REVISION_LENGTH} SPEC_REVISION)
|
|
|
|
|
|
|
|
set(GIT_VERSION "r${SPEC_VERSION}-${SPEC_REVISION}")
|
2014-05-18 14:19:16 +02:00
|
|
|
endif()
|
2013-11-27 10:35:48 +01:00
|
|
|
configure_file(icinga-version.h.cmake icinga-version.h)
|
|
|
|
endif()
|
2013-11-03 13:45:26 +01:00
|
|
|
|
|
|
|
if(WIN32)
|
|
|
|
set(Boost_USE_STATIC_LIBS ON)
|
|
|
|
add_definitions(-DBOOST_ALL_NO_LIB)
|
|
|
|
endif()
|
|
|
|
|
2013-12-18 12:54:49 +01:00
|
|
|
find_package(Boost ${BOOST_MIN_VERSION} COMPONENTS thread system program_options regex REQUIRED)
|
|
|
|
|
2013-11-03 13:45:26 +01:00
|
|
|
link_directories(${Boost_LIBRARY_DIRS})
|
|
|
|
include_directories(${Boost_INCLUDE_DIRS})
|
|
|
|
|
|
|
|
find_package(OpenSSL REQUIRED)
|
|
|
|
include_directories(${OPENSSL_INCLUDE_DIR})
|
|
|
|
|
|
|
|
include_directories(
|
2014-10-13 09:51:49 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/lib
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/lib
|
2013-11-03 13:45:26 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
#set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
|
|
|
|
|
|
|
if(APPLE)
|
|
|
|
set(CMAKE_INSTALL_NAME_DIR "@executable_path/../lib/icinga2")
|
|
|
|
endif(APPLE)
|
|
|
|
|
2013-11-30 13:47:51 +01:00
|
|
|
if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Qunused-arguments -g")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments -g")
|
|
|
|
endif()
|
|
|
|
|
2014-09-03 08:24:14 +02:00
|
|
|
if("${CMAKE_C_COMPILER_ID}" STREQUAL "SunPro")
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mt")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mt -library=stlport4")
|
|
|
|
endif()
|
|
|
|
|
2013-11-30 13:47:51 +01:00
|
|
|
if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
|
2014-04-16 15:08:47 +02:00
|
|
|
if(${CMAKE_SYSTEM_NAME} MATCHES AIX)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -lpthread")
|
|
|
|
else()
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
|
|
|
|
endif()
|
2013-11-05 07:32:11 +01:00
|
|
|
endif()
|
|
|
|
|
2013-11-03 13:45:26 +01:00
|
|
|
if(MSVC)
|
|
|
|
add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/Bin/${CMAKE_BUILD_TYPE} CACHE PATH "Library output path")
|
|
|
|
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/Bin/${CMAKE_BUILD_TYPE} CACHE PATH "Executable output path")
|
|
|
|
|
2014-08-31 11:01:37 +02:00
|
|
|
include(CheckSymbolExists)
|
2013-11-03 13:45:26 +01:00
|
|
|
include(CheckFunctionExists)
|
2013-11-13 11:55:44 +01:00
|
|
|
include(CheckLibraryExists)
|
2014-09-02 13:02:22 +02:00
|
|
|
include(CheckIncludeFileCXX)
|
2014-08-31 11:01:37 +02:00
|
|
|
|
|
|
|
check_symbol_exists(__COUNTER__ "" HAVE_COUNTER_MACRO)
|
|
|
|
|
|
|
|
if(NOT HAVE_COUNTER_MACRO AND ICINGA2_UNITY_BUILD)
|
|
|
|
message(STATUS "Your C/C++ compiler does not support the __COUNTER__ macro. Disabling unity build.")
|
|
|
|
set(ICINGA2_UNITY_BUILD FALSE)
|
|
|
|
endif()
|
|
|
|
|
2013-11-03 13:45:26 +01:00
|
|
|
check_function_exists(vfork HAVE_VFORK)
|
|
|
|
check_function_exists(backtrace_symbols HAVE_BACKTRACE_SYMBOLS)
|
|
|
|
check_function_exists(pipe2 HAVE_PIPE2)
|
2014-09-06 02:20:25 +02:00
|
|
|
check_function_exists(nice HAVE_NICE)
|
2014-03-06 12:16:00 +01:00
|
|
|
check_library_exists(dl dladdr "dlfcn.h" HAVE_DLADDR)
|
2014-04-14 03:02:33 +02:00
|
|
|
check_library_exists(execinfo backtrace_symbols "" HAVE_LIBEXECINFO)
|
2014-09-02 13:02:22 +02:00
|
|
|
check_include_file_cxx(cxxabi.h HAVE_CXXABI_H)
|
2014-04-14 03:02:33 +02:00
|
|
|
|
|
|
|
if(HAVE_LIBEXECINFO)
|
|
|
|
set(HAVE_BACKTRACE_SYMBOLS TRUE)
|
|
|
|
endif()
|
2013-11-03 13:45:26 +01:00
|
|
|
|
2013-11-15 09:04:39 +01:00
|
|
|
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h ESCAPE_QUOTES)
|
2013-11-03 13:45:26 +01:00
|
|
|
|
|
|
|
install(
|
2014-08-05 21:27:21 +02:00
|
|
|
FILES README.md COPYING COPYING.Exceptions AUTHORS ChangeLog NEWS
|
2013-11-03 13:45:26 +01:00
|
|
|
DESTINATION ${CMAKE_INSTALL_DOCDIR}
|
|
|
|
)
|
|
|
|
|
|
|
|
include(CTest)
|
|
|
|
enable_testing()
|
|
|
|
|
|
|
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
|
|
|
|
|
|
|
add_subdirectory(third-party)
|
|
|
|
add_subdirectory(tools)
|
|
|
|
add_subdirectory(lib)
|
|
|
|
add_subdirectory(icinga-app)
|
|
|
|
add_subdirectory(etc)
|
|
|
|
add_subdirectory(itl)
|
|
|
|
add_subdirectory(doc)
|
|
|
|
add_subdirectory(test)
|
2014-09-17 11:25:34 +02:00
|
|
|
add_subdirectory(agent)
|
2014-04-20 11:22:15 +02:00
|
|
|
|
|
|
|
set(CPACK_PACKAGE_NAME "Icinga2")
|
|
|
|
set(CPACK_PACKAGE_VENDOR "Icinga Development Team")
|
|
|
|
set(CPACK_PACKAGE_VERSION ${ICINGA2_VERSION})
|
|
|
|
set(CPACK_NSIS_DISPLAY_NAME "Icinga 2")
|
|
|
|
set(CPACK_PACKAGE_INSTALL_DIRECTORY "ICINGA2")
|
|
|
|
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/icinga-app\\\\icinga.ico")
|
|
|
|
set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}/icinga-app\\\\icinga.ico")
|
|
|
|
set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}/icinga-app\\\\icinga.ico")
|
|
|
|
set(CPACK_NSIS_INSTALLED_ICON_NAME "sbin\\\\icinga2.exe")
|
|
|
|
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt")
|
|
|
|
|
|
|
|
set(CPACK_NSIS_EXECUTABLES_DIRECTORY "sbin")
|
|
|
|
set(CPACK_PACKAGE_EXECUTABLES "Icinga2SetupAgent;Icinga 2 Agent Wizard")
|
|
|
|
set(CPACK_NSIS_MUI_FINISHPAGE_RUN "Icinga2SetupAgent")
|
2014-04-20 15:35:51 +02:00
|
|
|
set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "nsExec::Exec '\\\"$INSTDIR\\\\sbin\\\\icinga2\\\" --scm-uninstall'")
|
2014-04-20 11:22:15 +02:00
|
|
|
|
|
|
|
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)
|
|
|
|
include(InstallRequiredSystemLibraries)
|
|
|
|
|
|
|
|
if(WIN32)
|
|
|
|
install(
|
|
|
|
PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}
|
|
|
|
C:\\\\openssl\\\\bin\\\\libeay32.dll C:\\\\openssl\\\\bin\\\\ssleay32.dll
|
|
|
|
DESTINATION ${CMAKE_INSTALL_SBINDIR}
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2014-05-09 10:23:54 +02:00
|
|
|
include(CPack)
|