Changeset: 9fb539508bca for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9fb539508bca Modified Files: CMakeLists.txt Branch: cmake-fun Log Message:
MSVC uses different socket libraries. diffs (135 lines): diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1606,69 +1606,80 @@ check_include_file("winsock.h" HAVE_WINS # Socket libraries set(SOCKET_LIBRARIES ) -check_symbol_exists("gethostbyname" "netdb.h;sys/socket.h" HAVE_GETHOSTBYNAME) -if(NOT HAVE_GETHOSTBYNAME) - message(STATUS "Trying to find gethostbyname by linking to nsl") - set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES};nsl") - check_symbol_exists("gethostbyname" "netdb.h;sys/socket.h" HAVE_GETHOSTBYNAME) - if(HAVE_GETHOSTBYNAME) - list(APPEND SOCKET_LIBRARIES nsl) - else() - message(FATAL_ERROR "Could not find gethostbyname symbol") +if(MSVC) + find_library(WSOCK32_LIBRARY NAMES wsock32) + if(WSOCK32_LIBRARY) + list(APPEND SOCKET_LIBRARIES "wsock32") + endif() + find_library(WS2_32_LIBRARY NAMES Ws2_32) + if(WS2_32_LIBRARY) + list(APPEND SOCKET_LIBRARIES "Ws2_32") endif() - set(CMAKE_REQUIRED_LIBRARIES "${PREV_CMAKE_REQUIRED_LIBRARIES}") -endif() - -check_symbol_exists("hstrerror" "netdb.h;sys/socket.h" HAVE_HSTERROR) -if(NOT HAVE_HSTERROR) - message(STATUS "Trying to find hstrerror by linking to resolv") - set(CMAKE_REQUIRED_LIBRARIES "${PREV_CMAKE_REQUIRED_LIBRARIES};resolv") - check_symbol_exists("hstrerror" "netdb.h;sys/socket.h" HAVE_HSTERROR) - if(HAVE_HSTERROR) - list(APPEND SOCKET_LIBRARIES resolv) - else() - message(FATAL_ERROR "Could not find hstrerror symbol") +else() + check_symbol_exists("gethostbyname" "netdb.h;sys/socket.h" HAVE_GETHOSTBYNAME) + if(NOT HAVE_GETHOSTBYNAME) + message(STATUS "Trying to find gethostbyname by linking to nsl") + set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES};nsl") + check_symbol_exists("gethostbyname" "netdb.h;sys/socket.h" HAVE_GETHOSTBYNAME) + if(HAVE_GETHOSTBYNAME) + list(APPEND SOCKET_LIBRARIES nsl) + else() + message(FATAL_ERROR "Could not find gethostbyname symbol") + endif() + set(CMAKE_REQUIRED_LIBRARIES "${PREV_CMAKE_REQUIRED_LIBRARIES}") endif() - set(CMAKE_REQUIRED_LIBRARIES "${PREV_CMAKE_REQUIRED_LIBRARIES}") -endif() -check_symbol_exists("setsockopt" "sys/types.h;sys/socket.h" HAVE_SETSOCKOPT) -if(NOT HAVE_SETSOCKOPT) - message(STATUS "Trying to find setsockopt by linking to socket") - set(CMAKE_REQUIRED_LIBRARIES "${PREV_CMAKE_REQUIRED_LIBRARIES};socket") - check_symbol_exists("setsockopt" "sys/types.h;sys/socket.h" HAVE_SETSOCKOPT) - if(HAVE_SETSOCKOPT) - list(APPEND SOCKET_LIBRARIES socket) - else() - message(FATAL_ERROR "Could not find setsockopt symbol") + check_symbol_exists("hstrerror" "netdb.h;sys/socket.h" HAVE_HSTERROR) + if(NOT HAVE_HSTERROR) + message(STATUS "Trying to find hstrerror by linking to resolv") + set(CMAKE_REQUIRED_LIBRARIES "${PREV_CMAKE_REQUIRED_LIBRARIES};resolv") + check_symbol_exists("hstrerror" "netdb.h;sys/socket.h" HAVE_HSTERROR) + if(HAVE_HSTERROR) + list(APPEND SOCKET_LIBRARIES resolv) + else() + message(FATAL_ERROR "Could not find hstrerror symbol") + endif() + set(CMAKE_REQUIRED_LIBRARIES "${PREV_CMAKE_REQUIRED_LIBRARIES}") endif() - set(CMAKE_REQUIRED_LIBRARIES "${PREV_CMAKE_REQUIRED_LIBRARIES}") -endif() -check_symbol_exists("getaddrinfo" "sys/types.h;sys/socket.h;netdb.h" HAVE_GETADDRINFO) -if(NOT HAVE_GETADDRINFO) - message(STATUS "Trying to find getaddrinfo by linking to socket") - set(CMAKE_REQUIRED_LIBRARIES "${PREV_CMAKE_REQUIRED_LIBRARIES};socket") + check_symbol_exists("setsockopt" "sys/types.h;sys/socket.h" HAVE_SETSOCKOPT) + if(NOT HAVE_SETSOCKOPT) + message(STATUS "Trying to find setsockopt by linking to socket") + set(CMAKE_REQUIRED_LIBRARIES "${PREV_CMAKE_REQUIRED_LIBRARIES};socket") + check_symbol_exists("setsockopt" "sys/types.h;sys/socket.h" HAVE_SETSOCKOPT) + if(HAVE_SETSOCKOPT) + list(APPEND SOCKET_LIBRARIES socket) + else() + message(FATAL_ERROR "Could not find setsockopt symbol") + endif() + set(CMAKE_REQUIRED_LIBRARIES "${PREV_CMAKE_REQUIRED_LIBRARIES}") + endif() + check_symbol_exists("getaddrinfo" "sys/types.h;sys/socket.h;netdb.h" HAVE_GETADDRINFO) - if(HAVE_GETADDRINFO) - list(FIND ${SOCKET_LIBRARIES} socket LINKED_TO_SOCKET) - if(NOT LINKED_TO_SOCKET) - list(APPEND SOCKET_LIBRARIES socket) - endif() - else() - message(STATUS "Trying to find getaddrinfo by linking to nsl") - set(CMAKE_REQUIRED_LIBRARIES "${PREV_CMAKE_REQUIRED_LIBRARIES};nsl") + if(NOT HAVE_GETADDRINFO) + message(STATUS "Trying to find getaddrinfo by linking to socket") + set(CMAKE_REQUIRED_LIBRARIES "${PREV_CMAKE_REQUIRED_LIBRARIES};socket") check_symbol_exists("getaddrinfo" "sys/types.h;sys/socket.h;netdb.h" HAVE_GETADDRINFO) if(HAVE_GETADDRINFO) - list(FIND ${SOCKET_LIBRARIES} nsl LINKED_TO_NSL) - if(NOT LINKED_TO_NSL) - list(APPEND SOCKET_LIBRARIES nsl) + list(FIND ${SOCKET_LIBRARIES} socket LINKED_TO_SOCKET) + if(NOT LINKED_TO_SOCKET) + list(APPEND SOCKET_LIBRARIES socket) endif() else() - message(FATAL_ERROR "Could not find getaddrinfo symbol") + message(STATUS "Trying to find getaddrinfo by linking to nsl") + set(CMAKE_REQUIRED_LIBRARIES "${PREV_CMAKE_REQUIRED_LIBRARIES};nsl") + check_symbol_exists("getaddrinfo" "sys/types.h;sys/socket.h;netdb.h" HAVE_GETADDRINFO) + if(HAVE_GETADDRINFO) + list(FIND ${SOCKET_LIBRARIES} nsl LINKED_TO_NSL) + if(NOT LINKED_TO_NSL) + list(APPEND SOCKET_LIBRARIES nsl) + endif() + else() + message(FATAL_ERROR "Could not find getaddrinfo symbol") + endif() endif() + set(CMAKE_REQUIRED_LIBRARIES "${PREV_CMAKE_REQUIRED_LIBRARIES}") endif() - set(CMAKE_REQUIRED_LIBRARIES "${PREV_CMAKE_REQUIRED_LIBRARIES}") endif() cmake_push_check_state() _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list