diff --git a/.ci/install.sh b/.ci/install.sh index ed25fcf2..6019e0a2 100755 --- a/.ci/install.sh +++ b/.ci/install.sh @@ -4,7 +4,7 @@ set -ex if [ $TRAVIS_OS_NAME == osx ]; then brew update - brew install qt5 lmdb clang-format ninja libsodium + brew install qt5 lmdb clang-format ninja libsodium cmark brew upgrade boost cmake curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py diff --git a/.ci/script.sh b/.ci/script.sh index 69433dba..622bda9b 100755 --- a/.ci/script.sh +++ b/.ci/script.sh @@ -22,7 +22,9 @@ if [ $TRAVIS_OS_NAME == osx ]; then fi # Build & install dependencies -cmake -GNinja -Hdeps -B.deps -DUSE_BUNDLED_BOOST=${USE_BUNDLED_BOOST} +cmake -GNinja -Hdeps -B.deps \ + -DUSE_BUNDLED_BOOST=${USE_BUNDLED_BOOST} \ + -DUSE_BUNDLED_CMARK=${USE_BUNDLED_CMARK} cmake --build .deps # Build nheko diff --git a/.travis.yml b/.travis.yml index e6c6d443..bd165f88 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,7 @@ matrix: env: - DEPLOYMENT=1 - USE_BUNDLED_BOOST=0 + - USE_BUNDLED_CMARK=0 - os: linux compiler: gcc env: @@ -24,6 +25,7 @@ matrix: - QT_PKG=510 - DEPLOYMENT=1 - USE_BUNDLED_BOOST=1 + - USE_BUNDLED_CMARK=1 addons: apt: sources: ["ubuntu-toolchain-r-test"] @@ -36,6 +38,7 @@ matrix: - QT_VERSION="-5.10.1" - QT_PKG=510 - USE_BUNDLED_BOOST=1 + - USE_BUNDLED_CMARK=1 addons: apt: sources: ["ubuntu-toolchain-r-test"] @@ -48,6 +51,7 @@ matrix: - QT_VERSION=571 - QT_PKG=57 - USE_BUNDLED_BOOST=1 + - USE_BUNDLED_CMARK=1 addons: apt: sources: ["ubuntu-toolchain-r-test"] @@ -60,6 +64,7 @@ matrix: - QT_VERSION=592 - QT_PKG=59 - USE_BUNDLED_BOOST=1 + - USE_BUNDLED_CMARK=1 addons: apt: sources: ["ubuntu-toolchain-r-test", "llvm-toolchain-trusty-5.0"] diff --git a/README.md b/README.md index 681d8d29..d9d0ca49 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,7 @@ sudo port install nheko - CMake 3.1 or greater. - [mtxclient](https://github.com/mujx/mtxclient) - [LMDB](https://symas.com/lightning-memory-mapped-database/) +- [cmark](https://github.com/commonmark/cmark) - Boost 1.66 or greater. - [libolm](https://git.matrix.org/git/olm) - [libsodium](https://github.com/jedisct1/libsodium) @@ -115,6 +116,7 @@ sudo pacman -S qt5-base \ gcc \ fontconfig \ lmdb \ + cmark \ boost \ libsodium ``` @@ -139,7 +141,7 @@ sudo apt-get install -y g++-7 qt59base qt59svg qt59tools qt59multimedia cmake li ```bash brew update -brew install qt5 lmdb cmake llvm libsodium spdlog boost +brew install qt5 lmdb cmake llvm libsodium spdlog boost cmark ``` ##### Windows @@ -166,6 +168,7 @@ cd vcpkg boost-signals2 \ boost-system \ boost-thread \ + cmark \ libsodium \ lmdb \ openssl \ diff --git a/appveyor.yml b/appveyor.yml index aaaf280d..95c862d0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -64,6 +64,8 @@ build_script: -DCMAKE_TOOLCHAIN_FILE=C:/Tools/vcpkg/scripts/buildsystems/vcpkg.cmake -DLMDBXX_INCLUDE_DIR=.deps/usr/include -DTWEENY_INCLUDE_DIR=.deps/usr/include + -DCMARK_INCLUDE_DIR=.deps/usr/include + -DCMARK_LIBRARY=.deps/usr/lib/cmark_static.lib - cmake --build build --config Release after_build: diff --git a/cmake/Findcmark.cmake b/cmake/Findcmark.cmake index fd7d062a..29092bb0 100644 --- a/cmake/Findcmark.cmake +++ b/cmake/Findcmark.cmake @@ -2,23 +2,25 @@ # CMake module to search for the cmark library # -find_path(CMARK_INCLUDE_DIR - NAMES cmark.h - PATHS /usr/include - /usr/local/include - $ENV{LIB_DIR}/include - $ENV{LIB_DIR}/include/cmark) +include(FindPkgConfig) +pkg_check_modules(PC_CMARK QUIET cmark) -find_library(CMARK_LIBRARY - NAMES cmark - PATHS /usr/lib /usr/local/lib $ENV{LIB_DIR}/lib) - -if(OLM_FOUND) - set(OLM_INCLUDE_DIRS ${CMARK_INCLUDE_DIR}) +if(NOT CMARK_INCLUDE_DIR) + find_path(CMARK_INCLUDE_DIR + NAMES cmark.h + PATHS ${PC_CMARK_INCLUDEDIR} + ${PC_CMARK_INCLUDE_DIRS} + /usr/include + /usr/local/include) +endif() - if(NOT OLM_LIBRARIES) - set(OLM_LIBRARIES ${CMARK_LIBRARY}) - endif() +if(NOT CMARK_LIBRARY) + find_library(CMARK_LIBRARY + NAMES cmark + HINTS ${PC_CMARK_LIBDIR} + ${PC_CMARK_LIBRARY_DIRS} + /usr/lib + /usr/local/lib) endif() if(NOT TARGET cmark::cmark) @@ -37,3 +39,6 @@ find_package_handle_standard_args(cmark CMARK_LIBRARY) mark_as_advanced(CMARK_LIBRARY CMARK_INCLUDE_DIR) + +set(CMARK_LIBRARIES ${CMARK_LIBRARY}) +set(CMARK_INCLUDE_DIRS ${CMARK_INCLUDE_DIR}) diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index 5df60d27..25b1b89d 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -22,6 +22,7 @@ set(DEPS_DOWNLOAD_DIR "${DEPS_BUILD_DIR}/downloads" option(USE_BUNDLED "Use bundled dependencies." ON) option(USE_BUNDLED_BOOST "Use the bundled version of Boost." ${USE_BUNDLED}) +option(USE_BUNDLED_CMARK "Use the bundled version of cmark." ${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_TWEENY "Use the bundled version of Tweeny." ${USE_BUNDLED}) @@ -38,10 +39,10 @@ set(BOOST_SHA256 set( MTXCLIENT_URL - https://github.com/mujx/mtxclient/archive/659bfe7cd9b87bb009ebc703398fd93dc098b0f0.tar.gz + https://github.com/mujx/mtxclient/archive/1a539721ec86cb8b5f9d0b51cbe2251e46257a9b.tar.gz ) set(MTXCLIENT_HASH - d6794940354fd6e163ca52cab7878bba3c71ebfe3ca9a51ada5485a09c0d27f8) + 7c458f57f774c75afaf403869e57a753620b5b619b1a7cd0b63bbc4735fc8993) set( TWEENY_URL @@ -60,6 +61,9 @@ set(LMDBXX_HASH set(OLM_URL https://git.matrix.org/git/olm.git) set(OLM_TAG 4065c8e11a33ba41133a086ed3de4da94dcb6bae) +set(CMARK_URL https://github.com/commonmark/cmark/archive/0.28.3.tar.gz) +set(CMARK_HASH acc98685d3c1b515ff787ac7c994188dadaf28a2d700c10c1221da4199bae1fc) + set(SPDLOG_URL https://github.com/gabime/spdlog/archive/v1.1.0.tar.gz) set(SPDLOG_HASH 3dbcbfd8c07e25f5e0d662b194d3a7772ef214358c49ada23c044c4747ce8b19) @@ -84,6 +88,10 @@ if(USE_BUNDLED_OLM) include(Olm) endif() +if(USE_BUNDLED_CMARK) + include(cmark) +endif() + if(USE_BUNDLED_TWEENY) include(Tweeny) endif() diff --git a/deps/cmake/cmark.cmake b/deps/cmake/cmark.cmake new file mode 100644 index 00000000..e0d45e88 --- /dev/null +++ b/deps/cmake/cmark.cmake @@ -0,0 +1,21 @@ +set(WINDOWS_FLAGS "") + +if(MSVC) + set(WINDOWS_FLAGS "-DCMAKE_GENERATOR_PLATFORM=x64") +endif() + +ExternalProject_Add( + cmark + + URL ${CMARK_URL} + URL_HASH SHA256=${CMARK_HASH} + + BUILD_IN_SOURCE 0 + SOURCE_DIR ${DEPS_BUILD_DIR}/cmark + CONFIGURE_COMMAND ${CMAKE_COMMAND} + -DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR} + -DCMARK_TESTS=OFF + ${DEPS_BUILD_DIR}/cmark + ${WINDOWS_FLAGS}) + +list(APPEND THIRD_PARTY_DEPS cmark)