summaryrefslogtreecommitdiff
path: root/cmake/Dependencies.cmake
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-09-24 20:29:25 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-09-24 22:25:49 +0000
commitbfd288c196cfacda78d4b702c1540a0172ef5521 (patch)
treeaa7f42b97abd62f583f8eefc0e07741009671ca3 /cmake/Dependencies.cmake
parentd5d6e3f60f22aee2735cb80db407c201a00e357b (diff)
Revert "Improve cmake build for MSVC."
This reverts commit f87f8719d02a9adbc9413256fe22958267cfefee.
Diffstat (limited to 'cmake/Dependencies.cmake')
-rw-r--r--cmake/Dependencies.cmake77
1 files changed, 49 insertions, 28 deletions
diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake
index c641e094..5970fde7 100644
--- a/cmake/Dependencies.cmake
+++ b/cmake/Dependencies.cmake
@@ -5,44 +5,19 @@
5############################################################################### 5###############################################################################
6 6
7include(ModulePackage) 7include(ModulePackage)
8include(SimpleFindPackage)
9
10if (MSVC)
11 set(THREADS_USE_PTHREADS_WIN32 1)
12endif()
13 8
14find_package(Threads REQUIRED) 9find_package(Threads REQUIRED)
15 10
16if (MSVC)
17 set_property(TARGET Threads::Threads APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS "HAVE_STRUCT_TIMESPEC")
18endif()
19
20find_library(NSL_LIBRARIES nsl ) 11find_library(NSL_LIBRARIES nsl )
21find_library(RT_LIBRARIES rt ) 12find_library(RT_LIBRARIES rt )
22find_library(SOCKET_LIBRARIES socket ) 13find_library(SOCKET_LIBRARIES socket )
23 14
24# For toxcore. 15# For toxcore.
25 16pkg_use_module(LIBSODIUM libsodium )
26# Try to find both static and shared variants of sodium
27set(sodium_USE_STATIC_LIBS OFF)
28find_package(sodium)
29if (NOT TARGET sodium)
30 set(sodium_USE_STATIC_LIBS ON)
31 find_package(sodium REQUIRED)
32endif()
33 17
34# For toxav. 18# For toxav.
35simple_find_package(Opus 19pkg_use_module(OPUS opus )
36 PKGCFG_NAME opus 20pkg_use_module(VPX vpx )
37 INCLUDE_NAMES opus.h
38 PATH_SUFFIXES opus
39 LIB_NAMES opus)
40
41simple_find_package(Vpx
42 PKGCFG_NAME vpx
43 INCLUDE_NAMES vpx_codec.h
44 PATH_SUFFIXES vpx
45 LIB_NAMES vpx vpxmd)
46 21
47# For tox-bootstrapd. 22# For tox-bootstrapd.
48pkg_use_module(LIBCONFIG libconfig ) 23pkg_use_module(LIBCONFIG libconfig )
@@ -54,3 +29,49 @@ pkg_use_module(MSGPACK msgpack )
54pkg_use_module(OPENCV opencv ) 29pkg_use_module(OPENCV opencv )
55pkg_use_module(PORTAUDIO portaudio-2.0) 30pkg_use_module(PORTAUDIO portaudio-2.0)
56pkg_use_module(SNDFILE sndfile ) 31pkg_use_module(SNDFILE sndfile )
32
33###############################################################################
34#
35# :: For MSVC Windows builds.
36#
37# These require specific installation paths of dependencies:
38# - libsodium in third-party/libsodium/Win32/Release/v140/dynamic
39# - pthreads in third-party/pthreads-win32/Pre-built.2
40#
41###############################################################################
42
43if(MSVC)
44 # libsodium
45 # ---------
46 find_library(LIBSODIUM_LIBRARIES
47 NAMES sodium libsodium
48 PATHS
49 "third_party/libsodium/Win32/Release/v140/dynamic"
50 "third_party/libsodium/x64/Release/v140/dynamic"
51 )
52 if(LIBSODIUM_LIBRARIES)
53 include_directories("third_party/libsodium/include")
54 set(LIBSODIUM_FOUND TRUE)
55 message("libsodium: ${LIBSODIUM_LIBRARIES}")
56 else()
57 message(FATAL_ERROR "libsodium libraries not found")
58 endif()
59
60 # pthreads
61 # --------
62 if(CMAKE_USE_WIN32_THREADS_INIT)
63 find_library(CMAKE_THREAD_LIBS_INIT
64 NAMES pthreadVC2
65 PATHS
66 "third_party/pthreads-win32/Pre-built.2/lib/x86"
67 "third_party/pthreads-win32/Pre-built.2/lib/x64"
68 )
69 if(CMAKE_THREAD_LIBS_INIT)
70 include_directories("third_party/pthreads-win32/Pre-built.2/include")
71 add_definitions(-DHAVE_STRUCT_TIMESPEC)
72 message("libpthreads: ${CMAKE_THREAD_LIBS_INIT}")
73 else()
74 message(FATAL_ERROR "libpthreads libraries not found")
75 endif()
76 endif()
77endif()