Skip to content

Commit

Permalink
Limit symbol exports in CMake build.
Browse files Browse the repository at this point in the history
  • Loading branch information
rpavlik committed Mar 23, 2022
1 parent b46b912 commit 9e82faa
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/CMakeLists.txt
Expand Up @@ -17,7 +17,18 @@ set_target_properties(
target_include_directories(percetto PUBLIC $<BUILD_INTERFACE:${PERFETTO_SDK_PATH}>)
target_include_directories(percetto PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)

if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
# Limit what symbols are exported
set_property(
TARGET percetto
APPEND_STRING
PROPERTY LINK_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/percetto.exports")
# Re-link if the version script changes.
set_property(
TARGET percetto
APPEND
PROPERTY LINK_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/percetto.exports")
endif()
install(FILES percetto.h perfetto-port.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(
TARGETS percetto
Expand Down
14 changes: 14 additions & 0 deletions src/percetto.exports
@@ -0,0 +1,14 @@
{
global:
percetto_register_group_category;
percetto_register_track;
percetto_event_begin;
percetto_event_end;
percetto_event;
percetto_event_extended;
percetto_init_with_args;
percetto_init;

local:
*;
};

0 comments on commit 9e82faa

Please sign in to comment.