#[[
// Copyright 2021 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
]]

if (NOT __MOSQUITTO_INCLUDED)
  set(__MOSQUITTO_INCLUDED TRUE)

  ExternalProject_Add(
    ext_mosquitto
    PREFIX ${PROJECT_BINARY_DIR}/mosquitto
    DOWNLOAD_DIR ${PROJECT_BINARY_DIR}/download
    DOWNLOAD_NAME mosquitto_v2.0.12.tar.gz
    URL https://github.com/eclipse/mosquitto/archive/v2.0.12.tar.gz
    URL_HASH SHA256=b4995d1505f5643d98ff9a921e0399437fc95c4f0c92693cfe28401baf1fed21
    BUILD_IN_SOURCE TRUE
    CMAKE_ARGS
    -DWITH_CJSON:STRING=OFF
    -DWITH_TLS:STRING=OFF
    -DWITH_STATIC_LIBRARIES:STRING=ON
    -DWITH_THREADING:STRING=ON
    -DWITH_CLIENTS:STRING=OFF
    -DWITH_BROKER:STRING=OFF
    -DWITH_APPS:STRING=OFF
    -DWITH_PLUGINS:STRING=OFF
    -DDOCUMENTATION:STRING=OFF
    -DCMAKE_INSTALL_PREFIX:STRING=${CMAKE_INSTALL_PREFIX}
    -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
    -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
    # for debug
    # LOG_DOWNLOAD 1
    # LOG_CONFIGURE 1
    # LOG_INSTALL 1
  )

endif()
