diff options
author | Vladislav Vaintroub <vvaintroub@mysql.com> | 2009-09-30 03:39:37 +0200 |
---|---|---|
committer | Vladislav Vaintroub <vvaintroub@mysql.com> | 2009-09-30 03:39:37 +0200 |
commit | b73763e0f913a1b3e841cbe91f9d11802cbf054c (patch) | |
tree | abeea5fd6b9b99995ec6b277906b6ddbacc5752a | |
parent | 2bc1930c6c40b964fce9c698a1ca75da3138ad63 (diff) | |
download | mariadb-git-b73763e0f913a1b3e841cbe91f9d11802cbf054c.tar.gz |
Backport of the patch
http://lists.mysql.com/commits/57725
Vladislav Vaintroub 2008-11-03
Cleanup CMakeLists.txt(s) - remove winsock2 (ws2_32) from
TARGET_LINK_LIBRARIES.
Every exe or dll linked with mysys needs ws2_32, because
mysys uses winsock function WSAStartup in my_init().
However, there is no need to explicitely add ws2_32 to
the list of TARGET_LINK_LIBRARIES multiple times.
Visual Studio comes with a handy pragma that tells linker
to add library. So patch replaces bunch of ws2_32 in
CMakeLists with single pragma comment(lib,"ws2_32")
in my_init.c
Additionally, reference to non-existing "debug" library
has been removed from TARGET_LINK_LIBRARIES. The correct
name of the library is "dbug".
-rwxr-xr-x | client/CMakeLists.txt | 20 | ||||
-rwxr-xr-x | extra/CMakeLists.txt | 10 | ||||
-rwxr-xr-x | libmysql/CMakeLists.txt | 2 | ||||
-rw-r--r-- | mysys/my_init.c | 2 | ||||
-rwxr-xr-x | scripts/CMakeLists.txt | 2 | ||||
-rwxr-xr-x | sql/CMakeLists.txt | 5 | ||||
-rw-r--r-- | sql/udf_example.c | 5 | ||||
-rwxr-xr-x | storage/myisam/CMakeLists.txt | 8 | ||||
-rwxr-xr-x | tests/CMakeLists.txt | 4 |
9 files changed, 32 insertions, 26 deletions
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 4fadc4e7ae5..176613e2dc8 100755 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -30,27 +30,27 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/strings) ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc sql_string.cc ../mysys/my_conio.c) -TARGET_LINK_LIBRARIES(mysql mysqlclient wsock32) +TARGET_LINK_LIBRARIES(mysql mysqlclient) ADD_EXECUTABLE(mysqltest mysqltest.cc) SET_SOURCE_FILES_PROPERTIES(mysqltest.cc PROPERTIES COMPILE_FLAGS "-DTHREADS") -TARGET_LINK_LIBRARIES(mysqltest mysqlclient mysys regex wsock32 dbug) +TARGET_LINK_LIBRARIES(mysqltest mysqlclient mysys regex dbug) ADD_EXECUTABLE(mysqlcheck mysqlcheck.c) -TARGET_LINK_LIBRARIES(mysqlcheck mysqlclient wsock32) +TARGET_LINK_LIBRARIES(mysqlcheck mysqlclient) ADD_EXECUTABLE(mysqldump mysqldump.c ../sql-common/my_user.c ../mysys/mf_getdate.c) -TARGET_LINK_LIBRARIES(mysqldump mysqlclient wsock32) +TARGET_LINK_LIBRARIES(mysqldump mysqlclient) ADD_EXECUTABLE(mysqlimport mysqlimport.c) -TARGET_LINK_LIBRARIES(mysqlimport mysqlclient wsock32) +TARGET_LINK_LIBRARIES(mysqlimport mysqlclient) ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c ../mysys/my_getpagesize.c) -TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient wsock32) +TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient) ADD_DEPENDENCIES(mysql_upgrade GenFixPrivs) ADD_EXECUTABLE(mysqlshow mysqlshow.c) -TARGET_LINK_LIBRARIES(mysqlshow mysqlclient wsock32) +TARGET_LINK_LIBRARIES(mysqlshow mysqlclient) ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc ../mysys/mf_tempdir.c @@ -59,14 +59,14 @@ ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc ../mysys/my_bitmap.c ../mysys/my_vle.c ../mysys/base64.c) -TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient wsock32) +TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient) ADD_EXECUTABLE(mysqladmin mysqladmin.cc) -TARGET_LINK_LIBRARIES(mysqladmin mysqlclient wsock32) +TARGET_LINK_LIBRARIES(mysqladmin mysqlclient) ADD_EXECUTABLE(mysqlslap mysqlslap.c) SET_SOURCE_FILES_PROPERTIES(mysqlslap.c PROPERTIES COMPILE_FLAGS "-DTHREADS") -TARGET_LINK_LIBRARIES(mysqlslap mysqlclient mysys zlib wsock32 dbug) +TARGET_LINK_LIBRARIES(mysqlslap mysqlclient mysys zlib dbug) ADD_EXECUTABLE(echo echo.c) diff --git a/extra/CMakeLists.txt b/extra/CMakeLists.txt index cec0db6a4ae..0d09e676af1 100755 --- a/extra/CMakeLists.txt +++ b/extra/CMakeLists.txt @@ -20,7 +20,7 @@ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) ADD_EXECUTABLE(comp_err comp_err.c) -TARGET_LINK_LIBRARIES(comp_err debug dbug mysys strings zlib wsock32) +TARGET_LINK_LIBRARIES(comp_err dbug mysys strings zlib) GET_TARGET_PROPERTY(COMP_ERR_EXE comp_err LOCATION) @@ -39,16 +39,16 @@ ADD_CUSTOM_TARGET(GenError DEPENDS ${PROJECT_SOURCE_DIR}/include/mysqld_error.h) ADD_EXECUTABLE(my_print_defaults my_print_defaults.c) -TARGET_LINK_LIBRARIES(my_print_defaults strings mysys debug dbug taocrypt wsock32) +TARGET_LINK_LIBRARIES(my_print_defaults strings mysys dbug taocrypt) ADD_EXECUTABLE(perror perror.c) -TARGET_LINK_LIBRARIES(perror strings mysys debug dbug wsock32) +TARGET_LINK_LIBRARIES(perror strings mysys dbug) ADD_EXECUTABLE(resolveip resolveip.c) -TARGET_LINK_LIBRARIES(resolveip strings mysys debug dbug wsock32) +TARGET_LINK_LIBRARIES(resolveip strings mysys dbug) ADD_EXECUTABLE(replace replace.c) -TARGET_LINK_LIBRARIES(replace strings mysys debug dbug wsock32) +TARGET_LINK_LIBRARIES(replace strings mysys dbug) IF(EMBED_MANIFESTS) MYSQL_EMBED_MANIFEST("myTest" "asInvoker") diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index 06c17c80bfe..29fe4ca33c3 100755 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -108,7 +108,7 @@ TARGET_LINK_LIBRARIES(mysqlclient) ADD_LIBRARY(libmysql SHARED ${CLIENT_SOURCES} dll.c libmysql.def) ADD_DEPENDENCIES(libmysql GenError) -TARGET_LINK_LIBRARIES(libmysql wsock32) +TARGET_LINK_LIBRARIES(libmysql) IF(EMBED_MANIFESTS) MYSQL_EMBED_MANIFEST("myTest" "asInvoker") diff --git a/mysys/my_init.c b/mysys/my_init.c index a60927be693..c4fda599481 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -27,6 +27,8 @@ #ifdef _MSC_VER #include <locale.h> #include <crtdbg.h> +/* WSAStartup needs winsock library*/
+#pragma comment(lib, "ws2_32") #endif my_bool have_tcpip=0; static void my_win_init(void); diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index f0db25be79a..25cdae2b522 100755 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -24,7 +24,7 @@ ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/scripts/mysql_fix_privilege_tabl # Build comp_sql - used for embedding SQL in C or C++ programs ADD_EXECUTABLE(comp_sql comp_sql.c) -TARGET_LINK_LIBRARIES(comp_sql debug dbug mysys strings) +TARGET_LINK_LIBRARIES(comp_sql dbug mysys strings) # Use comp_sql to build mysql_fix_privilege_tables_sql.c GET_TARGET_PROPERTY(COMP_SQL_EXE comp_sql LOCATION) diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index 592092ba7aa..1b7175a7b82 100755 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -96,7 +96,6 @@ SET_TARGET_PROPERTIES(mysqld PROPERTIES ENABLE_EXPORTS TRUE) SET (MYSQLD_CORE_LIBS mysys zlib dbug strings yassl taocrypt vio regex sql) TARGET_LINK_LIBRARIES(mysqld ${MYSQLD_CORE_LIBS} ${MYSQLD_STATIC_ENGINE_LIBS}) -TARGET_LINK_LIBRARIES(mysqld ws2_32.lib) IF(MSVC AND NOT WITHOUT_DYNAMIC_PLUGINS) @@ -129,7 +128,7 @@ ADD_CUSTOM_COMMAND( # Gen_lex_hash ADD_EXECUTABLE(gen_lex_hash gen_lex_hash.cc) -TARGET_LINK_LIBRARIES(gen_lex_hash debug dbug mysqlclient wsock32) +TARGET_LINK_LIBRARIES(gen_lex_hash dbug mysqlclient) GET_TARGET_PROPERTY(GEN_LEX_HASH_EXE gen_lex_hash LOCATION) ADD_CUSTOM_COMMAND( OUTPUT ${PROJECT_SOURCE_DIR}/sql/lex_hash.h @@ -152,4 +151,4 @@ SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ADD_LIBRARY(udf_example MODULE udf_example.c udf_example.def) ADD_DEPENDENCIES(udf_example strings GenError) -TARGET_LINK_LIBRARIES(udf_example strings wsock32) +TARGET_LINK_LIBRARIES(udf_example strings) diff --git a/sql/udf_example.c b/sql/udf_example.c index 30d85d95034..1d6a9828594 100644 --- a/sql/udf_example.c +++ b/sql/udf_example.c @@ -138,6 +138,11 @@ typedef long long longlong; #endif #include <mysql.h> #include <ctype.h> +
+#ifdef _WIN32
+/* inet_aton needs winsock library */
+#pragma comment(lib, "ws2_32")
+#endif
static pthread_mutex_t LOCK_hostname; diff --git a/storage/myisam/CMakeLists.txt b/storage/myisam/CMakeLists.txt index c05e0046e64..0f070510e5c 100755 --- a/storage/myisam/CMakeLists.txt +++ b/storage/myisam/CMakeLists.txt @@ -34,16 +34,16 @@ MYSQL_STORAGE_ENGINE(MYISAM) IF(NOT SOURCE_SUBLIBS) ADD_EXECUTABLE(myisam_ftdump myisam_ftdump.c) - TARGET_LINK_LIBRARIES(myisam_ftdump myisam mysys debug dbug strings zlib wsock32) + TARGET_LINK_LIBRARIES(myisam_ftdump myisam mysys dbug strings zlib) ADD_EXECUTABLE(myisamchk myisamchk.c) - TARGET_LINK_LIBRARIES(myisamchk myisam mysys debug dbug strings zlib wsock32) + TARGET_LINK_LIBRARIES(myisamchk myisam mysys dbug strings zlib) ADD_EXECUTABLE(myisamlog myisamlog.c) - TARGET_LINK_LIBRARIES(myisamlog myisam mysys debug dbug strings zlib wsock32) + TARGET_LINK_LIBRARIES(myisamlog myisam mysys dbug strings zlib) ADD_EXECUTABLE(myisampack myisampack.c) - TARGET_LINK_LIBRARIES(myisampack myisam mysys debug dbug strings zlib wsock32) + TARGET_LINK_LIBRARIES(myisampack myisam mysys dbug strings zlib) SET_TARGET_PROPERTIES(myisamchk myisampack PROPERTIES LINK_FLAGS "setargv.obj") diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9ddfadcda4e..270aaf53c20 100755 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -20,7 +20,7 @@ ADD_DEFINITIONS("-DMYSQL_CLIENT") INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) ADD_EXECUTABLE(mysql_client_test mysql_client_test.c ../mysys/my_memmem.c) -TARGET_LINK_LIBRARIES(mysql_client_test mysqlclient wsock32) +TARGET_LINK_LIBRARIES(mysql_client_test mysqlclient) ADD_EXECUTABLE(bug25714 bug25714.c) -TARGET_LINK_LIBRARIES(bug25714 mysqlclient wsock32) +TARGET_LINK_LIBRARIES(bug25714 mysqlclient) |