Skip to content

Commit f3d9ce1

Browse files
committed
Limit symbol exports in CMake build.
1 parent faa210b commit f3d9ce1

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

src/CMakeLists.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,18 @@ set_target_properties(
1717
target_include_directories(percetto PUBLIC $<BUILD_INTERFACE:${PERFETTO_SDK_PATH}>)
1818
target_include_directories(percetto PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
1919
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
20-
20+
if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
21+
# Limit what symbols are exported
22+
set_property(
23+
TARGET percetto
24+
APPEND_STRING
25+
PROPERTY LINK_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/percetto.exports")
26+
# Re-link if the version script changes.
27+
set_property(
28+
TARGET percetto
29+
APPEND
30+
PROPERTY LINK_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/percetto.exports")
31+
endif()
2132
install(FILES percetto.h perfetto-port.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
2233
install(
2334
TARGETS percetto

src/percetto.exports

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
global:
3+
percetto_register_group_category;
4+
percetto_register_track;
5+
percetto_event_begin;
6+
percetto_event_end;
7+
percetto_event;
8+
percetto_event_extended;
9+
percetto_init_with_args;
10+
percetto_init;
11+
12+
local:
13+
*;
14+
};

0 commit comments

Comments
 (0)