Implement support for unity builds

fixes #7034
fixes #7035
This commit is contained in:
Gunnar Beutner 2014-08-30 18:08:28 +02:00
parent 7ec6564248
commit eb091a87b0
26 changed files with 241 additions and 28 deletions

View File

@ -40,6 +40,7 @@ set(ICINGA2_COMMAND_GROUP "icingacmd" CACHE STRING "Icinga 2 command group")
set(ICINGA2_RUNDIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/run" CACHE STRING "/run directory") 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_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_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" ICINGA2_LICENSE_GPL)
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.Exceptions" ICINGA2_LICENSE_ADDITIONS) file(READ "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.Exceptions" ICINGA2_LICENSE_ADDITIONS)

View File

@ -139,6 +139,7 @@ variables are supported:
- `ICINGA2_COMMAND_USER`: The command user Icinga 2 should use; defaults to `icinga` - `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_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_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_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` - `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` - `CMAKE_INSTALL_SYSCONFDIR`: The configuration directory; defaults to `CMAKE_INSTALL_PREFIX/etc`

View File

@ -19,7 +19,15 @@ mkclass_target(checkercomponent.ti checkercomponent.thpp)
mkembedconfig_target(checker-type.conf checker-type.cpp) 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) target_link_libraries(checker ${Boost_LIBRARIES} base config icinga remote)

View File

@ -22,7 +22,17 @@ mkclass_target(statusdatawriter.ti statusdatawriter.thpp)
mkembedconfig_target(compat-type.conf compat-type.cpp) 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) target_link_libraries(compat ${Boost_LIBRARIES} base config icinga)

View File

@ -22,7 +22,15 @@ if(MYSQL_FOUND)
mkembedconfig_target(db_ido_mysql-type.conf db_ido_mysql-type.cpp) 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}) include_directories(${MYSQL_INCLUDE_DIR})
target_link_libraries(db_ido_mysql ${Boost_LIBRARIES} ${MYSQL_CLIENT_LIBS} base config icinga db_ido) target_link_libraries(db_ido_mysql ${Boost_LIBRARIES} ${MYSQL_CLIENT_LIBS} base config icinga db_ido)

View File

@ -25,7 +25,15 @@ if(PostgreSQL_FOUND)
link_directories(${PostgreSQL_LIBRARY_DIRS}) link_directories(${PostgreSQL_LIBRARY_DIRS})
include_directories(${PostgreSQL_INCLUDE_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) target_link_libraries(db_ido_pgsql ${Boost_LIBRARIES} ${PostgreSQL_LIBRARIES} base config icinga db_ido)

View File

@ -19,7 +19,15 @@ mkclass_target(demo.ti demo.thpp)
mkembedconfig_target(demo-type.conf demo-type.cpp) 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) target_link_libraries(demo ${Boost_LIBRARIES} base config icinga remote)

View File

@ -19,7 +19,8 @@ mkclass_target(livestatuslistener.ti livestatuslistener.thpp)
mkembedconfig_target(livestatus-type.conf livestatus-type.cpp) 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 avgaggregator.cpp column.cpp combinerfilter.cpp commandstable.cpp
commentstable.cpp contactgroupstable.cpp contactstable.cpp countaggregator.cpp commentstable.cpp contactgroupstable.cpp contactstable.cpp countaggregator.cpp
downtimestable.cpp endpointstable.cpp filter.cpp historytable.cpp downtimestable.cpp endpointstable.cpp filter.cpp historytable.cpp
@ -29,7 +30,14 @@ add_library(livestatus SHARED aggregator.cpp andfilter.cpp attributefilter.cpp
minaggregator.cpp negatefilter.cpp orfilter.cpp minaggregator.cpp negatefilter.cpp orfilter.cpp
servicegroupstable.cpp servicestable.cpp statehisttable.cpp servicegroupstable.cpp servicestable.cpp statehisttable.cpp
statustable.cpp stdaggregator.cpp sumaggregator.cpp table.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) target_link_libraries(livestatus ${Boost_LIBRARIES} base config icinga remote)

View File

@ -19,7 +19,15 @@ mkclass_target(notificationcomponent.ti notificationcomponent.thpp)
mkembedconfig_target(notification-type.conf notification-type.cpp) 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) target_link_libraries(notification ${Boost_LIBRARIES} base config icinga)

View File

@ -20,7 +20,15 @@ mkclass_target(perfdatawriter.ti perfdatawriter.thpp)
mkembedconfig_target(perfdata-type.conf perfdata-type.cpp) 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) target_link_libraries(perfdata ${Boost_LIBRARIES} base config icinga)

View File

@ -7,6 +7,8 @@
#cmakedefine HAVE_DLADDR #cmakedefine HAVE_DLADDR
#cmakedefine HAVE_LIBEXECINFO #cmakedefine HAVE_LIBEXECINFO
#cmakedefine ICINGA2_UNITY_BUILD
#define ICINGA_PREFIX "${CMAKE_INSTALL_PREFIX}" #define ICINGA_PREFIX "${CMAKE_INSTALL_PREFIX}"
#define ICINGA_SYSCONFDIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}" #define ICINGA_SYSCONFDIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}"
#define ICINGA_RUNDIR "${ICINGA2_RUNDIR}" #define ICINGA_RUNDIR "${ICINGA2_RUNDIR}"

View File

@ -22,7 +22,7 @@ mkclass_target(logger.ti logger.thpp)
mkclass_target(streamlogger.ti streamlogger.thpp) mkclass_target(streamlogger.ti streamlogger.thpp)
mkclass_target(sysloglogger.ti sysloglogger.thpp) mkclass_target(sysloglogger.ti sysloglogger.thpp)
add_library(base SHARED set(base_SOURCES
application.cpp application.thpp array.cpp context.cpp application.cpp application.thpp array.cpp context.cpp
convert.cpp dictionary.cpp dynamicobject.cpp dynamicobject.thpp dynamictype.cpp convert.cpp dictionary.cpp dynamicobject.cpp dynamicobject.thpp dynamictype.cpp
exception.cpp fifo.cpp filelogger.cpp filelogger.thpp logger.cpp logger.thpp exception.cpp fifo.cpp filelogger.cpp filelogger.thpp logger.cpp logger.thpp
@ -35,6 +35,12 @@ add_library(base SHARED
value-operators.cpp workqueue.cpp 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) target_link_libraries(base ${CMAKE_DL_LIBS} ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} cJSON mmatch)
if(HAVE_LIBEXECINFO) if(HAVE_LIBEXECINFO)

View File

@ -56,10 +56,10 @@
# pragma warning(disable:4251) # pragma warning(disable:4251)
# pragma warning(disable:4275) # pragma warning(disable:4275)
# pragma warning(disable:4345) # pragma warning(disable:4345)
#else /* _MSC_VER */
# include "config.h"
#endif /* _MSC_VER */ #endif /* _MSC_VER */
#include "config.h"
#ifdef _WIN32 #ifdef _WIN32
# include "base/win32.hpp" # include "base/win32.hpp"
#else #else

View File

@ -35,9 +35,9 @@ inline bool InitializeOnceHelper(InitializeFunc func)
} }
#define INITIALIZE_ONCE(func) \ #define INITIALIZE_ONCE(func) \
namespace { \ namespace { namespace TOKENPASTE2(io, __COUNTER__) { \
I2_EXPORT bool l_InitializeOnce(icinga::InitializeOnceHelper(func)); \ I2_EXPORT bool l_InitializeOnce(icinga::InitializeOnceHelper(func)); \
} } }
} }

View File

@ -24,6 +24,7 @@
#include "base/qstring.hpp" #include "base/qstring.hpp"
#include "base/object.hpp" #include "base/object.hpp"
#include "base/initialize.hpp" #include "base/initialize.hpp"
#include "base/utility.hpp"
#include <boost/function.hpp> #include <boost/function.hpp>
namespace icinga namespace icinga
@ -99,7 +100,7 @@ struct FactoryHelper
}; };
#define REGISTER_TYPE(type) \ #define REGISTER_TYPE(type) \
namespace { \ namespace { namespace TOKENPASTE2(rt, __COUNTER__) { \
void RegisterType(void) \ void RegisterType(void) \
{ \ { \
icinga::Type *t = new TypeImpl<type>(); \ icinga::Type *t = new TypeImpl<type>(); \
@ -108,7 +109,7 @@ struct FactoryHelper
} \ } \
\ \
INITIALIZE_ONCE(RegisterType); \ INITIALIZE_ONCE(RegisterType); \
} } }
} }

View File

@ -30,6 +30,13 @@
namespace icinga 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 #ifdef _WIN32
#define MS_VC_EXCEPTION 0x406D1388 #define MS_VC_EXCEPTION 0x406D1388

View File

@ -26,13 +26,19 @@ mkembedconfig_target(base-type.conf base-type.cpp)
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) 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 aexpression.cpp applyrule.cpp base-type.conf base-type.cpp
configcompilercontext.cpp configcompiler.cpp configerror.cpp configitembuilder.cpp configcompilercontext.cpp configcompiler.cpp configerror.cpp configitembuilder.cpp
configitem.cpp ${FLEX_config_lexer_OUTPUTS} ${BISON_config_parser_OUTPUTS} configitem.cpp ${FLEX_config_lexer_OUTPUTS} ${BISON_config_parser_OUTPUTS}
configtype.cpp debuginfo.cpp objectrule.cpp typerule.cpp typerulelist.cpp 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) target_link_libraries(config ${Boost_LIBRARIES} base)
set_target_properties ( set_target_properties (

View File

@ -19,7 +19,7 @@ mkclass_target(dbconnection.ti dbconnection.thpp)
mkembedconfig_target(db_ido-type.conf db_ido-type.cpp) 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 commanddbobject.cpp dbconnection.cpp dbconnection.thpp dbconnection.thpp
db_ido-type.cpp dbevents.cpp dbobject.cpp dbquery.cpp dbreference.cpp dbtype.cpp db_ido-type.cpp dbevents.cpp dbobject.cpp dbquery.cpp dbreference.cpp dbtype.cpp
dbvalue.cpp endpointdbobject.cpp hostdbobject.cpp hostgroupdbobject.cpp dbvalue.cpp endpointdbobject.cpp hostdbobject.cpp hostgroupdbobject.cpp
@ -27,6 +27,12 @@ add_library(db_ido SHARED
userdbobject.cpp usergroupdbobject.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}) include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(db_ido ${Boost_LIBRARIES} base config icinga remote) target_link_libraries(db_ido ${Boost_LIBRARIES} base config icinga remote)

View File

@ -19,10 +19,16 @@ mkclass_target(hello.ti hello.thpp)
mkembedconfig_target(hello-type.conf hello-type.cpp) mkembedconfig_target(hello-type.conf hello-type.cpp)
add_library(hello SHARED set(hello_SOURCES
hello.cpp hello.thpp hello-type.cpp 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) target_link_libraries(hello ${Boost_LIBRARIES} base config)
set_target_properties ( set_target_properties (

View File

@ -40,7 +40,7 @@ mkclass_target(user.ti user.thpp)
mkembedconfig_target(icinga-type.conf icinga-type.cpp) 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 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 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 cib.cpp command.cpp command.thpp comment.cpp comment.thpp compatutility.cpp dependency.cpp dependency.thpp
@ -54,6 +54,12 @@ add_library(icinga SHARED
user.cpp user.thpp usergroup.cpp usergroup.thpp icinga-type.cpp 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) target_link_libraries(icinga ${Boost_LIBRARIES} base config remote)
set_target_properties ( set_target_properties (

View File

@ -21,13 +21,19 @@ else()
set(WindowsSources "") set(WindowsSources "")
endif() endif()
add_library(methods SHARED set(methods_SOURCES
castfuncs.cpp clusterchecktask.cpp clusterzonechecktask.cpp castfuncs.cpp clusterchecktask.cpp clusterzonechecktask.cpp
icingachecktask.cpp nullchecktask.cpp nulleventtask.cpp icingachecktask.cpp nullchecktask.cpp nulleventtask.cpp
pluginchecktask.cpp plugineventtask.cpp pluginnotificationtask.cpp pluginchecktask.cpp plugineventtask.cpp pluginnotificationtask.cpp
randomchecktask.cpp timeperiodtask.cpp ${WindowsSources} 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) target_link_libraries(methods ${Boost_LIBRARIES} base config icinga)
set_target_properties ( set_target_properties (

View File

@ -21,12 +21,18 @@ mkclass_target(zone.ti zone.thpp)
mkembedconfig_target(remote-type.conf remote-type.cpp) mkembedconfig_target(remote-type.conf remote-type.cpp)
add_library(remote SHARED set(remote_SOURCES
apiclient.cpp apifunction.cpp apilistener.cpp apilistener-sync.cpp apiclient.cpp apifunction.cpp apilistener.cpp apilistener-sync.cpp
apilistener.thpp authority.cpp endpoint.cpp endpoint.thpp jsonrpc.cpp apilistener.thpp authority.cpp endpoint.cpp endpoint.thpp jsonrpc.cpp
messageorigin.cpp remote-type.cpp zone.cpp zone.thpp 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}) include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(remote ${Boost_LIBRARIES} base config) target_link_libraries(remote ${Boost_LIBRARIES} base config)

View File

@ -17,12 +17,20 @@
include(BoostTestTargets) include(BoostTestTargets)
add_boost_test(base set(base_test_SOURCES
SOURCES base-array.cpp base-convert.cpp base-dictionary.cpp base-fifo.cpp 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-match.cpp base-netstring.cpp base-object.cpp base-serialize.cpp
base-shellescape.cpp base-stacktrace.cpp base-stream.cpp base-shellescape.cpp base-stacktrace.cpp base-stream.cpp
base-string.cpp base-timer.cpp base-type.cpp base-value.cpp base-string.cpp base-timer.cpp base-type.cpp base-value.cpp
icinga-perfdata.cpp test.cpp icinga-perfdata.cpp test.cpp
)
if(ICINGA2_UNITY_BUILD)
mkunity_target(test base_test_SOURCES)
endif()
add_boost_test(base
SOURCES test.cpp ${base_test_SOURCES}
LIBRARIES base config icinga LIBRARIES base config icinga
TESTS base_array/construct TESTS base_array/construct
base_array/getset base_array/getset

View File

@ -17,6 +17,7 @@
add_subdirectory(mkclass) add_subdirectory(mkclass)
add_subdirectory(mkembedconfig) add_subdirectory(mkembedconfig)
add_subdirectory(mkunity)
if(UNIX OR CYGWIN) if(UNIX OR CYGWIN)
configure_file(icinga2-enable-feature.cmake ${CMAKE_CURRENT_BINARY_DIR}/icinga2-enable-feature @ONLY) configure_file(icinga2-enable-feature.cmake ${CMAKE_CURRENT_BINARY_DIR}/icinga2-enable-feature @ONLY)

View File

@ -0,0 +1,47 @@
# 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()

37
tools/mkunity/mkunity.c Normal file
View File

@ -0,0 +1,37 @@
/******************************************************************************
* 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;
}