Skip to content

Commit 93bb914

Browse files
chore: Update CMake configuration for improved security and threading support (#146)
- Added required Threads package to CMakeLists.txt - Enhanced compiler flags for position-independent code and security features - Updated build dependencies in debian/control to include libc6-dev
1 parent 9da8df1 commit 93bb914

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

CMakeLists.txt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
cmake_minimum_required(VERSION 3.0)
22
project(deepin-diskmanager)
33

4+
find_package(Threads REQUIRED)
45

56
option(DOTEST "option for test" OFF)
67

@@ -20,10 +21,16 @@ else()
2021
# -Wl, -O2 Enable linker optimizations
2122
# -Wl, --gc-sections Remove unused code resulting from -fdsta-sections and
2223
# -ffunction-sections
23-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O2 -Wl,--gc-sections")
24-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O2 -Wl,--gc-sections")
24+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O2")
25+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O2")
26+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
2527
endif()
2628

29+
# 添加位置无关代码和安全编译标志
30+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-all -fPIC")
31+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all -fPIE")
32+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z relro -z now -z noexecstack -pie")
33+
2734
set(QT_VERSION_MAJOR 6)
2835
if (${QT_VERSION_MAJOR} GREATER_EQUAL 6)
2936
set(DTK_VERSION 6)
@@ -40,8 +47,6 @@ endif()
4047
#set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g -fsanitize=address -O2")
4148
#set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -g -fsanitize=address -O2")
4249
#set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -g -fsanitize=address -O2")
43-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-all -z relro -z now -z noexecstack -pie")
44-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all -z relro -z now -z noexecstack -pie")
4550

4651
ADD_SUBDIRECTORY(basestruct)
4752
ADD_SUBDIRECTORY(log)

basestruct/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ target_include_directories(${PROJECT_NAME} PUBLIC
3333
target_link_libraries(${PROJECT_NAME} PRIVATE
3434
Qt${QT_VERSION_MAJOR}::Widgets
3535
Qt${QT_VERSION_MAJOR}::DBus
36+
Threads::Threads
3637
)
3738

3839
set(CMAKE_INSTALL_PREFIX /usr)

debian/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Source: deepin-diskmanager
22
Section: tools
33
Priority: optional
44
Maintainer: deepin <packages@deepin.com>
5-
Build-Depends: debhelper (>= 11), cmake, pkg-config, qt6-tools-dev, qt6-base-dev, libx11-dev, libdtk6widget-dev,qt6-tools-dev-tools,qt6-base-private-dev, libparted-dev,libparted-fs-resize0, libpolkit-qt6-1-dev, libgtest-dev, libgmock-dev
5+
Build-Depends: debhelper (>= 11), cmake, pkg-config, libc6-dev, qt6-tools-dev, qt6-base-dev, libx11-dev, libdtk6widget-dev,qt6-tools-dev-tools,qt6-base-private-dev, libparted-dev,libparted-fs-resize0, libpolkit-qt6-1-dev, libgtest-dev, libgmock-dev
66
Standards-Version: 4.1.3
77

88
Package: deepin-diskmanager

0 commit comments

Comments
 (0)