Implement CMake options for some of the modules

fixes #7794
fixes #7795
This commit is contained in:
Gunnar Beutner 2014-12-19 09:45:35 +01:00
parent 23acc2408d
commit cb7f93dc19
14 changed files with 199 additions and 96 deletions

View File

@ -28,8 +28,15 @@ if(NOT CMAKE_BUILD_TYPE)
FORCE)
endif()
option(ICINGA2_WITH_MYSQL "MySQL support" ON)
option(ICINGA2_WITH_PGSQL "PostgreSQL support" ON)
option(ICINGA2_WITH_MYSQL "Build the MySQL IDO module" ON)
option(ICINGA2_WITH_PGSQL "Build the PostgreSQL IDO module" ON)
option(ICINGA2_WITH_CHECKER "Build the checker module" ON)
option(ICINGA2_WITH_COMPAT "Build the compat module" ON)
option(ICINGA2_WITH_DEMO "Build the demo module" OFF)
option(ICINGA2_WITH_HELLO "Build the hello module" OFF)
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)
file(STRINGS icinga2.spec VERSION_LINE REGEX "^Version: ")
string(REPLACE "Version: " "" ICINGA2_VERSION ${VERSION_LINE})

View File

@ -157,6 +157,13 @@ Only use this for special packaging purposes and if you know what you are doing.
Defaults to `OFF`.
- `ICINGA2_WITH_MYSQL`: Determines whether the MySQL IDO module is built; defaults to `ON`
- `ICINGA2_WITH_PGSQL`: Determines whether the PostgreSQL IDO module is built; defaults to `ON`
- `ICINGA2_WITH_CHECKER`: Determines whether the checker module is built; defaults to `ON`
- `ICINGA2_WITH_COMPAT`: Determines whether the compat module is built; defaults to `ON`
- `ICINGA2_WITH_DEMO`: Determines whether the demo module is built; defaults to `OFF`
- `ICINGA2_WITH_HELLO`: Determines whether the hello module is built; defaults to `OFF`
- `ICINGA2_WITH_LIVESTATUS`: Determines whether the Livestatus module is built; defaults to `ON`
- `ICINGA2_WITH_NOTIFICATION`: Determines whether the notification module is built; defaults to `ON`
- `ICINGA2_WITH_PERFDATA`: Determines whether the perfdata module is built; defaults to `ON`
### Building Icinga 2 RPMs

View File

@ -55,20 +55,9 @@ install_if_not_exists(icinga2/conf.d/templates.conf ${CMAKE_INSTALL_SYSCONFDIR}/
install_if_not_exists(icinga2/conf.d/timeperiods.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
install_if_not_exists(icinga2/conf.d/users.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
install_if_not_exists(icinga2/features-available/api.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
install_if_not_exists(icinga2/features-available/checker.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
install_if_not_exists(icinga2/features-available/command.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
install_if_not_exists(icinga2/features-available/compatlog.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
install_if_not_exists(icinga2/features-available/debuglog.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
install_if_not_exists(icinga2/features-available/gelf.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
install_if_not_exists(icinga2/features-available/graphite.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
install_if_not_exists(icinga2/features-available/icingastatus.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
install_if_not_exists(icinga2/features-available/ido-mysql.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
install_if_not_exists(icinga2/features-available/ido-pgsql.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
install_if_not_exists(icinga2/features-available/livestatus.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
install_if_not_exists(icinga2/features-available/mainlog.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
install_if_not_exists(icinga2/features-available/notification.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
install_if_not_exists(icinga2/features-available/perfdata.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
install_if_not_exists(icinga2/features-available/statusdata.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
install_if_not_exists(icinga2/features-available/syslog.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
install_if_not_exists(icinga2/scripts/mail-host-notification.sh ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/scripts)
install_if_not_exists(icinga2/scripts/mail-service-notification.sh ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/scripts)
@ -84,8 +73,6 @@ install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SYSCONFDI
if(NOT WIN32)
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SYSCONFDIR}/icinga2/features-enabled\")")
install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink ../features-available/checker.conf \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SYSCONFDIR}/icinga2/features-enabled/checker.conf\")")
install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink ../features-available/notification.conf \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SYSCONFDIR}/icinga2/features-enabled/notification.conf\")")
install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink ../features-available/mainlog.conf \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SYSCONFDIR}/icinga2/features-enabled/mainlog.conf\")")
install(
@ -94,8 +81,7 @@ if(NOT WIN32)
)
else()
install(
FILES icinga2/features-enabled/checker.conf icinga2/features-enabled/notification.conf
icinga2/features-enabled/mainlog.conf
FILES icinga2/features-enabled/mainlog.conf
DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-enabled
)
endif()

View File

@ -18,23 +18,46 @@
add_subdirectory(base)
add_subdirectory(cli)
add_subdirectory(config)
add_subdirectory(icinga)
add_subdirectory(db_ido)
add_subdirectory(methods)
add_subdirectory(hello)
add_subdirectory(remote)
add_subdirectory(checker)
add_subdirectory(compat)
add_subdirectory(icinga)
add_subdirectory(methods)
if(ICINGA2_WITH_HELLO)
add_subdirectory(hello)
endif()
if(ICINGA2_WITH_CHECKER)
add_subdirectory(checker)
endif()
if(ICINGA2_WITH_COMPAT)
add_subdirectory(compat)
endif()
if(ICINGA2_WITH_MYSQL OR ICINGA2_WITH_PGSQL)
add_subdirectory(db_ido)
endif()
if(ICINGA2_WITH_MYSQL)
add_subdirectory(db_ido_mysql)
add_subdirectory(db_ido_mysql)
endif()
if(ICINGA2_WITH_PGSQL)
add_subdirectory(db_ido_pgsql)
add_subdirectory(db_ido_pgsql)
endif()
add_subdirectory(demo)
add_subdirectory(livestatus)
add_subdirectory(notification)
add_subdirectory(perfdata)
if(ICINGA2_WITH_DEMO)
add_subdirectory(demo)
endif()
if(ICINGA2_WITH_LIVESTATUS)
add_subdirectory(livestatus)
endif()
if(ICINGA2_WITH_NOTIFICATION)
add_subdirectory(notification)
endif()
if(ICINGA2_WITH_PERFDATA)
add_subdirectory(perfdata)
endif()

View File

@ -70,6 +70,8 @@ set_target_properties (
FOLDER Lib
)
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/cache/icinga2\")")
install(
TARGETS base
RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}

View File

@ -37,9 +37,23 @@ set_target_properties (
FOLDER Components
)
install_if_not_exists(
${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/checker.conf
${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
)
if(NOT WIN32)
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SYSCONFDIR}/icinga2/features-enabled\")")
install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink ../features-available/checker.conf \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SYSCONFDIR}/icinga2/features-enabled/checker.conf\")")
else()
install(
FILES ${PROJECT_SOURCE_DIR}/etc/icinga2/features-enabled/checker.conf
DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-enabled
)
endif()
install(
TARGETS checker
RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/icinga2
)

View File

@ -42,10 +42,24 @@ set_target_properties (
FOLDER Components
)
install_if_not_exists(
${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/command.conf
${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
)
install_if_not_exists(
${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/compatlog.conf
${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
)
install_if_not_exists(
${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/statusdata.conf
${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
)
install(TARGETS compat RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/icinga2)
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/log/icinga2/compat/archives\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/cache/icinga2\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/spool/icinga2\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_RUNDIR}/icinga2/cmd\")")

View File

@ -18,46 +18,51 @@
find_package(MySQL)
if(MYSQL_FOUND)
mkclass_target(idomysqlconnection.ti idomysqlconnection.thpp)
mkclass_target(idomysqlconnection.ti idomysqlconnection.thpp)
mkembedconfig_target(db_ido_mysql-type.conf db_ido_mysql-type.cpp)
mkembedconfig_target(db_ido_mysql-type.conf db_ido_mysql-type.cpp)
set(db_ido_mysql_SOURCES
idomysqlconnection.cpp idomysqlconnection.thpp db_ido_mysql-type.cpp
)
set(db_ido_mysql_SOURCES
idomysqlconnection.cpp idomysqlconnection.thpp db_ido_mysql-type.cpp
)
if(ICINGA2_UNITY_BUILD)
mkunity_target(db_ido_mysql db_ido_mysql_SOURCES)
endif()
if(ICINGA2_UNITY_BUILD)
mkunity_target(db_ido_mysql db_ido_mysql_SOURCES)
endif()
add_library(db_ido_mysql SHARED ${db_ido_mysql_SOURCES})
add_library(db_ido_mysql SHARED ${db_ido_mysql_SOURCES})
include_directories(${MYSQL_INCLUDE_DIR})
target_link_libraries(db_ido_mysql ${Boost_LIBRARIES} ${MYSQL_CLIENT_LIBS} base config icinga db_ido)
include_directories(${MYSQL_INCLUDE_DIR})
target_link_libraries(db_ido_mysql ${Boost_LIBRARIES} ${MYSQL_CLIENT_LIBS} base config icinga db_ido)
set_target_properties (
db_ido_mysql PROPERTIES
INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
FOLDER Components
)
set_target_properties (
db_ido_mysql PROPERTIES
INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
FOLDER Components
)
install(
TARGETS db_ido_mysql
RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
)
install_if_not_exists(
${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/ido-mysql.conf
${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
)
install(
DIRECTORY schema
DESTINATION ${CMAKE_INSTALL_DATADIR}/icinga2-ido-mysql
FILES_MATCHING PATTERN "*.sql"
)
install(
TARGETS db_ido_mysql
RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
)
install(
DIRECTORY schema/upgrade
DESTINATION ${CMAKE_INSTALL_DATADIR}/icinga2-ido-mysql/schema
FILES_MATCHING PATTERN "*.sql"
)
install(
DIRECTORY schema
DESTINATION ${CMAKE_INSTALL_DATADIR}/icinga2-ido-mysql
FILES_MATCHING PATTERN "*.sql"
)
install(
DIRECTORY schema/upgrade
DESTINATION ${CMAKE_INSTALL_DATADIR}/icinga2-ido-mysql/schema
FILES_MATCHING PATTERN "*.sql"
)
else()
message(FATAL_ERROR "You have selected MySQL support, but MySQL could not be found. You can disable the MySQL IDO module using -DICINGA2_WITH_MYSQL=OFF.")
message(FATAL_ERROR "You have selected MySQL support, but MySQL could not be found. You can disable the MySQL IDO module using -DICINGA2_WITH_MYSQL=OFF.")
endif()

View File

@ -18,48 +18,53 @@
find_package(PostgreSQL)
if(PostgreSQL_FOUND)
mkclass_target(idopgsqlconnection.ti idopgsqlconnection.thpp)
mkclass_target(idopgsqlconnection.ti idopgsqlconnection.thpp)
mkembedconfig_target(db_ido_pgsql-type.conf db_ido_pgsql-type.cpp)
mkembedconfig_target(db_ido_pgsql-type.conf db_ido_pgsql-type.cpp)
link_directories(${PostgreSQL_LIBRARY_DIRS})
include_directories(${PostgreSQL_INCLUDE_DIRS})
link_directories(${PostgreSQL_LIBRARY_DIRS})
include_directories(${PostgreSQL_INCLUDE_DIRS})
set(db_ido_pgsql_SOURCES
idopgsqlconnection.cpp idopgsqlconnection.thpp db_ido_pgsql-type.cpp
)
set(db_ido_pgsql_SOURCES
idopgsqlconnection.cpp idopgsqlconnection.thpp db_ido_pgsql-type.cpp
)
if(ICINGA2_UNITY_BUILD)
mkunity_target(db_ido_pgsql db_ido_pgsql_SOURCES)
endif()
if(ICINGA2_UNITY_BUILD)
mkunity_target(db_ido_pgsql db_ido_pgsql_SOURCES)
endif()
add_library(db_ido_pgsql SHARED ${db_ido_pgsql_SOURCES})
add_library(db_ido_pgsql SHARED ${db_ido_pgsql_SOURCES})
target_link_libraries(db_ido_pgsql ${Boost_LIBRARIES} ${PostgreSQL_LIBRARIES} base config icinga db_ido)
target_link_libraries(db_ido_pgsql ${Boost_LIBRARIES} ${PostgreSQL_LIBRARIES} base config icinga db_ido)
set_target_properties (
db_ido_pgsql PROPERTIES
INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
FOLDER Components
)
set_target_properties (
db_ido_pgsql PROPERTIES
INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
FOLDER Components
)
install(
TARGETS db_ido_pgsql
RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
)
install_if_not_exists(
${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/ido-pgsql.conf
${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
)
install(
DIRECTORY schema
DESTINATION ${CMAKE_INSTALL_DATADIR}/icinga2-ido-pgsql
FILES_MATCHING PATTERN "*.sql"
)
install(
TARGETS db_ido_pgsql
RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
)
install(
DIRECTORY schema/upgrade
DESTINATION ${CMAKE_INSTALL_DATADIR}/icinga2-ido-pgsql/schema
FILES_MATCHING PATTERN "*.sql"
)
install(
DIRECTORY schema
DESTINATION ${CMAKE_INSTALL_DATADIR}/icinga2-ido-pgsql
FILES_MATCHING PATTERN "*.sql"
)
install(
DIRECTORY schema/upgrade
DESTINATION ${CMAKE_INSTALL_DATADIR}/icinga2-ido-pgsql/schema
FILES_MATCHING PATTERN "*.sql"
)
else()
message(FATAL_ERROR "You have selected PostgreSQL support, but PostgreSQL could not be found. You can disable the PostgreSQL IDO module using -DICINGA2_WITH_PGSQL=OFF.")
message(FATAL_ERROR "You have selected PostgreSQL support, but PostgreSQL could not be found. You can disable the PostgreSQL IDO module using -DICINGA2_WITH_PGSQL=OFF.")
endif()

View File

@ -42,3 +42,4 @@ install(
RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/icinga2
)

View File

@ -42,3 +42,4 @@ install(
RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/icinga2
)

View File

@ -47,4 +47,10 @@ set_target_properties (
FOLDER Components
)
install_if_not_exists(
${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/livestatus.conf
${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
)
install(TARGETS livestatus RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/icinga2)

View File

@ -37,4 +37,20 @@ set_target_properties (
FOLDER Components
)
install_if_not_exists(
${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/notification.conf
${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
)
if(NOT WIN32)
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SYSCONFDIR}/icinga2/features-enabled\")")
install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink ../features-available/notification.conf \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SYSCONFDIR}/icinga2/features-enabled/notification.conf\")")
else()
install(
FILES ${PROJECT_SOURCE_DIR}/etc/icinga2/features-enabled/notification.conf
DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-enabled
)
endif()
install(TARGETS notification RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/icinga2)

View File

@ -39,6 +39,21 @@ set_target_properties (
FOLDER Components
)
install_if_not_exists(
${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/gelf.conf
${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
)
install_if_not_exists(
${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/graphite.conf
${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
)
install_if_not_exists(
${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/perfdata.conf
${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
)
install(
TARGETS perfdata
RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
@ -47,3 +62,4 @@ install(
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/spool/icinga2/perfdata\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/spool/icinga2/tmp\")")