1 Star 0 Fork 2

深度社区/deepin-diskmanager

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
CMakeLists.txt 2.60 KB
一键复制 编辑 原始数据 按行查看 历史
yuandandangit 提交于 2021-11-16 15:58 . fix: 添加安全加固编译参数
cmake_minimum_required(VERSION 3.0)
project(deepin-diskmanager)
option(DOTEST "option for test" OFF)
# 是否开启单元测试编译
set(DOTEST ON)
option(DOAPP "option for test app" OFF)
set(DOAPP ON)
#compile flags
if (CMAKE_BUILD_TYPE MATCHES Debug)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra")
# Enable Qt builtin debug mode
add_definitions("-DQT_MESSAGELOGCONTEXT")
else()
# -Wl, -O2 Enable linker optimizations
# -Wl, --gc-sections Remove unused code resulting from -fdsta-sections and
# -ffunction-sections
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O2 -Wl,--gc-sections")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O2 -Wl,--gc-sections")
endif()
# 检查内存泄漏代码
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fsanitize=address -O2")
#set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fsanitize=address -O2")
#set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -g -fsanitize=address -O2")
#set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -g -fsanitize=address -O2")
#set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -g -fsanitize=address -O2")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fsanitize=address -O2")
#set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address -O2")
#set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g -fsanitize=address -O2")
#set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -g -fsanitize=address -O2")
#set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -g -fsanitize=address -O2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-all -z relro -z now -z noexecstack -pie")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all -z relro -z now -z noexecstack -pie")
ADD_SUBDIRECTORY(basestruct)
ADD_SUBDIRECTORY(log)
ADD_SUBDIRECTORY(application)
ADD_SUBDIRECTORY(service)
# 开启单元测试
if(DOTEST)
if(DOAPP)
# 添加gocv覆盖率文件的输出
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fprofile-arcs -ftest-coverage")
# 设置测试模块
set(QT Core Gui Widgets Network DBus Sql LinguistTools Svg Test)
find_package(Qt5 COMPONENTS ${QT} REQUIRED)
# 添加子模块apptest
add_subdirectory(tests)
else()
# 添加gocv覆盖率文件的输出
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fprofile-arcs -ftest-coverage")
# 设置测试模块
set(QT Core Gui Widgets Network DBus Sql LinguistTools Svg Multimedia Test)
find_package(Qt5 COMPONENTS ${QT} REQUIRED)
# 添加子模块test
add_subdirectory(test)
endif()
endif()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/linuxdeepin/deepin-diskmanager.git
git@gitee.com:linuxdeepin/deepin-diskmanager.git
linuxdeepin
deepin-diskmanager
deepin-diskmanager
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385