Fix windows build.

The threading networking functions (on windows: winsock and friends) need to be
linked into the toxnetwork library, not the toxcore library, anymore. On Linux
and OSX, there is no winsock. On OSX, there is no need to link against threading
libraries, and on Linux, toxnetwork can have unresolved symbols when linking, so
this failure wasn't caught before.

Tested by building on the iphydf/windows-x86-qt5 docker image.
This commit is contained in:
iphydf 2016-08-18 10:29:39 +01:00
parent 4d83451da6
commit b044cfbf15
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9

View File

@ -96,6 +96,16 @@ endif()
#
################################################################################
# toxcore_PKGCONFIG_LIBS is what's added to the Libs: line in toxcore.pc. It
# needs to contain all the libraries a program using toxcore should link against
# if it's statically linked. If it's dynamically linked, there is no need to
# explicitly link against all the dependencies, but it doesn't harm much(*)
# either.
#
# (*) It allows client code to use symbols from our dependencies without
# explicitly linking against them.
set(toxcore_PKGCONFIG_LIBS)
# LAYER 1: Crypto core
# --------------------
add_library(toxcrypto ${LIBTYPE}
@ -109,11 +119,22 @@ add_library(toxnetwork ${LIBTYPE}
toxcore/network.c
toxcore/util.c)
target_link_libraries(toxnetwork toxcrypto)
if(CMAKE_THREAD_LIBS_INIT)
target_link_libraries(toxnetwork ${CMAKE_THREAD_LIBS_INIT})
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} "-l${CMAKE_THREAD_LIBS_INIT}")
endif()
if(RT_LIBRARIES)
target_link_libraries(toxnetwork ${RT_LIBRARIES})
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} "-lrt")
endif()
if(WIN32)
target_link_libraries(toxnetwork ws2_32 iphlpapi)
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} "-lws2_32 -liphlpapi")
endif()
# LAYER 3: Distributed Hash Table
# -------------------------------
add_library(toxdht ${LIBTYPE}
@ -162,15 +183,6 @@ add_library(toxcore ${LIBTYPE}
toxcore/tox.c)
target_link_libraries(toxcore toxgroup)
target_link_libraries(toxcore ${CMAKE_THREAD_LIBS_INIT})
if(CMAKE_THREAD_LIBS_INIT)
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} "-l${CMAKE_THREAD_LIBS_INIT}")
endif()
if(WIN32)
target_link_libraries(toxcore ws2_32 iphlpapi)
endif()
################################################################################
#