mirror of
https://github.com/unittest-cpp/unittest-cpp
synced 2026-09-26 16:19:30 +03:00
Add support for Cygwin
Add UNITTEST_CYGWIN directive and use it to: include Posix/TimeHelpers.h for Cygwin, exclude the signal handling in SignalTranslator.h/.cpp as Cygwin does not have the necessary Posix signal handling support, i.e. sigjmp_buf or siglongjmp. Reimplement SleepMs in TimeHelpers.cpp using C++11 rather than usleep as that is not present on Cygwin. Update CMakeLists.txt to exclude SignalTranslator.h/.cpp from the build.
This commit is contained in:
parent
bc5d87f484
commit
d288acf175
4 changed files with 14 additions and 2 deletions
|
|
@ -60,6 +60,10 @@ endif(WIN32)
|
|||
|
||||
file(GLOB platformHeaders_ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} UnitTest++/${platformDir_}/*.h)
|
||||
file(GLOB platformSources_ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} UnitTest++/${platformDir_}/*.cpp)
|
||||
if(CYGWIN)
|
||||
list(REMOVE_ITEM platformHeaders_ UnitTest++/${platformDir_}/SignalTranslator.h)
|
||||
list(REMOVE_ITEM platformSources_ UnitTest++/${platformDir_}/SignalTranslator.cpp)
|
||||
endif()
|
||||
source_group(${platformDir_} FILES ${platformHeaders_} ${platformSources_})
|
||||
|
||||
# create the lib
|
||||
|
|
|
|||
|
|
@ -20,11 +20,17 @@
|
|||
#define UNITTEST_WIN32
|
||||
#endif
|
||||
|
||||
#ifndef __CYGWIN__
|
||||
#if defined(unix) || defined(__unix__) || defined(__unix) || defined(linux) || \
|
||||
defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) \
|
||||
|| defined (__HAIKU__)
|
||||
#define UNITTEST_POSIX
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__CYGWIN__)
|
||||
#define UNITTEST_CYGWIN
|
||||
#endif
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
#define UNITTEST_MINGW
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
#include "TimeHelpers.h"
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace UnitTest {
|
||||
|
|
@ -27,7 +29,7 @@ namespace UnitTest {
|
|||
|
||||
void TimeHelpers::SleepMs(int ms)
|
||||
{
|
||||
usleep(static_cast<useconds_t>(ms * 1000));
|
||||
std::this_thread::sleep_for(std::chrono::microseconds(ms * 1000));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include "Config.h"
|
||||
|
||||
#if defined UNITTEST_POSIX
|
||||
#if defined(UNITTEST_POSIX) || defined(UNITTEST_CYGWIN)
|
||||
#include "Posix/TimeHelpers.h"
|
||||
#else
|
||||
#include "Win32/TimeHelpers.h"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue