2017-04-06 02:06:42 +03:00
|
|
|
cmake_minimum_required(VERSION 3.1)
|
|
|
|
|
|
|
|
project(nheko CXX)
|
|
|
|
|
2017-05-02 04:22:33 +03:00
|
|
|
option(BUILD_TESTS "Build all tests" OFF)
|
|
|
|
|
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)
|
2017-04-06 02:06:42 +03:00
|
|
|
|
2017-07-01 16:34:36 +03:00
|
|
|
if (APPLE)
|
|
|
|
find_package(Qt5MacExtras REQUIRED)
|
|
|
|
endif(APPLE)
|
|
|
|
|
2017-05-30 14:35:01 +03:00
|
|
|
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!")
|
2017-05-30 14:35:01 +03:00
|
|
|
endif()
|
|
|
|
endif(Qt5Widgets_FOUND)
|
|
|
|
|
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")
|
2017-04-11 17:45:47 +03:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
|
|
|
|
-Wall \
|
|
|
|
-Wextra \
|
|
|
|
-Werror \
|
|
|
|
-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
|
|
|
|
|
|
|
set(SRC_FILES
|
2017-06-05 02:14:05 +03:00
|
|
|
src/AvatarProvider.cc
|
2017-04-06 02:06:42 +03:00
|
|
|
src/ChatPage.cc
|
|
|
|
src/Deserializable.cc
|
2017-04-23 21:31:08 +03:00
|
|
|
src/EmojiCategory.cc
|
|
|
|
src/EmojiItemDelegate.cc
|
|
|
|
src/EmojiPanel.cc
|
|
|
|
src/EmojiPickButton.cc
|
|
|
|
src/EmojiProvider.cc
|
2017-04-28 14:56:45 +03:00
|
|
|
src/ImageItem.cc
|
2017-04-30 01:55:10 +03:00
|
|
|
src/ImageOverlayDialog.cc
|
2017-04-25 14:37:54 +03:00
|
|
|
src/TimelineItem.cc
|
|
|
|
src/TimelineView.cc
|
|
|
|
src/TimelineViewManager.cc
|
2017-04-06 02:06:42 +03:00
|
|
|
src/InputValidator.cc
|
|
|
|
src/Login.cc
|
|
|
|
src/LoginPage.cc
|
2017-06-02 18:04:51 +03:00
|
|
|
src/LogoutDialog.cc
|
2017-04-06 02:06:42 +03:00
|
|
|
src/MainWindow.cc
|
|
|
|
src/MatrixClient.cc
|
|
|
|
src/Profile.cc
|
|
|
|
src/RoomInfoListItem.cc
|
2017-05-12 15:43:35 +03:00
|
|
|
src/RoomMessages.cc
|
2017-04-06 02:06:42 +03:00
|
|
|
src/RoomList.cc
|
2017-05-07 17:15:38 +03:00
|
|
|
src/RoomState.cc
|
2017-04-08 02:53:23 +03:00
|
|
|
src/Register.cc
|
2017-04-06 02:06:42 +03:00
|
|
|
src/RegisterPage.cc
|
|
|
|
src/SlidingStackWidget.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
|
2017-05-21 16:36:06 +03:00
|
|
|
src/TrayIcon.cc
|
2017-04-06 02:06:42 +03:00
|
|
|
src/TopRoomBar.cc
|
|
|
|
src/UserInfoWidget.cc
|
2017-07-08 14:41:49 +03:00
|
|
|
src/Versions.cc
|
2017-04-06 02:06:42 +03:00
|
|
|
src/WelcomePage.cc
|
|
|
|
src/main.cc
|
|
|
|
|
|
|
|
src/ui/Avatar.cc
|
|
|
|
src/ui/Badge.cc
|
2017-04-26 02:23:12 +03:00
|
|
|
src/ui/CircularProgress.cc
|
2017-04-06 02:06:42 +03:00
|
|
|
src/ui/FlatButton.cc
|
2017-04-26 02:23:12 +03:00
|
|
|
src/ui/OverlayModal.cc
|
2017-05-24 22:45:13 +03:00
|
|
|
src/ui/ScrollBar.cc
|
2017-04-06 02:06:42 +03:00
|
|
|
src/ui/RaisedButton.cc
|
|
|
|
src/ui/Ripple.cc
|
|
|
|
src/ui/RippleOverlay.cc
|
|
|
|
src/ui/OverlayWidget.cc
|
|
|
|
src/ui/TextField.cc
|
|
|
|
src/ui/Theme.cc
|
|
|
|
src/ui/ThemeManager.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
|
2017-05-07 17:15:38 +03:00
|
|
|
src/events/MessageEventContent.cc
|
2017-05-02 04:22:33 +03:00
|
|
|
src/events/NameEventContent.cc
|
|
|
|
src/events/PowerLevelsEventContent.cc
|
|
|
|
src/events/TopicEventContent.cc
|
2017-05-07 17:15:38 +03:00
|
|
|
|
|
|
|
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)
|
2017-05-07 17:15:38 +03:00
|
|
|
include_directories(include/events/messages)
|
2017-04-06 02:06:42 +03:00
|
|
|
|
|
|
|
qt5_wrap_cpp(MOC_HEADERS
|
2017-06-05 02:14:05 +03:00
|
|
|
include/AvatarProvider.h
|
2017-04-06 02:06:42 +03:00
|
|
|
include/ChatPage.h
|
2017-04-23 21:31:08 +03:00
|
|
|
include/EmojiCategory.h
|
|
|
|
include/EmojiItemDelegate.h
|
|
|
|
include/EmojiPanel.h
|
|
|
|
include/EmojiPickButton.h
|
2017-04-28 14:56:45 +03:00
|
|
|
include/ImageItem.h
|
2017-04-30 01:55:10 +03:00
|
|
|
include/ImageOverlayDialog.h
|
2017-04-25 14:37:54 +03:00
|
|
|
include/TimelineItem.h
|
|
|
|
include/TimelineView.h
|
|
|
|
include/TimelineViewManager.h
|
2017-04-06 02:06:42 +03:00
|
|
|
include/LoginPage.h
|
2017-06-02 18:04:51 +03:00
|
|
|
include/LogoutDialog.h
|
2017-04-06 02:06:42 +03:00
|
|
|
include/MainWindow.h
|
|
|
|
include/MatrixClient.h
|
|
|
|
include/RegisterPage.h
|
|
|
|
include/RoomInfoListItem.h
|
|
|
|
include/RoomList.h
|
2017-05-19 03:28:15 +03:00
|
|
|
include/Splitter.h
|
2017-04-06 02:06:42 +03:00
|
|
|
include/UserInfoWidget.h
|
|
|
|
include/SlidingStackWidget.h
|
|
|
|
include/TopRoomBar.h
|
2017-05-21 16:36:06 +03:00
|
|
|
include/TrayIcon.h
|
2017-04-06 02:06:42 +03:00
|
|
|
include/TextInputWidget.h
|
|
|
|
include/WelcomePage.h
|
|
|
|
|
|
|
|
include/ui/Avatar.h
|
|
|
|
include/ui/Badge.h
|
2017-04-26 02:23:12 +03:00
|
|
|
include/ui/CircularProgress.h
|
2017-04-06 02:06:42 +03:00
|
|
|
include/ui/FlatButton.h
|
|
|
|
include/ui/OverlayWidget.h
|
2017-05-24 22:45:13 +03:00
|
|
|
include/ui/ScrollBar.h
|
2017-04-06 02:06:42 +03:00
|
|
|
include/ui/RaisedButton.h
|
|
|
|
include/ui/Ripple.h
|
|
|
|
include/ui/RippleOverlay.h
|
|
|
|
include/ui/TextField.h
|
|
|
|
include/ui/Theme.h
|
|
|
|
include/ui/ThemeManager.h
|
|
|
|
)
|
|
|
|
|
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)
|
|
|
|
|
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})
|
|
|
|
|
2017-05-07 17:15:38 +03:00
|
|
|
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)
|
2017-05-07 17:15:38 +03:00
|
|
|
add_test(MatrixEventCollection event_collection_test)
|
|
|
|
add_test(MatrixMessageEvents message_events)
|
2017-05-02 04:22:33 +03:00
|
|
|
else()
|
2017-05-29 19:09:12 +03:00
|
|
|
add_executable (nheko ${OS_BUNDLE} ${SRC_FILES} ${UI_HEADERS} ${MOC_HEADERS} ${QRC} ${LANG_QRC} ${QM_SRC})
|
2017-05-02 04:22:33 +03:00
|
|
|
target_link_libraries (nheko matrix_events Qt5::Widgets Qt5::Network)
|
|
|
|
|
2017-07-01 16:34:36 +03:00
|
|
|
if (APPLE)
|
|
|
|
target_link_libraries(nheko Qt5::MacExtras)
|
|
|
|
endif(APPLE)
|
|
|
|
|
2017-05-02 04:22:33 +03:00
|
|
|
if(WIN32)
|
|
|
|
target_link_libraries(nheko Qt5::WinMain)
|
|
|
|
endif(WIN32)
|
|
|
|
endif()
|