set(ICINGA2_RUNDIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/run" CACHE STRING "/run directory")
set(ICINGA2_PLUGINDIR "/usr/lib/nagios/plugins" CACHE STRING "Path for the check plugins")
set(ICINGA2_GIT_VERSION_INFO ON CACHE BOOL "Whether to use git describe")
+set(ICINGA2_UNITY_BUILD OFF CACHE BOOL "Whether to perform a unity build")
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/COPYING" ICINGA2_LICENSE_GPL)
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.Exceptions" ICINGA2_LICENSE_ADDITIONS)
- `ICINGA2_COMMAND_USER`: The command user Icinga 2 should use; defaults to `icinga`
- `ICINGA2_GIT_VERSION_INFO`: Whether to use Git to determine the version number; defaults to `ON`
- `ICINGA2_COMMAND_GROUP`: The command group Icinga 2 should use; defaults to `icingacmd`
+- `ICINGA2_UNITY_BUILD`: Whether to perform a unity build
- `ICINGA2_PLUGINDIR`: The path for the Monitoring Plugins project binaries; defaults to `/usr/lib/nagios/plugins`
- `ICINGA2_RUNDIR`: The location of the "run" directory; defaults to `CMAKE_INSTALL_LOCALSTATEDIR/run`
- `CMAKE_INSTALL_SYSCONFDIR`: The configuration directory; defaults to `CMAKE_INSTALL_PREFIX/etc`
mkembedconfig_target(checker-type.conf checker-type.cpp)
-add_library(checker SHARED checkercomponent.cpp checkercomponent.thpp checker-type.cpp)
+set(checker_SOURCES
+ checkercomponent.cpp checkercomponent.thpp checker-type.cpp
+)
+
+if(ICINGA2_UNITY_BUILD)
+ mkunity_target(checker checker_SOURCES)
+endif()
+
+add_library(checker SHARED ${checker_SOURCES})
target_link_libraries(checker ${Boost_LIBRARIES} base config icinga remote)
mkembedconfig_target(compat-type.conf compat-type.cpp)
-add_library(compat SHARED checkresultreader.cpp checkresultreader.thpp compatlogger.cpp compatlogger.thpp externalcommandlistener.cpp externalcommandlistener.thpp statusdatawriter.cpp statusdatawriter.thpp compat-type.cpp)
+set(compat_SOURCES
+ checkresultreader.cpp checkresultreader.thpp compatlogger.cpp
+ compatlogger.thpp externalcommandlistener.cpp externalcommandlistener.thpp
+ statusdatawriter.cpp statusdatawriter.thpp compat-type.cpp
+)
+
+if(ICINGA2_UNITY_BUILD)
+ mkunity_target(compat compat_SOURCES)
+endif()
+
+add_library(compat SHARED ${compat_SOURCES})
target_link_libraries(compat ${Boost_LIBRARIES} base config icinga)
mkembedconfig_target(db_ido_mysql-type.conf db_ido_mysql-type.cpp)
- add_library(db_ido_mysql SHARED 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()
+
+ 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)
link_directories(${PostgreSQL_LIBRARY_DIRS})
include_directories(${PostgreSQL_INCLUDE_DIRS})
- add_library(db_ido_pgsql SHARED 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()
+
+ 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)
mkembedconfig_target(demo-type.conf demo-type.cpp)
-add_library(demo SHARED demo.cpp demo.thpp demo-type.cpp)
+set(demo_SOURCES
+ demo.cpp demo.thpp demo-type.cpp
+)
+
+if(ICINGA2_UNITY_BUILD)
+ mkunity_target(demo demo_SOURCES)
+endif()
+
+add_library(demo SHARED ${demo_SOURCES})
target_link_libraries(demo ${Boost_LIBRARIES} base config icinga remote)
mkembedconfig_target(livestatus-type.conf livestatus-type.cpp)
-add_library(livestatus SHARED aggregator.cpp andfilter.cpp attributefilter.cpp
+set(livestatus_SOURCES
+ aggregator.cpp andfilter.cpp attributefilter.cpp
avgaggregator.cpp column.cpp combinerfilter.cpp commandstable.cpp
commentstable.cpp contactgroupstable.cpp contactstable.cpp countaggregator.cpp
downtimestable.cpp endpointstable.cpp filter.cpp historytable.cpp
minaggregator.cpp negatefilter.cpp orfilter.cpp
servicegroupstable.cpp servicestable.cpp statehisttable.cpp
statustable.cpp stdaggregator.cpp sumaggregator.cpp table.cpp
- timeperiodstable.cpp livestatus-type.cpp)
+ timeperiodstable.cpp livestatus-type.cpp
+)
+
+if(ICINGA2_UNITY_BUILD)
+ mkunity_target(livestatus livestatus_SOURCES)
+endif()
+
+add_library(livestatus SHARED ${livestatus_SOURCES})
target_link_libraries(livestatus ${Boost_LIBRARIES} base config icinga remote)
mkembedconfig_target(notification-type.conf notification-type.cpp)
-add_library(notification SHARED notificationcomponent.cpp notificationcomponent.thpp notification-type.cpp)
+set(notification_SOURCES
+ notificationcomponent.cpp notificationcomponent.thpp notification-type.cpp
+)
+
+if(ICINGA2_UNITY_BUILD)
+ mkunity_target(notification notification_SOURCES)
+endif()
+
+add_library(notification SHARED ${notification_SOURCES})
target_link_libraries(notification ${Boost_LIBRARIES} base config icinga)
mkembedconfig_target(perfdata-type.conf perfdata-type.cpp)
-add_library(perfdata SHARED graphitewriter.cpp graphitewriter.thpp perfdatawriter.cpp perfdatawriter.thpp perfdata-type.cpp)
+set(perfdata_SOURCES
+ graphitewriter.cpp graphitewriter.thpp perfdatawriter.cpp perfdatawriter.thpp perfdata-type.cpp
+)
+
+if(ICINGA2_UNITY_BUILD)
+ mkunity_target(perfdata perfdata_SOURCES)
+endif()
+
+add_library(perfdata SHARED ${perfdata_SOURCES})
target_link_libraries(perfdata ${Boost_LIBRARIES} base config icinga)
#cmakedefine HAVE_DLADDR
#cmakedefine HAVE_LIBEXECINFO
+#cmakedefine ICINGA2_UNITY_BUILD
+
#define ICINGA_PREFIX "${CMAKE_INSTALL_PREFIX}"
#define ICINGA_SYSCONFDIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}"
#define ICINGA_RUNDIR "${ICINGA2_RUNDIR}"
mkclass_target(streamlogger.ti streamlogger.thpp)
mkclass_target(sysloglogger.ti sysloglogger.thpp)
-add_library(base SHARED
+set(base_SOURCES
application.cpp application.thpp array.cpp context.cpp
convert.cpp dictionary.cpp dynamicobject.cpp dynamicobject.thpp dynamictype.cpp
exception.cpp fifo.cpp filelogger.cpp filelogger.thpp logger.cpp logger.thpp
value-operators.cpp workqueue.cpp
)
+if(ICINGA2_UNITY_BUILD)
+ mkunity_target(base base_SOURCES)
+endif()
+
+add_library(base SHARED ${base_SOURCES})
+
target_link_libraries(base ${CMAKE_DL_LIBS} ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} cJSON mmatch)
if(HAVE_LIBEXECINFO)
- target_link_libraries(base execinfo)
+ target_link_libraries(base execinfo)
endif()
include_directories(${icinga2_SOURCE_DIR}/third-party/cJSON)
# pragma warning(disable:4251)
# pragma warning(disable:4275)
# pragma warning(disable:4345)
-#else /* _MSC_VER */
-# include "config.h"
#endif /* _MSC_VER */
+#include "config.h"
+
#ifdef _WIN32
# include "base/win32.hpp"
#else
}
#define INITIALIZE_ONCE(func) \
- namespace { \
+ namespace { namespace TOKENPASTE2(io, __COUNTER__) { \
I2_EXPORT bool l_InitializeOnce(icinga::InitializeOnceHelper(func)); \
- }
+ } }
}
#include "base/qstring.hpp"
#include "base/object.hpp"
#include "base/initialize.hpp"
+#include "base/utility.hpp"
#include <boost/function.hpp>
namespace icinga
};
#define REGISTER_TYPE(type) \
- namespace { \
+ namespace { namespace TOKENPASTE2(rt, __COUNTER__) { \
void RegisterType(void) \
{ \
icinga::Type *t = new TypeImpl<type>(); \
} \
\
INITIALIZE_ONCE(RegisterType); \
- }
+ } }
}
namespace icinga
{
+#define TOKENPASTE(x, y) x ## y
+#define TOKENPASTE2(x, y) TOKENPASTE(x, y)
+
+#if defined(ICINGA2_UNITY_BUILD) && !defined(__COUNTER__)
+# error "Your compiler needs to support __COUNTER__ in order to do unity builds."
+#endif /* ICINGA2_UNITY_BUILD && !defined(__COUNTER__) */
+
#ifdef _WIN32
#define MS_VC_EXCEPTION 0x406D1388
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
-add_library(config SHARED
+set(config_SOURCES
aexpression.cpp applyrule.cpp base-type.conf base-type.cpp
configcompilercontext.cpp configcompiler.cpp configerror.cpp configitembuilder.cpp
configitem.cpp ${FLEX_config_lexer_OUTPUTS} ${BISON_config_parser_OUTPUTS}
configtype.cpp debuginfo.cpp objectrule.cpp typerule.cpp typerulelist.cpp
)
+if(ICINGA2_UNITY_BUILD)
+ mkunity_target(config config_SOURCES)
+endif()
+
+add_library(config SHARED ${config_SOURCES})
+
target_link_libraries(config ${Boost_LIBRARIES} base)
set_target_properties (
mkembedconfig_target(db_ido-type.conf db_ido-type.cpp)
-add_library(db_ido SHARED
+set(db_ido_SOURCES
commanddbobject.cpp dbconnection.cpp dbconnection.thpp dbconnection.thpp
db_ido-type.cpp dbevents.cpp dbobject.cpp dbquery.cpp dbreference.cpp dbtype.cpp
dbvalue.cpp endpointdbobject.cpp hostdbobject.cpp hostgroupdbobject.cpp
userdbobject.cpp usergroupdbobject.cpp
)
+if(ICINGA2_UNITY_BUILD)
+ mkunity_target(db_ido db_ido_SOURCES)
+endif()
+
+add_library(db_ido SHARED ${db_ido_SOURCES})
+
include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(db_ido ${Boost_LIBRARIES} base config icinga remote)
mkembedconfig_target(hello-type.conf hello-type.cpp)
-add_library(hello SHARED
+set(hello_SOURCES
hello.cpp hello.thpp hello-type.cpp
)
+if(ICINGA2_UNITY_BUILD)
+ mkunity_target(hello hello_SOURCES)
+endif()
+
+add_library(hello SHARED ${hello_SOURCES})
+
target_link_libraries(hello ${Boost_LIBRARIES} base config)
set_target_properties (
mkembedconfig_target(icinga-type.conf icinga-type.cpp)
-add_library(icinga SHARED
+set(icinga_SOURCES
api.cpp apievents.cpp checkable.cpp checkable.thpp checkable-dependency.cpp checkable-downtime.cpp checkable-event.cpp
checkable-flapping.cpp checkcommand.cpp checkcommand.thpp checkresult.cpp checkresult.thpp
cib.cpp command.cpp command.thpp comment.cpp comment.thpp compatutility.cpp dependency.cpp dependency.thpp
user.cpp user.thpp usergroup.cpp usergroup.thpp icinga-type.cpp
)
+if(ICINGA2_UNITY_BUILD)
+ mkunity_target(icinga icinga_SOURCES)
+endif()
+
+add_library(icinga SHARED ${icinga_SOURCES})
+
target_link_libraries(icinga ${Boost_LIBRARIES} base config remote)
set_target_properties (
set(WindowsSources "")
endif()
-add_library(methods SHARED
+set(methods_SOURCES
castfuncs.cpp clusterchecktask.cpp clusterzonechecktask.cpp
icingachecktask.cpp nullchecktask.cpp nulleventtask.cpp
pluginchecktask.cpp plugineventtask.cpp pluginnotificationtask.cpp
randomchecktask.cpp timeperiodtask.cpp ${WindowsSources}
)
+if(ICINGA2_UNITY_BUILD)
+ mkunity_target(methods methods_SOURCES)
+endif()
+
+add_library(methods SHARED ${methods_SOURCES})
+
target_link_libraries(methods ${Boost_LIBRARIES} base config icinga)
set_target_properties (
mkembedconfig_target(remote-type.conf remote-type.cpp)
-add_library(remote SHARED
+set(remote_SOURCES
apiclient.cpp apifunction.cpp apilistener.cpp apilistener-sync.cpp
apilistener.thpp authority.cpp endpoint.cpp endpoint.thpp jsonrpc.cpp
messageorigin.cpp remote-type.cpp zone.cpp zone.thpp
)
+if(ICINGA2_UNITY_BUILD)
+ mkunity_target(remote remote_SOURCES)
+endif()
+
+add_library(remote SHARED ${remote_SOURCES})
+
include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(remote ${Boost_LIBRARIES} base config)
include(BoostTestTargets)
+set(base_test_SOURCES
+ base-array.cpp base-convert.cpp base-dictionary.cpp base-fifo.cpp
+ base-match.cpp base-netstring.cpp base-object.cpp base-serialize.cpp
+ base-shellescape.cpp base-stacktrace.cpp base-stream.cpp
+ base-string.cpp base-timer.cpp base-type.cpp base-value.cpp
+ icinga-perfdata.cpp test.cpp
+)
+
+if(ICINGA2_UNITY_BUILD)
+ mkunity_target(test base_test_SOURCES)
+endif()
+
add_boost_test(base
- SOURCES base-array.cpp base-convert.cpp base-dictionary.cpp base-fifo.cpp
- base-match.cpp base-netstring.cpp base-object.cpp base-serialize.cpp
- base-shellescape.cpp base-stacktrace.cpp base-stream.cpp
- base-string.cpp base-timer.cpp base-type.cpp base-value.cpp
- icinga-perfdata.cpp test.cpp
+ SOURCES test.cpp ${base_test_SOURCES}
LIBRARIES base config icinga
TESTS base_array/construct
base_array/getset
add_subdirectory(mkclass)
add_subdirectory(mkembedconfig)
+add_subdirectory(mkunity)
if(UNIX OR CYGWIN)
configure_file(icinga2-enable-feature.cmake ${CMAKE_CURRENT_BINARY_DIR}/icinga2-enable-feature @ONLY)
--- /dev/null
+# Icinga 2
+# 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
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+add_executable(mkunity mkunity.c)
+
+set_target_properties (
+ mkunity PROPERTIES
+ FOLDER Bin
+)
+
+function(MKUNITY_TARGET Prefix UnityInputRef)
+ set(UnityInput ${${UnityInputRef}})
+ set(UnityOutput ${CMAKE_CURRENT_BINARY_DIR}/${Prefix}_unity.cpp)
+ set(RealSources "")
+ set(UnitySources "")
+ foreach(UnitySource ${UnityInput})
+ if(${UnitySource} MATCHES "\\.cpp\$")
+ list(APPEND UnitySources ${UnitySource})
+ else()
+ list(APPEND RealSources ${UnitySource})
+ endif()
+ endforeach()
+ add_custom_command(
+ OUTPUT ${UnityOutput}
+ COMMAND mkunity
+ ARGS ${Prefix} ${UnitySources} >${UnityOutput}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ DEPENDS mkunity ${UnityInput}
+ )
+ list(APPEND RealSources ${UnityOutput})
+ set(${UnityInputRef} ${RealSources} PARENT_SCOPE)
+endfunction()
+
--- /dev/null
+/******************************************************************************
+ * Icinga 2 *
+ * 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 *
+ * as published by the Free Software Foundation; either version 2 *
+ * of the License, or (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software Foundation *
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ******************************************************************************/
+
+#include <stdlib.h>
+#include <stdio.h>
+
+int main(int argc, char **argv)
+{
+ int i;
+
+ if (argc < 3) {
+ fprintf(stderr, "Syntax: %s <prefix> [<file> ...]\n", argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ for (i = 2; i < argc; i++) {
+ printf("#include \"%s/%s\"\n", argv[1], argv[i]);
+ }
+
+ return EXIT_SUCCESS;
+}