CMakeLists.txt 2.76 KB
Newer Older
1
cmake_minimum_required(VERSION 2.8.11)
2
set(CMAKE_CXX_STANDARD 14)
3
set(QT_MIN_VERSION "5.8.0")
4 5 6

project(kaidan)

7 8
# CMake options
option(I18N "Enable i18n support" FALSE)
9
option(SAILFISH_OS "Build with Sailfish OS GUI, needs 3rdparty/kaidansf submodule" FALSE)
10 11 12 13 14 15 16 17 18

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

19 20 21
# CMake modules include
include(FeatureSummary)
include(GNUInstallDirs)
22

23 24 25 26
#
# Dependecies
#

27 28 29 30
# CMake module path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")

# Find packages
31
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Qml Quick Sql QuickControls2)
Linus Jahn's avatar
Linus Jahn committed
32
find_package(KF5Kirigami2 REQUIRED)
Linus Jahn's avatar
Linus Jahn committed
33 34
find_package(Gloox REQUIRED)

35
#
36
# Load submodules
37 38
#

39 40 41 42
# Main kaidan sources
include("${CMAKE_SOURCE_DIR}/src/CMakeLists.txt")

# I18n support
43 44 45
if(I18N)
	include("${CMAKE_SOURCE_DIR}/i18n/CMakeLists.txt")
endif()
46

47 48
# Sailfish OS GUI
if(SAILFISH_OS)
Ilya Bizyaev's avatar
Ilya Bizyaev committed
49 50
	if(EXISTS "${CMAKE_SOURCE_DIR}/3rdparty/kaidansf/CMakeLists.txt")
		include("${CMAKE_SOURCE_DIR}/3rdparty/kaidansf/CMakeLists.txt")
51 52 53 54 55 56
	else()
		message(FATAL_ERROR "Could NOT find KaidanSF adaptions for Sailfish OS.")
	endif()
endif()


57 58 59
#
# Sources / Resources
#
60

61 62 63 64 65
# normal kirigami GUI, if no Sailfish OS build
if(NOT SAILFISH_OS)
	set(KAIDAN_QML_QRC kaidan_qml.qrc)
endif()

66
add_executable(${PROJECT_NAME}
67 68 69 70
	${KAIDAN_SOURCES}
	${KAIDAN_QML_QRC}
	${I18N_QRC_CPP}     # only set if enabled
	${KAIDANSF_SOURCES} #
71 72
)

73

74 75 76 77
#
# Linker Flags
#

78 79
target_link_libraries(${PROJECT_NAME}
	Qt5::Core
80
	Qt5::Sql
81 82
	Qt5::Qml
	Qt5::Quick
Linus Jahn's avatar
Linus Jahn committed
83
	${GLOOX_LIBRARIES}
84
)
85

86

87 88 89 90
#
# Global C++ variables
#

91 92 93 94 95
if(SAILFISH_OS)
	set(KAIDAN_COMPILE_DEFINITIONS
		SAILFISH_OS=True
		PLATFORM_DISPLAY_NAME="Sailfish OS"
	)
96 97 98 99
else()
	set(KAIDAN_COMPILE_DEFINITIONS
		NOTIFICATIONS_LIBNOTIFY=True
	)
100 101
endif()

102
target_compile_definitions(${PROJECT_NAME} PRIVATE
103
	DEBUG_SOURCE_PATH="${CMAKE_SOURCE_DIR}"
104
	${KAIDAN_COMPILE_DEFINITIONS}
105
)
106 107 108


#
109
# Install Kaidan
110 111
#

112 113
if(UNIX AND NOT APPLE)
	# install kaidan binary
114
	install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}
115 116 117
		DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
	)

118
	# install kaidan media
119 120 121
	install(DIRECTORY "data/images"
		DESTINATION "${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}"
	)
122

123 124 125 126 127 128 129 130
	# 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"
	)
131 132 133 134 135

	# install desktop file
	install(FILES "misc/kaidan.desktop"
		DESTINATION "${CMAKE_INSTALL_FULL_DATADIR}/applications"
	)
136
endif()
137 138 139


feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)