2 # Copyright (C) 2012-2014 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)
19 set(BOOST_MIN_VERSION "1.41.0")
22 list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
24 if(NOT CMAKE_BUILD_TYPE)
25 set(CMAKE_BUILD_TYPE Release CACHE STRING
26 "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
30 file(STRINGS icinga2.spec VERSION_LINE REGEX "^Version: ")
31 string(REPLACE "Version: " "" ICINGA2_VERSION ${VERSION_LINE})
33 set(ICINGA2_USER "icinga" CACHE STRING "Icinga 2 user")
34 set(ICINGA2_GROUP "icinga" CACHE STRING "Icinga 2 group")
35 set(ICINGA2_COMMAND_USER "icinga" CACHE STRING "Icinga 2 command user")
36 set(ICINGA2_COMMAND_GROUP "icingacmd" CACHE STRING "Icinga 2 command group")
38 file(READ "${CMAKE_CURRENT_SOURCE_DIR}/COPYING" ICINGA2_LICENSE_GPL)
39 file(READ "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.Exceptions" ICINGA2_LICENSE_ADDITIONS)
40 set(ICINGA2_LICENSE "${ICINGA2_LICENSE_GPL}\n\n---\n\n${ICINGA2_LICENSE_ADDITIONS}")
41 file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt" ${ICINGA2_LICENSE})
43 set(CPACK_PACKAGE_CONTACT "Icinga Development Team")
44 set(CPACK_PACKAGE_VERSION ${ICINGA2_VERSION})
45 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt")
46 set(CPACK_WIX_UPGRADE_GUID "68C75073-7CEF-4FC9-8DA5-581758729696")
47 set(CPACK_SOURCE_IGNORE_FILES "/.git/" "/debian/" "/.vagrant/" "/release/" "/debug/" "/build/" )
50 include(GetGitRevisionDescription)
51 git_describe(GIT_VERSION --tags)
52 if(GIT_VERSION MATCHES "-NOTFOUND$")
53 configure_file(icinga-version.h.fallback ${CMAKE_CURRENT_BINARY_DIR}/icinga-version.h COPYONLY)
55 configure_file(icinga-version.h.cmake icinga-version.h)
56 configure_file(${CMAKE_CURRENT_BINARY_DIR}/icinga-version.h ${CMAKE_CURRENT_SOURCE_DIR}/icinga-version.h.fallback COPYONLY)
60 set(Boost_USE_STATIC_LIBS ON)
61 add_definitions(-DBOOST_ALL_NO_LIB)
64 find_package(Boost ${BOOST_MIN_VERSION} COMPONENTS thread system program_options regex REQUIRED)
66 link_directories(${Boost_LIBRARY_DIRS})
67 include_directories(${Boost_INCLUDE_DIRS})
69 find_package(OpenSSL REQUIRED)
70 include_directories(${OPENSSL_INCLUDE_DIR})
73 ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/lib ${CMAKE_CURRENT_SOURCE_DIR}/components
74 ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/lib ${CMAKE_CURRENT_BINARY_DIR}/components
77 #set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
80 set(CMAKE_INSTALL_NAME_DIR "@executable_path/../lib/icinga2")
83 if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
84 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Qunused-arguments -g")
85 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments -g")
88 if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
89 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
90 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
94 add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
95 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
96 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
99 set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/Bin/${CMAKE_BUILD_TYPE} CACHE PATH "Library output path")
100 set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/Bin/${CMAKE_BUILD_TYPE} CACHE PATH "Executable output path")
102 include(CheckFunctionExists)
103 include(CheckLibraryExists)
104 check_function_exists(vfork HAVE_VFORK)
105 check_function_exists(backtrace_symbols HAVE_BACKTRACE_SYMBOLS)
106 check_function_exists(pipe2 HAVE_PIPE2)
107 check_library_exists(dl dladdr "dlfcn.h" HAVE_DLADDR)
108 check_library_exists(crypto BIO_f_zlib "" HAVE_BIOZLIB)
110 include(GNUInstallDirs)
111 configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h ESCAPE_QUOTES)
114 FILES README COPYING COPYING.Exceptions AUTHORS ChangeLog INSTALL NEWS
115 DESTINATION ${CMAKE_INSTALL_DOCDIR}
121 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
123 add_subdirectory(third-party)
124 add_subdirectory(tools)
125 add_subdirectory(lib)
126 add_subdirectory(components)
127 add_subdirectory(icinga-app)
128 add_subdirectory(etc)
129 add_subdirectory(itl)
130 add_subdirectory(doc)
131 add_subdirectory(test)
132 add_subdirectory(pki)