Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Adam <dev@robert-adam.de>2021-03-04 20:39:19 +0300
committerRobert Adam <dev@robert-adam.de>2021-03-06 20:57:22 +0300
commit678e872c2124ec5175106616881f7df41be66647 (patch)
treee34cd09698bf7034b1cb52c9ce055c8688052301
parentff40c92ab4eec3b5d006809f162480e422d3babc (diff)
BUILD(cmake): Always define _USE_MATH_DEFINES
This is needed in order for the <cmath> header to also define constants like M_PI. Instead of manually defining the macro every time before including <cmath>, the macro is now defined via cmake and thus always defined.
-rw-r--r--CMakeLists.txt3
-rw-r--r--plugins/mumble_plugin_win32.h1
-rw-r--r--src/mumble/AudioOutput.cpp10
-rw-r--r--src/mumble/AudioOutputSpeech.cpp12
-rw-r--r--src/mumble/ManualPlugin.cpp5
-rw-r--r--src/murmur/murmur_pch.h4
-rw-r--r--src/tests/Resample.cpp2
7 files changed, 8 insertions, 29 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 856d1eca1..47b88ab7b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -108,6 +108,9 @@ endif()
# Make the build year accessible as a macro
add_compile_definitions(MUMBLE_BUILD_YEAR=${MUMBLE_BUILD_YEAR})
+# Make sure that math constants are always defined
+add_compile_definitions(_USE_MATH_DEFINES)
+
add_subdirectory(src)
if(g15 AND WIN32)
diff --git a/plugins/mumble_plugin_win32.h b/plugins/mumble_plugin_win32.h
index fd101e954..b2d530579 100644
--- a/plugins/mumble_plugin_win32.h
+++ b/plugins/mumble_plugin_win32.h
@@ -10,7 +10,6 @@
# error "Include mumble_plugin_main.h instead of mumble_plugin_win32.h"
#endif
-#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
// Define "NOMINMAX" only if it isn't already.
diff --git a/src/mumble/AudioOutput.cpp b/src/mumble/AudioOutput.cpp
index a52cc393b..d177103c9 100644
--- a/src/mumble/AudioOutput.cpp
+++ b/src/mumble/AudioOutput.cpp
@@ -3,14 +3,6 @@
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.
-// <cmath> includes <math.h>, but only if it isn't already included.
-// We include <cmath> as first header to make sure that we include <math.h> with _USE_MATH_DEFINES.
-#ifdef _MSC_VER
-# define _USE_MATH_DEFINES
-#endif
-
-#include <cmath>
-
#include "AudioOutput.h"
#include "AudioInput.h"
@@ -29,6 +21,8 @@
#include "VoiceRecorder.h"
#include "Global.h"
+#include <cmath>
+
// Remember that we cannot use static member classes that are not pointers, as the constructor
// for AudioOutputRegistrar() might be called before they are initialized, as the constructor
// is called from global initialization.
diff --git a/src/mumble/AudioOutputSpeech.cpp b/src/mumble/AudioOutputSpeech.cpp
index a0f28579d..ee7426a1e 100644
--- a/src/mumble/AudioOutputSpeech.cpp
+++ b/src/mumble/AudioOutputSpeech.cpp
@@ -3,16 +3,6 @@
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.
-// We want to include <math.h> with _USE_MATH_DEFINES defined.
-// To make sure we do so before anything else includes the header without it
-// (triggering the guard and effectively preventing a "fix include")
-// we define and include before anything else.
-#ifdef _MSC_VER
-# define _USE_MATH_DEFINES
-#endif
-
-#include <cmath>
-
#include "AudioOutputSpeech.h"
#include "Audio.h"
@@ -26,6 +16,8 @@
#include "Utils.h"
#include "Global.h"
+#include <cmath>
+
AudioOutputSpeech::AudioOutputSpeech(ClientUser *user, unsigned int freq, MessageHandler::UDPMessageType type,
unsigned int systemMaxBufferSize)
: AudioOutputUser(user->qsName) {
diff --git a/src/mumble/ManualPlugin.cpp b/src/mumble/ManualPlugin.cpp
index 38eae17c1..34e185f65 100644
--- a/src/mumble/ManualPlugin.cpp
+++ b/src/mumble/ManualPlugin.cpp
@@ -3,8 +3,6 @@
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.
-#define _USE_MATH_DEFINES
-
#include <QtCore/QtCore>
#include <QtGui/QtGui>
#include <QtWidgets/QMessageBox>
@@ -14,6 +12,7 @@
#include <QPointer>
#include <float.h>
+#include <cmath>
#include "../../plugins/mumble_plugin.h"
#include "Global.h"
@@ -416,5 +415,3 @@ MumblePlugin *ManualPlugin_getMumblePlugin() {
MumblePluginQt *ManualPlugin_getMumblePluginQt() {
return &manualqt;
}
-
-#undef _USE_MATH_DEFINES
diff --git a/src/murmur/murmur_pch.h b/src/murmur/murmur_pch.h
index b900346a0..f10f718a8 100644
--- a/src/murmur/murmur_pch.h
+++ b/src/murmur/murmur_pch.h
@@ -7,10 +7,6 @@
# ifndef MUMBLE_MURMUR_MURMUR_PCH_H_
# define MUMBLE_MURMUR_MURMUR_PCH_H_
-# ifdef _MSC_VER
-# define _USE_MATH_DEFINES
-# endif
-
# include <QtCore/QtGlobal>
# ifdef Q_OS_WIN
diff --git a/src/tests/Resample.cpp b/src/tests/Resample.cpp
index ec0f256cd..be9fe30d8 100644
--- a/src/tests/Resample.cpp
+++ b/src/tests/Resample.cpp
@@ -15,7 +15,6 @@
#include <QtCore>
-#define _USE_MATH_DEFINES
#include <cmath>
#include <speex/speex_resampler.h>
@@ -132,5 +131,4 @@ int main(int argc, char **argv) {
return 0;
}
-#undef _USE_MATH_DEFINES
#undef ITER