Skip to content

Add support for Cygwin #166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions UnitTest++/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion UnitTest++/Posix/TimeHelpers.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "TimeHelpers.h"
#include <chrono>
#include <thread>
#include <unistd.h>

namespace UnitTest {
Expand Down Expand Up @@ -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));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't use <chrono> in UnitTest++ at this time. UnitTest++ does not require a modern compiler.

}

}
2 changes: 1 addition & 1 deletion UnitTest++/TimeHelpers.h
Original file line number Diff line number Diff line change
@@ -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"
Expand Down