-
Notifications
You must be signed in to change notification settings - Fork 69
/
CMakeLists.txt
116 lines (93 loc) · 4.17 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
cmake_minimum_required(VERSION 3.1.0)
project(deepin-unioncode)
message("processor: ${CMAKE_SYSTEM_PROCESSOR}")
function(print_directory arg)
execute_process(COMMAND ls ${ARGV0} OUTPUT_VARIABLE outVar)
message(STATUS "print_directory native: ${ARGV0}\n" ${outVar})
endfunction()
set(VERSION $ENV{VERSION})
if (NOT VERSION)
set(VERSION "0.0.1")
endif()
message(STATUS "build version ${VERSION}")
option(ENABLE_SANITIZE_CHECK "Enable Sanitize Check " OFF)
set(CMAKE_VERBOSE_MAKEFILE ON)
if (ENABLE_SANITIZE_CHECK AND (CMAKE_BUILD_TYPE STREQUAL "Debug"))
message("debug type open sanitize check")
set(CMAKE_CXX_FLAGS "-fsanitize=undefined,address,leak -fno-omit-frame-pointer")
set(CMAKE_C_FLAGS "-fsanitize=undefined,address,leak -fno-omit-frame-pointer")
set(CMAKE_L_FLAGS "-fsanitize=undefined,address,leak -fno-omit-frame-pointer")
# set(CMAKE_CXX_FLAGS "-fsanitize=thread")
# set(CMAKE_C_FLAGS "-fsanitize=thread")
# set(CMAKE_L_FLAGS "-fsanitize=thread")
endif()
set(LIBRARY_INSTALL_PREFIX "/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/${PROJECT_NAME}")
#set(ARCHIVE_INSTALL_RPEFIX "") undefined the static lib archive
set(RUNTIME_INSTALL_RPEFIX "/usr/bin")
set(SOURCES_INSTALL_RPEFIX "/usr/share/${PROJECT_NAME}")
set(INCLUDE_INSTALL_RPEFIX "/usr/include/${PROJECT_NAME}")
set(PLUGIN_INSTALL_PATH ${LIBRARY_INSTALL_PREFIX}/plugins)
set(TOOLS_INSTALL_PATH ${LIBRARY_INSTALL_PREFIX}/tools)
# set install runtime path
set(CMAKE_INSTALL_RPATH ${LIBRARY_INSTALL_PREFIX} ${PLUGIN_PATH})
message(STATUS "LIBRARY_INSTALL_PREFIX ${LIBRARY_INSTALL_PREFIX}")
message(STATUS "RUNTIME_INSTALL_RPEFIX ${RUNTIME_INSTALL_RPEFIX}")
message(STATUS "SOURCES_INSTALL_RPEFIX ${SOURCES_INSTALL_RPEFIX}")
message(STATUS "INCLUDE_INSTALL_RPEFIX ${INCLUDE_INSTALL_RPEFIX}")
message(STATUS "PLUGIN_INSTALL_PATH ${PLUGIN_INSTALL_PATH}")
message(STATUS "TOOLS_INSTALL_PATH ${TOOLS_INSTALL_PATH}")
message(STATUS "CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}")
# build runtime path
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/${CMAKE_BUILD_TYPE})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/${CMAKE_BUILD_TYPE})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/${CMAKE_BUILD_TYPE})
link_directories(${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
add_definitions(-DQT_MESSAGELOGCONTEXT)
# Setup the environment
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
if ((${CMAKE_SYSTEM_PROCESSOR} STREQUAL "sw_64")
OR (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "loongarch64")
OR (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "mips64")
)
message(STATUS "add cmake params found thread library from ${CMAKE_SYSTEM_PROCESSOR}")
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
set(CMAKE_HAVE_THREADS_LIBRARY ON)
set(CMAKE_USE_WIN32_THREADS_INIT OFF)
set(CMAKE_USE_PTHREADS_INIT ON)
set(THREADS_PREFER_PTHREAD_FLAG ON)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wl,--as-need -fPIE")
find_package(Dtk COMPONENTS Widget REQUIRED)
include_directories(${PROJECT_NAME} PRIVATE ${DtkWidget_INCLUDE_DIRS})
# Use Qt modules no WebEngineWidgets WebChannel
set(QtFindModules Core Gui Widgets Concurrent Network DBus)
foreach(QtModule ${QtFindModules})
find_package(Qt5 COMPONENTS ${QtModule} REQUIRED)
# include qt module private include directors
include_directories(${Qt5${QtModule}_PRIVATE_INCLUDE_DIRS})
# can use target_link_libraries(xxx ${QtUseModules})
list(APPEND QtUseModules "Qt5::${QtModule}")
message("QtModule found ${QtModule} OK!")
endforeach()
set(PkgConfigFindModules)
include(FindPkgConfig)
foreach(PkgConfigModule ${PkgConfigFindModules})
pkg_check_modules(PkgUseModuleVal REQUIRED ${PkgConfigModule})
list(APPEND PkgUseModules ${PkgUseModuleVal_LDFLAGS})
include_directories(${PkgUseModuleVal_INCLUDE_DIRS})
endforeach(PkgConfigModule)
include_directories(${PROJECT_SOURCE_DIR}/src)
option(ENABLE_UNIT_TESTS "Enable unit tests" OFF)
message(STATUS "Enable testing: ${ENABLE_UNIT_TESTS}")
if(ENABLE_UNIT_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
# sub directories
add_subdirectory(3rdparty)
add_subdirectory(src)
add_subdirectory(assets)