Skip to content

Commit ed077cb

Browse files
committed
cmake: general cleanups
1 parent d0d2318 commit ed077cb

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

CMakeLists.txt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,8 @@ option(SENTRY_PLUGIN_BUNDLE_CRASHPAD_HANDLER "Bundle the crashpad_handler with t
8080

8181
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
8282

83-
include(ExternalProject)
8483
include(CheckCCompilerFlag)
85-
include(FetchContent)
84+
include(CheckPIESupported)
8685

8786
# Those libraries we definitely need.
8887
include(FindPkgConfig)
@@ -97,11 +96,23 @@ pkg_check_modules(LIBUDEV REQUIRED IMPORTED_TARGET libudev)
9796
set(THREADS_PREFER_PTHREAD_FLAG ON)
9897
find_package(Threads REQUIRED)
9998

99+
# flutter-pi executable
100100
add_executable(
101101
flutter-pi
102102
src/main.c
103103
)
104104

105+
# disable PIE for the main executable
106+
check_pie_supported(OUTPUT_VARIABLE CHECK_PIE_SUPPORTED_OUTPUT LANGUAGES CXX)
107+
set_property(TARGET flutter-pi PROPERTY POSITION_INDEPENDENT_CODE TRUE)
108+
if(NOT CMAKE_CXX_LINK_PIE_SUPPORTED)
109+
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+
endif()
112+
113+
# flutterpi_module
114+
# We separate the actual flutter-pi code into a separate object library
115+
# so we can link against it in the tests.
105116
add_library(
106117
flutterpi_module OBJECT
107118
src/flutter-pi.c
@@ -130,6 +141,9 @@ add_library(
130141
src/plugins/services.c
131142
)
132143

144+
# Disable PIC again just to make sure.
145+
set_property(TARGET flutterpi_module PROPERTY POSITION_INDEPENDENT_CODE OFF)
146+
133147
target_link_libraries(flutterpi_module PUBLIC
134148
PkgConfig::DRM
135149
PkgConfig::GBM

0 commit comments

Comments
 (0)