summaryrefslogtreecommitdiff
path: root/cmake/Dependencies.cmake
diff options
context:
space:
mode:
authorMick Sayson <mick@sayson.com>2018-09-20 01:01:40 -0700
committeriphydf <iphydf@users.noreply.github.com>2018-09-22 11:14:45 +0000
commitf87f8719d02a9adbc9413256fe22958267cfefee (patch)
treeeef1842aac108c8887e043e33d16859f85ca8c3c /cmake/Dependencies.cmake
parentdc0b2e79193ef303b1ae240e79996d4619138d31 (diff)
Improve cmake build for MSVC.
Diffstat (limited to 'cmake/Dependencies.cmake')
-rw-r--r--cmake/Dependencies.cmake77
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
7include(ModulePackage) 7include(ModulePackage)
8include(SimpleFindPackage)
9
10if (MSVC)
11 set(THREADS_USE_PTHREADS_WIN32 1)
12endif()
8 13
9find_package(Threads REQUIRED) 14find_package(Threads REQUIRED)
10 15
16if (MSVC)
17 set_property(TARGET Threads::Threads APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS "HAVE_STRUCT_TIMESPEC")
18endif()
19
11find_library(NSL_LIBRARIES nsl ) 20find_library(NSL_LIBRARIES nsl )
12find_library(RT_LIBRARIES rt ) 21find_library(RT_LIBRARIES rt )
13find_library(SOCKET_LIBRARIES socket ) 22find_library(SOCKET_LIBRARIES socket )
14 23
15# For toxcore. 24# For toxcore.
16pkg_use_module(LIBSODIUM libsodium ) 25
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()
17 33
18# For toxav. 34# For toxav.
19pkg_use_module(OPUS opus ) 35simple_find_package(Opus
20pkg_use_module(VPX vpx ) 36 PKGCFG_NAME opus
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)
21 46
22# For tox-bootstrapd. 47# For tox-bootstrapd.
23pkg_use_module(LIBCONFIG libconfig ) 48pkg_use_module(LIBCONFIG libconfig )
@@ -29,49 +54,3 @@ pkg_use_module(MSGPACK msgpack )
29pkg_use_module(OPENCV opencv ) 54pkg_use_module(OPENCV opencv )
30pkg_use_module(PORTAUDIO portaudio-2.0) 55pkg_use_module(PORTAUDIO portaudio-2.0)
31pkg_use_module(SNDFILE sndfile ) 56pkg_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()