CPGen
C++ project generator
Loading...
Searching...
No Matches
CMakeEmitter.hpp
Go to the documentation of this file.
1#pragma once
2
13#include "CPGen/Core/Config.hpp"
14#include "CPGen/Core/Module.hpp"
16
17#include <string>
18#include <vector>
19
37class CMakeEmitter : public Emitter {
38public:
39 [[nodiscard]] std::vector<OutputFile>
40 emit(const ResolvedProject &project) override;
41
42private:
45 [[nodiscard]] static std::string minimumRequired(float version);
46 [[nodiscard]] static std::string projectHeader(const std::string &name);
47 [[nodiscard]] static std::string cxxStandard(CppStandard standard);
48 [[nodiscard]] static std::string fetchContentInclude();
49 [[nodiscard]] static std::string declareModule(const FetchContent &fc);
50 [[nodiscard]] static std::string
51 makeAvailable(const std::vector<std::string> &modules);
52 [[nodiscard]] static std::string compileOptions();
53 [[nodiscard]] static std::string clangTidyBlock();
54 [[nodiscard]] static std::string
55 targetDeclaration(TargetType type, const std::string &target_name,
56 const std::vector<std::string> &sources);
57 [[nodiscard]] static std::string
58 includeDirectories(const std::string &target_name);
59 [[nodiscard]] static std::string
60 targetLink(const std::string &target_name,
61 const std::vector<std::string> &libs);
62 [[nodiscard]] static std::string enableTesting();
63 [[nodiscard]] static std::string
64 cppStandardString(CppStandard standard) noexcept;
66
72 [[nodiscard]] static std::string assemble(const ResolvedProject &project);
73
81 [[nodiscard]] static std::string
82 applyInjections(const std::vector<TargetInjection> &injections,
83 const std::string &target_name,
84 const std::string &cmake_name);
85
92 [[nodiscard]] static std::string
93 cmakeTargetName(const ResolvedTarget &target,
94 const std::string &project_name);
95
101 [[nodiscard]] static std::vector<std::string>
102 conventionalSources(const ResolvedTarget &target);
103};
Project configuration types produced by the CLI and consumed by the resolvers.
CppStandard
Selects the C++ language standard to pass to the compiler.
Definition Config.hpp:29
TargetType
Describes the CMake target kind to generate for a build target.
Definition Config.hpp:19
Base interface for all pipeline emitters.
Defines the FetchContent descriptor used by module definitions.
Generates a fully assembled CMakeLists.txt from a ResolvedProject.
Definition CMakeEmitter.hpp:37
std::vector< OutputFile > emit(const ResolvedProject &project) override
Produce output files from a resolved project.
Definition CMakeEmitter.cpp:18
Abstract base class for pipeline emitters.
Definition Emitter.hpp:35
Describes a CMake FetchContent dependency to be downloaded at build time.
Definition Module.hpp:20
Aggregated output of the full resolver pipeline.
Definition Resolved.hpp:105
A build target after module injections have been applied.
Definition Resolved.hpp:64