diff options
Diffstat (limited to 'cmake/Dependencies.cmake')
-rw-r--r-- | cmake/Dependencies.cmake | 77 |
1 files changed, 28 insertions, 49 deletions
diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake index 5970fde7..c641e094 100644 --- a/cmake/Dependencies.cmake +++ b/cmake/Dependencies.cmake | |||
@@ -5,19 +5,44 @@ | |||
5 | ############################################################################### | 5 | ############################################################################### |
6 | 6 | ||
7 | include(ModulePackage) | 7 | include(ModulePackage) |
8 | include(SimpleFindPackage) | ||
9 | |||
10 | if (MSVC) | ||
11 | set(THREADS_USE_PTHREADS_WIN32 1) | ||
12 | endif() | ||
8 | 13 | ||
9 | find_package(Threads REQUIRED) | 14 | find_package(Threads REQUIRED) |
10 | 15 | ||
16 | if (MSVC) | ||
17 | set_property(TARGET Threads::Threads APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS "HAVE_STRUCT_TIMESPEC") | ||
18 | endif() | ||
19 | |||
11 | find_library(NSL_LIBRARIES nsl ) | 20 | find_library(NSL_LIBRARIES nsl ) |
12 | find_library(RT_LIBRARIES rt ) | 21 | find_library(RT_LIBRARIES rt ) |
13 | find_library(SOCKET_LIBRARIES socket ) | 22 | find_library(SOCKET_LIBRARIES socket ) |
14 | 23 | ||
15 | # For toxcore. | 24 | # For toxcore. |
16 | pkg_use_module(LIBSODIUM libsodium ) | 25 | |
26 | # Try to find both static and shared variants of sodium | ||
27 | set(sodium_USE_STATIC_LIBS OFF) | ||
28 | find_package(sodium) | ||
29 | if (NOT TARGET sodium) | ||
30 | set(sodium_USE_STATIC_LIBS ON) | ||
31 | find_package(sodium REQUIRED) | ||
32 | endif() | ||
17 | 33 | ||
18 | # For toxav. | 34 | # For toxav. |
19 | pkg_use_module(OPUS opus ) | 35 | simple_find_package(Opus |
20 | pkg_use_module(VPX vpx ) | 36 | PKGCFG_NAME opus |
37 | INCLUDE_NAMES opus.h | ||
38 | PATH_SUFFIXES opus | ||
39 | LIB_NAMES opus) | ||
40 | |||
41 | simple_find_package(Vpx | ||
42 | PKGCFG_NAME vpx | ||
43 | INCLUDE_NAMES vpx_codec.h | ||
44 | PATH_SUFFIXES vpx | ||
45 | LIB_NAMES vpx vpxmd) | ||
21 | 46 | ||
22 | # For tox-bootstrapd. | 47 | # For tox-bootstrapd. |
23 | pkg_use_module(LIBCONFIG libconfig ) | 48 | pkg_use_module(LIBCONFIG libconfig ) |
@@ -29,49 +54,3 @@ pkg_use_module(MSGPACK msgpack ) | |||
29 | pkg_use_module(OPENCV opencv ) | 54 | pkg_use_module(OPENCV opencv ) |
30 | pkg_use_module(PORTAUDIO portaudio-2.0) | 55 | pkg_use_module(PORTAUDIO portaudio-2.0) |
31 | pkg_use_module(SNDFILE sndfile ) | 56 | pkg_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 | |||
43 | if(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() | ||
77 | endif() | ||