@@ -24,12 +24,6 @@ src/PassiveSocket.cpp
24
24
# append to sources so that dependency checks work on headers
25
25
LIST (APPEND CLSOCKET_SOURCES ${CLSOCKET_HEADERS} )
26
26
27
- # OS and compiler checks.
28
- if (WIN32 )
29
- add_definitions (-D_WINSOCK_DEPRECATED_NO_WARNINGS)
30
- SET (PROJECT_LIBS Ws2_32.lib)
31
- endif ()
32
-
33
27
OPTION (BUILD_SHARED_LIBS "Build libs as shared" ON )
34
28
if (DEFINED CLSOCKET_SHARED)
35
29
message (FATAL_ERROR "The CLSOCKET_SHARED option is deprecated, instead use BUILD_SHARED_LIBS." )
@@ -40,7 +34,11 @@ endif()
40
34
41
35
# make the lib
42
36
ADD_LIBRARY (clsocket ${CLSOCKET_SOURCES} )
43
- TARGET_LINK_LIBRARIES (clsocket ${PROJECT_LIBS} )
37
+ target_include_directories (clsocket PUBLIC src)
38
+ if (WIN32 )
39
+ add_definitions (-D_WINSOCK_DEPRECATED_NO_WARNINGS)
40
+ target_link_libraries (clsocket PRIVATE Ws2_32)
41
+ endif ()
44
42
# target_include_directories was added in 2.8.11
45
43
set_target_properties (clsocket PROPERTIES
46
44
INCLUDE_DIRECTORIES ${PROJECT_SOURCE_DIR} /src
@@ -59,13 +57,13 @@ if(UNIX)
59
57
60
58
if (CLSOCKET_EXAMPLES)
61
59
ADD_EXECUTABLE (clsocket-example examples/RecvAsync.cpp)
62
- TARGET_LINK_LIBRARIES (clsocket-example clsocket pthread)
60
+ target_link_libraries (clsocket-example clsocket pthread)
63
61
install (TARGETS clsocket-example DESTINATION bin)
64
62
65
63
ADD_EXECUTABLE (querydaytime-example examples/QueryDayTime.cpp)
66
- TARGET_LINK_LIBRARIES (querydaytime-example clsocket)
64
+ target_link_libraries (querydaytime-example clsocket)
67
65
68
66
ADD_EXECUTABLE (echoserver-example examples/EchoServer.cpp)
69
- TARGET_LINK_LIBRARIES (echoserver-example clsocket)
67
+ target_link_libraries (echoserver-example clsocket)
70
68
endif ()
71
69
endif ()
0 commit comments