Use proper cmake detection of features.
This attempts to organize all needed items and places appropriate defines in a single location. Redundant comparisons/defines were removed when noticed. A few caveats, however: * This may be better targeted towards the 5_1_0 branch instead of master right now. * Cmake will run a little slower on configuration/generation now. That's due to the sanity checks it runs. * There are some more checks to be added later, but this should be a solid start. Thanks to the [libical](https://github.com/libical/libical) project for inspiration.
This commit is contained in:
@@ -10,9 +10,13 @@
|
||||
#endif
|
||||
|
||||
#if defined(LINUX)
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#if defined(HAVE_FCNTL_H)
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#ifndef PID_THREAD_HELPERS_H
|
||||
#define PID_THREAD_HELPERS_H
|
||||
|
||||
#if defined(HAVE_STDINT_H)
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#include "global.h"
|
||||
|
||||
RString ThreadsVersion();
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
|
||||
#if defined(CPU_X86)
|
||||
|
||||
#if defined(HAVE_STDINT_H)
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
inline uint32_t ArchSwap32( uint32_t n )
|
||||
{
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
#include "arch/ArchHooks/ArchHooks.h"
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#include <sys/types.h>
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
RString CrashHandler::GetLogsDirectory()
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
// Replace the main function.
|
||||
extern "C" int sm_main( int argc, char *argv[] );
|
||||
|
||||
#define HAVE_VERSION_INFO
|
||||
#define HAVE_CXA_DEMANGLE
|
||||
#define HAVE_FFMPEG
|
||||
#define HAVE_PTHREAD_COND_TIMEDWAIT
|
||||
@@ -12,11 +11,6 @@ extern "C" int sm_main( int argc, char *argv[] );
|
||||
* this in all cases. If only they could be consistent... */
|
||||
#define HAVE_DECL_SIGUSR1 1
|
||||
|
||||
/* We have <machine/endian.h> which gets pulled in when we use gcc 4.0's <cstdlib>
|
||||
* but no <endian.h>. The definitions of LITTLE_ENDIAN, BIG_ENDIAN and end up conflicting
|
||||
* even though they resolve to the same thing (bug in gcc?). */
|
||||
#define HAVE_MACHINE_ENDIAN_H
|
||||
#define HAVE_INTTYPES_H
|
||||
#define __STDC_FORMAT_MACROS
|
||||
#define CRASH_HANDLER
|
||||
|
||||
@@ -25,7 +19,6 @@ extern "C" int sm_main( int argc, char *argv[] );
|
||||
#define NO_GL_FLUSH
|
||||
|
||||
#define CPU_X86
|
||||
#define ENDIAN_LITTLE
|
||||
#define BACKTRACE_METHOD_X86_DARWIN
|
||||
#define BACKTRACE_LOOKUP_METHOD_DLADDR
|
||||
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
#include "RageUtil.h"
|
||||
#include "RageException.h"
|
||||
#include "archutils/Unix/EmergencyShutdown.h"
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <assert.h>
|
||||
|
||||
/* We can define this symbol to catch failed assert() calls. This is only used
|
||||
|
||||
@@ -2,13 +2,17 @@
|
||||
#include "Backtrace.h"
|
||||
#include "RageUtil.h"
|
||||
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <cstdlib>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/stat.h>
|
||||
#include <cerrno>
|
||||
#if defined(HAVE_FCNTL_H)
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#if defined(BACKTRACE_METHOD_X86_LINUX)
|
||||
#include "archutils/Common/PthreadHelpers.h"
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstdarg>
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <cstring>
|
||||
#include <cerrno>
|
||||
|
||||
|
||||
@@ -3,10 +3,14 @@
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstdarg>
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <cerrno>
|
||||
#include <limits.h>
|
||||
#if defined(HAVE_FCNTL_H)
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#include <csignal>
|
||||
|
||||
#include "RageLog.h" /* for RageLog::GetAdditionalLog, etc, only */
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#include "global.h"
|
||||
#include "GetSysInfo.h"
|
||||
|
||||
#if defined(HAVE_SYS_UTSNAME_H)
|
||||
#include <sys/utsname.h>
|
||||
#endif
|
||||
|
||||
void GetKernel( RString &sys, int &iVersion )
|
||||
{
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
#include "archutils/Common/PthreadHelpers.h"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <sys/mman.h>
|
||||
#include <cerrno>
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <alloca.h>
|
||||
#endif
|
||||
|
||||
#if !defined(MISSING_STDINT_H) /* need to define int64_t if so */
|
||||
#if defined(HAVE_STDINT_H) /* need to define int64_t if so */
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
@@ -19,13 +19,7 @@
|
||||
#ifdef BSD
|
||||
#undef ALIGN
|
||||
#undef MACHINE
|
||||
#if defined(__NetBSD_Version__) && __NetBSD_Version__ < 299000900
|
||||
#define lrintf(x) ((int)rint(x))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* For RageLog */
|
||||
#define HAVE_VERSION_INFO
|
||||
|
||||
#include "archutils/Common/gcc_byte_swaps.h"
|
||||
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
#include <commctrl.h>
|
||||
#include "archutils/Win32/ddk/dbghelp.h"
|
||||
#include <io.h>
|
||||
#if defined(HAVE_FCNTL_H)
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#include <shellapi.h>
|
||||
|
||||
#include "arch/ArchHooks/ArchHooks.h"
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
#pragma warning (disable : 4005) // macro redefinitions (ARRAYSIZE)
|
||||
#endif
|
||||
|
||||
#define snprintf _snprintf // Unsure if this goes with __MINGW32__ right now.
|
||||
|
||||
/*
|
||||
The following warnings are disabled in all builds.
|
||||
Enable them in the project file at your peril (or if you feel like
|
||||
@@ -82,7 +80,6 @@ C4355: 'this' : used in base member initializer list
|
||||
|
||||
#endif
|
||||
|
||||
#include <direct.h> // has stuff that should be in unistd.h
|
||||
#include <wchar.h> // needs to be included before our fixes below
|
||||
|
||||
#define lstat stat
|
||||
@@ -90,9 +87,6 @@ C4355: 'this' : used in base member initializer list
|
||||
#define isnan _isnan
|
||||
#define isfinite _finite
|
||||
|
||||
// mkdir is missing the mode arg
|
||||
#define mkdir(p,m) mkdir(p)
|
||||
|
||||
typedef time_t time_t;
|
||||
struct tm;
|
||||
struct tm *my_localtime_r( const time_t *timep, struct tm *result );
|
||||
@@ -135,43 +129,12 @@ int64_t llabs( int64_t i ) { return i >= 0 ? i : -i; }
|
||||
#undef max
|
||||
#define NOMINMAX // make sure Windows doesn't try to define this
|
||||
|
||||
// Windows is missing some basic math functions:
|
||||
// But MinGW isn't.
|
||||
#if !defined(__MINGW32__) && (!defined(_MSC_VER) || _MSC_VER < 1700) // cstdint and truncf were first implemented in Visual Studio 2012
|
||||
#define NEED_TRUNCF
|
||||
#define MISSING_STDINT_H
|
||||
#endif
|
||||
|
||||
// MinGW provides us with this function already
|
||||
|
||||
#if !defined(__MINGW32__) && (!defined(_MSC_VER) || _MSC_VER < 1800) // lrintf, roundf and strtof were first implemented in Visual Studio 2013
|
||||
#define NEED_ROUNDF
|
||||
#define NEED_STRTOF
|
||||
inline long int lrintf( float f )
|
||||
{
|
||||
int retval;
|
||||
|
||||
_asm fld f;
|
||||
_asm fistp retval;
|
||||
|
||||
return retval;
|
||||
}
|
||||
#endif
|
||||
|
||||
// For RageLog.
|
||||
#define HAVE_VERSION_INFO
|
||||
|
||||
/* We implement the crash handler interface (though that interface isn't
|
||||
* completely uniform across platforms yet). */
|
||||
#if !defined(SMPACKAGE)
|
||||
#define CRASH_HANDLER
|
||||
#endif
|
||||
|
||||
// autoconf does this for us
|
||||
#if !defined(__MINGW32__)
|
||||
#define ENDIAN_LITTLE
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) // It might be MinGW or Cygwin(?)
|
||||
#include "archutils/Common/gcc_byte_swaps.h"
|
||||
#elif defined(_MSC_VER) && (_MSC_VER >= 1310) // Byte swap functions were first implemented in Visual Studio .NET 2003
|
||||
|
||||
Reference in New Issue
Block a user