# Icinga 2
-# Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)
+# Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
cmake_minimum_required(VERSION 2.6)
+set(BOOST_MIN_VERSION "1.41.0")
+
project(icinga2)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+if(NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE Release CACHE STRING
+ "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
+ FORCE)
+endif()
+
file(STRINGS icinga2.spec VERSION_LINE REGEX "^Version: ")
string(REPLACE "Version: " "" ICINGA2_VERSION ${VERSION_LINE})
-set(ICINGA2_USER "icinga")
-set(ICINGA2_GROUP "icinga")
-set(ICINGA2_COMMAND_USER "icinga")
-set(ICINGA2_COMMAND_GROUP "icingacmd")
+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")
+set(ICINGA2_GIT_VERSION_INFO ON CACHE BOOL "Whether to use git describe")
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})
-set(CPACK_PACKAGE_VERSION ${ICINGA2_VERSION})
-set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt")
-set(CPACK_WIX_UPGRADE_GUID "68C75073-7CEF-4FC9-8DA5-581758729696")
-include(CPack)
-
include(GetGitRevisionDescription)
-set(GIT_VERSION ${CPACK_PACKAGE_VERSION})
git_describe(GIT_VERSION --tags)
-configure_file(icinga-version.h.cmake icinga-version.h)
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/icinga-version.h.force)
+ configure_file(icinga-version.h.force ${CMAKE_CURRENT_BINARY_DIR}/icinga-version.h COPYONLY)
+else()
+ if(NOT ICINGA2_GIT_VERSION_INFO OR GIT_VERSION MATCHES "-NOTFOUND$")
+ file(STRINGS icinga2.spec SPEC_VERSION REGEX "^Version:")
+ string(LENGTH "${SPEC_VERSION}" SPEC_LENGTH)
+ math(EXPR SPEC_LENGTH "${SPEC_LENGTH} - 9")
+ string(SUBSTRING ${SPEC_VERSION} 9 ${SPEC_LENGTH} SPEC_VERSION)
+ set(GIT_VERSION "r${SPEC_VERSION}")
+ endif()
+ configure_file(icinga-version.h.cmake icinga-version.h)
+endif()
if(WIN32)
set(Boost_USE_STATIC_LIBS ON)
add_definitions(-DBOOST_ALL_NO_LIB)
endif()
-find_package(Boost 1.41.0 COMPONENTS thread system program_options REQUIRED)
+find_package(Boost ${BOOST_MIN_VERSION} COMPONENTS thread system program_options regex REQUIRED)
+
link_directories(${Boost_LIBRARY_DIRS})
include_directories(${Boost_INCLUDE_DIRS})
set(CMAKE_INSTALL_NAME_DIR "@executable_path/../lib/icinga2")
endif(APPLE)
+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()
+
+if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
+ 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()
+endif()
+
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
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")
include(CheckFunctionExists)
+include(CheckLibraryExists)
check_function_exists(vfork HAVE_VFORK)
check_function_exists(backtrace_symbols HAVE_BACKTRACE_SYMBOLS)
check_function_exists(pipe2 HAVE_PIPE2)
-check_function_exists(BIO_f_zlib HAVE_BIOZLIB)
+check_library_exists(dl dladdr "dlfcn.h" HAVE_DLADDR)
+check_library_exists(execinfo backtrace_symbols "" HAVE_LIBEXECINFO)
+
+if(HAVE_LIBEXECINFO)
+ set(HAVE_BACKTRACE_SYMBOLS TRUE)
+endif()
include(GNUInstallDirs)
-configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
+configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h ESCAPE_QUOTES)
install(
FILES README COPYING COPYING.Exceptions AUTHORS ChangeLog INSTALL NEWS
add_subdirectory(itl)
add_subdirectory(doc)
add_subdirectory(test)
-add_subdirectory(pki)
\ No newline at end of file
+add_subdirectory(pki)
+
+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")
+set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "nsExec::Exec '\\\"$INSTDIR\\\\sbin\\\\icinga2\\\" --scm-uninstall'")
+
+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()
+
+include(CPack)