1# Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com> 2# 3# Redistribution and use in source and binary forms, 4# with or without modification, are permitted provided 5# that the following conditions are met: 6# 7# Redistributions of source code must retain the above 8# copyright notice, this list of conditions and the 9# following disclaimer. 10# 11# Redistributions in binary form must reproduce the above 12# copyright notice, this list of conditions and the following 13# disclaimer in the documentation and/or other materials 14# provided with the distribution. 15# 16# Neither the name of the copyright holder nor the names 17# of any other contributors may be used to endorse or 18# promote products derived from this software without 19# specific prior written permission. 20# 21# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 22# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 23# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 26# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 31# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 33# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 34# OF SUCH DAMAGE. 35 36# Some systems have their socket functions in a library. 37# (Solaris -lsocket/-lnsl, Windows -lws2_32). This macro appends those 38# libraries to the given list 39macro(append_needed_socket_libraries LIBRARIES_LIST) 40 if(CMAKE_SYSTEM_NAME STREQUAL "Windows" AND CMAKE_SIZEOF_VOID_P EQUAL 4) 41 # x86 Windows uses STDCALL for these functions, so their names are mangled, 42 # meaning the platform checks don't work. Hardcoding these until we get 43 # a better solution. 44 set(HAVE_SOCKET 1) 45 set(HAVE_SELECT 1) 46 set(HAVE_INET_ADDR 1) 47 set(NEED_LIB_WS2_32 1) 48 else() 49 check_function_exists_may_need_library(socket HAVE_SOCKET socket ws2_32) 50 check_function_exists_may_need_library(select HAVE_SELECT ws2_32) 51 check_function_exists_may_need_library(inet_addr HAVE_INET_ADDR nsl ws2_32) 52 endif() 53 54 if(NEED_LIB_SOCKET) 55 list(APPEND ${LIBRARIES_LIST} socket) 56 endif() 57 if(NEED_LIB_NSL) 58 list(APPEND ${LIBRARIES_LIST} nsl) 59 endif() 60 if(NEED_LIB_WS2_32) 61 list(APPEND ${LIBRARIES_LIST} ws2_32) 62 endif() 63 64endmacro()