matrixion/CMakeLists.txt

369 lines
10 KiB
Text
Raw Normal View History

2017-04-06 02:06:42 +03:00
cmake_minimum_required(VERSION 3.1)
2017-05-02 04:22:33 +03:00
option(BUILD_TESTS "Build all tests" OFF)
2017-10-01 22:38:46 +03:00
option(APPVEYOR_BUILD "Build on appveyor" OFF)
2017-05-02 04:22:33 +03:00
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# Include Qt basic functions
include(QtCommon)
project(nheko LANGUAGES C CXX VERSION 0.1.0)
# Set PROJECT_VERSION_PATCH and PROJECT_VERSION_TWEAK to 0 if not present, needed by add_project_meta
fix_project_version()
# Set additional project information
set(COMPANY "Nheko")
set(COPYRIGHT "Copyright (c) 2017 Mujx")
set(IDENTIFIER "com.mujx.nheko")
add_project_meta(META_FILES_TO_INCLUDE)
#
# LMDB
#
2017-10-01 22:38:46 +03:00
if(APPVEYOR_BUILD)
set(LMDB_VERSION "LMDB_0.9.21")
set(NTDLIB "C:/WINDDK/7600.16385.1/lib/win7/amd64/ntdll.lib")
2017-10-01 22:38:46 +03:00
execute_process(
COMMAND git clone --depth=1 --branch ${LMDB_VERSION} https://github.com/LMDB/lmdb)
set(LMDB_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/lmdb/libraries/liblmdb)
add_library(lmdb
${CMAKE_SOURCE_DIR}/lmdb/libraries/liblmdb/lmdb.h
${CMAKE_SOURCE_DIR}/lmdb/libraries/liblmdb/mdb.c
${CMAKE_SOURCE_DIR}/lmdb/libraries/liblmdb/midl.h
${CMAKE_SOURCE_DIR}/lmdb/libraries/liblmdb/midl.c)
else()
find_path (LMDB_INCLUDE_DIR NAMES lmdb.h PATHS "$ENV{LMDB_DIR}/include")
find_library (LMDB_LIBRARY NAMES lmdb PATHS "$ENV{LMDB_DIR}/lib" )
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LMDB DEFAULT_MSG LMDB_INCLUDE_DIR LMDB_LIBRARY)
endif()
if (NOT EXISTS "${CMAKE_SOURCE_DIR}/libs/lmdbxx/.git" )
message(WARNING "The git submodules are not available.")
message(STATUS "Running git submodule update --init --recursive ...")
execute_process(COMMAND git submodule update --init --recursive)
endif()
#
# Discover Qt dependencies.
#
2017-04-06 02:06:42 +03:00
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Network REQUIRED)
2017-05-29 19:09:12 +03:00
find_package(Qt5LinguistTools REQUIRED)
find_package(Qt5Concurrent REQUIRED)
2017-04-06 02:06:42 +03:00
2017-07-01 16:34:36 +03:00
if (APPLE)
find_package(Qt5MacExtras REQUIRED)
endif(APPLE)
if (Qt5Widgets_FOUND)
if (Qt5Widgets_VERSION VERSION_LESS 5.7.0)
message(STATUS "Qt version ${Qt5Widgets_VERSION}")
2017-05-30 14:44:51 +03:00
message(WARNING "Minimum supported Qt5 version is 5.7!")
endif()
endif(Qt5Widgets_FOUND)
#
# Set up compiler flags.
#
2017-04-06 02:06:42 +03:00
set(CMAKE_C_COMPILER gcc)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
2017-04-11 18:25:39 +03:00
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
2017-04-06 14:58:48 +03:00
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
2017-04-11 18:25:39 +03:00
message("Setting build type to '${CMAKE_BUILD_TYPE}'")
else(NOT CMAKE_BUILD_TYPE)
message("Build type set to '${CMAKE_BUILD_TYPE}'")
endif(NOT CMAKE_BUILD_TYPE)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
set(PATCH_OUT "0")
else("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
find_program(GIT git)
if(GIT)
execute_process(
2017-04-06 14:58:48 +03:00
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND ${GIT} rev-parse --short HEAD
OUTPUT_VARIABLE GIT_OUT OUTPUT_STRIP_TRAILING_WHITESPACE
)
2017-04-11 18:25:39 +03:00
set(PATCH_OUT "0-${GIT_OUT}")
else(GIT)
set(PATCH_OUT "0")
endif(GIT)
endif("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
set(PROJECT_VERSION_PATCH ${PATCH_OUT})
set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "1")
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
set(PROJECT_VERSION_MAJOR ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR})
set(PROJECT_VERSION ${CPACK_PACKAGE_VERSION})
message(STATUS "Version: ${PROJECT_VERSION}")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-Wall \
-Wextra \
2017-09-18 20:42:36 +03:00
-march=native \
-Werror \
2017-09-18 20:42:36 +03:00
-pipe \
-pedantic \
-Wunreachable-code")
2017-04-11 19:21:11 +03:00
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
if (GCC_VERSION VERSION_GREATER 4.9)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always" )
endif()
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always" )
endif()
2017-04-09 17:09:22 +03:00
endif()
2017-04-06 02:06:42 +03:00
#
# Declare source and header files.
#
2017-04-06 02:06:42 +03:00
set(SRC_FILES
2017-11-30 14:53:28 +03:00
# Dialogs
src/dialogs/ImageOverlayDialog.cc
src/dialogs/JoinRoomDialog.cc
src/dialogs/LeaveRoomDialog.cc
src/dialogs/LogoutDialog.cc
# Emoji
src/emoji/EmojiCategory.cc
src/emoji/EmojiItemDelegate.cc
src/emoji/EmojiPanel.cc
src/emoji/EmojiPickButton.cc
src/emoji/EmojiProvider.cc
# Timeline
src/timeline/TimelineViewManager.cc
src/timeline/TimelineItem.cc
src/timeline/TimelineView.cc
src/timeline/widgets/FileItem.cc
src/timeline/widgets/ImageItem.cc
# UI components
src/ui/Avatar.cc
src/ui/Badge.cc
src/ui/LoadingIndicator.cc
src/ui/FlatButton.cc
src/ui/FloatingButton.cc
src/ui/Label.cc
src/ui/OverlayModal.cc
src/ui/ScrollBar.cc
src/ui/SnackBar.cc
src/ui/RaisedButton.cc
src/ui/Ripple.cc
src/ui/RippleOverlay.cc
src/ui/OverlayWidget.cc
src/ui/TextField.cc
src/ui/ToggleButton.cc
src/ui/Theme.cc
src/ui/ThemeManager.cc
src/AvatarProvider.cc
src/Cache.cc
2017-10-04 11:33:34 +03:00
src/ChatPage.cc
2017-04-06 02:06:42 +03:00
src/Deserializable.cc
src/InputValidator.cc
src/Login.cc
src/LoginPage.cc
src/MainWindow.cc
src/MatrixClient.cc
src/Profile.cc
2017-10-04 11:33:34 +03:00
src/QuickSwitcher.cc
src/Register.cc
src/RegisterPage.cc
2017-04-06 02:06:42 +03:00
src/RoomInfoListItem.cc
src/RoomList.cc
2017-10-04 11:33:34 +03:00
src/RoomMessages.cc
src/RoomState.cc
2017-10-15 22:08:51 +03:00
src/SideBarActions.cc
2017-05-19 03:28:15 +03:00
src/Splitter.cc
2017-04-06 02:06:42 +03:00
src/Sync.cc
src/TextInputWidget.cc
src/TopRoomBar.cc
2017-10-04 11:33:34 +03:00
src/TrayIcon.cc
src/TypingDisplay.cc
2017-04-06 02:06:42 +03:00
src/UserInfoWidget.cc
2017-11-30 14:53:28 +03:00
src/UserSettingsPage.cc
src/Versions.cc
2017-04-06 02:06:42 +03:00
src/WelcomePage.cc
src/main.cc
)
2017-05-02 04:22:33 +03:00
set(MATRIX_EVENTS
2017-05-03 01:55:47 +03:00
src/events/Event.cc
2017-05-02 04:22:33 +03:00
src/events/AliasesEventContent.cc
src/events/AvatarEventContent.cc
src/events/CanonicalAliasEventContent.cc
src/events/CreateEventContent.cc
src/events/HistoryVisibilityEventContent.cc
src/events/JoinRulesEventContent.cc
src/events/MemberEventContent.cc
src/events/MessageEventContent.cc
2017-05-02 04:22:33 +03:00
src/events/NameEventContent.cc
src/events/PowerLevelsEventContent.cc
src/events/TopicEventContent.cc
src/events/messages/Audio.cc
src/events/messages/Emote.cc
src/events/messages/File.cc
src/events/messages/Image.cc
src/events/messages/Location.cc
src/events/messages/Notice.cc
src/events/messages/Text.cc
src/events/messages/Video.cc
2017-05-02 04:22:33 +03:00
)
2017-04-06 02:06:42 +03:00
include_directories(include)
include_directories(include/ui)
2017-05-02 04:22:33 +03:00
include_directories(include/events)
include_directories(include/events/messages)
2017-08-06 11:01:46 +03:00
include_directories(libs/lmdbxx)
2017-08-06 11:01:46 +03:00
include_directories(${LMDB_INCLUDE_DIR})
2017-04-06 02:06:42 +03:00
qt5_wrap_cpp(MOC_HEADERS
2017-11-30 14:53:28 +03:00
# Dialogs
include/dialogs/ImageOverlayDialog.h
include/dialogs/JoinRoomDialog.h
include/dialogs/LeaveRoomDialog.h
include/dialogs/LogoutDialog.h
# Emoji
include/emoji/EmojiCategory.h
include/emoji/EmojiItemDelegate.h
include/emoji/EmojiPanel.h
include/emoji/EmojiPickButton.h
include/emoji/EmojiProvider.h
# Timeline
include/timeline/TimelineItem.h
include/timeline/TimelineView.h
include/timeline/TimelineViewManager.h
include/timeline/widgets/FileItem.h
include/timeline/widgets/ImageItem.h
# UI components
include/ui/Avatar.h
include/ui/Badge.h
include/ui/LoadingIndicator.h
include/ui/FlatButton.h
include/ui/Label.h
include/ui/FloatingButton.h
include/ui/OverlayWidget.h
include/ui/ScrollBar.h
include/ui/SnackBar.h
include/ui/RaisedButton.h
include/ui/Ripple.h
include/ui/RippleOverlay.h
include/ui/TextField.h
include/ui/ToggleButton.h
include/ui/Theme.h
include/ui/ThemeManager.h
include/AvatarProvider.h
2017-04-06 02:06:42 +03:00
include/ChatPage.h
include/LoginPage.h
include/MainWindow.h
include/MatrixClient.h
2017-10-04 11:33:34 +03:00
include/QuickSwitcher.h
2017-04-06 02:06:42 +03:00
include/RegisterPage.h
include/RoomInfoListItem.h
include/RoomList.h
2017-10-15 22:08:51 +03:00
include/SideBarActions.h
2017-05-19 03:28:15 +03:00
include/Splitter.h
2017-10-04 11:33:34 +03:00
include/TextInputWidget.h
2017-04-06 02:06:42 +03:00
include/TopRoomBar.h
2017-05-21 16:36:06 +03:00
include/TrayIcon.h
2017-10-04 11:33:34 +03:00
include/TypingDisplay.h
include/UserInfoWidget.h
2017-11-30 14:53:28 +03:00
include/UserSettingsPage.h
2017-04-06 02:06:42 +03:00
include/WelcomePage.h
)
#
# Bundle translations.
#
2017-05-29 19:09:12 +03:00
FILE(GLOB LANG_TS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/resources/langs/*.ts")
qt5_add_translation(QM_SRC ${LANG_TS_SRC})
add_custom_target(LANG_QRC ALL DEPENDS ${QM_SRC})
# Generate a qrc file for the translations
set(_qrc ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc)
file(WRITE ${_qrc} "<RCC> <qresource prefix=\"/translations\">")
foreach(_lang ${QM_SRC})
get_filename_component(_filename ${_lang} NAME)
file(APPEND ${_qrc} "<file>${_filename}</file>")
endforeach(_lang)
file(APPEND ${_qrc} "</qresource> </RCC>")
qt5_add_resources(LANG_QRC ${_qrc})
2017-04-06 02:06:42 +03:00
qt5_add_resources(QRC resources/res.qrc)
#
# Matrix events library.
#
2017-05-02 04:22:33 +03:00
add_library(matrix_events ${MATRIX_EVENTS} src/Deserializable.cc)
target_link_libraries(matrix_events Qt5::Core)
if (BUILD_TESTS)
enable_testing()
2017-04-09 17:09:22 +03:00
2017-05-02 04:22:33 +03:00
find_package(GTest REQUIRED)
include_directories(${GTEST_INCLUDE_DIRS})
add_executable(events_test tests/events.cc)
target_link_libraries(events_test matrix_events ${GTEST_BOTH_LIBRARIES})
add_executable(event_collection_test tests/event_collection.cc)
target_link_libraries(event_collection_test matrix_events ${GTEST_BOTH_LIBRARIES})
add_executable(message_events tests/message_events.cc)
target_link_libraries(message_events matrix_events ${GTEST_BOTH_LIBRARIES})
2017-05-02 04:22:33 +03:00
add_test(MatrixEvents events_test)
add_test(MatrixEventCollection event_collection_test)
add_test(MatrixMessageEvents message_events)
2017-10-08 16:49:56 +03:00
endif()
2017-10-01 22:38:46 +03:00
if(APPVEYOR_BUILD)
set (NHEKO_LIBS matrix_events Qt5::Widgets Qt5::Network Qt5::Concurrent lmdb)
2017-10-01 22:38:46 +03:00
else()
set (NHEKO_LIBS matrix_events Qt5::Widgets Qt5::Network Qt5::Concurrent ${LMDB_LIBRARY})
2017-10-01 22:38:46 +03:00
endif()
set (NHEKO_DEPS ${SRC_FILES} ${UI_HEADERS} ${MOC_HEADERS} ${QRC} ${LANG_QRC} ${QM_SRC} ${META_FILES_TO_INCLUDE})
2017-10-08 16:49:56 +03:00
if(APPLE)
add_executable (nheko ${OS_BUNDLE} ${NHEKO_DEPS})
2017-10-08 16:49:56 +03:00
target_link_libraries (nheko ${NHEKO_LIBS} Qt5::MacExtras)
elseif(WIN32)
add_executable (nheko ${OS_BUNDLE} ${ICON_FILE} ${NHEKO_DEPS})
2017-10-08 16:49:56 +03:00
target_link_libraries (nheko ${NTDLIB} ${NHEKO_LIBS} Qt5::WinMain)
else()
add_executable (nheko ${OS_BUNDLE} ${NHEKO_DEPS})
2017-10-08 16:49:56 +03:00
target_link_libraries (nheko ${NHEKO_LIBS})
2017-05-02 04:22:33 +03:00
endif()