summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2016-08-18 10:29:39 +0100
committeriphydf <iphydf@users.noreply.github.com>2016-08-21 14:21:57 +0100
commitb044cfbf1509ff45b2d4b0f518dadd8ad7c05046 (patch)
treeb7568db37835374f920490b93dbb2f3eb0cc6308 /CMakeLists.txt
parent4d83451da6f478473c6519c3dccd7a60f32b3acf (diff)
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.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt30
1 files changed, 21 insertions, 9 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bed16d26..25c8ed15 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -96,6 +96,16 @@ endif()
96# 96#
97################################################################################ 97################################################################################
98 98
99# toxcore_PKGCONFIG_LIBS is what's added to the Libs: line in toxcore.pc. It
100# needs to contain all the libraries a program using toxcore should link against
101# if it's statically linked. If it's dynamically linked, there is no need to
102# explicitly link against all the dependencies, but it doesn't harm much(*)
103# either.
104#
105# (*) It allows client code to use symbols from our dependencies without
106# explicitly linking against them.
107set(toxcore_PKGCONFIG_LIBS)
108
99# LAYER 1: Crypto core 109# LAYER 1: Crypto core
100# -------------------- 110# --------------------
101add_library(toxcrypto ${LIBTYPE} 111add_library(toxcrypto ${LIBTYPE}
@@ -109,11 +119,22 @@ add_library(toxnetwork ${LIBTYPE}
109 toxcore/network.c 119 toxcore/network.c
110 toxcore/util.c) 120 toxcore/util.c)
111target_link_libraries(toxnetwork toxcrypto) 121target_link_libraries(toxnetwork toxcrypto)
122
123if(CMAKE_THREAD_LIBS_INIT)
124 target_link_libraries(toxnetwork ${CMAKE_THREAD_LIBS_INIT})
125 set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} "-l${CMAKE_THREAD_LIBS_INIT}")
126endif()
127
112if(RT_LIBRARIES) 128if(RT_LIBRARIES)
113 target_link_libraries(toxnetwork ${RT_LIBRARIES}) 129 target_link_libraries(toxnetwork ${RT_LIBRARIES})
114 set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} "-lrt") 130 set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} "-lrt")
115endif() 131endif()
116 132
133if(WIN32)
134 target_link_libraries(toxnetwork ws2_32 iphlpapi)
135 set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} "-lws2_32 -liphlpapi")
136endif()
137
117# LAYER 3: Distributed Hash Table 138# LAYER 3: Distributed Hash Table
118# ------------------------------- 139# -------------------------------
119add_library(toxdht ${LIBTYPE} 140add_library(toxdht ${LIBTYPE}
@@ -162,15 +183,6 @@ add_library(toxcore ${LIBTYPE}
162 toxcore/tox.c) 183 toxcore/tox.c)
163target_link_libraries(toxcore toxgroup) 184target_link_libraries(toxcore toxgroup)
164 185
165target_link_libraries(toxcore ${CMAKE_THREAD_LIBS_INIT})
166if(CMAKE_THREAD_LIBS_INIT)
167 set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} "-l${CMAKE_THREAD_LIBS_INIT}")
168endif()
169
170if(WIN32)
171 target_link_libraries(toxcore ws2_32 iphlpapi)
172endif()
173
174 186
175################################################################################ 187################################################################################
176# 188#