]> granicus.if.org Git - icinga2/commitdiff
Fix build problems with Visual Studio 2017 5855/head
authorGunnar Beutner <gunnar.beutner@icinga.com>
Wed, 13 Dec 2017 10:35:38 +0000 (11:35 +0100)
committerGunnar Beutner <gunnar.beutner@icinga.com>
Thu, 14 Dec 2017 07:55:36 +0000 (08:55 +0100)
CMakeLists.txt
choco/CMakeLists.txt
lib/base/console.cpp
lib/base/functionwrapper.hpp
test/CMakeLists.txt
test/icinga-checkable-flapping.cpp
test/icinga-checkable-test.cpp

index 9af23aef4870f7058e76fa7d58afd8fa7930170f..32c3a26a1b99669f344467f1d599aa8ba7359ecb 100644 (file)
@@ -96,7 +96,8 @@ endif()
 if(WIN32)
   set(Boost_USE_STATIC_LIBS ON)
   add_definitions(-DBOOST_ALL_NO_LIB)
-  add_definitions(/bigobj)
+  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /bigobj")
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
 endif()
 
 if(NOT DEFINED LOGROTATE_HAS_SU)
index 60be372172d6387c5b56a940dbc44ee5a8d16ff8..69c758eabfa601a752d6773ca265cd0a26876821 100644 (file)
@@ -24,6 +24,6 @@ if(WIN32)
   add_custom_target(choco-pkg ALL
     COMMAND choco pack
     COMMAND ${CMAKE_COMMAND} -E rename ${CMAKE_CURRENT_BINARY_DIR}/icinga2.${SPEC_VERSION}.nupkg ${CMAKE_CURRENT_BINARY_DIR}/icinga2.nupkg
-    DEPENDS icinga2.nuspec ${CMAKE_CURRENT_BINARY_DIR}/chocolateyInstall.ps1 chocolateyUninstall.ps1
+    DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/icinga2.nuspec ${CMAKE_CURRENT_BINARY_DIR}/chocolateyInstall.ps1 chocolateyUninstall.ps1
   )
 endif()
index 62dccd2df58eb21222f5b8fe373fdb44090c287c..0578079956c3b4190ada73ae25fa084f4adc36d9 100644 (file)
@@ -25,7 +25,8 @@ using namespace icinga;
 
 static ConsoleType l_ConsoleType = Console_Dumb;
 
-INITIALIZE_ONCE([]() {
+static void InitializeConsole(void)
+{
        l_ConsoleType = Console_Dumb;
 
 #ifndef _WIN32
@@ -34,7 +35,9 @@ INITIALIZE_ONCE([]() {
 #else /* _WIN32 */
        l_ConsoleType = Console_Windows;
 #endif /* _WIN32 */
-})
+}
+
+INITIALIZE_ONCE(InitializeConsole);
 
 ConsoleColorTag::ConsoleColorTag(int color, ConsoleType consoleType)
        : m_Color(color), m_ConsoleType(consoleType)
index a87efeeafff6e7878e661a599b9cf7af50ba25eb..a8cbce913195c4cfc4c2e7a2d9a881d9cd2e6d0d 100644 (file)
@@ -23,6 +23,7 @@
 #include "base/i2-base.hpp"
 #include "base/value.hpp"
 #include <vector>
+#include <boost/function_types/function_arity.hpp>
 #include <type_traits>
 
 using namespace std::placeholders;
@@ -80,9 +81,9 @@ private:
 public:
        template <typename FuncType>
        auto operator () (FuncType f, const std::vector<Value>& args)
-           -> decltype(call(f, args, BuildIndices<boost::function_traits<typename boost::remove_pointer<FuncType>::type>::arity>{}))
+           -> decltype(call(f, args, BuildIndices<boost::function_types::function_arity<typename boost::remove_pointer<FuncType>::type>::value>{}))
        {
-               return call(f, args, BuildIndices<boost::function_traits<typename boost::remove_pointer<FuncType>::type>::arity>{});
+               return call(f, args, BuildIndices<boost::function_types::function_arity<typename boost::remove_pointer<FuncType>::type>::value>{});
        }
 };
 
@@ -96,7 +97,7 @@ std::function<Value (const std::vector<Value>&)> WrapFunction(FuncType function,
     EnableIf<std::is_same<decltype(unpack_caller()(FuncType(), std::vector<Value>())), void>::value>* = 0)
 {
        return [function](const std::vector<Value>& arguments) {
-               constexpr int arity = boost::function_traits<typename boost::remove_pointer<FuncType>::type>::arity;
+               constexpr int arity = boost::function_types::function_arity<typename boost::remove_pointer<FuncType>::type>::value;
 
                if (arguments.size() < arity)
                        BOOST_THROW_EXCEPTION(std::invalid_argument("Too few arguments for function."));
@@ -113,7 +114,7 @@ std::function<Value (const std::vector<Value>&)> WrapFunction(FuncType function,
                EnableIf<!std::is_same<decltype(unpack_caller()(FuncType(), std::vector<Value>())), void>::value>* = 0)
 {
        return [function](const std::vector<Value>& arguments) {
-               constexpr int arity = boost::function_traits<typename boost::remove_pointer<FuncType>::type>::arity;
+               constexpr int arity = boost::function_types::function_arity<typename boost::remove_pointer<FuncType>::type>::value;
 
                if (arity > 0) {
                        if (arguments.size() < arity)
index 2a234419d301ec9dedd032a99295362de04aae02..62f1ce847c0ff14a6098751984ce9ccb2be94c92 100644 (file)
@@ -141,8 +141,12 @@ set(icinga_checkable_test_SOURCES
     icinga-checkable-flapping.cpp
 )
 
+if(ICINGA2_UNITY_BUILD)
+    mkunity_target(icinga_checkable test icinga_checkable_test_SOURCES)
+endif()
+
 add_boost_test(icinga_checkable
-  SOURCES icinga-checkable-test.cpp ${icinga_checkable_test_SOURCES}
+  SOURCES test-runner.cpp icinga-checkable-test.cpp ${icinga_checkable_test_SOURCES}
   LIBRARIES base config icinga cli
   TESTS icinga_checkable_flapping/host_not_flapping
         icinga_checkable_flapping/host_flapping
index 1618fd3eb33ed8d2e0f2791aff53288d4f1cf777..8efc896505f86fa9036bbb15a6df1f6b2990b799 100644 (file)
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
  ******************************************************************************/
 
-#include <boost/test/unit_test.hpp>
-#include <bitset>
 #include "icinga/host.hpp"
+#include <bitset>
 #include <iostream>
+#include <BoostTestTargetConfig.h>
 
 using namespace icinga;
 
@@ -48,7 +48,7 @@ static void LogFlapping(const Checkable::Ptr& obj)
        int oldestIndex = (obj->GetFlappingBuffer() & 0xFF00000) >> 20;
 
     std::cout << "Flapping: " << obj->IsFlapping() << "\nHT: " << obj->GetFlappingThresholdHigh() << " LT: " << obj->GetFlappingThresholdLow()
-       << "\nOur value: " << obj->GetFlappingCurrent() << "\nPtr: " << oldestIndex << " Buf: " << stateChangeBuf << '\n';
+       << "\nOur value: " << obj->GetFlappingCurrent() << "\nPtr: " << oldestIndex << " Buf: " << stateChangeBuf.to_ulong() << '\n';
 }
 
 
index dee1adc8a33800e4d1eac586c6e79576782ace77..9178f85a53e65ba351efc75d396d65fbf6696e6f 100644 (file)
@@ -17,9 +17,6 @@
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
  ******************************************************************************/
 
-#define BOOST_TEST_MAIN
-#define BOOST_TEST_MODULE icinga2_test
-
 #include "cli/daemonutility.hpp"
 #include "base/application.hpp"
 #include "base/loader.hpp"
@@ -35,24 +32,6 @@ struct IcingaCheckableFixture
                BOOST_TEST_MESSAGE("setup running Icinga 2 core");
 
                Application::InitializeBase();
-
-               /* start the Icinga application and load the configuration */
-               Application::DeclareSysconfDir("etc");
-               Application::DeclareLocalStateDir("var");
-
-               ActivationScope ascope;
-
-               Loader::LoadExtensionLibrary("icinga");
-               Loader::LoadExtensionLibrary("methods"); //loaded by ITL
-
-               std::vector<std::string> configs;
-               std::vector<ConfigItem::Ptr> newItems;
-
-               DaemonUtility::LoadConfigFiles(configs, newItems, "icinga2.debug", "icinga2.vars");
-
-               /* ignore config errors */
-               WorkQueue upq;
-               ConfigItem::ActivateItems(upq, newItems);
        }
 
        ~IcingaCheckableFixture(void)