# Copyright 2018 Julian Ospald <hasufell@posteo.de>
# Distributed under the terms of the GNU General Public License v2

# TODO: no release tag yet, but older releases are not cmake compatible
SCM_REPOSITORY="https://github.com/cquery-project/cquery.git"
SCM_REVISION="6aa854dbe21d0bf871c452040a45a5c24dd385e3"

SCM_SECONDARY_REPOSITORIES="
    doctest
    loguru
    msgpack_c
    pugixml
    rapidjson
    sparsepp
    predef
    preprocessor
    gtest
"

SCM_EXTERNAL_REFS="
    third_party/doctest:doctest
    third_party/loguru:loguru
    third_party/msgpack-c:msgpack_c
    third_party/pugixml:pugixml
    third_party/rapidjson:rapidjson
    third_party/sparsepp:sparsepp
"

SCM_doctest_REPOSITORY="https://github.com/onqtam/doctest.git"
SCM_loguru_REPOSITORY="https://github.com/emilk/loguru.git"
SCM_msgpack_c_REPOSITORY="https://github.com/msgpack/msgpack-c.git"
SCM_pugixml_REPOSITORY="https://github.com/zeux/pugixml.git"
SCM_rapidjson_REPOSITORY="https://github.com/Tencent/rapidjson.git"
SCM_sparsepp_REPOSITORY="https://github.com/greg7mdp/sparsepp.git"
SCM_predef_REPOSITORY="https://github.com/boostorg/predef.git"
SCM_preprocessor_REPOSITORY="https://github.com/boostorg/preprocessor.git"
SCM_gtest_REPOSITORY="https://github.com/google/googletest.git"

SCM_msgpack_c_EXTERNAL_REFS="
    external/boost/predef:predef
    external/boost/preprocessor:preprocessor
"

SCM_rapidjson_EXTERNAL_REFS="
    thirdparty/gtest:gtest
"

require scm-git
require cmake [ api=2 ]

CLANG_VERSION="6.0.0"
CLANG_TARBALL_NAME="clang+llvm-${CLANG_VERSION}-x86_64-linux-gnu-ubuntu-14.04"


SUMMARY="C/C++ language server supporting multi-million line code base"
HOMEPAGE="https://github.com/cquery-project/cquery"
DOWNLOADS="
    !system-clang? (
        platform:amd64? ( https://releases.llvm.org/${CLANG_VERSION}/${CLANG_TARBALL_NAME}.tar.xz )
    )
"

LICENCES="MIT"
SLOT="0"
PLATFORMS="~amd64"
MYOPTIONS="
    system-clang [[ description = [ Use system clang, NOT RECOMMENDED! ] ]]
    platform: amd64
"

DEPENDENCIES="
    build+run:
        dev-libs/ncurses-libtinfo
        sys-libs/zlib
        system-clang? ( dev-lang/clang[>=6.0.0] )
"

BUGS_TO="hasufell@posteo.de"

REMOTE_IDS="github:cquery-project/cquery"
UPSTREAM_DOCUMENTATION="https://github.com/cquery-project/cquery/wiki"

CMAKE_SRC_CONFIGURE_PARAMS=(
    -DCLANG_DOWNLOAD_LOCATION="${WORKBASE}"
)

CMAKE_SRC_CONFIGURE_OPTIONS=(
    'system-clang SYSTEM_CLANG'
)