forked from albertlauncher/albert
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
142 lines (108 loc) · 4.13 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
cmake_minimum_required(VERSION 3.1.3) # Least supporting CMAKE_CXX_STANDARD
###############################################################################
project(albert VERSION 0.16.1)
###############################################################################
include(GNUInstallDirs)
###############################################################################
add_definitions(-DALBERT_VERSION="${PROJECT_VERSION}")
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
# Set standard
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Set additional compiler flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic") #-Wconversion -Wunused
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DQT_QML_DEBUG")
# Color make output
SET(CMAKE_COLOR_MAKEFILE ON)
# Put the binaries in dedicated toplevel directories
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
###############################################################################
add_subdirectory(lib/globalshortcut)
add_subdirectory(lib/xdg)
add_subdirectory(plugins/)
###############################################################################
set(TARGET_NAME_LIB ${PROJECT_NAME}-lib)
file(GLOB_RECURSE LIB_SRC include/* src/lib/*)
add_library(${TARGET_NAME_LIB} SHARED ${LIB_SRC})
add_library(albert::lib ALIAS ${TARGET_NAME_LIB})
set_target_properties(${TARGET_NAME_LIB} PROPERTIES
OUTPUT_NAME ${PROJECT_NAME}
INSTALL_RPATH "$ORIGIN"
)
target_compile_definitions(${TARGET_NAME_LIB} PRIVATE -DCORE) #export branch
target_include_directories(${TARGET_NAME_LIB}
PUBLIC
include
PRIVATE
include/albert
include/albert/util
src/lib
)
find_package(Qt5 5.5.0
COMPONENTS
Gui
Sql
)
target_link_libraries(${TARGET_NAME_LIB}
PRIVATE
Qt5::Gui
Qt5::Sql
)
###############################################################################
option(BUILD_WITH_QTCHARTS "Use QtCharts to plot stats." ON)
find_package(Qt5 5.5.0
COMPONENTS
Concurrent
Network
Sql
Widgets
OPTIONAL_COMPONENTS
Charts
)
set(TARGET_NAME_BIN ${PROJECT_NAME}-bin)
file(GLOB_RECURSE BIN_SRC src/app/*)
if(NOT BUILD_WITH_QTCHARTS) # TODO: remove Apr 2020
list(REMOVE_ITEM BIN_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/app/settingswidget/statswidget.h")
list(REMOVE_ITEM BIN_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/app/settingswidget/statswidget.cpp")
endif()
add_executable(${TARGET_NAME_BIN} ${BIN_SRC} resources.qrc)
set_target_properties(${TARGET_NAME_BIN} PROPERTIES
OUTPUT_NAME ${PROJECT_NAME}
INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}/albert/" # Set the RPATH for the library lookup
)
target_include_directories(${TARGET_NAME_BIN} PRIVATE src/app src/app/settingswidget)
if (DEFINED CMAKE_LIBRARY_ARCHITECTURE)
target_compile_definitions(${TARGET_NAME_BIN} PRIVATE -DMULTIARCH_TUPLE="${CMAKE_LIBRARY_ARCHITECTURE}")
endif()
target_link_libraries(${TARGET_NAME_BIN}
PRIVATE
Qt5::Concurrent
Qt5::Network
Qt5::Sql
Qt5::Widgets
albert::lib
globalshortcut
xdg
)
if(BUILD_WITH_QTCHARTS)
target_link_libraries(${TARGET_NAME_BIN} PRIVATE Qt5::Charts)
target_compile_definitions(${TARGET_NAME_BIN} PRIVATE -DBUILD_WITH_QTCHARTS) #export branch
endif()
###############################################################################
install(TARGETS ${TARGET_NAME_LIB} ${TARGET_NAME_BIN}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/albert
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
# Do platform specific post target stuff
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
# Install desktop entry and icon
install(FILES resources/albert.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications )
install(FILES resources/icons/albert.svg DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps)
endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")