You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cmkr/include/cmake.hpp

130 lines
3.3 KiB

4 years ago
#pragma once
#include <map>
#include <mpark/variant.hpp>
#include <stdexcept>
4 years ago
#include <string>
#include <tsl/ordered_map.h>
#include <vector>
4 years ago
4 years ago
namespace cmkr {
namespace cmake {
4 years ago
4 years ago
struct Setting {
std::string name;
std::string comment;
mpark::variant<bool, std::string> val;
4 years ago
bool cache = false;
bool force = false;
};
struct Option {
std::string name;
std::string comment;
bool val = false;
};
struct Package {
std::string name;
std::string version;
bool required = true;
bool config = true;
std::vector<std::string> components;
};
struct Vcpkg {
4 years ago
std::string url;
std::vector<std::string> packages;
};
enum TargetType {
target_executable,
target_library,
target_shared,
target_static,
target_interface,
target_custom,
};
template <typename T>
using Condition = tsl::ordered_map<std::string, T>;
using ConditionVector = Condition<std::vector<std::string>>;
struct Target {
4 years ago
std::string name;
TargetType type = {};
// https://cmake.org/cmake/help/latest/manual/cmake-commands.7.html#project-commands
ConditionVector compile_definitions;
ConditionVector compile_features;
ConditionVector compile_options;
ConditionVector include_directories;
ConditionVector link_directories;
ConditionVector link_libraries;
ConditionVector link_options;
ConditionVector precompile_headers;
ConditionVector headers;
ConditionVector sources;
std::string alias;
tsl::ordered_map<std::string, std::string> properties;
Condition<std::string> cmake_before;
Condition<std::string> cmake_after;
ConditionVector include_before;
ConditionVector include_after;
4 years ago
};
4 years ago
struct Test {
std::string name;
std::vector<std::string> configurations;
std::string working_directory;
std::string command;
std::vector<std::string> arguments;
4 years ago
};
4 years ago
struct Install {
std::vector<std::string> targets;
std::vector<std::string> files;
std::vector<std::string> dirs;
std::vector<std::string> configs;
std::string destination;
};
4 years ago
struct CMake {
// This is the CMake version required to use all cmkr versions.
std::string cmake_version = "3.15";
std::string cmkr_include = "cmkr.cmake";
std::string build_dir = "build";
4 years ago
std::string generator;
4 years ago
std::string config;
Condition<std::vector<std::string>> subdirs;
4 years ago
std::vector<std::string> cppflags;
std::vector<std::string> cflags;
std::vector<std::string> linkflags;
std::vector<std::string> gen_args;
std::vector<std::string> build_args;
std::string project_name;
std::string project_version;
std::string project_description;
std::vector<std::string> project_languages;
Condition<std::string> cmake_before;
Condition<std::string> cmake_after;
ConditionVector include_before;
ConditionVector include_after;
4 years ago
std::vector<Setting> settings;
std::vector<Option> options;
std::vector<Package> packages;
Vcpkg vcpkg;
tsl::ordered_map<std::string, std::map<std::string, std::string>> contents;
std::vector<Target> targets;
4 years ago
std::vector<Test> tests;
4 years ago
std::vector<Install> installs;
tsl::ordered_map<std::string, std::string> conditions;
4 years ago
CMake(const std::string &path, bool build);
};
4 years ago
} // namespace cmake
} // namespace cmkr