1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-08-07 02:42:49 +03:00

Windows build fixes

- use /MT flag instead of /MD
 - add debug libraries to package
This commit is contained in:
Georg Richter
2013-10-04 19:09:08 +02:00
parent 7038dc9280
commit d5a772de56
13 changed files with 65 additions and 22 deletions

View File

@@ -19,6 +19,8 @@ ENDIF()
IF(NOT WIN32) IF(NOT WIN32)
OPTION(WITH_MYSQLCOMPAT "creates libmysql* symbolic links" ON) OPTION(WITH_MYSQLCOMPAT "creates libmysql* symbolic links" ON)
OPTION(WITH_OPENSSL "enables SSL support" ON) OPTION(WITH_OPENSSL "enables SSL support" ON)
ELSE()
OPTION(WITH_OPENSSL "enables SSL support" OFF)
ENDIF() ENDIF()
OPTION(WITH_SQLITE "Enables Sqlite support" OFF) OPTION(WITH_SQLITE "Enables Sqlite support" OFF)
@@ -30,13 +32,22 @@ IF(WIN32)
# Speedup system tests # Speedup system tests
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/WindowsCache.cmake) INCLUDE(${CMAKE_SOURCE_DIR}/cmake/WindowsCache.cmake)
IF (MSVC) IF (MSVC)
FOREACH(flag_var SET(CONFIG_TYPES "DEBUG" "RELEASE" "RELWITHDEBINFO")
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE FOREACH(BUILD_TYPE ${CONFIG_TYPES})
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) FOREACH(COMPILER CXX C)
IF(${flag_var} MATCHES "/MD") SET(COMPILER_FLAGS "${CMAKE_${COMPILER}_FLAGS_${BUILD_TYPE}}")
STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") IF (NOT COMPILER_FLAGS STREQUAL "")
ENDIF() STRING(REPLACE "/MD" "/MT" COMPILER_FLAGS ${COMPILER_FLAGS})
ENDFOREACH(flag_var) IF (CMAKE_BUILD_TYPE STREQUAL "Debug")
SET(COMPILER_FLAGS "${COMPILER_FLAGS} /RTC1 /RTCc")
STRING(REPLACE "/Zi" "/ZI" COMPILER_FLAGS ${COMPILER_FLAGS})
ENDIF()
MESSAGE (STATUS "CMAKE_${COMPILER}_FLAGS_${BUILD_TYPE}= ${COMPILER_FLAGS}")
SET(CMAKE_${COMPILER}_FLAGS_${BUILD_TYPE} ${COMPILER_FLAGS} CACHE
STRING "overwritten by libmariadb" FORCE)
ENDIF()
ENDFOREACH()
ENDFOREACH()
ENDIF() ENDIF()
ENDIF() ENDIF()

View File

@@ -264,4 +264,9 @@ inline double ulonglong2double(ulonglong value)
#define statistic_increment(V,L) thread_safe_increment((V),(L)) #define statistic_increment(V,L) thread_safe_increment((V),(L))
#define strcasecmp(A,B) _stricmp((A),(B)) #define strcasecmp(A,B) _stricmp((A),(B))
#define close(A) _close((A))
#define fdopen(A,B) _fdopen((A),(B))
#define sopen(A,B,C,D) _sopen((A),(B),(C),(D))
#endif #endif

View File

@@ -38,16 +38,16 @@ extern "C" {
/* we use the mysqlnd implementation */ /* we use the mysqlnd implementation */
typedef struct charset_info_st typedef struct charset_info_st
{ {
uint nr; /* so far only 1 byte for charset */ unsigned int nr; /* so far only 1 byte for charset */
uint state; unsigned int state;
char *csname; char *csname;
char *name; char *name;
char *dir; char *dir;
char *encoding; char *encoding;
uint char_minlen; unsigned int char_minlen;
uint char_maxlen; unsigned int char_maxlen;
uint (*mb_charlen)(uint c); unsigned int (*mb_charlen)(unsigned int c);
uint (*mb_valid)(const char *start, const char *end); unsigned int (*mb_valid)(const char *start, const char *end);
} CHARSET_INFO; } CHARSET_INFO;
extern const CHARSET_INFO compiled_charsets[]; extern const CHARSET_INFO compiled_charsets[];
@@ -56,7 +56,7 @@ extern CHARSET_INFO *my_charset_bin;
extern CHARSET_INFO *my_charset_latin1; extern CHARSET_INFO *my_charset_latin1;
extern CHARSET_INFO *my_charset_utf8_general_ci; extern CHARSET_INFO *my_charset_utf8_general_ci;
CHARSET_INFO *find_compiled_charset(uint cs_number); CHARSET_INFO *find_compiled_charset(unsigned int cs_number);
CHARSET_INFO *find_compiled_charset_by_name(const char *name); CHARSET_INFO *find_compiled_charset_by_name(const char *name);
size_t mysql_cset_escape_quotes(const CHARSET_INFO *cset, char *newstr, const char *escapestr, size_t escapestr_len); size_t mysql_cset_escape_quotes(const CHARSET_INFO *cset, char *newstr, const char *escapestr, size_t escapestr_len);

View File

@@ -155,8 +155,8 @@ IF(OPENSSL_FOUND)
ENDIF() ENDIF()
IF(WIN32) IF(WIN32)
TARGET_LINK_LIBRARIES(libmariadb ws2_32) TARGET_LINK_LIBRARIES(libmariadb ws2_32 advapi32 kernel32)
TARGET_LINK_LIBRARIES(mariadbclient ws2_32) TARGET_LINK_LIBRARIES(mariadbclient ws2_32 advapi32 kernel32)
ELSE() ELSE()
TARGET_LINK_LIBRARIES(libmariadb m) TARGET_LINK_LIBRARIES(libmariadb m)
TARGET_LINK_LIBRARIES(mariadbclient m) TARGET_LINK_LIBRARIES(mariadbclient m)

View File

@@ -2050,7 +2050,11 @@ static void DBUGOpenFile(CODE_STATE *cs,
} }
else else
{ {
#ifdef _WIN32
if (fopen_s(&fp, name, append ? "a+" : "w"))
#else
if (!(fp= fopen(name, append ? "a+" : "w"))) if (!(fp= fopen(name, append ? "a+" : "w")))
#endif
{ {
(void) fprintf(stderr, ERR_OPEN, cs->process, name); (void) fprintf(stderr, ERR_OPEN, cs->process, name);
perror(""); perror("");

View File

@@ -36,7 +36,11 @@ FILE *my_fopen(const char *FileName, int Flags, myf MyFlags)
FileName, Flags, MyFlags)); FileName, Flags, MyFlags));
make_ftype(type,Flags); make_ftype(type,Flags);
#ifdef _WIN32
if (fopen_s(&fd, FileName, type) == 0)
#else
if ((fd = fopen(FileName, type)) != 0) if ((fd = fopen(FileName, type)) != 0)
#endif
{ {
/* /*
The test works if MY_NFILE < 128. The problem is that fileno() is char The test works if MY_NFILE < 128. The problem is that fileno() is char

View File

@@ -55,7 +55,11 @@ int my_getwd(my_string buf, uint size, myf MyFlags)
#endif #endif
{ {
#if defined(HAVE_GETCWD) #if defined(HAVE_GETCWD)
if (!getcwd(buf,size-2) && MyFlags & MY_WME) #ifdef _WIN32
if (!(_getcwd(buf,size-2)) && MyFlags & MY_WME)
#else
if (!(getcwd(buf,size-2)) && MyFlags & MY_WME)
#endif
{ {
my_errno=errno; my_errno=errno;
my_error(EE_GETWD,MYF(ME_BELL+ME_WAITTANG),errno); my_error(EE_GETWD,MYF(ME_BELL+ME_WAITTANG),errno);
@@ -151,7 +155,11 @@ int my_setwd(const char *dir, myf MyFlags)
dir=buff; dir=buff;
} }
#endif /* VMS */ #endif /* VMS */
#ifdef _WIN32
if ((res=_chdir((char*) dir)) != 0)
#else
if ((res=chdir((char*) dir)) != 0) if ((res=chdir((char*) dir)) != 0)
#endif
{ {
my_errno=errno; my_errno=errno;
if (MyFlags & MY_WME) if (MyFlags & MY_WME)

View File

@@ -1336,7 +1336,7 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
static int madb_alloc_stmt_fields(MYSQL_STMT *stmt) static int madb_alloc_stmt_fields(MYSQL_STMT *stmt)
{ {
int i; uint i;
MEM_ROOT *fields_alloc_root= &((MADB_STMT_EXTENSION *)stmt->extension)->fields_alloc_root; MEM_ROOT *fields_alloc_root= &((MADB_STMT_EXTENSION *)stmt->extension)->fields_alloc_root;
DBUG_ENTER("madb_alloc_stmt_fields"); DBUG_ENTER("madb_alloc_stmt_fields");

View File

@@ -161,7 +161,8 @@ static int create_dyncol_num(MYSQL *mysql)
static int mdev_x1(MYSQL *mysql) static int mdev_x1(MYSQL *mysql)
{ {
int i, rc; int rc;
uint i;
uint num_keys[5]= {1,2,3,4,5}; uint num_keys[5]= {1,2,3,4,5};
char *strval[]= {"Val1", "Val2", "Val3", "Val4", "Val5"}; char *strval[]= {"Val1", "Val2", "Val3", "Val4", "Val5"};
DYNAMIC_COLUMN_VALUE vals[5]; DYNAMIC_COLUMN_VALUE vals[5];

View File

@@ -3798,6 +3798,7 @@ static int test_conc_5(MYSQL *mysql)
mysql_free_result(res); mysql_free_result(res);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
return OK;
} }
struct my_tests_st my_tests[] = { struct my_tests_st my_tests[] = {

View File

@@ -80,7 +80,7 @@ static int test_conc_27(MYSQL *mysql)
#ifndef _WIN32 #ifndef _WIN32
pthread_create(&threads[i], NULL, (void *)thread_conc27, NULL); pthread_create(&threads[i], NULL, (void *)thread_conc27, NULL);
#else #else
hthreads[i]= CreateThread(NULL, 0, thread_conc27, NULL, 0, &threads[i]); hthreads[i]= CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)thread_conc27, NULL, 0, &threads[i]);
if (hthreads[i]==NULL) if (hthreads[i]==NULL)
diag("error while starting thread"); diag("error while starting thread");
#endif #endif

View File

@@ -1,4 +1,5 @@
SET(CLIENT_LIB_DIR ${CMAKE_BINARY_DIR}/libmariadb/${CMAKE_BUILD_TYPE}) SET(CLIENT_LIB_DIR ${CMAKE_BINARY_DIR}/libmariadb/${CMAKE_BUILD_TYPE})
SET(CLIENT_DBG_DIR ${CMAKE_BINARY_DIR}/libmariadb/Debug)
SET(CLIENT_INC_DIR ${CMAKE_SOURCE_DIR}/include) SET(CLIENT_INC_DIR ${CMAKE_SOURCE_DIR}/include)
SET(PRODUCT_NAME "MariaDB C Client Library") SET(PRODUCT_NAME "MariaDB C Client Library")

View File

@@ -6,7 +6,7 @@
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" /> <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of @PRODUCT_NAME@ is already installed." /> <MajorUpgrade DowngradeErrorMessage="A newer version of @PRODUCT_NAME@ is already installed." />
<MediaTemplate /> <MediaTemplate EmbedCab="yes" />
<UIRef Id="WixUI_Mondo" /> <UIRef Id="WixUI_Mondo" />
<WixVariable Id="WixUILicenseRtf" Value="@CMAKE_SOURCE_DIR@/win/packaging/license.rtf" /> <WixVariable Id="WixUILicenseRtf" Value="@CMAKE_SOURCE_DIR@/win/packaging/license.rtf" />
@@ -16,6 +16,7 @@
<Feature Id="ProductFeature" Title="@PRODUCT_NAME@ @PRODUCT_VERSION@" Level="1"> <Feature Id="ProductFeature" Title="@PRODUCT_NAME@ @PRODUCT_VERSION@" Level="1">
<ComponentRef Id="RegistryKeys" /> <ComponentRef Id="RegistryKeys" />
<ComponentRef Id="Library"/> <ComponentRef Id="Library"/>
<ComponentRef Id="DebugLibrary" />
<Feature Id="DebugFeature" Title="Debug Information" Level="2"> <Feature Id="DebugFeature" Title="Debug Information" Level="2">
<ComponentRef Id="Debug" /> <ComponentRef Id="Debug" />
</Feature> </Feature>
@@ -30,7 +31,9 @@
<Directory Id="ProgramFilesFolder"> <Directory Id="ProgramFilesFolder">
<Directory Id="Mariadb" Name="@PRODUCT_MANUFACTURER@"> <Directory Id="Mariadb" Name="@PRODUCT_MANUFACTURER@">
<Directory Id="INSTALLFOLDER" Name="@PRODUCT_NAME@" > <Directory Id="INSTALLFOLDER" Name="@PRODUCT_NAME@" >
<Directory Id="instlib" Name="lib" /> <Directory Id="instlib" Name="lib">
<Directory Id="instlib_debug" Name="debug"/>
</Directory>
<Directory Id="instinclude" Name="include" /> <Directory Id="instinclude" Name="include" />
</Directory> </Directory>
</Directory> </Directory>
@@ -50,6 +53,11 @@
<File Id="libdllimp" Name="libmariadb.lib" DiskId="1" Source="@CLIENT_LIB_DIR@/libmariadb.lib" /> <File Id="libdllimp" Name="libmariadb.lib" DiskId="1" Source="@CLIENT_LIB_DIR@/libmariadb.lib" />
<File Id="libstatic" Name="mariadbclient.lib" DiskId="1" Source="@CLIENT_LIB_DIR@/mariadbclient.lib" /> <File Id="libstatic" Name="mariadbclient.lib" DiskId="1" Source="@CLIENT_LIB_DIR@/mariadbclient.lib" />
</Component> </Component>
<Component Id="DebugLibrary" Guid="1b8f741d-e7d9-48f1-9e11-9270216d1dc7" KeyPath="yes" DiskId="1" Directory="instlib_debug">
<File Id="dlibdll" Name="libmariadb.dll" DiskId="1" Source="@CLIENT_DBG_DIR@/libmariadb.dll" />
<File Id="dlibdllimp" Name="libmariadb.lib" DiskId="1" Source="@CLIENT_DBG_DIR@/libmariadb.lib" />
<File Id="dlibstatic" Name="mariadbclient.lib" DiskId="1" Source="@CLIENT_DBG_DIR@/mariadbclient.lib" />
</Component>
<Component Id="Debug" Guid="FFAFCCCC-4E0C-4A87-840C-53B63C8A427A" KeyPath="yes" Directory="instlib" DiskId="1"> <Component Id="Debug" Guid="FFAFCCCC-4E0C-4A87-840C-53B63C8A427A" KeyPath="yes" Directory="instlib" DiskId="1">
<File Id="libdllpdb" Name="libmariadb.pdb" DiskId="1" Source="@CLIENT_LIB_DIR@/libmariadb.pdb" /> <File Id="libdllpdb" Name="libmariadb.pdb" DiskId="1" Source="@CLIENT_LIB_DIR@/libmariadb.pdb" />
<File Id="libstaticpdb" Name="mariadbclient.pdb" DiskId="1" Source="@CLIENT_LIB_DIR@/mariadbclient.pdb" /> <File Id="libstaticpdb" Name="mariadbclient.pdb" DiskId="1" Source="@CLIENT_LIB_DIR@/mariadbclient.pdb" />