cross-platform-generator
Public Types | Public Member Functions | Private Member Functions | Private Attributes
cpg.utils.CMake Class Reference

Utility class for running cmake using the cmake CLI. More...

Public Types

enum  Generators {
  Generators.VS2005, Generators.VS2008, Generators.VS2010, Generators.VS2012,
  Generators.VS2013, Generators.VS2015, Generators.VS2017
}
 The different type of generators supported by cmake. More...
 
enum  Platforms { Platforms.Win32 }
 The different kind of supported platforms. More...
 

Public Member Functions

void RedirectOutput (Action< string, int > callback)
 Redirects the standard output to a custom callback. More...
 
void SetSourceDirectory (string path)
 Sets the location to search for source files. More...
 
void SetOutputDirectory (string path)
 Sets the directory to put the generated files in. More...
 
void SetGenerator (Generators generator)
 Sets what generator to use. More...
 
 CMake (ref ObservableCollection< Variable > variables, ObservableCollection< PostGenerateStep > post_generate_steps)
 Constructor: finds the cmake process and initializes the variables and post generate steps. More...
 
void Generate ()
 Runs cmake. this calls set arguments before running cmake and all arguments from a previous call are cleared. More...
 
void SetPlatform (Platforms platform)
 Sets the platform to generate the project for. More...
 

Private Member Functions

void OnOutputDataRecieved (object sender, DataReceivedEventArgs e)
 calls the callback passed with the RedirectOutput function. More...
 
string GetCMakeArgs ()
 sets the arguments to be used when the processed is started. The arguments passed are read from the variable list passed with the contructor. More...
 
void Log (string text, int verbosity=kVerbosity)
 writes a message using the set output callback More...
 
void Process__Exited (object sender, EventArgs e)
 Callback for when generation is done. More...
 

Private Attributes

const int kVerbosity = 0
 The verbosity used to log all messages.
 
Process process_
 Cmake process used to run cmake commands.
 
Action< string, int > output_callback_
 Callback used to replace the standard output stream.
 
readonly ObservableCollection< Variablevariables_
 Variables to run cmake with.
 
readonly ObservableCollection< PostGenerateSteppost_generate_steps_
 The commands to run after generation was succesfull.
 
string source_directory_
 The directory used to search for source files.
 
string output_directory_
 The directory to put the generated files in.
 
Generators generator_
 The cmake generot used to generate the project.
 
List< string > default_arguments_
 Default arguments that are always used when projects are generated.
 
Platforms platform_
 The platform to generate the project for.
 
string cmake_path_
 The install path of cmake.
 

Detailed Description

Utility class for running cmake using the cmake CLI.

Author
Stan Pepels

Member Enumeration Documentation

◆ Generators

The different type of generators supported by cmake.

Enumerator
VS2005 

generates solution for visual studio 2005

VS2008 

generates solution for visual studio 2008

VS2010 

generates solution for visual studio 2010

VS2012 

generates solution for visual studio 2012

VS2013 

generates solution for visual studio 2013

VS2015 

generates solution for visual studio 2015

VS2017 

generates solution for visual studio 2017

◆ Platforms

The different kind of supported platforms.

Enumerator
Win32 

Windows.

Constructor & Destructor Documentation

◆ CMake()

cpg.utils.CMake.CMake ( ref ObservableCollection< Variable variables,
ObservableCollection< PostGenerateStep post_generate_steps 
)
inline

Constructor: finds the cmake process and initializes the variables and post generate steps.

Parameters
[in]variables(ref ObservableCollection<Variables>) Refrence to a list of variabels to be used when generating a project
[in]post_generate_steps(ObservableCollection<PostGenerateStep>) Refrence to the list of steps to execute after generating a project.
Remarks
This class should not modify the variables directly.

Member Function Documentation

◆ Generate()

void cpg.utils.CMake.Generate ( )
inline

Runs cmake. this calls set arguments before running cmake and all arguments from a previous call are cleared.

See also
CMake.SetArgumets

◆ GetCMakeArgs()

string cpg.utils.CMake.GetCMakeArgs ( )
inlineprivate

sets the arguments to be used when the processed is started. The arguments passed are read from the variable list passed with the contructor.

Returns
(string) List of argumets created from the variable list.
See also
cpg.CMake.variables_

◆ Log()

void cpg.utils.CMake.Log ( string  text,
int  verbosity = kVerbosity 
)
inlineprivate

writes a message using the set output callback

Parameters
[in]text(string) The message to write.
[in]verbosity(int) The vervosity used to write the message
See also
cpg.CMake.kVerbosity

◆ OnOutputDataRecieved()

void cpg.utils.CMake.OnOutputDataRecieved ( object  sender,
DataReceivedEventArgs  e 
)
inlineprivate

calls the callback passed with the RedirectOutput function.

Parameters
[in]sender(object) The sender of the event.
[in]e(DataReceivedEventArgs) The parameters containing data of the event.
See also
CMake.RedirectOutput

◆ Process__Exited()

void cpg.utils.CMake.Process__Exited ( object  sender,
EventArgs  e 
)
inlineprivate

Callback for when generation is done.

Parameters
[in]sender(object) The sender of the event.
[in]e(EventArgs) Arguments send with the event.

◆ RedirectOutput()

void cpg.utils.CMake.RedirectOutput ( Action< string, int >  callback)
inline

Redirects the standard output to a custom callback.

Parameters
[in]callback(Action<string>) Callback used to process the output.

◆ SetGenerator()

void cpg.utils.CMake.SetGenerator ( Generators  generator)
inline

Sets what generator to use.

Parameters
[in]generator(cpg.CMake.Generators) The new generator to use.

◆ SetOutputDirectory()

void cpg.utils.CMake.SetOutputDirectory ( string  path)
inline

Sets the directory to put the generated files in.

Parameters
[in]path(string) absolute path to a location on disk

◆ SetPlatform()

void cpg.utils.CMake.SetPlatform ( Platforms  platform)
inline

Sets the platform to generate the project for.

Parameters
[in]platform(cpg.CMake.Platforms) The new platform the generate projects for.

◆ SetSourceDirectory()

void cpg.utils.CMake.SetSourceDirectory ( string  path)
inline

Sets the location to search for source files.

Parameters
[in]path(string) absolute path to a location on disk.

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