CMakeLists.txt 4.47 KB
Newer Older
Linus Jahn's avatar
Linus Jahn committed
1
cmake_minimum_required(VERSION 2.8.11)
2
set(CMAKE_CXX_STANDARD 14)
3
set(QT_MIN_VERSION "5.8.0")
Linus Jahn's avatar
Linus Jahn committed
4 5 6

project(kaidan)

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

9 10
# CMake options
option(I18N "Enable i18n support" FALSE)
11
option(SAILFISH_OS "Build with Sailfish OS GUI, needs 3rdparty/kaidansf submodule" 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 23

# 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)

Linus Jahn's avatar
Linus Jahn committed
24 25 26
# CMake modules include
include(FeatureSummary)
include(GNUInstallDirs)
Linus Jahn's avatar
Linus Jahn committed
27

28 29 30 31
#
# Dependecies
#

Linus Jahn's avatar
Linus Jahn committed
32 33 34 35
# CMake module path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")

# Find packages
36
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Qml Quick Sql QuickControls2)
Linus Jahn's avatar
Linus Jahn committed
37
find_package(KF5Kirigami2 REQUIRED)
Linus Jahn's avatar
Linus Jahn committed
38 39
find_package(Gloox REQUIRED)

40 41 42 43 44 45 46
# optional QWidget style integration (not on ubuntu touch)
if(NOT UBUNTU_TOUCH)
	find_package(Qt5Widgets)
	set_package_properties(Qt5Widgets PROPERTIES
		DESCRIPTION "Integration with QWidget based desktop styles"
		TYPE OPTIONAL
	)
47 48
endif()

49 50 51 52 53 54 55 56
if(Qt5Widgets_FOUND)
	add_definitions(-DHAVE_QWIDGETS -DQAPPLICATION_CLASS=QApplication)
	set(__Qt5Widgets_LIBRARIES Qt5::Widgets)
else()
	add_definitions(-DQAPPLICATION_CLASS=QGuiApplication)
endif()


57
#
58
# Load submodules
59 60
#

61 62 63 64
# Main kaidan sources
include("${CMAKE_SOURCE_DIR}/src/CMakeLists.txt")

# I18n support
65 66 67
if(I18N)
	include("${CMAKE_SOURCE_DIR}/i18n/CMakeLists.txt")
endif()
68

69 70
# Sailfish OS GUI
if(SAILFISH_OS)
Ilya Bizyaev's avatar
Ilya Bizyaev committed
71 72
	if(EXISTS "${CMAKE_SOURCE_DIR}/3rdparty/kaidansf/CMakeLists.txt")
		include("${CMAKE_SOURCE_DIR}/3rdparty/kaidansf/CMakeLists.txt")
73 74 75 76 77 78
	else()
		message(FATAL_ERROR "Could NOT find KaidanSF adaptions for Sailfish OS.")
	endif()
endif()


79 80 81
#
# Sources / Resources
#
Linus Jahn's avatar
Linus Jahn committed
82

83 84 85 86 87
# normal kirigami GUI, if no Sailfish OS build
if(NOT SAILFISH_OS)
	set(KAIDAN_QML_QRC kaidan_qml.qrc)
endif()

88 89 90 91 92 93
# Include bundled icons on Ubuntu Touch,
# because its icon theme is missing some required icons
if(UBUNTU_TOUCH)
	set(KAIDAN_ICONS_QRC kirigami-icons.qrc)
endif()

Linus Jahn's avatar
Linus Jahn committed
94
add_executable(${PROJECT_NAME}
95 96
	${KAIDAN_SOURCES}
	${KAIDAN_QML_QRC}
97 98
	${KAIDAN_ICONS_QRC} # only set if enabled
	${I18N_QRC_CPP}     #
99
	${KAIDANSF_SOURCES} #
Linus Jahn's avatar
Linus Jahn committed
100 101
)

102

103 104 105 106
#
# Linker Flags
#

Linus Jahn's avatar
Linus Jahn committed
107 108
target_link_libraries(${PROJECT_NAME}
	Qt5::Core
109
	Qt5::Sql
Linus Jahn's avatar
Linus Jahn committed
110 111
	Qt5::Qml
	Qt5::Quick
112
	${__Qt5Widgets_LIBRARIES}
Linus Jahn's avatar
Linus Jahn committed
113
	${GLOOX_LIBRARIES}
Linus Jahn's avatar
Linus Jahn committed
114
)
115

116

117 118 119 120
#
# Global C++ variables
#

121 122 123 124 125
if(SAILFISH_OS)
	set(KAIDAN_COMPILE_DEFINITIONS
		SAILFISH_OS=True
		PLATFORM_DISPLAY_NAME="Sailfish OS"
	)
126 127 128 129
elseif(UBUNTU_TOUCH)
	set(KAIDAN_COMPILE_DEFINITIONS
		UBUNTU_TOUCH=True
	)
130 131 132 133
else()
	set(KAIDAN_COMPILE_DEFINITIONS
		NOTIFICATIONS_LIBNOTIFY=True
	)
134 135
endif()

136
target_compile_definitions(${PROJECT_NAME} PRIVATE
137
	DEBUG_SOURCE_PATH="${CMAKE_SOURCE_DIR}"
138
	${KAIDAN_COMPILE_DEFINITIONS}
139
)
140 141 142


#
143
# Install Kaidan
144 145
#

146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
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
	install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}
	        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)
165
	# install kaidan binary
166
	install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}
167
	        DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
168 169
	)

170
	# install kaidan media
171
	install(DIRECTORY "data/images"
172
	        DESTINATION "${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}"
173
	)
174

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


feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)