2023-02-20 10:36:55 +08:00
|
|
|
|
cmake_minimum_required(VERSION 3.16)
|
2018-03-05 21:25:21 +08:00
|
|
|
|
|
2022-08-19 13:33:51 +08:00
|
|
|
|
if (NOT DEFINED VERSION)
|
2024-04-03 10:24:24 +08:00
|
|
|
|
set(VERSION 6.0.37)
|
2022-08-19 13:33:51 +08:00
|
|
|
|
endif()
|
2018-03-05 21:25:21 +08:00
|
|
|
|
|
2018-03-05 21:43:32 +08:00
|
|
|
|
project(dde-dock)
|
|
|
|
|
|
2023-06-19 14:51:04 +08:00
|
|
|
|
find_package(DtkTools REQUIRED)
|
|
|
|
|
|
2022-08-12 08:13:00 +00:00
|
|
|
|
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
|
|
|
|
|
set(CMAKE_HAVE_THREADS_LIBRARY 1)
|
|
|
|
|
set(CMAKE_USE_PTHREADS_INIT 1)
|
|
|
|
|
set(CMAKE_PREFER_PTHREAD_FLAG ON)
|
|
|
|
|
|
2018-03-05 21:25:21 +08:00
|
|
|
|
#set(CMAKE_VERBOSE_MAKEFILE ON)
|
2023-03-21 16:15:46 +08:00
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
2018-03-05 21:25:21 +08:00
|
|
|
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|
|
|
|
set(CMAKE_AUTOMOC ON)
|
|
|
|
|
set(CMAKE_AUTORCC ON)
|
2018-03-06 15:15:50 +08:00
|
|
|
|
set(CMAKE_CXX_FLAGS "-g -Wall")
|
2018-03-05 21:25:21 +08:00
|
|
|
|
|
2021-10-25 13:38:56 +08:00
|
|
|
|
# 增加安全编译参数
|
2022-02-23 21:41:26 +08:00
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all")
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-all")
|
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "-z relro -z now -z noexecstack -pie")
|
2021-10-25 13:38:56 +08:00
|
|
|
|
|
2020-10-14 15:08:18 +08:00
|
|
|
|
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "mips64")
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -ftree-vectorize -march=loongson3a -mhard-float -mno-micromips -mno-mips16 -flax-vector-conversions -mloongson-ext2 -mloongson-mmi -fPIE")
|
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
|
|
|
|
|
endif()
|
|
|
|
|
|
2019-03-13 14:01:38 +08:00
|
|
|
|
# generate a compile commands file as complete database for vim-YouCompleteMe or some other similar tools
|
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
|
|
2023-05-04 11:20:04 +08:00
|
|
|
|
# Install settings
|
|
|
|
|
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
|
|
|
|
set(CMAKE_INSTALL_PREFIX /usr)
|
|
|
|
|
endif ()
|
2018-11-05 11:25:04 +08:00
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
|
2018-03-05 21:25:21 +08:00
|
|
|
|
if (NOT (${CMAKE_BUILD_TYPE} MATCHES "Debug"))
|
2018-03-06 15:15:50 +08:00
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Ofast")
|
2018-03-05 21:25:21 +08:00
|
|
|
|
|
|
|
|
|
# generate qm
|
|
|
|
|
execute_process(COMMAND bash "translate_generation.sh"
|
2021-03-25 14:20:52 +08:00
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
2018-03-05 21:25:21 +08:00
|
|
|
|
endif ()
|
|
|
|
|
|
2018-12-14 14:55:41 +08:00
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DQT_DEBUG")
|
|
|
|
|
|
2018-05-10 17:26:41 +08:00
|
|
|
|
# Test architecture
|
2022-09-07 09:38:48 +08:00
|
|
|
|
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "sw_64")
|
|
|
|
|
# add compiler flags -mieee for mathmatic
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mieee")
|
|
|
|
|
add_definitions(-DDISABLE_SHOW_ANIMATION)
|
2018-05-10 17:26:41 +08:00
|
|
|
|
endif()
|
|
|
|
|
|
2022-09-16 20:12:52 +00:00
|
|
|
|
function(generation_dbus_interface xmldir outdir)
|
2022-12-07 05:39:06 +00:00
|
|
|
|
IF(EXISTS ${outdir})
|
|
|
|
|
file(REMOVE_RECURSE ${outdir})
|
2022-09-16 20:12:52 +00:00
|
|
|
|
ENDIF()
|
2022-12-07 05:39:06 +00:00
|
|
|
|
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${outdir})
|
2022-09-16 20:12:52 +00:00
|
|
|
|
file(GLOB_RECURSE allXmls ${xmldir}/*.xml)
|
|
|
|
|
foreach(XMLFILE ${allXmls})
|
|
|
|
|
string(FIND ${XMLFILE} "/" INDEX REVERSE)
|
|
|
|
|
string(SUBSTRING ${XMLFILE} ${INDEX} -1 classname)
|
|
|
|
|
string(REPLACE "/" "" classname ${classname})
|
|
|
|
|
string(REPLACE ".xml" "" classname ${classname})
|
|
|
|
|
string(REPLACE "." "_" classname ${classname})
|
|
|
|
|
string(TOLOWER ${classname} filename)
|
|
|
|
|
|
2023-06-19 14:51:04 +08:00
|
|
|
|
execute_process(COMMAND ${DTK_XML2CPP} -c ${classname} -p ${outdir}/${filename} ${XMLFILE}
|
2022-09-16 20:12:52 +00:00
|
|
|
|
WORKING_DIRECTORY ${outdir})
|
|
|
|
|
endforeach()
|
|
|
|
|
endfunction(generation_dbus_interface)
|
|
|
|
|
|
2018-03-05 21:25:21 +08:00
|
|
|
|
file(GLOB INTERFACES "interfaces/*.h")
|
2023-05-11 13:31:11 +08:00
|
|
|
|
add_definitions(-DCVERSION="${VERSION}")
|
2020-12-16 17:38:41 +08:00
|
|
|
|
#因为单元测试需要直接测试源代码,而主程序代码中include的单元使用了相对路径
|
|
|
|
|
#单元测试的CMakeLists和主程序的CMakeLists路径不同,编译单元测试时会提示找不到文件
|
|
|
|
|
#因此设置搜索路径
|
|
|
|
|
include_directories(
|
2021-04-07 10:41:13 +08:00
|
|
|
|
frame/accessible
|
2020-12-16 17:38:41 +08:00
|
|
|
|
frame/controller
|
|
|
|
|
frame/dbus
|
|
|
|
|
frame/dbus/sni
|
2021-04-12 16:53:03 +08:00
|
|
|
|
frame/display
|
2020-12-16 17:38:41 +08:00
|
|
|
|
frame/item
|
|
|
|
|
frame/item/components
|
|
|
|
|
frame/item/resources
|
2022-05-12 17:35:50 +08:00
|
|
|
|
frame/model
|
2020-12-16 17:38:41 +08:00
|
|
|
|
frame/util
|
|
|
|
|
frame/window
|
2021-09-22 13:12:27 +08:00
|
|
|
|
frame/window/components
|
2022-05-12 17:09:10 +08:00
|
|
|
|
frame/window/tray
|
|
|
|
|
frame/window/tray/widgets
|
2020-12-16 17:38:41 +08:00
|
|
|
|
frame/xcb
|
2021-04-07 10:41:13 +08:00
|
|
|
|
../widgets
|
|
|
|
|
../interfaces
|
2021-03-25 14:20:52 +08:00
|
|
|
|
)
|
2021-04-07 10:41:13 +08:00
|
|
|
|
aux_source_directory(frame/accessible ACCESSIBLE)
|
2020-12-16 17:38:41 +08:00
|
|
|
|
aux_source_directory(frame/controller CONTROLLER)
|
|
|
|
|
aux_source_directory(frame/dbus DBUS)
|
|
|
|
|
aux_source_directory(frame/dbus/sni SNI)
|
2021-04-12 16:53:03 +08:00
|
|
|
|
aux_source_directory(frame/display DISPLAY)
|
2020-12-16 17:38:41 +08:00
|
|
|
|
aux_source_directory(frame/item ITEM)
|
2022-05-12 17:35:50 +08:00
|
|
|
|
aux_source_directory(frame/model MODEL)
|
2021-09-22 13:12:27 +08:00
|
|
|
|
aux_source_directory(frame/item/components ITEMCOMPONENTS)
|
2020-12-16 17:38:41 +08:00
|
|
|
|
aux_source_directory(frame/item/resources RESOURCES)
|
|
|
|
|
aux_source_directory(frame/util UTIL)
|
|
|
|
|
aux_source_directory(frame/window WINDOW)
|
2021-09-22 13:12:27 +08:00
|
|
|
|
aux_source_directory(frame/window/components WINDOWCOMPONENTS)
|
2022-05-12 17:09:10 +08:00
|
|
|
|
aux_source_directory(frame/window/tray WINDOWTRAY)
|
|
|
|
|
aux_source_directory(frame/window/tray/widgets WINDOWTRAYWIDGET)
|
2020-12-16 17:38:41 +08:00
|
|
|
|
aux_source_directory(frame/xcb XCB)
|
|
|
|
|
|
|
|
|
|
file(GLOB SRC_PATH
|
2021-04-07 10:41:13 +08:00
|
|
|
|
${ACCESSIBLE}
|
2020-12-16 17:38:41 +08:00
|
|
|
|
${CONTROLLER}
|
|
|
|
|
${DBUS}
|
|
|
|
|
${SNI}
|
2021-04-12 16:53:03 +08:00
|
|
|
|
${DISPLAY}
|
2020-12-16 17:38:41 +08:00
|
|
|
|
${ITEM}
|
2022-05-12 17:35:50 +08:00
|
|
|
|
${MODEL}
|
2021-09-22 13:12:27 +08:00
|
|
|
|
${ITEMCOMPONENTS}
|
2020-12-16 17:38:41 +08:00
|
|
|
|
${UTIL}
|
|
|
|
|
${WINDOW}
|
2021-09-22 13:12:27 +08:00
|
|
|
|
${WINDOWCOMPONENTS}
|
2022-05-12 17:09:10 +08:00
|
|
|
|
${WINDOWTRAY}
|
|
|
|
|
${WINDOWTRAYWIDGET}
|
2020-12-16 17:38:41 +08:00
|
|
|
|
${XCB}
|
2021-03-25 14:20:52 +08:00
|
|
|
|
)
|
2020-12-16 17:38:41 +08:00
|
|
|
|
|
2018-03-05 21:25:21 +08:00
|
|
|
|
add_subdirectory("frame")
|
|
|
|
|
add_subdirectory("plugins")
|
2022-05-12 16:24:54 +08:00
|
|
|
|
#add_subdirectory("tests")
|
2018-03-05 21:25:21 +08:00
|
|
|
|
|
2018-03-05 21:43:32 +08:00
|
|
|
|
## qm files
|
2018-03-05 21:25:21 +08:00
|
|
|
|
file(GLOB QM_FILES "translations/*.qm")
|
|
|
|
|
install(FILES ${QM_FILES}
|
2022-03-15 15:40:45 +08:00
|
|
|
|
DESTINATION share/dde-dock/translations)
|
2018-03-05 21:25:21 +08:00
|
|
|
|
|
|
|
|
|
## dev files
|
2018-11-05 11:25:04 +08:00
|
|
|
|
install(FILES ${INTERFACES}
|
2022-08-11 09:35:21 +08:00
|
|
|
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dde-dock)
|
2018-11-05 11:25:04 +08:00
|
|
|
|
|
2022-08-11 09:37:59 +08:00
|
|
|
|
configure_file(dde-dock.pc.in dde-dock.pc @ONLY)
|
2020-11-06 15:28:30 +08:00
|
|
|
|
install(FILES ${CMAKE_BINARY_DIR}/dde-dock.pc
|
2021-03-25 14:20:52 +08:00
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
2018-11-05 11:25:04 +08:00
|
|
|
|
|
2022-08-19 13:52:50 +08:00
|
|
|
|
configure_file(
|
2023-03-07 09:43:11 +08:00
|
|
|
|
${CMAKE_SOURCE_DIR}/cmake/DdeDock/DdeDockConfig.cmake.in
|
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/DdeDockConfig.cmake
|
2022-08-19 13:52:50 +08:00
|
|
|
|
@ONLY)
|
2023-03-07 09:43:11 +08:00
|
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/DdeDockConfig.cmake
|
2021-03-25 14:20:52 +08:00
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/DdeDock)
|
2018-03-05 21:43:32 +08:00
|
|
|
|
|
2020-05-20 17:38:00 +08:00
|
|
|
|
install(FILES gschema/com.deepin.dde.dock.module.gschema.xml
|
2022-08-11 09:35:21 +08:00
|
|
|
|
DESTINATION ${CMAKE_INSTALL_DATADIR}/glib-2.0/schemas)
|
2021-03-25 14:20:52 +08:00
|
|
|
|
|
2021-11-26 14:59:36 +08:00
|
|
|
|
#dconfig
|
|
|
|
|
file(GLOB DCONFIG_FILES "configs/*.json")
|
2023-02-16 13:51:55 +08:00
|
|
|
|
install(FILES ${DCONFIG_FILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/dsg/configs/dde-dock/)
|
2021-11-26 14:59:36 +08:00
|
|
|
|
|
2021-03-25 14:20:52 +08:00
|
|
|
|
# Address Sanitizer 内存错误检测工具,打开下面的编译选项可以看到调试信息,正常运行时不需要这些信息
|
|
|
|
|
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fsanitize=address -O2")
|
|
|
|
|
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fsanitize=address -O2")
|