CMakeLists.txt 4.75 KB
Newer Older
Linus Jahn's avatar
Linus Jahn committed
1
cmake_minimum_required(VERSION 2.8.11)
2
find_package(ECM 5.40.0 REQUIRED NO_MODULE)
3
set(CMAKE_CXX_STANDARD 14)
4
set(QT_MIN_VERSION "5.8.0")
Linus Jahn's avatar
Linus Jahn committed
5 6 7

project(kaidan)

8 9
set(APPLICATION_ID "im.kaidan.kaidan")

10 11
# CMake options
option(I18N "Enable i18n support" FALSE)
12 13
option(UBUNTU_TOUCH "Building a Ubuntu Touch click (internal use only!)" FALSE)
option(CLICK_ARCH "Architecture that will be used in the click's manifest")
14
option(CLICK_DATE "Date used in the version number in the click's manifest")
Linus Jahn's avatar
Linus Jahn committed
15 16 17 18 19 20 21 22

# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)

# Instruct CMake to run moc, uic and rcc automatically when needed.
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
23
set(AUTOMOC_MOC_OPTIONS -Muri=im.kaidan.kaidan)
Linus Jahn's avatar
Linus Jahn committed
24

25 26 27 28
#
# Dependecies
#

Linus Jahn's avatar
Linus Jahn committed
29
# CMake module path
30 31 32 33 34 35 36 37 38 39 40
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake" ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})

# CMake modules include
include(GNUInstallDirs)
include(KDEInstallDirs)
include(KDECompilerSettings NO_POLICY_SCOPE)
include(KDECMakeSettings)
include(ECMInstallIcons)
include(ECMAddAppIcon)
include(FeatureSummary)
kde_enable_exceptions()
Linus Jahn's avatar
Linus Jahn committed
41 42

# Find packages
43
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Qml Quick Svg Sql QuickControls2)
Linus Jahn's avatar
Linus Jahn committed
44
find_package(KF5Kirigami2 REQUIRED)
Linus Jahn's avatar
Linus Jahn committed
45 46
find_package(Gloox REQUIRED)

47 48
# optional QWidget style integration (not on mobile)
if(NOT UBUNTU_TOUCH AND NOT ANDROID)
49 50 51 52 53
	find_package(Qt5Widgets)
	set_package_properties(Qt5Widgets PROPERTIES
		DESCRIPTION "Integration with QWidget based desktop styles"
		TYPE OPTIONAL
	)
54 55
endif()

56 57 58 59 60 61 62
if(Qt5Widgets_FOUND)
	add_definitions(-DHAVE_QWIDGETS -DQAPPLICATION_CLASS=QApplication)
	set(__Qt5Widgets_LIBRARIES Qt5::Widgets)
else()
	add_definitions(-DQAPPLICATION_CLASS=QGuiApplication)
endif()

63 64 65 66 67 68
if (ANDROID)
	find_package(Qt5 REQUIRED COMPONENTS AndroidExtras)
	find_library(CRYPTO_LIBRARIES crypto)
	find_library(SSL_LIBRARIES ssl)
endif()

69

70
#
71
# Load submodules
72 73
#

74 75 76 77
# Main kaidan sources
include("${CMAKE_SOURCE_DIR}/src/CMakeLists.txt")

# I18n support
78 79 80
if(I18N)
	include("${CMAKE_SOURCE_DIR}/i18n/CMakeLists.txt")
endif()
81

82

83 84 85
#
# Sources / Resources
#
Linus Jahn's avatar
Linus Jahn committed
86

87 88
# Include bundled icons on Ubuntu Touch and Android
if(UBUNTU_TOUCH OR ANDROID)
89 90 91
	set(KAIDAN_ICONS_QRC kirigami-icons.qrc)
endif()

92 93 94 95 96
# Bundle images on Android
if(ANDROID)
	set(KAIDAN_IMAGES_QRC "data/images/images.qrc")
endif()

Linus Jahn's avatar
Linus Jahn committed
97
add_executable(${PROJECT_NAME}
98
	${KAIDAN_SOURCES}
99 100 101
	${KAIDAN_ICONS_QRC}  # only set if enabled
	${KAIDAN_IMAGES_QRC} #
	${I18N_QRC_CPP}      #
102
	"kaidan_qml.qrc"
Linus Jahn's avatar
Linus Jahn committed
103
)
104 105
set_target_properties(${PROJECT_NAME} PROPERTIES C_VISIBILITY_PRESET default)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_VISIBILITY_PRESET default)
Linus Jahn's avatar
Linus Jahn committed
106

107

108 109 110 111
#
# Linker Flags
#

Linus Jahn's avatar
Linus Jahn committed
112 113
target_link_libraries(${PROJECT_NAME}
	Qt5::Core
114
	Qt5::Sql
Linus Jahn's avatar
Linus Jahn committed
115 116
	Qt5::Qml
	Qt5::Quick
117
	Qt5::Svg
118
	${__Qt5Widgets_LIBRARIES}
Linus Jahn's avatar
Linus Jahn committed
119
	${GLOOX_LIBRARIES}
Linus Jahn's avatar
Linus Jahn committed
120
)
121

122 123 124
if (ANDROID)
	target_link_libraries(${PROJECT_NAME} Qt5::AndroidExtras Qt5::QuickControls2 KF5::Kirigami2 ${CRYPTO_LIBRARIES} ${SSL_LIBRARIES})
endif()
125

126 127 128 129
#
# Global C++ variables
#

130
if(UBUNTU_TOUCH)
131 132 133
	set(KAIDAN_COMPILE_DEFINITIONS
		UBUNTU_TOUCH=True
	)
134
elseif(NOT ANDROID)
135 136 137
	set(KAIDAN_COMPILE_DEFINITIONS
		NOTIFICATIONS_LIBNOTIFY=True
	)
138 139
endif()

140
target_compile_definitions(${PROJECT_NAME} PRIVATE
141
	DEBUG_SOURCE_PATH="${CMAKE_SOURCE_DIR}"
142
	${KAIDAN_COMPILE_DEFINITIONS}
143
)
144 145 146


#
147
# Install Kaidan
148 149
#

150 151 152 153 154 155
if(UBUNTU_TOUCH AND CLICK_ARCH)
	# will replace ${CLICK_ARCH} with its value
	configure_file(${CMAKE_SOURCE_DIR}/misc/ubuntu-touch/manifest.json.in
	               ${CMAKE_SOURCE_DIR}/misc/ubuntu-touch/manifest.json)

	# install kaidan binary
156
	install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/bin/${PROJECT_NAME}
157 158 159 160 161 162 163 164 165 166 167 168
	        DESTINATION ${CMAKE_INSTALL_PREFIX}
	)
	# install kaidan media
	install(DIRECTORY "data/images"
	        DESTINATION "${CMAKE_INSTALL_FULL_DATADIR}/${APPLICATION_ID}"
	)
	# install icon
	install(FILES "misc/kaidan.svg" "misc/ubuntu-touch/apparmor.json"
	              "misc/ubuntu-touch/kaidan.desktop" "misc/ubuntu-touch/manifest.json"
	        DESTINATION "${CMAKE_INSTALL_PREFIX}"
	)
elseif(UNIX AND NOT APPLE)
169
	# install kaidan binary
170
	install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/bin/${PROJECT_NAME}
171
	        DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
172 173
	)

174
	# install kaidan media
175
	install(DIRECTORY "data/images"
176
	        DESTINATION "${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}"
177
	)
178

179 180
	# install icon (scalable + 128x)
	install(FILES "misc/kaidan.svg"
181
	        DESTINATION "${CMAKE_INSTALL_FULL_DATADIR}/icons/hicolor/scalable/apps"
182 183
	)
	install(FILES "misc/kaidan-128x128.png"
184 185
	        DESTINATION "${CMAKE_INSTALL_FULL_DATADIR}/icons/hicolor/128x128/apps"
	        RENAME "kaidan.png"
186
	)
187 188
	# install desktop file
	install(FILES "misc/kaidan.desktop"
189
	        DESTINATION "${CMAKE_INSTALL_FULL_DATADIR}/applications"
190
	)
191
endif()
Linus Jahn's avatar
Linus Jahn committed
192 193 194


feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)