2 # Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software Foundation
16 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
18 cmake_minimum_required(VERSION 2.6)
20 list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
22 if(NOT CMAKE_BUILD_TYPE)
23 set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
24 "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
28 file(STRINGS icinga2.spec VERSION_LINE REGEX "^Version: ")
29 string(REPLACE "Version: " "" ICINGA2_VERSION ${VERSION_LINE})
31 set(ICINGA2_USER "icinga")
32 set(ICINGA2_GROUP "icinga")
33 set(ICINGA2_COMMAND_USER "icinga")
34 set(ICINGA2_COMMAND_GROUP "icingacmd")
36 file(READ "${CMAKE_CURRENT_SOURCE_DIR}/COPYING" ICINGA2_LICENSE_GPL)
37 file(READ "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.Exceptions" ICINGA2_LICENSE_ADDITIONS)
38 set(ICINGA2_LICENSE "${ICINGA2_LICENSE_GPL}\n\n---\n\n${ICINGA2_LICENSE_ADDITIONS}")
39 file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt" ${ICINGA2_LICENSE})
41 set(CPACK_PACKAGE_CONTACT "Icinga Development Team")
42 set(CPACK_PACKAGE_VERSION ${ICINGA2_VERSION})
43 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt")
44 set(CPACK_WIX_UPGRADE_GUID "68C75073-7CEF-4FC9-8DA5-581758729696")
47 include(GetGitRevisionDescription)
48 set(GIT_VERSION ${CPACK_PACKAGE_VERSION})
49 git_describe(GIT_VERSION --tags)
50 configure_file(icinga-version.h.cmake icinga-version.h)
53 set(Boost_USE_STATIC_LIBS ON)
54 add_definitions(-DBOOST_ALL_NO_LIB)
57 find_package(Boost 1.41.0 COMPONENTS thread system program_options regex REQUIRED)
58 link_directories(${Boost_LIBRARY_DIRS})
59 include_directories(${Boost_INCLUDE_DIRS})
61 find_package(OpenSSL REQUIRED)
62 include_directories(${OPENSSL_INCLUDE_DIR})
65 ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/lib ${CMAKE_CURRENT_SOURCE_DIR}/components
66 ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/lib ${CMAKE_CURRENT_BINARY_DIR}/components
69 #set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
72 set(CMAKE_INSTALL_NAME_DIR "@executable_path/../lib/icinga2")
75 if("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
76 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Qunused-arguments")
77 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments")
81 add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
82 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
83 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
86 set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/Bin/${CMAKE_BUILD_TYPE} CACHE PATH "Library output path")
87 set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/Bin/${CMAKE_BUILD_TYPE} CACHE PATH "Executable output path")
89 include(CheckFunctionExists)
90 include(CheckLibraryExists)
91 check_function_exists(vfork HAVE_VFORK)
92 check_function_exists(backtrace_symbols HAVE_BACKTRACE_SYMBOLS)
93 check_function_exists(pipe2 HAVE_PIPE2)
94 check_library_exists(crypto BIO_f_zlib "" HAVE_BIOZLIB)
96 include(GNUInstallDirs)
97 configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h ESCAPE_QUOTES)
100 FILES README COPYING COPYING.Exceptions AUTHORS ChangeLog INSTALL NEWS
101 DESTINATION ${CMAKE_INSTALL_DOCDIR}
107 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
109 add_subdirectory(third-party)
110 add_subdirectory(tools)
111 add_subdirectory(lib)
112 add_subdirectory(components)
113 add_subdirectory(icinga-app)
114 add_subdirectory(etc)
115 add_subdirectory(itl)
116 add_subdirectory(doc)
117 add_subdirectory(test)
118 add_subdirectory(pki)