Commit dbd49335066bae6984df76fd0b31302fe5cb8239

Authored by Daniel Mensinger
Committed by Henry Schreiner
1 parent f583e5ba

meson: Basic meson support (#299)

* meson: Basic meson support

With this patch, CLI11 can be used as a meson
subproject: http://mesonbuild.com/Subprojects.html

However, CMake is still required for testing and
installation. The current meson.build is not a
complete replacement.

* meson: Added meson test

* Adding Azure test
.gitignore
@@ -5,3 +5,5 @@ a.out* @@ -5,3 +5,5 @@ a.out*
5 /Makefile 5 /Makefile
6 /CMakeFiles/* 6 /CMakeFiles/*
7 /cmake_install.cmake 7 /cmake_install.cmake
  8 +/*.kdev4
  9 +!/meson.build
azure-pipelines.yml
@@ -48,6 +48,22 @@ jobs: @@ -48,6 +48,22 @@ jobs:
48 - template: .ci/azure-build.yml 48 - template: .ci/azure-build.yml
49 - template: .ci/azure-test.yml 49 - template: .ci/azure-test.yml
50 50
  51 +- job: Meson
  52 + pool:
  53 + vmImage: 'ubuntu-latest'
  54 + steps:
  55 + - task: UsePythonVersion@0
  56 + inputs:
  57 + versionSpec: '3.6'
  58 + - script: python3 -m pip install meson ninja
  59 + - script: meson build
  60 + displayName: Run meson to generate build
  61 + workingDirectory: tests/mesonTest
  62 + - script: ninja -C tests/mesonTest/build
  63 + displayName: Build with Ninja
  64 + - script: ./tests/mesonTest/build/main --help
  65 + displayName: Run help
  66 +
51 - job: Docker 67 - job: Docker
52 variables: 68 variables:
53 cli11.single: OFF 69 cli11.single: OFF
meson.build 0 → 100644
  1 +project('CLI11', ['cpp'],
  2 + version : run_command(find_program('scripts/ExtractVersion.py')).stdout().strip(),
  3 + default_options : ['cpp_std=c++11']
  4 +)
  5 +
  6 +CLI11_inc = include_directories(['include'])
  7 +
  8 +CLI11_dep = declare_dependency(
  9 + include_directories : CLI11_inc,
  10 + version : meson.project_version(),
  11 +)
scripts/ExtractVersion.py 0 → 100755
  1 +#!/usr/bin/env python3
  2 +
  3 +import os
  4 +import re
  5 +
  6 +base_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
  7 +config_h = os.path.join(base_path, 'include', 'CLI', 'Version.hpp')
  8 +data = {'MAJOR': 0, 'MINOR': 0, 'PATCH': 0}
  9 +reg = re.compile(r'^\s*#define\s+CLI11_VERSION_([A-Z]+)\s+([0-9]+).*$')
  10 +
  11 +with open(config_h, 'r') as fp:
  12 + for l in fp:
  13 + m = reg.match(l)
  14 + if m:
  15 + data[m.group(1)] = int(m.group(2))
  16 +
  17 +print('{}.{}.{}'.format(data['MAJOR'], data['MINOR'], data['PATCH']))
tests/mesonTest/README.md 0 → 100644
  1 +# CLI11 Meson test / example
  2 +
  3 +Requirements: meson, ninja
  4 +
  5 +## Build
  6 +
  7 +```bash
  8 +meson build
  9 +ninja -C build
  10 +```
tests/mesonTest/main.cpp 0 → 100644
  1 +#include <CLI/CLI.hpp>
  2 +
  3 +int main(int argc, char **argv) {
  4 + CLI::App app{"App description"};
  5 +
  6 + std::string filename = "default";
  7 + app.add_option("-f,--file", filename, "A help string");
  8 +
  9 + CLI11_PARSE(app, argc, argv);
  10 + return 0;
  11 +}
tests/mesonTest/meson.build 0 → 100644
  1 +project('mesonTest', ['c', 'cpp'], default_options: ['cpp_std=c++11'])
  2 +
  3 +cli11_dep = subproject('CLI11').get_variable('CLI11_dep')
  4 +
  5 +mainExe = executable('main', ['main.cpp'], dependencies: [cli11_dep])
tests/mesonTest/subprojects/CLI11 0 → 120000
  1 +../../..
0 \ No newline at end of file 2 \ No newline at end of file