Skip to content

Commit

Permalink
Merge pull request #18 from kknox/mingwSupport
Browse files Browse the repository at this point in the history
Adding mingw32 support as a compilation platform
  • Loading branch information
Timmy committed Sep 12, 2013
2 parents e3536fe + 943fae2 commit 8506ac0
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ else( )
message( FATAL_ERROR "Compiler not supported or not detected" )
endif( )

# If UNICODE is defined, pass extra definitions into
if( UNICODE )
# If UNICODE is defined for microsoft compilers, pass extra definitions
if( MSVC AND UNICODE )
add_definitions( "/DUNICODE /D_UNICODE" )
endif( )

Expand Down
2 changes: 1 addition & 1 deletion src/client/openCL.misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "unicode.compatibility.h"

// Creating a portable defintion of countof
#if defined( _WIN32 )
#if defined( _MSC_VER )
#define countOf _countof
#else
#define countOf( arr ) ( sizeof( arr ) / sizeof( arr[ 0 ] ) )
Expand Down
2 changes: 1 addition & 1 deletion src/include/sharedLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ inline void* LoadFunctionAddr( void* libHandle, std::string funcName )
#if defined( _WIN32 )
HMODULE fileHandle = reinterpret_cast< HMODULE >( libHandle );

void* pFunc = ::GetProcAddress( fileHandle, funcName.c_str( ) );
void* pFunc = reinterpret_cast< void* >( ::GetProcAddress( fileHandle, funcName.c_str( ) ) );
#else
void* pFunc = ::dlsym( libHandle, funcName.c_str( ) );
#endif
Expand Down
5 changes: 4 additions & 1 deletion src/include/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@
#include <tchar.h>
#include "targetver.h"

#if !defined( NOMINMAX )
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#endif

#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>
#endif
6 changes: 4 additions & 2 deletions src/library/private.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@
#endif

// Creating a portable defintion of countof
#if defined( _WIN32 )
// This excludes mingw compilers; mingw32 does not have _countof
#if defined( _MSC_VER )
#define countOf _countof
#else
#define countOf( arr ) ( sizeof( arr ) / sizeof( arr[ 0 ] ) )
#endif

#if defined( _WIN32 )
// This excludes mingw compilers; mingw32 does not have <intrin.h>
#if defined( _MSC_VER )
#include <intrin.h>

#if defined( _WIN64 )
Expand Down
3 changes: 2 additions & 1 deletion src/statTimer/statisticalTimer.CPU.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class CpuStatTimer : public baseStatTimer
cl_ulong clkFrequency;

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

Expand Down
3 changes: 3 additions & 0 deletions src/statTimer/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@
// #include <tchar.h>
#include "targetver.h"

#if !defined( NOMINMAX )
#define NOMINMAX
#endif

#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>
Expand Down
6 changes: 5 additions & 1 deletion src/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ set( clFFT.Test.Headers
set( clFFT.Test.Files ${clFFT.Test.Source} ${clFFT.Test.Headers} )

set( LD_PTHREAD "" )
if( CMAKE_COMPILER_IS_GNUCXX )
if( MINGW )
# -std=c++0x causes g++ to go into strict ANSI mode, which doesn't declare non-standard functions
# Googletest for mingw appears to have a dependency on _stricmp and off64_t
set( CMAKE_CXX_FLAGS "-std=gnu++0x ${CMAKE_CXX_FLAGS}" )
elseif( CMAKE_COMPILER_IS_GNUCXX )
set( CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}" )
set( LD_PTHREAD "-lpthread" )
endif( )
Expand Down
6 changes: 4 additions & 2 deletions src/tests/gtest_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ time_t random_test_parameter_seed;
float tolerance;
bool verbose;

#if defined( _WIN32 )
#define NOMINMAX
#if defined( MSVC_VER )
#if !defined( NOMINMAX )
#define NOMINMAX
#endif
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <intrin.h>

Expand Down
1 change: 0 additions & 1 deletion src/tests/test_constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
* ************************************************************************/


#include "test_constants.h"
#include <gtest/gtest.h>
#include <stdexcept>
Expand Down

0 comments on commit 8506ac0

Please sign in to comment.