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:
Jason Felds
2015-09-05 10:51:17 -04:00
parent 92f449c8bf
commit e093d204c8
42 changed files with 438 additions and 159 deletions
@@ -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"
-37
View File
@@ -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