Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to link winsock in cmake?

Tags:

c++

cmake

winsock

I found only this strings

    find_library(WSOCK32_LIBRARY wsock32)
    find_library(WS2_32_LIBRARY ws2_32)

(i'm begginer in cmake) how to link winsock2 (winsock?) in cmake?

like image 663
Fedcomp Avatar asked Feb 27 '13 18:02

Fedcomp


1 Answers

Since these are both part of the Windows SDK, you shouldn't need to do a search for them. Assuming you have the SDK installed, you can just do something like:

add_executable(MyExe main.cpp)
if(WIN32)
  target_link_libraries(MyExe wsock32 ws2_32)
endif()
like image 109
Fraser Avatar answered Nov 09 '22 13:11

Fraser