Skip to content
This repository has been archived by the owner on Aug 25, 2018. It is now read-only.

Commit

Permalink
fixes compilation on Windows using MinGW
Browse files Browse the repository at this point in the history
  • Loading branch information
disog authored and mloskot committed Jul 13, 2016
1 parent dd79b09 commit ae05a4c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
13 changes: 10 additions & 3 deletions CMakeLists.txt
Expand Up @@ -4,7 +4,7 @@ project(nanodbc)
option(NANODBC_USE_UNICODE "build with unicode support turned on" OFF)
option(NANODBC_USE_BOOST_CONVERT "build using Boost.Locale for string convert" OFF)
option(NANODBC_HANDLE_NODATA_BUG "enable special handling for SQL_NO_DATA (required for vertica)" OFF)
option(NANODBC_DISABLE_ASYNC "disable async features entierly (may help resolve issues in VS2015 builds)" OFF)
option(NANODBC_DISABLE_ASYNC "disable async features entirely (may help resolve issues in VS2015 builds)" OFF)
option(NANODBC_STATIC "build static instead of shared library" OFF)
option(NANODBC_EXAMPLES "build examples" ON)
option(NANODBC_TEST "build tests" ON)
Expand Down Expand Up @@ -186,6 +186,8 @@ if(UNIX)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${ODBC_LINK_FLAGS}")
elseif(MSVC)
set(ODBC_LIBRARIES odbc32.lib odbccp32.lib Ws2_32.lib)
elseif(MINGW)
set(ODBC_LIBRARIES odbc32 odbccp32)
endif()

########################################
Expand All @@ -209,9 +211,14 @@ endif()
if(NANODBC_INSTALL)
install(FILES src/nanodbc.h DESTINATION include)
if(NANODBC_STATIC)
install(TARGETS nanodbc ARCHIVE DESTINATION lib)
install(TARGETS nanodbc
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib)
else()
install(TARGETS nanodbc LIBRARY DESTINATION lib)
install(TARGETS nanodbc
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
endif()
message(STATUS "Target install: Turned on")
else()
Expand Down
2 changes: 2 additions & 0 deletions examples/table_schema.cpp
Expand Up @@ -11,7 +11,9 @@
#include <string>

#ifdef _WIN32
#ifndef __MINGW32__
#define NOMINMAX
#endif
#include <windows.h> // SQLLEN, SQLULEN, SQLHWND
#endif
#include <sql.h>
Expand Down
4 changes: 3 additions & 1 deletion src/nanodbc.cpp
Expand Up @@ -44,7 +44,9 @@

#ifdef _WIN32
// needs to be included above sql.h for windows
#define NOMINMAX
#ifndef __MINGW32__
#define NOMINMAX
#endif
#include <windows.h>
#endif

Expand Down
4 changes: 3 additions & 1 deletion test/base_test_fixture.h
Expand Up @@ -26,7 +26,9 @@

#ifdef _WIN32
// needs to be included above sql.h for windows
#define NOMINMAX
#ifndef __MINGW32__
#define NOMINMAX
#endif
#include <windows.h>
#endif
#include <sql.h>
Expand Down
4 changes: 2 additions & 2 deletions test/mssql_test.cpp
Expand Up @@ -277,7 +277,7 @@ TEST_CASE_METHOD(mssql_fixture, "while_next_iteration_test", "[mssql][looping]")
while_next_iteration_test();
}

#ifdef WIN32
#if defined(WIN32) && !defined(NANODBC_DISABLE_ASYNC)
TEST_CASE_METHOD(mssql_fixture, "async_test", "[mssql][async]")
{
HANDLE event_handle = CreateEvent(nullptr, FALSE, FALSE, nullptr);
Expand All @@ -302,4 +302,4 @@ TEST_CASE_METHOD(mssql_fixture, "async_test", "[mssql][async]")

REQUIRE(row.get<int>(0) >= 0);
}
#endif //WIN32
#endif //defined(WIN32) && !defined(NANODBC_DISABLE_ASYNC)

0 comments on commit ae05a4c

Please sign in to comment.