Skip to content

Commit 13ebda8

Browse files
committed
fix lto builds
1 parent 1388f45 commit 13ebda8

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ if(UNIX) # APPLE, LINUX, FREE_BSD
113113
message(STATUS "To disable AddressSanitizer, use -DPCM_NO_ASAN=1 option")
114114
set(PCM_ASAN "-fsanitize=address")
115115
endif()
116-
set(PCM_HARDENING_FLAGS "-fPIE -fstack-protector -D_FORTIFY_SOURCE=2 -ftrapv ${PCM_ASAN} -fwrapv -fno-delete-null-pointer-checks -fno-strict-overflow -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer")
116+
set(PCM_HARDENING_FLAGS "-fstack-protector -D_FORTIFY_SOURCE=2 -ftrapv ${PCM_ASAN} -fwrapv -fno-delete-null-pointer-checks -fno-strict-overflow -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer")
117117
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5)
118118
message(WARNING "Old gcc compiler (version < 5), -fsanitize=undefined option is not supported.")
119119
elseif()

src/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# SPDX-License-Identifier: BSD-3-Clause
2-
# Copyright (c) 2022, Intel Corporation
2+
# Copyright (c) 2022-2025, Intel Corporation
33

44
include(FindOpenSSL)
55

@@ -60,6 +60,7 @@ if(UNIX) # LINUX, FREE_BSD, APPLE
6060
$<$<CONFIG:RelWithDebInfo>:PCM_SILENT>
6161
)
6262

63+
set_target_properties(PCM_STATIC PROPERTIES POSITION_INDEPENDENT_CODE ON)
6364
set_target_properties(PCM_STATIC_SILENT PROPERTIES POSITION_INDEPENDENT_CODE ON)
6465

6566
# libpcm.so
@@ -192,6 +193,10 @@ if(PCM_BUILD_EXECUTABLES)
192193
target_compile_options(${PROJECT_NAME} PRIVATE "${PCM_MSVC_RUNTIME_LIBRARY_OPTIONS}")
193194
endif(MSVC)
194195

196+
if(UNIX)
197+
target_link_options(${PROJECT_NAME} PRIVATE "-fPIE")
198+
endif(UNIX)
199+
195200
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
196201
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "${PCM_STATIC_ASAN}")
197202
endif()
@@ -253,12 +258,14 @@ if(UNIX) # APPLE, LINUX, FREE_BSD
253258
# Daemon & client
254259
file(GLOB DAEMON_SOURCES "daemon/*.cpp")
255260
add_executable(daemon ${DAEMON_SOURCES})
261+
target_link_options(daemon PRIVATE "-fPIE")
256262
target_link_libraries(daemon PRIVATE PCM_STATIC Threads::Threads)
257263
set_target_properties(daemon PROPERTIES OUTPUT_NAME "pcm-daemon")
258264
install(TARGETS daemon DESTINATION ${CMAKE_INSTALL_SBINDIR})
259265

260266
file(GLOB CLIENT_SOURCES "client/*.cpp")
261267
add_executable(client ${CLIENT_SOURCES})
268+
target_link_options(client PRIVATE "-fPIE")
262269
target_link_libraries(client PRIVATE Threads::Threads)
263270
set_target_properties(client PROPERTIES OUTPUT_NAME "pcm-client")
264271
install(TARGETS client DESTINATION ${CMAKE_INSTALL_BINDIR})

0 commit comments

Comments
 (0)