set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/Bin/${CMAKE_BUILD_TYPE} CACHE PATH "Library output path")
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/Bin/${CMAKE_BUILD_TYPE} CACHE PATH "Executable output path")
+include(CheckSymbolExists)
include(CheckFunctionExists)
include(CheckLibraryExists)
+
+check_symbol_exists(__COUNTER__ "" HAVE_COUNTER_MACRO)
+
+if(NOT HAVE_COUNTER_MACRO AND ICINGA2_UNITY_BUILD)
+ message(STATUS "Your C/C++ compiler does not support the __COUNTER__ macro. Disabling unity build.")
+ set(ICINGA2_UNITY_BUILD FALSE)
+endif()
+
check_function_exists(vfork HAVE_VFORK)
check_function_exists(backtrace_symbols HAVE_BACKTRACE_SYMBOLS)
check_function_exists(pipe2 HAVE_PIPE2)
#ifndef CONFIG_H
#define CONFIG_H
+#cmakedefine HAVE_COUNTER_MACRO
#cmakedefine HAVE_BACKTRACE_SYMBOLS
#cmakedefine HAVE_PIPE2
#cmakedefine HAVE_VFORK
}
#define INITIALIZE_ONCE(func) \
- namespace { namespace TOKENPASTE2(io, __COUNTER__) { \
+ namespace { namespace UNIQUE_NAME(io) { \
I2_EXPORT bool l_InitializeOnce(icinga::InitializeOnceHelper(func)); \
} }
};
#define REGISTER_TYPE(type) \
- namespace { namespace TOKENPASTE2(rt, __COUNTER__) { \
+ namespace { namespace UNIQUE_NAME(rt) { \
void RegisterType(void) \
{ \
icinga::Type *t = new TypeImpl<type>(); \
#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 HAVE_COUNTER_MACRO
+# define UNIQUE_NAME(prefix) TOKENPASTE2(prefix, __COUNTER__)
+#else /* HAVE_COUNTER_MACRO */
+# define UNIQUE_NAME(prefix) prefix
+#endif /* HAVE_COUNTER_MACRO */
#ifdef _WIN32
#define MS_VC_EXCEPTION 0x406D1388