]> granicus.if.org Git - icinga2/blob - CMakeLists.txt
Add cmake build files.
[icinga2] / CMakeLists.txt
1 # Icinga 2
2 # Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)
3 #
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.
8 #
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.
13 #
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.
17
18 cmake_minimum_required(VERSION 2.6)
19 project(icinga2)
20 list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
21
22 file(STRINGS icinga2.spec VERSION_LINE REGEX "^Version: ")
23 string(REPLACE "Version: " "" ICINGA2_VERSION ${VERSION_LINE})
24
25 set(ICINGA2_USER "icinga")
26 set(ICINGA2_GROUP "icinga")
27 set(ICINGA2_COMMAND_USER "icinga")
28 set(ICINGA2_COMMAND_GROUP "icingacmd")
29
30 file(READ "${CMAKE_CURRENT_SOURCE_DIR}/COPYING" ICINGA2_LICENSE_GPL)
31 file(READ "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.Exceptions" ICINGA2_LICENSE_ADDITIONS)
32 set(ICINGA2_LICENSE "${ICINGA2_LICENSE_GPL}\n\n---\n\n${ICINGA2_LICENSE_ADDITIONS}")
33 file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt" ${ICINGA2_LICENSE})
34
35 set(CPACK_PACKAGE_VERSION ${ICINGA2_VERSION})
36 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt")
37 set(CPACK_WIX_UPGRADE_GUID "68C75073-7CEF-4FC9-8DA5-581758729696")
38 include(CPack)
39
40 include(GetGitRevisionDescription)
41 set(GIT_VERSION ${CPACK_PACKAGE_VERSION})
42 git_describe(GIT_VERSION --tags)
43 configure_file(icinga-version.h.cmake icinga-version.h)
44
45 if(WIN32)
46   set(Boost_USE_STATIC_LIBS ON)
47   add_definitions(-DBOOST_ALL_NO_LIB)
48 endif()
49
50 find_package(Boost 1.41.0 COMPONENTS thread system program_options REQUIRED)
51 link_directories(${Boost_LIBRARY_DIRS})
52 include_directories(${Boost_INCLUDE_DIRS})
53
54 find_package(OpenSSL REQUIRED)
55 include_directories(${OPENSSL_INCLUDE_DIR})
56
57 include_directories(
58   ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/lib ${CMAKE_CURRENT_SOURCE_DIR}/components
59   ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/lib ${CMAKE_CURRENT_BINARY_DIR}/components
60 )
61
62 #set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
63
64 if(APPLE)
65   set(CMAKE_INSTALL_NAME_DIR "@executable_path/../lib/icinga2")
66 endif(APPLE)
67
68 if(MSVC)
69   add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
70   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
71   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
72 endif()
73
74 set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/Bin/${CMAKE_BUILD_TYPE} CACHE PATH "Library output path")
75 set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/Bin/${CMAKE_BUILD_TYPE} CACHE PATH "Executable output path")
76
77 include(CheckFunctionExists)
78 check_function_exists(vfork HAVE_VFORK)
79 check_function_exists(backtrace_symbols HAVE_BACKTRACE_SYMBOLS)
80 check_function_exists(pipe2 HAVE_PIPE2)
81 check_function_exists(BIO_f_zlib HAVE_BIOZLIB)
82
83 include(GNUInstallDirs)
84 configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
85
86 install(
87   FILES README COPYING COPYING.Exceptions AUTHORS ChangeLog INSTALL NEWS
88   DESTINATION ${CMAKE_INSTALL_DOCDIR}
89 )
90
91 include(CTest)
92 enable_testing()
93
94 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
95
96 add_subdirectory(third-party)
97 add_subdirectory(tools)
98 add_subdirectory(lib)
99 add_subdirectory(components)
100 add_subdirectory(icinga-app)
101 add_subdirectory(etc)
102 add_subdirectory(itl)
103 add_subdirectory(doc)
104 add_subdirectory(test)
105 add_subdirectory(pki)