Merge commit '9ace11a0e2843cbde4af2b6ff7b49bcc6d429f78'

This commit is contained in:
2024-01-09 16:39:05 +01:00
152 changed files with 1542 additions and 1140 deletions

View File

@ -1,19 +1,26 @@
###############################################################################
#
# :: For UNIX-like systems that have pkg-config.
# :: For systems that have pkg-config.
#
###############################################################################
include(ModulePackage)
find_package(Threads REQUIRED)
find_package(PkgConfig REQUIRED)
find_library(NSL_LIBRARIES nsl )
find_library(RT_LIBRARIES rt )
find_library(SOCKET_LIBRARIES socket)
find_package(pthreads QUIET)
if(NOT TARGET PThreads4W::PThreads4W)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
endif()
# For toxcore.
pkg_search_module(LIBSODIUM libsodium IMPORTED_TARGET)
pkg_search_module(LIBSODIUM libsodium IMPORTED_TARGET REQUIRED)
if(MSVC)
find_package(unofficial-sodium REQUIRED)
endif()
# For toxav.
pkg_search_module(OPUS opus IMPORTED_TARGET)
@ -27,56 +34,3 @@ endif()
# For tox-bootstrapd.
pkg_search_module(LIBCONFIG libconfig IMPORTED_TARGET)
###############################################################################
#
# :: 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
# ---------
if(NOT LIBSODIUM_FOUND)
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()
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()
find_package(pthreads4w)
if(NOT pthreads4w_FOUND)
message(FATAL_ERROR "libpthreads libraries not found")
endif()
include_directories(${pthreads4w_INCLUDE_DIR})
link_libraries(${pthreads4w_LIBRARIES})
endif()
endif()
endif()

View File

@ -19,18 +19,16 @@ if(FULLY_STATIC)
set(ENABLE_STATIC ON)
endif()
find_package(PkgConfig)
function(add_module lib)
set(${lib}_SOURCES ${ARGN} PARENT_SCOPE)
if(ENABLE_SHARED)
add_library(${lib}_shared SHARED ${ARGN})
set_target_properties(${lib}_shared PROPERTIES OUTPUT_NAME ${lib})
endif()
if(ENABLE_STATIC)
add_library(${lib}_static STATIC ${ARGN})
set_target_properties(${lib}_static PROPERTIES OUTPUT_NAME ${lib})
if(NOT MSVC)
set_target_properties(${lib}_static PROPERTIES OUTPUT_NAME ${lib})
endif()
endif()
endfunction()