From 27e652c8825b877867784d135de9a70bcbbab157 Mon Sep 17 00:00:00 2001 From: stuartmorgan Date: Wed, 27 May 2020 10:55:34 -0700 Subject: [PATCH] Fix Linux plugin template build visibility (#58069) The CMake plugin build wasn't setting visibility to hidden by default, which meant that plugins exported everything by default. This would make bad interactions between plugins much more likely; only the intended API should be exported by the shared library. --- .../flutter_tools/templates/app/linux.tmpl/CMakeLists.txt.tmpl | 2 ++ .../templates/app/linux.tmpl/flutter/CMakeLists.txt | 2 ++ .../templates/plugin/linux.tmpl/CMakeLists.txt.tmpl | 3 +++ 3 files changed, 7 insertions(+) diff --git a/packages/flutter_tools/templates/app/linux.tmpl/CMakeLists.txt.tmpl b/packages/flutter_tools/templates/app/linux.tmpl/CMakeLists.txt.tmpl index 82a6975d26..c0f6e596ea 100644 --- a/packages/flutter_tools/templates/app/linux.tmpl/CMakeLists.txt.tmpl +++ b/packages/flutter_tools/templates/app/linux.tmpl/CMakeLists.txt.tmpl @@ -3,6 +3,8 @@ project(runner LANGUAGES CXX) set(BINARY_NAME "{{projectName}}") +cmake_policy(SET CMP0063 NEW) + set(CMAKE_INSTALL_RPATH "\$ORIGIN") # Configure build options. diff --git a/packages/flutter_tools/templates/app/linux.tmpl/flutter/CMakeLists.txt b/packages/flutter_tools/templates/app/linux.tmpl/flutter/CMakeLists.txt index 95ba370b7a..902cfa44c0 100644 --- a/packages/flutter_tools/templates/app/linux.tmpl/flutter/CMakeLists.txt +++ b/packages/flutter_tools/templates/app/linux.tmpl/flutter/CMakeLists.txt @@ -65,6 +65,8 @@ add_library(flutter_wrapper_plugin STATIC apply_standard_settings(flutter_wrapper_plugin) set_target_properties(flutter_wrapper_plugin PROPERTIES POSITION_INDEPENDENT_CODE ON) +set_target_properties(flutter_wrapper_plugin PROPERTIES + CXX_VISIBILITY_PRESET hidden) target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) target_include_directories(flutter_wrapper_plugin PUBLIC "${WRAPPER_ROOT}/include" diff --git a/packages/flutter_tools/templates/plugin/linux.tmpl/CMakeLists.txt.tmpl b/packages/flutter_tools/templates/plugin/linux.tmpl/CMakeLists.txt.tmpl index 65da6aded1..1177783285 100644 --- a/packages/flutter_tools/templates/plugin/linux.tmpl/CMakeLists.txt.tmpl +++ b/packages/flutter_tools/templates/plugin/linux.tmpl/CMakeLists.txt.tmpl @@ -8,6 +8,9 @@ add_library(${PLUGIN_NAME} SHARED "${PLUGIN_NAME}.cc" ) apply_standard_settings(${PLUGIN_NAME}) +set_target_properties(${PLUGIN_NAME} PROPERTIES + CXX_VISIBILITY_PRESET hidden) +target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL) target_include_directories(${PLUGIN_NAME} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include") target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin)