siplasplas
A library for C++ reflection and introspection
cpp::CMakeTarget::Metadata Struct Reference

Represents the set of properties that define a target. More...

#include <siplasplas/cmake/target.hpp>

Static Public Member Functions

static Metadata loadFromFile (const CMakeProject &project, const std::string &targetName)
 Loads target properties from a JSON file. More...
 

Public Attributes

std::string name
 
std::string sourceDir
 
std::string binaryDir
 
std::vector< std::string > sources
 
std::vector< std::string > includeDirs
 
std::string binary
 
std::string binaryDebug
 
std::string binaryRelease
 

Detailed Description

Represents the set of properties that define a target.

This structure is just an aggregation of the set of target properties CMakeTarget needs to work. Currently those are:

Todo:
Rename to "Properties".
  • name: Name of the target.
  • sourceDir: Relative path to the target sources subtree.
  • binaryDir: Relative path to the target binary subtree.
  • sources: List of target sources.
  • includeDirs: List of target include directories.
  • binary: Absolute path to the target output binary.

Member Function Documentation

static Metadata cpp::CMakeTarget::Metadata::loadFromFile ( const CMakeProject project,
const std::string &  targetName 
)
static

Loads target properties from a JSON file.

Todo:

remove when merging fixing-windows-support

Throw an exception instead of UB?

This function reads target properties from a JSON file named "<\p targetName>.json" located at the root of the project binary directory. The JSON file has a dictionary mapping from the name of the different target properties (NAME, SOURCES, INCLUDE_DIRECTORIES, LOCATION) to their values. See export_target.cmake.

Passing a target name that doesn't exist in the CMake project has undefined behavior.

Todo:
Document export_target.cmake and the JSON file format.
Parameters
projectReference to the CMakeProject the target belongs to.
targetNameName of the target to load.
Returns
An instance of CMakeTarget::Metadata with the read properties.

Member Data Documentation

std::string cpp::CMakeTarget::Metadata::binaryRelease
Todo:
remove when merging fixing-windows-support

The documentation for this struct was generated from the following file: