From eb091a87b0a15b3a73de7f75cda465da171222bf Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Sat, 30 Aug 2014 18:08:28 +0200 Subject: [PATCH] Implement support for unity builds fixes #7034 fixes #7035 --- CMakeLists.txt | 1 + INSTALL.md | 1 + components/checker/CMakeLists.txt | 10 +++++- components/compat/CMakeLists.txt | 12 ++++++- components/db_ido_mysql/CMakeLists.txt | 10 +++++- components/db_ido_pgsql/CMakeLists.txt | 10 +++++- components/demo/CMakeLists.txt | 10 +++++- components/livestatus/CMakeLists.txt | 12 +++++-- components/notification/CMakeLists.txt | 10 +++++- components/perfdata/CMakeLists.txt | 10 +++++- config.h.cmake | 2 ++ lib/base/CMakeLists.txt | 10 ++++-- lib/base/i2-base.hpp | 4 +-- lib/base/initialize.hpp | 4 +-- lib/base/type.hpp | 5 +-- lib/base/utility.hpp | 7 ++++ lib/config/CMakeLists.txt | 8 ++++- lib/db_ido/CMakeLists.txt | 8 ++++- lib/hello/CMakeLists.txt | 8 ++++- lib/icinga/CMakeLists.txt | 8 ++++- lib/methods/CMakeLists.txt | 8 ++++- lib/remote/CMakeLists.txt | 8 ++++- test/CMakeLists.txt | 18 +++++++--- tools/CMakeLists.txt | 1 + tools/mkunity/CMakeLists.txt | 47 ++++++++++++++++++++++++++ tools/mkunity/mkunity.c | 37 ++++++++++++++++++++ 26 files changed, 241 insertions(+), 28 deletions(-) create mode 100644 tools/mkunity/CMakeLists.txt create mode 100644 tools/mkunity/mkunity.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 19518eba1..5dfbd11c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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_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) diff --git a/INSTALL.md b/INSTALL.md index 893233cf4..ead71cfad 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -139,6 +139,7 @@ variables are supported: - `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` diff --git a/components/checker/CMakeLists.txt b/components/checker/CMakeLists.txt index 1790ecc31..2c60df751 100644 --- a/components/checker/CMakeLists.txt +++ b/components/checker/CMakeLists.txt @@ -19,7 +19,15 @@ mkclass_target(checkercomponent.ti checkercomponent.thpp) 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) diff --git a/components/compat/CMakeLists.txt b/components/compat/CMakeLists.txt index 2efab5f20..ad7f9ec8a 100644 --- a/components/compat/CMakeLists.txt +++ b/components/compat/CMakeLists.txt @@ -22,7 +22,17 @@ mkclass_target(statusdatawriter.ti statusdatawriter.thpp) 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) diff --git a/components/db_ido_mysql/CMakeLists.txt b/components/db_ido_mysql/CMakeLists.txt index 59f2def0e..a2799ac39 100644 --- a/components/db_ido_mysql/CMakeLists.txt +++ b/components/db_ido_mysql/CMakeLists.txt @@ -22,7 +22,15 @@ if(MYSQL_FOUND) 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) diff --git a/components/db_ido_pgsql/CMakeLists.txt b/components/db_ido_pgsql/CMakeLists.txt index 7e589a27e..0136a6d5a 100644 --- a/components/db_ido_pgsql/CMakeLists.txt +++ b/components/db_ido_pgsql/CMakeLists.txt @@ -25,7 +25,15 @@ if(PostgreSQL_FOUND) 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) diff --git a/components/demo/CMakeLists.txt b/components/demo/CMakeLists.txt index 5bd7b94f3..ac926c9d0 100644 --- a/components/demo/CMakeLists.txt +++ b/components/demo/CMakeLists.txt @@ -19,7 +19,15 @@ mkclass_target(demo.ti demo.thpp) 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) diff --git a/components/livestatus/CMakeLists.txt b/components/livestatus/CMakeLists.txt index 42d268271..38b5915fb 100644 --- a/components/livestatus/CMakeLists.txt +++ b/components/livestatus/CMakeLists.txt @@ -19,7 +19,8 @@ mkclass_target(livestatuslistener.ti livestatuslistener.thpp) 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 @@ -29,7 +30,14 @@ add_library(livestatus SHARED aggregator.cpp andfilter.cpp attributefilter.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) diff --git a/components/notification/CMakeLists.txt b/components/notification/CMakeLists.txt index cff9f0505..8da77f79d 100644 --- a/components/notification/CMakeLists.txt +++ b/components/notification/CMakeLists.txt @@ -19,7 +19,15 @@ mkclass_target(notificationcomponent.ti notificationcomponent.thpp) 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) diff --git a/components/perfdata/CMakeLists.txt b/components/perfdata/CMakeLists.txt index 0914923cc..16dda3518 100644 --- a/components/perfdata/CMakeLists.txt +++ b/components/perfdata/CMakeLists.txt @@ -20,7 +20,15 @@ mkclass_target(perfdatawriter.ti perfdatawriter.thpp) 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) diff --git a/config.h.cmake b/config.h.cmake index cde13a173..8f0f3f349 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -7,6 +7,8 @@ #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}" diff --git a/lib/base/CMakeLists.txt b/lib/base/CMakeLists.txt index 4dbf4d2fe..fa79a8dc1 100644 --- a/lib/base/CMakeLists.txt +++ b/lib/base/CMakeLists.txt @@ -22,7 +22,7 @@ mkclass_target(logger.ti logger.thpp) 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 @@ -35,10 +35,16 @@ add_library(base SHARED 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) diff --git a/lib/base/i2-base.hpp b/lib/base/i2-base.hpp index 3d5f5baf9..19f203634 100644 --- a/lib/base/i2-base.hpp +++ b/lib/base/i2-base.hpp @@ -56,10 +56,10 @@ # 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 diff --git a/lib/base/initialize.hpp b/lib/base/initialize.hpp index ceb355450..5baf050e7 100644 --- a/lib/base/initialize.hpp +++ b/lib/base/initialize.hpp @@ -35,9 +35,9 @@ inline bool InitializeOnceHelper(InitializeFunc func) } #define INITIALIZE_ONCE(func) \ - namespace { \ + namespace { namespace TOKENPASTE2(io, __COUNTER__) { \ I2_EXPORT bool l_InitializeOnce(icinga::InitializeOnceHelper(func)); \ - } + } } } diff --git a/lib/base/type.hpp b/lib/base/type.hpp index b4966c0a9..4656796ac 100644 --- a/lib/base/type.hpp +++ b/lib/base/type.hpp @@ -24,6 +24,7 @@ #include "base/qstring.hpp" #include "base/object.hpp" #include "base/initialize.hpp" +#include "base/utility.hpp" #include namespace icinga @@ -99,7 +100,7 @@ struct FactoryHelper }; #define REGISTER_TYPE(type) \ - namespace { \ + namespace { namespace TOKENPASTE2(rt, __COUNTER__) { \ void RegisterType(void) \ { \ icinga::Type *t = new TypeImpl(); \ @@ -108,7 +109,7 @@ struct FactoryHelper } \ \ INITIALIZE_ONCE(RegisterType); \ - } + } } } diff --git a/lib/base/utility.hpp b/lib/base/utility.hpp index c49beeb54..bd3dc8021 100644 --- a/lib/base/utility.hpp +++ b/lib/base/utility.hpp @@ -30,6 +30,13 @@ 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 diff --git a/lib/config/CMakeLists.txt b/lib/config/CMakeLists.txt index 30dafd5a2..1929b824a 100644 --- a/lib/config/CMakeLists.txt +++ b/lib/config/CMakeLists.txt @@ -26,13 +26,19 @@ mkembedconfig_target(base-type.conf base-type.cpp) 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 ( diff --git a/lib/db_ido/CMakeLists.txt b/lib/db_ido/CMakeLists.txt index 43f7b6548..222d906f1 100644 --- a/lib/db_ido/CMakeLists.txt +++ b/lib/db_ido/CMakeLists.txt @@ -19,7 +19,7 @@ mkclass_target(dbconnection.ti dbconnection.thpp) 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 @@ -27,6 +27,12 @@ add_library(db_ido SHARED 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) diff --git a/lib/hello/CMakeLists.txt b/lib/hello/CMakeLists.txt index 04dda7071..ce92e30f0 100644 --- a/lib/hello/CMakeLists.txt +++ b/lib/hello/CMakeLists.txt @@ -19,10 +19,16 @@ mkclass_target(hello.ti hello.thpp) 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 ( diff --git a/lib/icinga/CMakeLists.txt b/lib/icinga/CMakeLists.txt index 95363441f..cc61297c3 100644 --- a/lib/icinga/CMakeLists.txt +++ b/lib/icinga/CMakeLists.txt @@ -40,7 +40,7 @@ mkclass_target(user.ti user.thpp) 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 @@ -54,6 +54,12 @@ add_library(icinga SHARED 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 ( diff --git a/lib/methods/CMakeLists.txt b/lib/methods/CMakeLists.txt index 3ec48730c..35b557138 100644 --- a/lib/methods/CMakeLists.txt +++ b/lib/methods/CMakeLists.txt @@ -21,13 +21,19 @@ else() 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 ( diff --git a/lib/remote/CMakeLists.txt b/lib/remote/CMakeLists.txt index 5bff6e4da..b30b8dbfa 100644 --- a/lib/remote/CMakeLists.txt +++ b/lib/remote/CMakeLists.txt @@ -21,12 +21,18 @@ mkclass_target(zone.ti zone.thpp) 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) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index cea166d0d..29f480794 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -17,12 +17,20 @@ 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 diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index cc799f845..cefbb7012 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -17,6 +17,7 @@ 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) diff --git a/tools/mkunity/CMakeLists.txt b/tools/mkunity/CMakeLists.txt new file mode 100644 index 000000000..18e331b5c --- /dev/null +++ b/tools/mkunity/CMakeLists.txt @@ -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() + diff --git a/tools/mkunity/mkunity.c b/tools/mkunity/mkunity.c new file mode 100644 index 000000000..fb24fd484 --- /dev/null +++ b/tools/mkunity/mkunity.c @@ -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 +#include + +int main(int argc, char **argv) +{ + int i; + + if (argc < 3) { + fprintf(stderr, "Syntax: %s [ ...]\n", argv[0]); + return EXIT_FAILURE; + } + + for (i = 2; i < argc; i++) { + printf("#include \"%s/%s\"\n", argv[1], argv[i]); + } + + return EXIT_SUCCESS; +} -- 2.40.0