summaryrefslogtreecommitdiff
path: root/libcppbuild.h
blob: 2aba9872de66d9ea808ec99d1edf3759c30500c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// -*- c++ -*-
#pragma once

#include <string>
#include <vector>
//#include <source_location>

enum class TargetType
{
	Auto, // Default - deduce from target name
	Executable,
	StaticLibrary,
	DynamicLibrary,
};

struct BuildConfiguration
{
	TargetType type{TargetType::Auto};
	std::string target;
	std::vector<std::string> sources;
	std::vector<std::string> depends;
	std::vector<std::string> cxxflags;
	std::vector<std::string> cflags;
	std::vector<std::string> ldflags;
};

using BuildConfigurations = std::vector<BuildConfiguration>;

int reg(const char* location, BuildConfigurations (*cb)());

// Convenience macro - ugly but keeps things simple(r)
#define CONCAT(a, b) CONCAT_INNER(a, b)
#define CONCAT_INNER(a, b) a ## b
#define UNIQUE_NAME(base) CONCAT(base, __LINE__)
#define REG(cb) namespace { int UNIQUE_NAME(unique) = reg(__FILE__, cb); }