summaryrefslogtreecommitdiff
path: root/cmake/StrictAbi.cmake
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2017-01-15 16:16:16 +0000
committeriphydf <iphydf@users.noreply.github.com>2017-12-28 23:01:41 +0000
commitf2b6090eca42f4a364ef7517c5eec6d472e9b5f6 (patch)
tree3e83bf92287d822fef55f44e2ed3b9e1157c061e /cmake/StrictAbi.cmake
parent83377e6865dcf8aaf3652fde3d70d73c2a48b2cb (diff)
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.
Diffstat (limited to 'cmake/StrictAbi.cmake')
-rw-r--r--cmake/StrictAbi.cmake46
1 files changed, 31 insertions, 15 deletions
diff --git a/cmake/StrictAbi.cmake b/cmake/StrictAbi.cmake
index fdf3664b..5a646d77 100644
--- a/cmake/StrictAbi.cmake
+++ b/cmake/StrictAbi.cmake
@@ -9,26 +9,42 @@
9# 9#
10################################################################################ 10################################################################################
11 11
12function(make_version_script header ns lib) 12find_program(SHELL NAMES sh dash bash zsh fish)
13 execute_process(
14 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"
15 OUTPUT_VARIABLE ${lib}_SYMS
16 OUTPUT_STRIP_TRAILING_WHITESPACE)
17 string(REPLACE "\n" ";" ${lib}_SYMS ${${lib}_SYMS})
18 13
19 set(${lib}_VERSION_SCRIPT "${CMAKE_BINARY_DIR}/${lib}.ld") 14macro(make_version_script)
15 if(STRICT_ABI AND SHELL AND ENABLE_SHARED)
16 _make_version_script(${ARGN})
17 endif()
18endmacro()
20 19
21 file(WRITE ${${lib}_VERSION_SCRIPT} 20function(_make_version_script target)
21 set(${target}_VERSION_SCRIPT "${CMAKE_BINARY_DIR}/${target}.ld")
22
23 file(WRITE ${${target}_VERSION_SCRIPT}
22 "{ global:\n") 24 "{ global:\n")
23 foreach(sym ${${lib}_SYMS}) 25
24 file(APPEND ${${lib}_VERSION_SCRIPT} 26 foreach(sublib ${ARGN})
25 "${sym};\n") 27 string(REPLACE "^" ";" sublib ${sublib})
26 endforeach(sym) 28 list(GET sublib 0 header)
27 file(APPEND ${${lib}_VERSION_SCRIPT} 29 list(GET sublib 1 ns)
30
31 execute_process(
32 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"
33 OUTPUT_VARIABLE sublib_SYMS
34 OUTPUT_STRIP_TRAILING_WHITESPACE)
35 string(REPLACE "\n" ";" sublib_SYMS ${sublib_SYMS})
36
37 foreach(sym ${sublib_SYMS})
38 file(APPEND ${${target}_VERSION_SCRIPT}
39 "${sym};\n")
40 endforeach(sym)
41 endforeach(sublib)
42
43 file(APPEND ${${target}_VERSION_SCRIPT}
28 "local: *; };\n") 44 "local: *; };\n")
29 45
30 set_target_properties(${lib}_shared PROPERTIES 46 set_target_properties(${target}_shared PROPERTIES
31 LINK_FLAGS -Wl,--version-script,${${lib}_VERSION_SCRIPT}) 47 LINK_FLAGS -Wl,--version-script,${${target}_VERSION_SCRIPT})
32endfunction() 48endfunction()
33 49
34option(STRICT_ABI "Enforce strict ABI export in dynamic libraries" OFF) 50option(STRICT_ABI "Enforce strict ABI export in dynamic libraries" OFF)