mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Generate only one large library "libtoxcore".
This library contains all the code for the old libtoxcore, libtoxav, libtoxdns, and libtoxencryptsave. The build for toxav is still optional, and disabling it causes libtoxcore to simply not contain those symbols and the pkg-config file to not include opus and vpx as dependencies.
This commit is contained in:
parent
83377e6865
commit
f2b6090eca
205
CMakeLists.txt
205
CMakeLists.txt
|
@ -1,3 +1,19 @@
|
|||
################################################################################
|
||||
#
|
||||
# The main toxcore CMake build file.
|
||||
#
|
||||
# This file when processed with cmake produces:
|
||||
# - A number of small libraries (.a/.so/...) containing independent components
|
||||
# of toxcore. E.g. the DHT has its own library, and the system/network
|
||||
# abstractions are in their own library as well. These libraries are not
|
||||
# installed on `make install`. The toxdns, toxav, and toxencryptsave
|
||||
# libraries are also not installed.
|
||||
# - A number of small programs, statically linked if possible.
|
||||
# - One big library containing all of the toxcore, toxav, toxdns, and
|
||||
# toxencryptsave code.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
cmake_minimum_required(VERSION 2.8.6)
|
||||
cmake_policy(VERSION 2.8.6)
|
||||
project(toxcore)
|
||||
|
@ -30,7 +46,6 @@ math(EXPR SOVERSION_MAJOR ${SOVERSION_CURRENT}-${SOVERSION_AGE})
|
|||
set(SOVERSION "${SOVERSION_MAJOR}.${SOVERSION_AGE}.${SOVERSION_REVISION}")
|
||||
message("SOVERSION: ${SOVERSION}")
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# :: Dependencies and configuration
|
||||
|
@ -39,9 +54,8 @@ message("SOVERSION: ${SOVERSION}")
|
|||
|
||||
include(AddCompilerFlag)
|
||||
include(ApiDsl)
|
||||
include(CheckCCompilerFlag)
|
||||
include(CheckCXXCompilerFlag)
|
||||
include(MacRpath)
|
||||
include(ModulePackage)
|
||||
include(StrictAbi)
|
||||
|
||||
enable_testing()
|
||||
|
@ -172,20 +186,10 @@ endif()
|
|||
#
|
||||
################################################################################
|
||||
|
||||
# toxcore_PKGCONFIG_LIBS is what's added to the Libs: line in toxcore.pc. It
|
||||
# needs to contain all the libraries a program using toxcore should link against
|
||||
# if it's statically linked. If it's dynamically linked, there is no need to
|
||||
# explicitly link against all the dependencies, but it doesn't harm much(*)
|
||||
# either.
|
||||
#
|
||||
# (*) It allows client code to use symbols from our dependencies without
|
||||
# explicitly linking against them.
|
||||
set(toxcore_PKGCONFIG_LIBS)
|
||||
|
||||
# LAYER 1: Crypto core
|
||||
# --------------------
|
||||
apidsl(toxcore/crypto_core.api.h)
|
||||
add_module(toxcrypto
|
||||
add_submodule(toxcore toxcrypto
|
||||
toxcore/ccompat.h
|
||||
toxcore/crypto_core.c
|
||||
toxcore/crypto_core.h
|
||||
|
@ -194,10 +198,11 @@ include(CheckFunctionExists)
|
|||
check_function_exists(explicit_bzero HAVE_EXPLICIT_BZERO)
|
||||
check_function_exists(memset_s HAVE_MEMSET_S)
|
||||
target_link_modules(toxcrypto ${LIBSODIUM_LIBRARIES})
|
||||
set(toxcrypto_PKGCONFIG_REQUIRES ${toxcrypto_PKGCONFIG_REQUIRES} libsodium)
|
||||
|
||||
# LAYER 2: Basic networking
|
||||
# -------------------------
|
||||
add_module(toxnetwork
|
||||
add_submodule(toxcore toxnetwork
|
||||
toxcore/logger.c
|
||||
toxcore/logger.h
|
||||
toxcore/network.c
|
||||
|
@ -208,22 +213,22 @@ target_link_modules(toxnetwork toxcrypto)
|
|||
|
||||
if(CMAKE_THREAD_LIBS_INIT)
|
||||
target_link_modules(toxnetwork ${CMAKE_THREAD_LIBS_INIT})
|
||||
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} ${CMAKE_THREAD_LIBS_INIT})
|
||||
set(toxnetwork_PKGCONFIG_LIBS ${toxnetwork_PKGCONFIG_LIBS} ${CMAKE_THREAD_LIBS_INIT})
|
||||
endif()
|
||||
|
||||
if(RT_LIBRARIES)
|
||||
target_link_modules(toxnetwork ${RT_LIBRARIES})
|
||||
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} "-lrt")
|
||||
set(toxnetwork_PKGCONFIG_LIBS ${toxnetwork_PKGCONFIG_LIBS} "-lrt")
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
target_link_modules(toxnetwork ws2_32 iphlpapi)
|
||||
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} "-lws2_32 -liphlpapi")
|
||||
set(toxnetwork_PKGCONFIG_LIBS ${toxnetwork_PKGCONFIG_LIBS} "-lws2_32 -liphlpapi")
|
||||
endif()
|
||||
|
||||
# LAYER 3: Distributed Hash Table
|
||||
# -------------------------------
|
||||
add_module(toxdht
|
||||
add_submodule(toxcore toxdht
|
||||
toxcore/DHT.c
|
||||
toxcore/DHT.h
|
||||
toxcore/LAN_discovery.c
|
||||
|
@ -236,7 +241,7 @@ target_link_modules(toxdht toxnetwork)
|
|||
|
||||
# LAYER 4: Onion routing, TCP connections, crypto connections
|
||||
# -----------------------------------------------------------
|
||||
add_module(toxnetcrypto
|
||||
add_submodule(toxcore toxnetcrypto
|
||||
toxcore/TCP_client.c
|
||||
toxcore/TCP_client.h
|
||||
toxcore/TCP_connection.c
|
||||
|
@ -257,7 +262,7 @@ target_link_modules(toxnetcrypto toxdht)
|
|||
|
||||
# LAYER 5: Friend requests and connections
|
||||
# ----------------------------------------
|
||||
add_module(toxfriends
|
||||
add_submodule(toxcore toxfriends
|
||||
toxcore/friend_connection.c
|
||||
toxcore/friend_connection.h
|
||||
toxcore/friend_requests.c
|
||||
|
@ -266,14 +271,14 @@ target_link_modules(toxfriends toxnetcrypto)
|
|||
|
||||
# LAYER 6: Tox messenger
|
||||
# ----------------------
|
||||
add_module(toxmessenger
|
||||
add_submodule(toxcore toxmessenger
|
||||
toxcore/Messenger.c
|
||||
toxcore/Messenger.h)
|
||||
target_link_modules(toxmessenger toxfriends)
|
||||
|
||||
# LAYER 7: Group chats
|
||||
# --------------------
|
||||
add_module(toxgroup
|
||||
add_submodule(toxcore toxgroup
|
||||
toxcore/group.c
|
||||
toxcore/group.h)
|
||||
target_link_modules(toxgroup toxmessenger)
|
||||
|
@ -281,11 +286,12 @@ target_link_modules(toxgroup toxmessenger)
|
|||
# LAYER 8: Public API
|
||||
# -------------------
|
||||
apidsl(toxcore/tox.api.h)
|
||||
add_module(toxcore
|
||||
add_submodule(toxcore toxapi
|
||||
toxcore/tox_api.c
|
||||
toxcore/tox.c
|
||||
toxcore/tox.h)
|
||||
target_link_modules(toxcore toxgroup)
|
||||
target_link_modules(toxapi toxgroup)
|
||||
set(toxapi_API_HEADERS ${toxcore_SOURCE_DIR}/toxcore/tox.h^tox)
|
||||
|
||||
################################################################################
|
||||
#
|
||||
|
@ -295,7 +301,7 @@ target_link_modules(toxcore toxgroup)
|
|||
|
||||
if(BUILD_TOXAV)
|
||||
apidsl(toxav/toxav.api.h)
|
||||
add_module(toxav
|
||||
add_submodule(toxcore toxav
|
||||
toxav/audio.c
|
||||
toxav/audio.h
|
||||
toxav/bwcontroller.c
|
||||
|
@ -313,7 +319,11 @@ if(BUILD_TOXAV)
|
|||
toxav/toxav_old.c
|
||||
toxav/video.c
|
||||
toxav/video.h)
|
||||
target_link_modules(toxav toxcore ${OPUS_LIBRARIES} ${VPX_LIBRARIES})
|
||||
target_link_modules(toxav toxgroup ${OPUS_LIBRARIES} ${VPX_LIBRARIES})
|
||||
set(toxav_PKGCONFIG_REQUIRES ${toxav_PKGCONFIG_REQUIRES} opus vpx)
|
||||
|
||||
set(toxav_API_HEADERS ${toxcore_SOURCE_DIR}/toxav/toxav.h^toxav)
|
||||
make_version_script(toxav ${toxav_API_HEADERS})
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
|
@ -322,15 +332,54 @@ endif()
|
|||
#
|
||||
################################################################################
|
||||
|
||||
add_module(toxdns
|
||||
add_submodule(toxcore toxdns
|
||||
toxdns/toxdns.c)
|
||||
target_link_modules(toxdns toxcore)
|
||||
target_link_modules(toxdns toxnetwork)
|
||||
set(toxdns_API_HEADERS ${toxcore_SOURCE_DIR}/toxdns/toxdns.h^tox)
|
||||
|
||||
apidsl(toxencryptsave/toxencryptsave.api.h)
|
||||
add_module(toxencryptsave
|
||||
add_submodule(toxcore toxencryptsave
|
||||
toxencryptsave/toxencryptsave.c
|
||||
toxencryptsave/toxencryptsave.h)
|
||||
target_link_modules(toxencryptsave toxcore)
|
||||
target_link_modules(toxencryptsave toxcrypto)
|
||||
set(toxencryptsave_API_HEADERS ${toxcore_SOURCE_DIR}/toxencryptsave/toxencryptsave.h^tox)
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# :: All layers together in one library for ease of use
|
||||
#
|
||||
################################################################################
|
||||
|
||||
# Create combined library from all the sources.
|
||||
add_module(toxcore ${toxcore_SOURCES})
|
||||
|
||||
# Link it to all dependencies.
|
||||
foreach(sublib ${toxcore_SUBLIBS})
|
||||
set(toxcore_LINK_MODULES ${toxcore_LINK_MODULES} ${${sublib}_LINK_MODULES})
|
||||
endforeach()
|
||||
target_link_modules(toxcore ${toxcore_LINK_MODULES})
|
||||
|
||||
# Concatenate all the pkg-config Libs: lines.
|
||||
foreach(sublib ${toxcore_SUBLIBS})
|
||||
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} ${${sublib}_PKGCONFIG_LIBS})
|
||||
endforeach()
|
||||
|
||||
# Concatenate all the pkg-config Requires: lines.
|
||||
foreach(sublib ${toxcore_SUBLIBS})
|
||||
set(toxcore_PKGCONFIG_REQUIRES ${toxcore_PKGCONFIG_REQUIRES} ${${sublib}_PKGCONFIG_REQUIRES})
|
||||
endforeach()
|
||||
|
||||
# Collect all API headers.
|
||||
foreach(sublib ${toxcore_SUBLIBS})
|
||||
set(toxcore_API_HEADERS ${toxcore_API_HEADERS} ${${sublib}_API_HEADERS})
|
||||
endforeach()
|
||||
|
||||
# Make version script (on systems that support it) to limit symbol visibility.
|
||||
make_version_script(toxcore ${toxcore_API_HEADERS})
|
||||
|
||||
# Generate pkg-config file, install library to "lib" and install headers to
|
||||
# "include/tox".
|
||||
install_module(toxcore DESTINATION "include/tox")
|
||||
|
||||
################################################################################
|
||||
#
|
||||
|
@ -338,7 +387,9 @@ target_link_modules(toxencryptsave toxcore)
|
|||
#
|
||||
################################################################################
|
||||
|
||||
find_program(SPECTEST NAMES tox-spectest)
|
||||
find_program(SPECTEST NAMES
|
||||
tox-spectest
|
||||
../.stack-work/install/x86_64-linux/lts-2.22/7.8.4/bin/tox-spectest)
|
||||
|
||||
if(NOT SPECTEST)
|
||||
find_program(STACK NAMES stack)
|
||||
|
@ -360,6 +411,8 @@ if(MSGPACK_FOUND)
|
|||
testing/hstox/util.c)
|
||||
target_link_modules(toxcore-sut
|
||||
toxcore
|
||||
toxdht
|
||||
toxnetcrypto
|
||||
${MSGPACK_LIBRARIES})
|
||||
if(SPECTEST)
|
||||
add_test(NAME spectest COMMAND ${SPECTEST} $<TARGET_FILE:toxcore-sut>)
|
||||
|
@ -393,11 +446,10 @@ function(auto_test target)
|
|||
add_c_executable(auto_${target}_test auto_tests/${target}_test.c)
|
||||
target_link_modules(auto_${target}_test
|
||||
toxcore
|
||||
toxencryptsave
|
||||
toxcrypto
|
||||
toxmessenger
|
||||
toxnetcrypto
|
||||
${CHECK_LIBRARIES})
|
||||
if(BUILD_TOXAV)
|
||||
target_link_modules(auto_${target}_test toxav)
|
||||
endif()
|
||||
if(NOT ARGV1 STREQUAL "DONT_RUN")
|
||||
add_test(NAME ${target} COMMAND auto_${target}_test)
|
||||
set_tests_properties(${target} PROPERTIES TIMEOUT "${TEST_TIMEOUT_SECONDS}")
|
||||
|
@ -478,7 +530,7 @@ if(BOOTSTRAP_DAEMON)
|
|||
other/bootstrap_daemon/src/tox-bootstrapd.c
|
||||
other/bootstrap_node_packets.c
|
||||
other/bootstrap_node_packets.h)
|
||||
target_link_modules(tox-bootstrapd toxnetcrypto ${LIBCONFIG_LIBRARIES})
|
||||
target_link_modules(tox-bootstrapd toxfriends ${LIBCONFIG_LIBRARIES})
|
||||
install(TARGETS tox-bootstrapd RUNTIME DESTINATION bin)
|
||||
endif()
|
||||
endif()
|
||||
|
@ -495,7 +547,7 @@ if(NOT WIN32
|
|||
AND SNDFILE_FOUND AND PORTAUDIO_FOUND AND OPENCV_FOUND)
|
||||
add_c_executable(av_test testing/av_test.c)
|
||||
target_link_modules(av_test
|
||||
toxav
|
||||
toxcore
|
||||
${OPENCV_LIBRARIES}
|
||||
${PORTAUDIO_LIBRARIES}
|
||||
${SNDFILE_LIBRARIES})
|
||||
|
@ -533,80 +585,5 @@ endif()
|
|||
|
||||
if(NOT WIN32)
|
||||
add_c_executable(irc_syncbot testing/irc_syncbot.c)
|
||||
target_link_modules(irc_syncbot toxcore)
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# :: Installation and pkg-config
|
||||
#
|
||||
################################################################################
|
||||
|
||||
string(REPLACE ";" " " toxcore_PKGCONFIG_LIBS "${toxcore_PKGCONFIG_LIBS}")
|
||||
|
||||
if(BUILD_TOXAV)
|
||||
configure_file(
|
||||
"${toxcore_SOURCE_DIR}/other/pkgconfig/toxav.pc.in"
|
||||
"${CMAKE_BINARY_DIR}/toxav.pc"
|
||||
@ONLY
|
||||
)
|
||||
endif()
|
||||
|
||||
configure_file(
|
||||
"${toxcore_SOURCE_DIR}/other/pkgconfig/toxcore.pc.in"
|
||||
"${CMAKE_BINARY_DIR}/toxcore.pc"
|
||||
@ONLY
|
||||
)
|
||||
|
||||
configure_file(
|
||||
"${toxcore_SOURCE_DIR}/other/pkgconfig/toxdns.pc.in"
|
||||
"${CMAKE_BINARY_DIR}/toxdns.pc"
|
||||
@ONLY
|
||||
)
|
||||
|
||||
configure_file(
|
||||
"${toxcore_SOURCE_DIR}/other/pkgconfig/toxencryptsave.pc.in"
|
||||
"${CMAKE_BINARY_DIR}/toxencryptsave.pc"
|
||||
@ONLY
|
||||
)
|
||||
|
||||
configure_file(
|
||||
"${toxcore_SOURCE_DIR}/other/pkgconfig/libtoxcore.pc.in"
|
||||
"${CMAKE_BINARY_DIR}/libtoxcore.pc"
|
||||
@ONLY
|
||||
)
|
||||
|
||||
configure_file(
|
||||
"${toxcore_SOURCE_DIR}/other/pkgconfig/libtoxav.pc.in"
|
||||
"${CMAKE_BINARY_DIR}/libtoxav.pc"
|
||||
@ONLY
|
||||
)
|
||||
|
||||
install(FILES
|
||||
${CMAKE_BINARY_DIR}/libtoxcore.pc
|
||||
${CMAKE_BINARY_DIR}/toxcore.pc
|
||||
${CMAKE_BINARY_DIR}/toxdns.pc
|
||||
${CMAKE_BINARY_DIR}/toxencryptsave.pc
|
||||
DESTINATION "lib/pkgconfig")
|
||||
install(FILES
|
||||
toxcore/tox.h
|
||||
toxdns/toxdns.h
|
||||
toxencryptsave/toxencryptsave.h
|
||||
DESTINATION "include/tox")
|
||||
|
||||
if(BUILD_TOXAV)
|
||||
install(FILES
|
||||
${CMAKE_BINARY_DIR}/libtoxav.pc
|
||||
${CMAKE_BINARY_DIR}/toxav.pc
|
||||
DESTINATION "lib/pkgconfig")
|
||||
install(FILES
|
||||
toxav/toxav.h
|
||||
DESTINATION "include/tox")
|
||||
endif()
|
||||
|
||||
if(STRICT_ABI AND SHELL AND ENABLE_SHARED)
|
||||
if(BUILD_TOXAV)
|
||||
make_version_script(${toxcore_SOURCE_DIR}/toxav/toxav.h toxav toxav)
|
||||
endif()
|
||||
make_version_script(${toxcore_SOURCE_DIR}/toxcore/tox.h tox toxcore)
|
||||
target_link_modules(irc_syncbot toxcore toxnetwork)
|
||||
endif()
|
||||
|
|
|
@ -51,45 +51,123 @@ function(pkg_use_module mod pkg)
|
|||
endif()
|
||||
endfunction()
|
||||
|
||||
macro(add_submodule super lib)
|
||||
add_module(${lib} ${ARGN})
|
||||
set(${super}_SUBLIBS ${${super}_SUBLIBS} ${lib})
|
||||
set(${super}_SOURCES ${${super}_SOURCES} ${${lib}_SOURCES})
|
||||
endmacro()
|
||||
|
||||
function(add_module lib)
|
||||
set_source_language(${ARGN})
|
||||
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})
|
||||
endif()
|
||||
|
||||
# ${lib}_PKGCONFIG_LIBS is what's added to the Libs: line in ${lib}.pc. It
|
||||
# needs to contain all the libraries a program using ${lib} should link against
|
||||
# if it's statically linked. If it's dynamically linked, there is no need to
|
||||
# explicitly link against all the dependencies, but it doesn't harm much(*)
|
||||
# either.
|
||||
#
|
||||
# (*) It allows client code to use symbols from our dependencies without
|
||||
# explicitly linking against them.
|
||||
set(${lib}_PKGCONFIG_LIBS PARENT_SCOPE)
|
||||
# Requires: in pkg-config file.
|
||||
set(${lib}_PKGCONFIG_REQUIRES PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(install_module lib)
|
||||
if(ENABLE_SHARED)
|
||||
set_target_properties(${lib}_shared PROPERTIES
|
||||
OUTPUT_NAME ${lib}
|
||||
VERSION ${SOVERSION}
|
||||
SOVERSION ${SOVERSION_MAJOR}
|
||||
)
|
||||
install(TARGETS ${lib}_shared DESTINATION "lib")
|
||||
endif()
|
||||
if(ENABLE_STATIC)
|
||||
add_library(${lib}_static STATIC ${ARGN})
|
||||
set_target_properties(${lib}_static PROPERTIES OUTPUT_NAME ${lib})
|
||||
install(TARGETS ${lib}_static DESTINATION "lib")
|
||||
endif()
|
||||
|
||||
string(REPLACE ";" " " ${lib}_PKGCONFIG_LIBS "${${lib}_PKGCONFIG_LIBS}")
|
||||
string(REPLACE ";" " " ${lib}_PKGCONFIG_REQUIRES "${${lib}_PKGCONFIG_REQUIRES}")
|
||||
|
||||
configure_file(
|
||||
"${${lib}_SOURCE_DIR}/other/pkgconfig/${lib}.pc.in"
|
||||
"${CMAKE_BINARY_DIR}/${lib}.pc"
|
||||
@ONLY
|
||||
)
|
||||
|
||||
install(FILES
|
||||
${CMAKE_BINARY_DIR}/${lib}.pc
|
||||
DESTINATION "lib/pkgconfig")
|
||||
|
||||
foreach(sublib ${${lib}_API_HEADERS})
|
||||
string(REPLACE "^" ";" sublib ${sublib})
|
||||
list(GET sublib 0 header)
|
||||
|
||||
install(FILES ${header} ${ARGN})
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
function(target_link_modules target)
|
||||
# If the target we're adding dependencies to is a shared library, add it to
|
||||
# the set of targets.
|
||||
if(TARGET ${target}_shared)
|
||||
set(_targets ${_targets} ${target}_shared)
|
||||
# Shared libraries should first try to link against other shared libraries.
|
||||
set(${target}_shared_primary shared)
|
||||
# If that fails (because the shared target doesn't exist), try linking
|
||||
# against the static library. This requires the static library's objects to
|
||||
# be PIC.
|
||||
set(${target}_shared_secondary static)
|
||||
endif()
|
||||
# It can also be a static library at the same time.
|
||||
if(TARGET ${target}_static)
|
||||
set(_targets ${_targets} ${target}_static)
|
||||
# Static libraries aren't actually linked, but their dependencies are
|
||||
# recorded by "linking" them. If we link an executable to a static library,
|
||||
# we want to also link statically against its transitive dependencies.
|
||||
set(${target}_static_primary static)
|
||||
# If a dependency doesn't exist as static library, we link against the
|
||||
# shared one.
|
||||
set(${target}_static_secondary shared)
|
||||
endif()
|
||||
# If it's neither, then it's an executable.
|
||||
if(NOT _targets)
|
||||
set(_targets ${_targets} ${target})
|
||||
# Executables preferrably link against static libraries, so they are
|
||||
# standalone and can be shipped without any external dependencies. As a
|
||||
# frame of reference: nTox becomes an 1.3M binary instead of 139K on x86_64
|
||||
# Linux.
|
||||
set(${target}_primary static)
|
||||
set(${target}_secondary shared)
|
||||
endif()
|
||||
|
||||
foreach(target ${_targets})
|
||||
foreach(dep ${ARGN})
|
||||
if(TARGET ${dep}_shared)
|
||||
target_link_libraries(${target} ${dep}_shared)
|
||||
elseif(TARGET ${dep}_static)
|
||||
target_link_libraries(${target} ${dep}_static)
|
||||
foreach(_target ${_targets})
|
||||
if(TARGET ${dep}_${${_target}_primary})
|
||||
target_link_libraries(${_target} ${dep}_${${_target}_primary})
|
||||
elseif(TARGET ${dep}_${${_target}_secondary})
|
||||
target_link_libraries(${_target} ${dep}_${${_target}_secondary})
|
||||
else()
|
||||
target_link_libraries(${target} ${dep})
|
||||
# We record the modules linked to this target, so that we can collect
|
||||
# them later when linking a composed module.
|
||||
list(FIND LINK_MODULES ${dep} _index)
|
||||
if(_index EQUAL -1)
|
||||
set(LINK_MODULES ${LINK_MODULES} ${dep})
|
||||
endif()
|
||||
|
||||
target_link_libraries(${_target} ${dep})
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
set(${target}_LINK_MODULES ${${target}_LINK_MODULES} ${LINK_MODULES} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
|
|
@ -9,26 +9,42 @@
|
|||
#
|
||||
################################################################################
|
||||
|
||||
function(make_version_script header ns lib)
|
||||
find_program(SHELL NAMES sh dash bash zsh fish)
|
||||
|
||||
macro(make_version_script)
|
||||
if(STRICT_ABI AND SHELL AND ENABLE_SHARED)
|
||||
_make_version_script(${ARGN})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
function(_make_version_script target)
|
||||
set(${target}_VERSION_SCRIPT "${CMAKE_BINARY_DIR}/${target}.ld")
|
||||
|
||||
file(WRITE ${${target}_VERSION_SCRIPT}
|
||||
"{ global:\n")
|
||||
|
||||
foreach(sublib ${ARGN})
|
||||
string(REPLACE "^" ";" sublib ${sublib})
|
||||
list(GET sublib 0 header)
|
||||
list(GET sublib 1 ns)
|
||||
|
||||
execute_process(
|
||||
COMMAND ${SHELL} -c "egrep '^\\w' ${header} | grep '${ns}_[a-z0-9_]*(' | grep -v '^typedef' | grep -o '${ns}_[a-z0-9_]*(' | egrep -o '\\w+' | sort -u"
|
||||
OUTPUT_VARIABLE ${lib}_SYMS
|
||||
OUTPUT_VARIABLE sublib_SYMS
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(REPLACE "\n" ";" ${lib}_SYMS ${${lib}_SYMS})
|
||||
string(REPLACE "\n" ";" sublib_SYMS ${sublib_SYMS})
|
||||
|
||||
set(${lib}_VERSION_SCRIPT "${CMAKE_BINARY_DIR}/${lib}.ld")
|
||||
|
||||
file(WRITE ${${lib}_VERSION_SCRIPT}
|
||||
"{ global:\n")
|
||||
foreach(sym ${${lib}_SYMS})
|
||||
file(APPEND ${${lib}_VERSION_SCRIPT}
|
||||
foreach(sym ${sublib_SYMS})
|
||||
file(APPEND ${${target}_VERSION_SCRIPT}
|
||||
"${sym};\n")
|
||||
endforeach(sym)
|
||||
file(APPEND ${${lib}_VERSION_SCRIPT}
|
||||
endforeach(sublib)
|
||||
|
||||
file(APPEND ${${target}_VERSION_SCRIPT}
|
||||
"local: *; };\n")
|
||||
|
||||
set_target_properties(${lib}_shared PROPERTIES
|
||||
LINK_FLAGS -Wl,--version-script,${${lib}_VERSION_SCRIPT})
|
||||
set_target_properties(${target}_shared PROPERTIES
|
||||
LINK_FLAGS -Wl,--version-script,${${target}_VERSION_SCRIPT})
|
||||
endfunction()
|
||||
|
||||
option(STRICT_ABI "Enforce strict ABI export in dynamic libraries" OFF)
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
prefix=@CMAKE_INSTALL_PREFIX@
|
||||
libdir=${prefix}/lib
|
||||
includedir=${prefix}/include
|
||||
|
||||
Name: libtoxav
|
||||
Description: Tox A/V library - compatibility module (use toxav instead)
|
||||
Requires: toxav
|
||||
Version: @PROJECT_VERSION@
|
|
@ -1,8 +0,0 @@
|
|||
prefix=@CMAKE_INSTALL_PREFIX@
|
||||
libdir=${prefix}/lib
|
||||
includedir=${prefix}/include
|
||||
|
||||
Name: libtoxcore
|
||||
Description: Tox protocol library - compatibility module (use toxcore, toxdns, and toxencryptsave instead)
|
||||
Requires: toxcore toxdns toxencryptsave
|
||||
Version: @PROJECT_VERSION@
|
|
@ -1,10 +0,0 @@
|
|||
prefix=@CMAKE_INSTALL_PREFIX@
|
||||
libdir=${prefix}/lib
|
||||
includedir=${prefix}/include
|
||||
|
||||
Name: toxav
|
||||
Description: Tox A/V library
|
||||
Requires: opus toxcore vpx
|
||||
Version: @PROJECT_VERSION@
|
||||
Libs: -L${libdir} @toxav_PKGCONFIG_LIBS@ -ltoxav
|
||||
Cflags: -I${includedir}
|
|
@ -4,7 +4,7 @@ includedir=${prefix}/include
|
|||
|
||||
Name: toxcore
|
||||
Description: Tox protocol library
|
||||
Requires: libsodium
|
||||
Requires: @toxcore_PKGCONFIG_REQUIRES@
|
||||
Version: @PROJECT_VERSION@
|
||||
Libs: -L${libdir} -ltoxcore @toxcore_PKGCONFIG_LIBS@ -ltoxcrypto -ltoxnetwork -ltoxdht -ltoxnetcrypto -ltoxfriends -ltoxmessenger -ltoxgroup
|
||||
Libs: -L${libdir} -ltoxcore @toxcore_PKGCONFIG_LIBS@
|
||||
Cflags: -I${includedir}
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
prefix=@CMAKE_INSTALL_PREFIX@
|
||||
libdir=${prefix}/lib
|
||||
includedir=${prefix}/include
|
||||
|
||||
Name: toxdns
|
||||
Description: Tox DNS3 library
|
||||
Requires: toxcore
|
||||
Version: @PROJECT_VERSION@
|
||||
Libs: -L${libdir} @toxdns_PKGCONFIG_LIBS@ -ltoxdns
|
||||
Cflags: -I${includedir}
|
|
@ -1,10 +0,0 @@
|
|||
prefix=@CMAKE_INSTALL_PREFIX@
|
||||
libdir=${prefix}/lib
|
||||
includedir=${prefix}/include
|
||||
|
||||
Name: toxencryptsave
|
||||
Description: Tox block encryption library
|
||||
Requires: toxcore
|
||||
Version: @PROJECT_VERSION@
|
||||
Libs: -L${libdir} @toxencryptsave_PKGCONFIG_LIBS@ -ltoxencryptsave
|
||||
Cflags: -I${includedir}
|
|
@ -1,4 +1,4 @@
|
|||
#define _BSD_SOURCE
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "methods.h"
|
||||
|
||||
#include "byteswap.h"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#define _BSD_SOURCE
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "methods.h"
|
||||
|
||||
#include "byteswap.h"
|
||||
|
|
Loading…
Reference in New Issue
Block a user