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)
+ "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
+ FORCE)
endif()
option(ICINGA2_WITH_MYSQL "Build the MySQL IDO module" ON)
option(ICINGA2_WITH_LIVESTATUS "Build the Livestatus module" ON)
option(ICINGA2_WITH_NOTIFICATION "Build the notification module" ON)
option(ICINGA2_WITH_PERFDATA "Build the perfdata module" ON)
-option(ICINGA2_WITH_STUDIO "Build the Icinga Studio application" OFF)
option(ICINGA2_WITH_TESTS "Run unit tests" ON)
-file(STRINGS icinga2.spec VERSION_LINE REGEX "^Version: ")
+option (USE_SYSTEMD
+ "Configure icinga as native systemd service instead of a SysV initscript" OFF)
+
+set(HAVE_SYSTEMD ${USE_SYSTEMD})
+
+file(STRINGS VERSION VERSION_LINE REGEX "^Version: ")
string(REPLACE "Version: " "" ICINGA2_VERSION ${VERSION_LINE})
include(GNUInstallDirs)
set(ICINGA2_UNITY_BUILD ON CACHE BOOL "Whether to perform a unity build")
set(ICINGA2_LTO_BUILD OFF CACHE BOOL "Whether to use LTO")
+if(NOT WIN32)
+ set(ICINGA2_SYSCONFIGFILE "${CMAKE_INSTALL_FULL_SYSCONFDIR}/sysconfig/icinga2" CACHE PATH "where to store configuation for the init system, defaults to /etc/sysconfig/icinga2")
+
+endif()
+
site_name(ICINGA2_BUILD_HOST_NAME)
set(ICINGA2_BUILD_COMPILER_NAME "${CMAKE_CXX_COMPILER_ID}")
set(ICINGA2_BUILD_COMPILER_VERSION "${CMAKE_CXX_COMPILER_VERSION}")
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})
-file(STRINGS icinga2.spec SPEC_VERSION REGEX "^Version:")
+file(STRINGS VERSION SPEC_VERSION REGEX "^Version:")
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)
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_REVISION REGEX "^%define revision ")
+ file(STRINGS VERSION SPEC_REVISION REGEX "^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)
+ math(EXPR SPEC_REVISION_LENGTH "${SPEC_REVISION_LENGTH} - 10")
+ string(SUBSTRING ${SPEC_REVISION} 10 ${SPEC_REVISION_LENGTH} SPEC_REVISION)
set(GIT_VERSION "r${SPEC_VERSION}-${SPEC_REVISION}")
endif()
find_package(OpenSSL REQUIRED)
include_directories(${OPENSSL_INCLUDE_DIR})
+set(base_DEPS ${CMAKE_DL_LIBS} ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES})
+set(base_OBJS $<TARGET_OBJECTS:mmatch> $<TARGET_OBJECTS:socketpair> $<TARGET_OBJECTS:base>)
+
find_package(YAJL)
if(NOT YAJL_FOUND)
include_directories(${icinga2_BINARY_DIR}/third-party/yajl/include)
link_directories(${icinga2_BINARY_DIR}/third-party/yajl)
- set(YAJL_LIBRARIES "yajl")
+ list(APPEND base_OBJS $<TARGET_OBJECTS:yajl>)
+else()
+ list(APPEND base_DEPS ${YAJL_LIBRARIES})
endif()
find_package(Editline)
${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/lib
)
+if(HAVE_LIBEXECINFO)
+ list(APPEND base_DEPS execinfo)
+endif()
+
+if(UNIX OR CYGWIN)
+ list(APPEND base_OBJS $<TARGET_OBJECTS:execvpe>)
+endif()
+
+if(HAVE_SYSTEMD)
+ list(APPEND base_DEPS systemd)
+endif()
+
+
+if(EDITLINE_FOUND)
+ list(APPEND base_DEPS ${EDITLINE_LIBRARIES})
+ include_directories(${EDITLINE_INCLUDE_DIR})
+endif()
+
+if(TERMCAP_FOUND)
+ list(APPEND base_DEPS ${TERMCAP_LIBRARIES})
+ include_directories(${TERMCAP_INCLUDE_DIR})
+endif()
+
+if(WIN32)
+ list(APPEND base_DEPS ws2_32 dbghelp shlwapi msi)
+endif()
+
set(CMAKE_MACOSX_RPATH 1)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
endif()
endif()
-if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
- function(add_whole_static_library target library)
- target_link_libraries(${target} -force_load ${library})
- endfunction()
-elseif(MSVC)
- function(add_whole_static_library target library)
- target_link_libraries(${target} ${library})
- set_property(TARGET ${target} APPEND_STRING PROPERTY LINK_FLAGS "/wholearchive:${library} ")
- endfunction()
-else()
- function(add_whole_static_library target library)
- target_link_libraries(${target} -Wl,--whole-archive ${library} -Wl,--no-whole-archive)
- endfunction()
-endif()
-
include(CheckCXXCompilerFlag)
function(check_cxx_linker_flag flag var)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")
+
+ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9.0) AND NOT OPENBSD)
+ set(CMAKE_AR "gcc-ar")
+ set(CMAKE_RANLIB "gcc-ranlib")
+ endif()
endif()
endif()
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h ESCAPE_QUOTES)
install(
- FILES README.md COPYING COPYING.Exceptions AUTHORS CHANGELOG.md NEWS
+ FILES README.md COPYING AUTHORS CHANGELOG.md NEWS
DESTINATION ${CMAKE_INSTALL_DOCDIR}
)
add_subdirectory(icinga-installer)
endif()
-if(ICINGA2_WITH_STUDIO)
- add_subdirectory(icinga-studio)
-endif()
-
if(ICINGA2_WITH_TESTS)
add_subdirectory(test)
endif()
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/icinga-app\\\\icinga.ico")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt")
-set(CPACK_PACKAGE_EXECUTABLES "Icinga2SetupAgent;Icinga 2 Agent Wizard;icinga-studio;Icinga Studio")
+set(CPACK_PACKAGE_EXECUTABLES "Icinga2SetupAgent;Icinga 2 Agent Wizard")
set(CPACK_WIX_PRODUCT_ICON "${CMAKE_CURRENT_SOURCE_DIR}/icinga-app\\\\icinga.ico")
set(CPACK_WIX_UPGRADE_GUID "52F2BEAA-4DF0-4C3E-ABDC-C0F61DE4DF8A")
set(CPACK_WIX_EXTENSIONS "WixUtilExtension")