distributable:
  url: https://github.com/gabime/spdlog/archive/v{{version}}.tar.gz
  strip-components: 1

versions:
  github: gabime/spdlog

dependencies:
  fmt.dev: ^10

build:
  dependencies:
    cmake.org: ^3
  working-directory: build
  script:
    - 'sed -i.bak "s|// #define SPDLOG_FMT_EXTERNAL|#define SPDLOG_FMT_EXTERNAL|" ../include/spdlog/tweakme.h'

    - cmake ..
      -DSPDLOG_BUILD_BENCH=OFF
      -DSPDLOG_BUILD_TESTS=OFF
      -DSPDLOG_FMT_EXTERNAL=ON
      -DSPDLOG_BUILD_SHARED=ON
      -DCMAKE_INSTALL_PREFIX={{prefix}}
      -DCMAKE_BUILD_TYPE=Release

    - make --jobs {{ hw.concurrency }} install

test:
  fixture: |
    #include "spdlog/sinks/basic_file_sink.h"
    #include <iostream>
    #include <memory>
    int main()
    {
      try {
        auto console = spdlog::basic_logger_mt("basic_logger", "basic-log.txt");
        console->info("Test");
      }
      catch (const spdlog::spdlog_ex &ex)
      {
        std::cout << "Log init failed: " << ex.what() << std::endl;
        return 1;
      }
    }
  script: |
    mv $FIXTURE b.cpp
    c++ -std=c++11 b.cpp -lfmt
    ./a.out
    cat basic-log.txt | grep Test
