From bfd288c196cfacda78d4b702c1540a0172ef5521 Mon Sep 17 00:00:00 2001 From: iphydf Date: Mon, 24 Sep 2018 20:29:25 +0000 Subject: Revert "Improve cmake build for MSVC." This reverts commit f87f8719d02a9adbc9413256fe22958267cfefee. --- cmake/Dependencies.cmake | 77 ++++++++++++++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 28 deletions(-) (limited to 'cmake/Dependencies.cmake') 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 @@ ############################################################################### 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. - -# 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() +pkg_use_module(LIBSODIUM libsodium ) # For toxav. -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) +pkg_use_module(OPUS opus ) +pkg_use_module(VPX vpx ) # For tox-bootstrapd. pkg_use_module(LIBCONFIG libconfig ) @@ -54,3 +29,49 @@ 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