Include mtxclient in the build

remotes/origin/HEAD
Konstantinos Sideris 7 years ago
parent 70ffa43424
commit 0a9d95dfc9
  1. 1
      .gitignore
  2. 31
      CMakeLists.txt
  3. 16
      Makefile
  4. 25
      appveyor.yml
  5. 33
      cmake/MatrixStructs.cmake
  6. 82
      deps/CMakeLists.txt
  7. 23
      deps/cmake/Boost.cmake
  8. 30
      deps/cmake/MatrixClient.cmake
  9. 25
      deps/cmake/MatrixStructs.cmake
  10. 24
      deps/cmake/Olm.cmake
  11. 15
      deps/cmake/SpdLog.cmake
  12. 3
      src/MatrixClient.cc

1
.gitignore vendored

@ -94,3 +94,4 @@ package.dir
# Dependencies
.third-party
.deps

@ -29,6 +29,16 @@ set(IDENTIFIER "com.github.mujx.nheko")
add_project_meta(META_FILES_TO_INCLUDE)
set(DEPS_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/.deps/usr"
CACHE PATH "Path prefix for finding dependencies")
list(INSERT CMAKE_PREFIX_PATH 0 ${DEPS_PREFIX})
include_directories(SYSTEM ${DEPS_PREFIX}/include)
if(APPLE)
set(OPENSSL_ROOT_DIR /usr/local/opt/openssl)
endif()
#
# LMDB
#
@ -177,20 +187,10 @@ set(SRC_FILES
# ExternalProject dependencies
set(EXTERNAL_PROJECT_DEPS "")
#
# matrix-structs
#
find_library(MATRIX_STRUCTS_LIBRARY
NAMES matrix_structs
PATHS ${MATRIX_STRUCTS_ROOT}
${MATRIX_STRUCTS_ROOT}/lib
${MATRIX_STRUCTS_ROOT}/lib/static)
if(NOT MATRIX_STRUCTS_LIBRARY)
include(MatrixStructs)
set(EXTERNAL_PROJECT_DEPS ${EXTERNAL_PROJECT_DEPS} MatrixStructs)
endif()
include_directories(SYSTEM ${MATRIX_STRUCTS_INCLUDE_DIR})
find_package(MatrixStructs REQUIRED)
find_package(MatrixClient REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(ZLIB REQUIRED)
#
# tweeny
@ -293,7 +293,8 @@ include(Translations)
set(TRANSLATION_DEPS ${LANG_QRC} ${QRC} ${QM_SRC})
set(COMMON_LIBS
${MATRIX_STRUCTS_LIBRARY}
MatrixStructs::MatrixStructs
MatrixClient::MatrixClient
Qt5::Widgets
Qt5::Network
Qt5::Svg

@ -1,11 +1,23 @@
DEPS_BUILD_DIR=.deps
DEPS_SOURCE_DIR=deps
debug:
@cmake -H. -GNinja -Bbuild -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=1
@cmake --build build
third_party:
@mkdir -p ${DEPS_BUILD_DIR}/usr/{lib,include}/
@cmake -GNinja -H${DEPS_SOURCE_DIR} -B${DEPS_BUILD_DIR} \
-DCMAKE_BUILD_TYPE=Release \
-DUSE_BUNDLED_BOOST=OFF
@cmake --build ${DEPS_BUILD_DIR}
ci:
@cmake -H. -GNinja -Bbuild -DCMAKE_BUILD_TYPE=RelWithDebInfo
@cmake --build build
mkdir -p ${DEPS_BUILD_DIR}/usr/{lib,include}/
cmake -H${DEPS_SOURCE_DIR} -B${DEPS_BUILD_DIR} -DCMAKE_BUILD_TYPE=Release
cmake --build ${DEPS_BUILD_DIR}
cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build build
release:
@cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=RelWithDebInfo

@ -15,7 +15,19 @@ install:
- set QT_DIR=C:\Qt\5.10.1\msvc2017_64
- set PATH=%PATH%;%QT_DIR%\bin;C:\MinGW\bin
- call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
- vcpkg install lmdb:%PLATFORM%-windows
- vcpkg install
boost-asio:%PLATFORM%-windows
boost-beast:%PLATFORM%-windows
boost-iostreams:%PLATFORM%-windows
boost-random:%PLATFORM%-windows
boost-signals2:%PLATFORM%-windows
boost-system:%PLATFORM%-windows
boost-thread:%PLATFORM%-windows
libsodium:%PLATFORM%-windows
lmdb:%PLATFORM%-windows
openssl:%PLATFORM%-windows
spdlog:%PLATFORM%-windows
zlib:%PLATFORM%-windows
build_script:
# VERSION format: branch-master/branch-1.2
@ -35,6 +47,17 @@ build_script:
- echo %VERSION%
- echo %INSTVERSION%
- echo %DATE%
# Build & install the dependencies
- cmake -G "Visual Studio 15 2017 Win64" -Hdeps -B.deps
-DCMAKE_TOOLCHAIN_FILE=C:/Tools/vcpkg/scripts/buildsystems/vcpkg.cmake
-DCMAKE_BUILD_TYPE=Release
-DUSE_BUNDLED_BOOST=OFF
-DUSE_BUNDLED_SPDLOG=OFF
-DUSE_BUNDLED_GTEST=OFF
- cmake --build .deps --config Release
# Build nheko
- cmake -G "Visual Studio 15 2017 Win64" -H. -Bbuild
-DCMAKE_TOOLCHAIN_FILE=C:/Tools/vcpkg/scripts/buildsystems/vcpkg.cmake
-DCMAKE_BUILD_TYPE=Release

@ -1,33 +0,0 @@
include(ExternalProject)
#
# Build matrix-structs.
#
set(THIRD_PARTY_ROOT ${CMAKE_SOURCE_DIR}/.third-party)
set(MATRIX_STRUCTS_ROOT ${THIRD_PARTY_ROOT}/matrix_structs)
set(MATRIX_STRUCTS_INCLUDE_DIR ${MATRIX_STRUCTS_ROOT}/include)
set(MATRIX_STRUCTS_LIBRARY matrix_structs)
link_directories(${MATRIX_STRUCTS_ROOT})
set(WINDOWS_FLAGS "")
if(MSVC)
set(WINDOWS_FLAGS "-DCMAKE_GENERATOR_PLATFORM=x64")
endif()
ExternalProject_Add(
MatrixStructs
GIT_REPOSITORY https://github.com/mujx/matrix-structs
GIT_TAG 5e57c2385a79b6629d1998fec4a7c0baee23555e
BUILD_IN_SOURCE 1
SOURCE_DIR ${MATRIX_STRUCTS_ROOT}
CONFIGURE_COMMAND ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE=Release ${MATRIX_STRUCTS_ROOT}
${WINDOWS_FLAGS}
BUILD_COMMAND ${CMAKE_COMMAND} --build ${MATRIX_STRUCTS_ROOT} --config Release
INSTALL_COMMAND ""
)

@ -0,0 +1,82 @@
cmake_minimum_required(VERSION 3.1)
project(NHEKO_DEPS)
# Point CMake at any custom modules we may ship
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(DEPS_INSTALL_DIR "${CMAKE_BINARY_DIR}/usr"
CACHE PATH "Dependencies install directory.")
set(DEPS_BIN_DIR "${DEPS_INSTALL_DIR}/bin"
CACHE PATH "Dependencies binary install directory.")
set(DEPS_LIB_DIR "${DEPS_INSTALL_DIR}/lib"
CACHE PATH "Dependencies library install directory.")
set(DEPS_BUILD_DIR "${CMAKE_BINARY_DIR}/build"
CACHE PATH "Dependencies build directory.")
set(DEPS_DOWNLOAD_DIR "${DEPS_BUILD_DIR}/downloads"
CACHE PATH "Dependencies download directory.")
option(USE_BUNDLED "Use bundled dependencies." ON)
option(USE_BUNDLED_BOOST "Use the bundled version of Boost." ${USE_BUNDLED})
option(USE_BUNDLED_SPDLOG "Use the bundled version of spdlog." ${USE_BUNDLED})
option(USE_BUNDLED_OLM "Use the bundled version of libolm." ${USE_BUNDLED})
option(USE_BUNDLED_MATRIX_STRUCTS "Use the bundled version of matrix-structs."
${USE_BUNDLED})
option(USE_BUNDLED_MATRIX_CLIENT "Use the bundled version of mtxclient."
${USE_BUNDLED})
include(ExternalProject)
set(BOOST_URL
https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.tar.bz2)
set(BOOST_SHA256
5721818253e6a0989583192f96782c4a98eb6204965316df9f5ad75819225ca9)
set(MATRIX_STRUCTS_URL https://github.com/mujx/matrix-structs)
set(MATRIX_STRUCTS_TAG eeb7373729a1618e2b3838407863342b88b8a0de)
set(MTXCLIENT_URL https://github.com/mujx/mtxclient)
set(MTXCLIENT_TAG 219d2a8887376122e76ba0f64c0cc9935f62f308)
set(OLM_URL https://git.matrix.org/git/olm.git)
set(OLM_TAG 4065c8e11a33ba41133a086ed3de4da94dcb6bae)
set(SPDLOG_URL https://github.com/gabime/spdlog)
set(SPDLOG_TAG 560df2878ad308b27873b3cc5e810635d69cfad6)
if(USE_BUNDLED_BOOST)
include(Boost)
endif()
if(USE_BUNDLED_SPDLOG)
include(SpdLog)
endif()
if(USE_BUNDLED_OLM)
include(Olm)
endif()
if(USE_BUNDLED_MATRIX_STRUCTS)
include(MatrixStructs)
endif()
if(WIN32)
if("${TARGET_ARCH}" STREQUAL "X86_64")
set(TARGET_ARCH x64)
elseif(TARGET_ARCH STREQUAL "X86")
set(TARGET_ARCH ia32)
endif()
endif()
add_custom_target(third-party ALL
COMMAND ${CMAKE_COMMAND} -E touch .third-party
DEPENDS ${THIRD_PARTY_DEPS})
if(USE_BUNDLED_MATRIX_CLIENT)
include(MatrixClient)
add_dependencies(MatrixClient third-party)
endif()

@ -0,0 +1,23 @@
if(WIN32)
message(STATUS "Building Boost in Windows is not supported (skipping)")
return()
endif()
ExternalProject_Add(
Boost
URL ${BOOST_URL}
URL_HASH SHA256=${BOOST_SHA256}
DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/boost
DOWNLOAD_NO_PROGRESS 0
BUILD_IN_SOURCE 1
SOURCE_DIR ${DEPS_BUILD_DIR}/boost
CONFIGURE_COMMAND ${DEPS_BUILD_DIR}/boost/bootstrap.sh
--with-libraries=random,thread,system,iostreams,atomic,chrono,date_time,regex
--prefix=${DEPS_INSTALL_DIR}
BUILD_COMMAND ${DEPS_BUILD_DIR}/boost/b2 -d0 variant=release link=static threading=multi --layout=system
INSTALL_COMMAND ${DEPS_BUILD_DIR}/boost/b2 -d0 install
)
list(APPEND THIRD_PARTY_DEPS Boost)

@ -0,0 +1,30 @@
set(PLATFORM_FLAGS "")
if(MSVC)
set(PLATFORM_FLAGS "-DCMAKE_GENERATOR_PLATFORM=x64")
endif()
if(APPLE)
set(PLATFORM_FLAGS "-DOPENSSL_ROOT_DIR=/usr/local/opt/openssl")
endif()
ExternalProject_Add(
MatrixClient
DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/mtxclient
GIT_REPOSITORY ${MTXCLIENT_URL}
GIT_TAG ${MTXCLIENT_TAG}
BUILD_IN_SOURCE 1
SOURCE_DIR ${DEPS_BUILD_DIR}/mtxclient
CONFIGURE_COMMAND ${CMAKE_COMMAND}
-DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR}
-DCMAKE_BUILD_TYPE=Release
-DBUILD_LIB_TESTS=OFF
-DBUILD_LIB_EXAMPLES=OFF
${PLATFORM_FLAGS}
${DEPS_BUILD_DIR}/mtxclient
BUILD_COMMAND
${CMAKE_COMMAND} --build ${DEPS_BUILD_DIR}/mtxclient --config Release)
list(APPEND THIRD_PARTY_DEPS MatrixClient)

@ -0,0 +1,25 @@
set(WINDOWS_FLAGS "")
if(MSVC)
set(WINDOWS_FLAGS "-DCMAKE_GENERATOR_PLATFORM=x64")
endif()
ExternalProject_Add(
MatrixStructs
DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/matrix_structs
GIT_REPOSITORY ${MATRIX_STRUCTS_URL}
GIT_TAG ${MATRIX_STRUCTS_TAG}
BUILD_IN_SOURCE 1
SOURCE_DIR ${DEPS_BUILD_DIR}/matrix_structs
CONFIGURE_COMMAND ${CMAKE_COMMAND}
-DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR}
-DCMAKE_BUILD_TYPE=Release
${DEPS_BUILD_DIR}/matrix_structs
${WINDOWS_FLAGS}
BUILD_COMMAND ${CMAKE_COMMAND}
--build ${DEPS_BUILD_DIR}/matrix_structs
--config Release)
list(APPEND THIRD_PARTY_DEPS MatrixStructs)

@ -0,0 +1,24 @@
if(MSVC)
set(MAKE_CMD "mingw32-make.exe")
else()
set(MAKE_CMD "make")
endif()
set(OLM_NAME "${CMAKE_STATIC_LIBRARY_PREFIX}olm${CMAKE_STATIC_LIBRARY_SUFFIX}")
ExternalProject_Add(
Olm
GIT_REPOSITORY ${OLM_URL}
GIT_TAG ${OLM_TAG}
BUILD_IN_SOURCE 1
SOURCE_DIR ${DEPS_BUILD_DIR}/olm
CONFIGURE_COMMAND ""
BUILD_COMMAND ${MAKE_CMD} static
INSTALL_COMMAND
cp -R ${DEPS_BUILD_DIR}/olm/include ${DEPS_INSTALL_DIR} &&
cp ${DEPS_BUILD_DIR}/olm/build/libolm.a ${DEPS_INSTALL_DIR}/lib
)
list(APPEND THIRD_PARTY_DEPS Olm)

@ -0,0 +1,15 @@
ExternalProject_Add(
SpdLog
GIT_REPOSITORY ${SPDLOG_URL}
GIT_TAG ${SPDLOG_TAG}
BUILD_IN_SOURCE 1
SOURCE_DIR ${DEPS_BUILD_DIR}/spdlog
CONFIGURE_COMMAND ${CMAKE_COMMAND}
-DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR}
-DCMAKE_BUILD_TYPE=Release
${DEPS_BUILD_DIR}/spdlog
)
list(APPEND THIRD_PARTY_DEPS SpdLog)

@ -32,6 +32,7 @@
#include <mtx/errors.hpp>
#include "MatrixClient.h"
#include <mtxclient/http/client.hpp>
namespace {
std::unique_ptr<MatrixClient> instance_ = nullptr;
@ -39,6 +40,8 @@ std::unique_ptr<MatrixClient> instance_ = nullptr;
namespace http {
std::shared_ptr<mtx::http::Client> client_ = nullptr;
void
init()
{

Loading…
Cancel
Save