cmake: Don't use check_library_exists for Win32 API libraries

When building for X86 the CMake check_library_exists always fails to find
functions from the Win32 API due to name mangling conventions. The convention
for API functions is __stdcall and the CMake test code assumes __cdecl. Since
these are libraries from the Windows API we can simply link against the
libraries without checking for the functions.
This commit is contained in:
Rui Abreu Ferreira 2015-09-23 23:31:39 +01:00 committed by Seth Jackson
parent 7d42e9b7e8
commit f22dfeb00d
1 changed files with 5 additions and 16 deletions

View File

@ -59,11 +59,6 @@ if(HAVE_LIBDL)
list(APPEND LIBUV_LIBRARIES dl)
endif()
check_library_exists(iphlpapi GetAdaptersAddresses "iphlpapi.h" HAVE_LIBIPHLPAPI)
if(HAVE_LIBIPHLPAPI)
list(APPEND LIBUV_LIBRARIES iphlpapi)
endif()
check_library_exists(kstat kstat_lookup "kstat.h" HAVE_LIBKSTAT)
if(HAVE_LIBKSTAT)
list(APPEND LIBUV_LIBRARIES kstat)
@ -84,11 +79,6 @@ if(HAVE_LIBPERFSTAT)
list(APPEND LIBUV_LIBRARIES perfstat)
endif()
check_library_exists(psapi GetProcessMemoryInfo "psapi.h" HAVE_LIBPSAPI)
if(HAVE_LIBPSAPI)
list(APPEND LIBUV_LIBRARIES psapi)
endif()
check_library_exists(rt clock_gettime "time.h" HAVE_LIBRT)
if(HAVE_LIBRT)
list(APPEND LIBUV_LIBRARIES rt)
@ -99,13 +89,12 @@ if(HAVE_LIBSENDFILE)
list(APPEND LIBUV_LIBRARIES sendfile)
endif()
check_library_exists(userenv GetUserProfileDirectoryW "userenv.h" HAVE_LIBUSERENV)
if(HAVE_LIBUSERENV)
if(WIN32)
# check_library_exists() does not work for Win32 API calls in X86 due to name
# mangling calling conventions
list(APPEND LIBUV_LIBRARIES iphlpapi)
list(APPEND LIBUV_LIBRARIES psapi)
list(APPEND LIBUV_LIBRARIES userenv)
endif()
check_library_exists(ws2_32 WSAStartup "winsock2.h" HAVE_LIBWS232)
if(HAVE_LIBWS232)
list(APPEND LIBUV_LIBRARIES ws2_32)
endif()