From f58d9b5b60fd2795a2f5e3d3c787836ac5dd29e6 Mon Sep 17 00:00:00 2001 From: Qrox Date: Thu, 27 Feb 2020 20:46:11 +0800 Subject: [PATCH] Disable -Wredundant-decls in CMake on Windows build, and use winpthread nanosleep if present --- CMakeLists.txt | 4 +++- src/posix_time.cpp | 2 +- src/posix_time.h | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fc90e4be2b0a3..78ff7da591f4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -229,11 +229,13 @@ ELSE() -Wold-style-cast \ -Woverloaded-virtual \ -Wpedantic \ - -Wredundant-decls \ -Wsuggest-override \ -Wunused-macros \ -Wzero-as-null-pointer-constant \ -Wno-unknown-warning-option") + IF (NOT ${CMAKE_SYSTEM_NAME} MATCHES Windows) + SET(CATA_WARNINGS "${CATA_WARNINGS} -Wredundant-decls") + ENDIF() # Compact the whitespace in the warning string string(REGEX REPLACE "[\t ]+" " " CATA_WARNINGS "${CATA_WARNINGS}") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CATA_WARNINGS}") diff --git a/src/posix_time.cpp b/src/posix_time.cpp index bcee8631fc91a..39336a09cf405 100644 --- a/src/posix_time.cpp +++ b/src/posix_time.cpp @@ -1,6 +1,6 @@ #include "posix_time.h" -#if defined(_WIN32) && !defined(__CYGWIN__) +#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(WINPTHREAD_API) #include int diff --git a/src/posix_time.h b/src/posix_time.h index 5b822e67f070b..6e4a2ee808bf3 100644 --- a/src/posix_time.h +++ b/src/posix_time.h @@ -7,7 +7,7 @@ #include // IWYU pragma: keep -#if defined(_WIN32) && !defined(__CYGWIN__) +#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(WINPTHREAD_API) /* Windows platforms. */ /* Windows lacks the nanosleep() function. The following code was stuffed