CMakeLists.txt 3.43 KB
Newer Older
LNJ's avatar
LNJ committed
1
cmake_minimum_required(VERSION 2.8.11)
2 3
set(CMAKE_CXX_STANDARD 14)
set(QT_MIN_VERSION "5.7.0")
4
set(BOOST_MIN_VERSION "1.34.1")
LNJ's avatar
LNJ committed
5 6 7

project(kaidan)

8 9
# CMake options
option(I18N "Enable i18n support" FALSE)
10
option(SAILFISH_OS "Build with Sailfish OS GUI, needs libs/kaidansf submodule" FALSE)
11

12
# application name
LNJ's avatar
LNJ committed
13
set(APPLICATION_ID "io.github.kaidanim")
14 15
set(APPLICATION_NAME "kaidan")
set(APPLICATION_DISPLAY_NAME "Kaidan")
16
set(APPLICATION_DESCRIPTION "Cross platform XMPP client")
17

18

LNJ's avatar
LNJ committed
19 20
# Version
set(VERSION_MAJOR 0)
LNJ's avatar
LNJ committed
21 22 23
set(VERSION_MINOR 3)
set(VERSION_PATCH 1)
#set(VERSION_EXTRA "dev")
LNJ's avatar
LNJ committed
24 25 26 27 28 29 30 31 32 33 34 35 36
set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
if(VERSION_EXTRA)
	set(VERSION_STRING ${VERSION_STRING}-${VERSION_EXTRA})
endif()

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

LNJ's avatar
LNJ committed
37 38 39
# CMake modules include
include(FeatureSummary)
include(GNUInstallDirs)
LNJ's avatar
LNJ committed
40

41 42 43 44
#
# Dependecies
#

LNJ's avatar
LNJ committed
45 46 47 48
# CMake module path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")

# Find packages
49
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Qml Quick Sql QuickControls2)
LNJ's avatar
LNJ committed
50
find_package(KF5Kirigami2 REQUIRED)
LNJ's avatar
LNJ committed
51 52
find_package(Gloox REQUIRED)

53
#
54
# Load submodules
55 56
#

57 58 59 60
# Main kaidan sources
include("${CMAKE_SOURCE_DIR}/src/CMakeLists.txt")

# I18n support
61 62 63
if(I18N)
	include("${CMAKE_SOURCE_DIR}/i18n/CMakeLists.txt")
endif()
64

65 66 67 68 69 70 71 72 73 74
# Sailfish OS GUI
if(SAILFISH_OS)
	if(EXISTS "${CMAKE_SOURCE_DIR}/libs/kaidansf/CMakeLists.txt")
		include("${CMAKE_SOURCE_DIR}/libs/kaidansf/CMakeLists.txt")
	else()
		message(FATAL_ERROR "Could NOT find KaidanSF adaptions for Sailfish OS.")
	endif()
endif()


75 76 77
#
# Sources / Resources
#
LNJ's avatar
LNJ committed
78

79 80 81 82 83
# normal kirigami GUI, if no Sailfish OS build
if(NOT SAILFISH_OS)
	set(KAIDAN_QML_QRC kaidan_qml.qrc)
endif()

LNJ's avatar
LNJ committed
84
add_executable(${PROJECT_NAME}
85 86 87 88
	${KAIDAN_SOURCES}
	${KAIDAN_QML_QRC}
	${I18N_QRC_CPP}     # only set if enabled
	${KAIDANSF_SOURCES} #
LNJ's avatar
LNJ committed
89 90
)

91

92 93 94 95
#
# Linker Flags
#

LNJ's avatar
LNJ committed
96 97
target_link_libraries(${PROJECT_NAME}
	Qt5::Core
98
	Qt5::Sql
LNJ's avatar
LNJ committed
99 100
	Qt5::Qml
	Qt5::Quick
LNJ's avatar
LNJ committed
101
	${GLOOX_LIBRARIES}
LNJ's avatar
LNJ committed
102
)
103

104

105 106 107 108
#
# Global C++ variables
#

109 110 111 112 113
if(SAILFISH_OS)
	set(KAIDAN_COMPILE_DEFINITIONS
		SAILFISH_OS=True
		PLATFORM_DISPLAY_NAME="Sailfish OS"
	)
114 115 116 117
else()
	set(KAIDAN_COMPILE_DEFINITIONS
		NOTIFICATIONS_LIBNOTIFY=True
	)
118 119
endif()

120 121 122 123
target_compile_definitions(${PROJECT_NAME} PRIVATE
	APPLICATION_ID="${APPLICATION_ID}"
	APPLICATION_NAME="${APPLICATION_NAME}"
	APPLICATION_DISPLAY_NAME="${APPLICATION_DISPLAY_NAME}"
124
	APPLICATION_DESCRIPTION="${APPLICATION_DESCRIPTION}"
125 126

	VERSION_STRING="${VERSION_STRING}"
127

128 129
	DEBUG_SOURCE_PATH="${CMAKE_SOURCE_DIR}"

130
	${KAIDAN_COMPILE_DEFINITIONS}
131
)
132 133 134


#
135
# Install Kaidan
136 137
#

138 139
if(UNIX AND NOT APPLE)
	# install kaidan binary
140
	install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}
141 142 143
		DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
	)

144
	# install kaidan media
145 146 147
	install(DIRECTORY "data/images"
		DESTINATION "${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}"
	)
148

149 150 151 152 153 154 155 156
	# install icon (scalable + 128x)
	install(FILES "misc/kaidan.svg"
		DESTINATION "${CMAKE_INSTALL_FULL_DATADIR}/icons/hicolor/scalable/apps"
	)
	install(FILES "misc/kaidan-128x128.png"
		DESTINATION "${CMAKE_INSTALL_FULL_DATADIR}/icons/hicolor/128x128/apps"
		RENAME "kaidan.png"
	)
157 158 159 160 161

	# install desktop file
	install(FILES "misc/kaidan.desktop"
		DESTINATION "${CMAKE_INSTALL_FULL_DATADIR}/applications"
	)
162
endif()
LNJ's avatar
LNJ committed
163 164 165


feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)