summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake')
-rw-r--r--cmake/Dependencies.cmake37
-rw-r--r--cmake/ModulePackage.cmake48
2 files changed, 55 insertions, 30 deletions
diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake
index 8361e8e1..37eb40bd 100644
--- a/cmake/Dependencies.cmake
+++ b/cmake/Dependencies.cmake
@@ -16,8 +16,8 @@ find_library(SOCKET_LIBRARIES socket )
16pkg_use_module(LIBSODIUM libsodium ) 16pkg_use_module(LIBSODIUM libsodium )
17 17
18# For toxav. 18# For toxav.
19pkg_use_module(OPUS opus ) 19pkg_use_module(OPUS "opus;Opus" )
20pkg_use_module(VPX vpx ) 20pkg_use_module(VPX "vpx;libvpx" )
21 21
22# For tox-bootstrapd. 22# For tox-bootstrapd.
23pkg_use_module(LIBCONFIG libconfig ) 23pkg_use_module(LIBCONFIG libconfig )
@@ -38,18 +38,20 @@ pkg_use_module(MSGPACK msgpack )
38if(MSVC) 38if(MSVC)
39 # libsodium 39 # libsodium
40 # --------- 40 # ---------
41 find_library(LIBSODIUM_LIBRARIES 41 if(NOT LIBSODIUM_FOUND)
42 NAMES sodium libsodium 42 find_library(LIBSODIUM_LIBRARIES
43 PATHS 43 NAMES sodium libsodium
44 "third_party/libsodium/Win32/Release/v140/dynamic" 44 PATHS
45 "third_party/libsodium/x64/Release/v140/dynamic" 45 "third_party/libsodium/Win32/Release/v140/dynamic"
46 ) 46 "third_party/libsodium/x64/Release/v140/dynamic"
47 if(LIBSODIUM_LIBRARIES) 47 )
48 include_directories("third_party/libsodium/include") 48 if(LIBSODIUM_LIBRARIES)
49 set(LIBSODIUM_FOUND TRUE) 49 include_directories("third_party/libsodium/include")
50 message("libsodium: ${LIBSODIUM_LIBRARIES}") 50 set(LIBSODIUM_FOUND TRUE)
51 else() 51 message("libsodium: ${LIBSODIUM_LIBRARIES}")
52 message(FATAL_ERROR "libsodium libraries not found") 52 else()
53 message(FATAL_ERROR "libsodium libraries not found")
54 endif()
53 endif() 55 endif()
54 56
55 # pthreads 57 # pthreads
@@ -66,7 +68,12 @@ if(MSVC)
66 add_definitions(-DHAVE_STRUCT_TIMESPEC) 68 add_definitions(-DHAVE_STRUCT_TIMESPEC)
67 message("libpthreads: ${CMAKE_THREAD_LIBS_INIT}") 69 message("libpthreads: ${CMAKE_THREAD_LIBS_INIT}")
68 else() 70 else()
69 message(FATAL_ERROR "libpthreads libraries not found") 71 find_package(pthreads4w)
72 if(NOT pthreads4w_FOUND)
73 message(FATAL_ERROR "libpthreads libraries not found")
74 endif()
75 include_directories(${pthreads4w_INCLUDE_DIR})
76 link_libraries(${pthreads4w_LIBRARIES})
70 endif() 77 endif()
71 endif() 78 endif()
72endif() 79endif()
diff --git a/cmake/ModulePackage.cmake b/cmake/ModulePackage.cmake
index 9cc21863..04dbf16d 100644
--- a/cmake/ModulePackage.cmake
+++ b/cmake/ModulePackage.cmake
@@ -21,21 +21,39 @@ endif()
21 21
22find_package(PkgConfig) 22find_package(PkgConfig)
23 23
24function(pkg_use_module mod pkg) 24function(pkg_use_module mod pkgs)
25 if(PKG_CONFIG_FOUND) 25 foreach(pkg IN ITEMS ${pkgs})
26 pkg_search_module(${mod} ${pkg}) 26 if(PKG_CONFIG_FOUND)
27 endif() 27 pkg_search_module(${mod} ${pkg})
28 if(${mod}_FOUND) 28 endif()
29 link_directories(${${mod}_LIBRARY_DIRS}) 29 if(NOT ${mod}_FOUND)
30 include_directories(${${mod}_INCLUDE_DIRS}) 30 find_package(${pkg} QUIET)
31 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${${mod}_CFLAGS_OTHER}" PARENT_SCOPE) 31 # This is very very ugly, but the variables are sometimes used in this scope
32 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${${mod}_CFLAGS_OTHER}" PARENT_SCOPE) 32 # and sometimes in the parent scope, so we have to set them to both places.
33 33 set(${mod}_FOUND ${${pkg}_FOUND})
34 foreach(dir ${${mod}_INCLUDE_DIRS}) 34 set(${mod}_FOUND ${${pkg}_FOUND} PARENT_SCOPE)
35 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -isystem ${dir}" PARENT_SCOPE) 35 set(${mod}_LIBRARIES ${${pkg}_LIBS})
36 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${dir}" PARENT_SCOPE) 36 set(${mod}_LIBRARIES ${${pkg}_LIBS} PARENT_SCOPE)
37 endforeach() 37 set(${mod}_LIBRARY_DIRS ${${pkg}_LIBRARY_DIRS})
38 endif() 38 set(${mod}_LIBRARY_DIRS ${${pkg}_LIBRARY_DIRS} PARENT_SCOPE)
39 set(${mod}_INCLUDE_DIRS ${${pkg}_INCLUDE_DIRS})
40 set(${mod}_INCLUDE_DIRS ${${pkg}_INCLUDE_DIRS} PARENT_SCOPE)
41 endif()
42 if(${mod}_FOUND)
43 link_directories(${${mod}_LIBRARY_DIRS})
44 include_directories(${${mod}_INCLUDE_DIRS})
45 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${${mod}_CFLAGS_OTHER}" PARENT_SCOPE)
46 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${${mod}_CFLAGS_OTHER}" PARENT_SCOPE)
47
48 if(NOT MSVC)
49 foreach(dir ${${mod}_INCLUDE_DIRS})
50 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -isystem ${dir}" PARENT_SCOPE)
51 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${dir}" PARENT_SCOPE)
52 endforeach()
53 endif()
54 break()
55 endif()
56 endforeach()
39endfunction() 57endfunction()
40 58
41function(add_module lib) 59function(add_module lib)