Skip to content

Commit 2ff7fc5

Browse files
committed
cmake: add option for PIE/non-PIE
1 parent ed077cb commit 2ff7fc5

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ option(LTO "Check for IPO/LTO support and enable, if supported. May require gold
7070
option(LINT_EGL_HEADERS "Set an define that'll make the egl.h only export the extension definitions, prototypes that are explicitly marked as required." OFF)
7171
option(DEBUG_DRM_PLANE_ALLOCATIONS "Add logging in modesetting.c for debugging the process of choosing a fitting DRM plane for a framebuffer layer." OFF)
7272
option(USE_LEGACY_KMS "Force the use of legacy KMS." OFF)
73+
option(PIE "Compile as position-independent executable." OFF)
7374

7475
set(FILESYSTEM_LAYOUTS default meta-flutter)
7576
set(FILESYSTEM_LAYOUT "default" CACHE STRING "Where to look for the icudtl.dat, app.so/libapp.so, flutter asset bundle.")
@@ -104,11 +105,12 @@ add_executable(
104105

105106
# disable PIE for the main executable
106107
check_pie_supported(OUTPUT_VARIABLE CHECK_PIE_SUPPORTED_OUTPUT LANGUAGES CXX)
107-
set_property(TARGET flutter-pi PROPERTY POSITION_INDEPENDENT_CODE TRUE)
108+
set_property(TARGET flutter-pi PROPERTY POSITION_INDEPENDENT_CODE ${PIE})
108109
if(NOT CMAKE_CXX_LINK_PIE_SUPPORTED)
109110
message(WARNING "PIE is not supported at link time: ${CHECK_PIE_SUPPORTED_OUTPUT}.\n"
110-
"PIE link options will not be passed to linker.")
111+
"PIE link options will not be passed to linker.")
111112
endif()
113+
message(STATUS "PIE .................... ${PIE}")
112114

113115
# flutterpi_module
114116
# We separate the actual flutter-pi code into a separate object library
@@ -142,7 +144,7 @@ add_library(
142144
)
143145

144146
# Disable PIC again just to make sure.
145-
set_property(TARGET flutterpi_module PROPERTY POSITION_INDEPENDENT_CODE OFF)
147+
set_property(TARGET flutterpi_module PROPERTY POSITION_INDEPENDENT_CODE ${PIE})
146148

147149
target_link_libraries(flutterpi_module PUBLIC
148150
PkgConfig::DRM
@@ -377,6 +379,7 @@ endif()
377379
# Sentry Plugin
378380
set(HAVE_BUNDLED_CRASHPAD_HANDLER OFF)
379381
if (BUILD_SENTRY_PLUGIN)
382+
set(SENTRY_PIC ${PIE})
380383
add_subdirectory(third_party/sentry-native)
381384

382385
target_sources(flutterpi_module PRIVATE src/plugins/sentry/sentry.c)

0 commit comments

Comments
 (0)