Skip to content

Commit 8506ac0

Browse files
author
Timmy
committed
Merge pull request #18 from kknox/mingwSupport
Adding mingw32 support as a compilation platform
2 parents e3536fe + 943fae2 commit 8506ac0

File tree

10 files changed

+26
-12
lines changed

10 files changed

+26
-12
lines changed

src/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ else( )
211211
message( FATAL_ERROR "Compiler not supported or not detected" )
212212
endif( )
213213

214-
# If UNICODE is defined, pass extra definitions into
215-
if( UNICODE )
214+
# If UNICODE is defined for microsoft compilers, pass extra definitions
215+
if( MSVC AND UNICODE )
216216
add_definitions( "/DUNICODE /D_UNICODE" )
217217
endif( )
218218

src/client/openCL.misc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "unicode.compatibility.h"
2424

2525
// Creating a portable defintion of countof
26-
#if defined( _WIN32 )
26+
#if defined( _MSC_VER )
2727
#define countOf _countof
2828
#else
2929
#define countOf( arr ) ( sizeof( arr ) / sizeof( arr[ 0 ] ) )

src/include/sharedLibrary.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ inline void* LoadFunctionAddr( void* libHandle, std::string funcName )
7979
#if defined( _WIN32 )
8080
HMODULE fileHandle = reinterpret_cast< HMODULE >( libHandle );
8181

82-
void* pFunc = ::GetProcAddress( fileHandle, funcName.c_str( ) );
82+
void* pFunc = reinterpret_cast< void* >( ::GetProcAddress( fileHandle, funcName.c_str( ) ) );
8383
#else
8484
void* pFunc = ::dlsym( libHandle, funcName.c_str( ) );
8585
#endif

src/include/stdafx.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@
4242
#include <tchar.h>
4343
#include "targetver.h"
4444

45+
#if !defined( NOMINMAX )
4546
#define NOMINMAX
46-
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
47+
#endif
48+
49+
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
4750
// Windows Header Files:
4851
#include <windows.h>
4952
#endif

src/library/private.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,15 @@
4646
#endif
4747

4848
// Creating a portable defintion of countof
49-
#if defined( _WIN32 )
49+
// This excludes mingw compilers; mingw32 does not have _countof
50+
#if defined( _MSC_VER )
5051
#define countOf _countof
5152
#else
5253
#define countOf( arr ) ( sizeof( arr ) / sizeof( arr[ 0 ] ) )
5354
#endif
5455

55-
#if defined( _WIN32 )
56+
// This excludes mingw compilers; mingw32 does not have <intrin.h>
57+
#if defined( _MSC_VER )
5658
#include <intrin.h>
5759

5860
#if defined( _WIN64 )

src/statTimer/statisticalTimer.CPU.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ class CpuStatTimer : public baseStatTimer
4747
cl_ulong clkFrequency;
4848

4949
// For linux; the resolution of a high-precision timer
50-
#if defined( __GNUC__ )
50+
// Mingw32 does not define timespec; can use windows timers
51+
#if !defined( _WIN32 )
5152
timespec res;
5253
#endif
5354

src/statTimer/stdafx.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@
4141
// #include <tchar.h>
4242
#include "targetver.h"
4343

44+
#if !defined( NOMINMAX )
4445
#define NOMINMAX
46+
#endif
47+
4548
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
4649
// Windows Header Files:
4750
#include <windows.h>

src/tests/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ set( clFFT.Test.Headers
5050
set( clFFT.Test.Files ${clFFT.Test.Source} ${clFFT.Test.Headers} )
5151

5252
set( LD_PTHREAD "" )
53-
if( CMAKE_COMPILER_IS_GNUCXX )
53+
if( MINGW )
54+
# -std=c++0x causes g++ to go into strict ANSI mode, which doesn't declare non-standard functions
55+
# Googletest for mingw appears to have a dependency on _stricmp and off64_t
56+
set( CMAKE_CXX_FLAGS "-std=gnu++0x ${CMAKE_CXX_FLAGS}" )
57+
elseif( CMAKE_COMPILER_IS_GNUCXX )
5458
set( CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}" )
5559
set( LD_PTHREAD "-lpthread" )
5660
endif( )

src/tests/gtest_main.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ time_t random_test_parameter_seed;
2929
float tolerance;
3030
bool verbose;
3131

32-
#if defined( _WIN32 )
33-
#define NOMINMAX
32+
#if defined( MSVC_VER )
33+
#if !defined( NOMINMAX )
34+
#define NOMINMAX
35+
#endif
3436
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
3537
#include <intrin.h>
3638

src/tests/test_constants.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
* ************************************************************************/
1616

17-
1817
#include "test_constants.h"
1918
#include <gtest/gtest.h>
2019
#include <stdexcept>

0 commit comments

Comments
 (0)