cmake_minimum_required(VERSION 3.2)

# qc settings
include(ExternalProject)

set(QC_PROJECT_NAME qc)
set(QC_GIT_REPOSITORY https://github.com/rxnew/qc.git)
set(QC_GIT_TAG develop)

set(EXTERNAL_PROJECTS_INCLUDE_PATHS
    ${GRAPH_INCLUDE_PATH}
    ${JSON11_INCLUDE_PATH})

set(EXTERNAL_PROJECTS_LIBRARIES
    ${JSON11_LIBRARY})

ExternalProject_Add(
  ${QC_PROJECT_NAME}
  GIT_REPOSITORY ${QC_GIT_REPOSITORY}
  GIT_TAG ${QC_GIT_TAG}
  PREFIX ${CMAKE_CURRENT_BINARY_DIR}/projects/${QC_PROJECT_NAME}
  CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${INSTALL_EXTERNAL_PROJECTS_PREFIX}
             -DEXTERNAL_PROJECTS_INCLUDE_PATHS=${EXTERNAL_PROJECTS_INCLUDE_PATHS}
             -DEXTERNAL_PROJECTS_LIBRARIES=${EXTERNAL_PROJECTS_LIBRARIES}
             -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
  LOG_DOWNLOAD on
  )

set(QC_INCLUDE_PATH ${INSTALL_EXTERNAL_PROJECTS_PREFIX}/include)
set(QC_LIBRARY ${INSTALL_EXTERNAL_PROJECTS_PREFIX}/lib/libqc.a)

if(BUILD_EXTERNAL_PROJECT_NAMES)
  add_dependencies(${QC_PROJECT_NAME} ${BUILD_EXTERNAL_PROJECT_NAMES})
endif()

set(BUILD_EXTERNAL_PROJECT_NAMES ${BUILD_EXTERNAL_PROJECT_NAMES}
    ${QC_PROJECT_NAME})
