forked from Mirrorlandia_minetest/minetest
Fix msvc annoyances (#5963)
* MSVC: Fix '/std:c++11' is not a valid compiler option * MSVC/MINGW: Define 'WIN32_LEAN_AND_MEAN' for the whole project In some obscure cases 'Windows.h" got includet before that definition, which leaded to compilation warnings+errors * MSVC: '/arch:SSE' is only available for x86 * MSVC: Fix float conversation * MSVC/MINGW: use winthreads on Windows * MSVC: 'USE_CMAKE_CONFIG' might be already definied by CMake build system * MSVC: Use all available cpu cores for compiling * Add missing include ctime and use std::time_t
This commit is contained in:
parent
48cd217e3b
commit
d7343b6c93
@ -1,7 +1,9 @@
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include <richedit.h>
|
||||
#ifndef USE_CMAKE_CONFIG_H
|
||||
#define USE_CMAKE_CONFIG_H
|
||||
#endif
|
||||
#include "config.h"
|
||||
#undef USE_CMAKE_CONFIG_H
|
||||
|
||||
|
@ -703,9 +703,12 @@ include(CheckCXXCompilerFlag)
|
||||
|
||||
if(MSVC)
|
||||
# Visual Studio
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++11")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D WIN32_LEAN_AND_MEAN /MP")
|
||||
# EHa enables SEH exceptions (used for catching segfaults)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "/EHa /Ox /GL /FD /MT /GS- /Zi /arch:SSE /fp:fast /D NDEBUG /D _HAS_ITERATOR_DEBUGGING=0 /TP")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "/EHa /Ox /GL /FD /MT /GS- /Zi /fp:fast /D NDEBUG /D _HAS_ITERATOR_DEBUGGING=0 /TP")
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /arch:SSE")
|
||||
endif()
|
||||
#set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG /NODEFAULTLIB:\"libcmtd.lib\" /NODEFAULTLIB:\"libcmt.lib\"")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG /INCREMENTAL:NO /DEBUG /OPT:REF /OPT:ICF")
|
||||
|
||||
@ -748,6 +751,7 @@ else()
|
||||
|
||||
if(MINGW)
|
||||
set(OTHER_FLAGS "${OTHER_FLAGS} -mthreads -fexceptions")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWIN32_LEAN_AND_MEAN")
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG ${RELEASE_WARNING_FLAGS} ${WARNING_FLAGS} ${OTHER_FLAGS} -Wall -pipe -funroll-loops")
|
||||
|
@ -23,9 +23,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "database-postgresql.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
// Without this some of the network functions are not found on mingw
|
||||
#ifndef _WIN32_WINNT
|
||||
#define _WIN32_WINNT 0x0501
|
||||
|
@ -26,8 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "gettime.h"
|
||||
#include "log.h"
|
||||
|
||||
#if (defined(WIN32) || defined(_WIN32_WCE))
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#ifdef _WIN32
|
||||
#ifndef _WIN32_WINNT
|
||||
#define _WIN32_WINNT 0x0501
|
||||
#endif
|
||||
|
@ -223,7 +223,7 @@ void MeshUpdateQueue::fillDataFromMapBlockCache(QueuedMeshUpdate *q)
|
||||
|
||||
data->fillBlockDataBegin(q->p);
|
||||
|
||||
int t_now = time(0);
|
||||
std::time_t t_now = std::time(0);
|
||||
|
||||
// Collect data for 3*3*3 blocks from cache
|
||||
v3s16 dp;
|
||||
|
@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#ifndef MESH_GENERATOR_THREAD_HEADER
|
||||
#define MESH_GENERATOR_THREAD_HEADER
|
||||
|
||||
#include <ctime>
|
||||
#include <mutex>
|
||||
#include "mapblock_mesh.h"
|
||||
#include "threading/mutex_auto_lock.h"
|
||||
@ -30,7 +31,7 @@ struct CachedMapBlockData
|
||||
v3s16 p = v3s16(-1337, -1337, -1337);
|
||||
MapNode *data = nullptr; // A copy of the MapBlock's data member
|
||||
int refcount_from_queue = 0;
|
||||
int last_used_timestamp = std::time(0);
|
||||
std::time_t last_used_timestamp = std::time(0);
|
||||
|
||||
CachedMapBlockData() {}
|
||||
~CachedMapBlockData();
|
||||
|
@ -47,8 +47,8 @@ typedef float (*Interp3dFxn)(
|
||||
float x, float y, float z);
|
||||
|
||||
float cos_lookup[16] = {
|
||||
1.0, 0.9238, 0.7071, 0.3826, 0, -0.3826, -0.7071, -0.9238,
|
||||
1.0, -0.9238, -0.7071, -0.3826, 0, 0.3826, 0.7071, 0.9238
|
||||
1.0f, 0.9238f, 0.7071f, 0.3826f, .0f, -0.3826f, -0.7071f, -0.9238f,
|
||||
1.0f, -0.9238f, -0.7071f, -0.3826f, .0f, 0.3826f, 0.7071f, 0.9238f
|
||||
};
|
||||
|
||||
FlagDesc flagdesc_noiseparams[] = {
|
||||
|
@ -34,9 +34,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "log.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
// Without this some of the network functions are not found on mingw
|
||||
#ifndef _WIN32_WINNT
|
||||
#define _WIN32_WINNT 0x0501
|
||||
|
@ -21,9 +21,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#define SOCKET_HEADER
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#ifndef _WIN32_WINNT
|
||||
#define _WIN32_WINNT 0x0501
|
||||
#endif
|
||||
|
@ -261,10 +261,14 @@ bool Thread::bindToProcessor(unsigned int proc_number)
|
||||
|
||||
return false;
|
||||
|
||||
#elif USE_WIN_THREADS
|
||||
#elif _MSC_VER
|
||||
|
||||
return SetThreadAffinityMask(getThreadHandle(), 1 << proc_number);
|
||||
|
||||
#elif __MINGW32__
|
||||
|
||||
return SetThreadAffinityMask(pthread_gethandle(getThreadHandle()), 1 << proc_number);
|
||||
|
||||
#elif __FreeBSD_version >= 702106 || defined(__linux__)
|
||||
|
||||
cpu_set_t cpuset;
|
||||
@ -309,10 +313,14 @@ bool Thread::bindToProcessor(unsigned int proc_number)
|
||||
|
||||
bool Thread::setPriority(int prio)
|
||||
{
|
||||
#if USE_WIN_THREADS
|
||||
#ifdef _MSC_VER
|
||||
|
||||
return SetThreadPriority(getThreadHandle(), prio);
|
||||
|
||||
#elif __MINGW32__
|
||||
|
||||
return SetThreadPriority(pthread_gethandle(getThreadHandle()), prio);
|
||||
|
||||
#else
|
||||
|
||||
struct sched_param sparam;
|
||||
|
Loading…
Reference in New Issue
Block a user