From f87f8719d02a9adbc9413256fe22958267cfefee Mon Sep 17 00:00:00 2001 From: Mick Sayson Date: Thu, 20 Sep 2018 01:01:40 -0700 Subject: Improve cmake build for MSVC. --- cmake/Dependencies.cmake | 77 ++++++++++++++++++------------------------------ 1 file changed, 28 insertions(+), 49 deletions(-) (limited to 'cmake/Dependencies.cmake') 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 @@ ############################################################################### include(ModulePackage) +include(SimpleFindPackage) + +if (MSVC) + set(THREADS_USE_PTHREADS_WIN32 1) +endif() find_package(Threads REQUIRED) +if (MSVC) + set_property(TARGET Threads::Threads APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS "HAVE_STRUCT_TIMESPEC") +endif() + find_library(NSL_LIBRARIES nsl ) find_library(RT_LIBRARIES rt ) find_library(SOCKET_LIBRARIES socket ) # For toxcore. -pkg_use_module(LIBSODIUM libsodium ) + +# Try to find both static and shared variants of sodium +set(sodium_USE_STATIC_LIBS OFF) +find_package(sodium) +if (NOT TARGET sodium) + set(sodium_USE_STATIC_LIBS ON) + find_package(sodium REQUIRED) +endif() # For toxav. -pkg_use_module(OPUS opus ) -pkg_use_module(VPX vpx ) +simple_find_package(Opus + PKGCFG_NAME opus + INCLUDE_NAMES opus.h + PATH_SUFFIXES opus + LIB_NAMES opus) + +simple_find_package(Vpx + PKGCFG_NAME vpx + INCLUDE_NAMES vpx_codec.h + PATH_SUFFIXES vpx + LIB_NAMES vpx vpxmd) # For tox-bootstrapd. pkg_use_module(LIBCONFIG libconfig ) @@ -29,49 +54,3 @@ pkg_use_module(MSGPACK msgpack ) pkg_use_module(OPENCV opencv ) pkg_use_module(PORTAUDIO portaudio-2.0) pkg_use_module(SNDFILE sndfile ) - -############################################################################### -# -# :: For MSVC Windows builds. -# -# These require specific installation paths of dependencies: -# - libsodium in third-party/libsodium/Win32/Release/v140/dynamic -# - pthreads in third-party/pthreads-win32/Pre-built.2 -# -############################################################################### - -if(MSVC) - # libsodium - # --------- - find_library(LIBSODIUM_LIBRARIES - NAMES sodium libsodium - PATHS - "third_party/libsodium/Win32/Release/v140/dynamic" - "third_party/libsodium/x64/Release/v140/dynamic" - ) - if(LIBSODIUM_LIBRARIES) - include_directories("third_party/libsodium/include") - set(LIBSODIUM_FOUND TRUE) - message("libsodium: ${LIBSODIUM_LIBRARIES}") - else() - message(FATAL_ERROR "libsodium libraries not found") - endif() - - # pthreads - # -------- - if(CMAKE_USE_WIN32_THREADS_INIT) - find_library(CMAKE_THREAD_LIBS_INIT - NAMES pthreadVC2 - PATHS - "third_party/pthreads-win32/Pre-built.2/lib/x86" - "third_party/pthreads-win32/Pre-built.2/lib/x64" - ) - if(CMAKE_THREAD_LIBS_INIT) - include_directories("third_party/pthreads-win32/Pre-built.2/include") - add_definitions(-DHAVE_STRUCT_TIMESPEC) - message("libpthreads: ${CMAKE_THREAD_LIBS_INIT}") - else() - message(FATAL_ERROR "libpthreads libraries not found") - endif() - endif() -endif() -- cgit v1.2.3