ezEngine Release 26.9
Loading...
Searching...
No Matches
ezCppProject Struct Reference

#include <CppProject.h>

Inheritance diagram for ezCppProject:

Classes

struct  MachineSpecificCompilerPaths
 Describes a compiler configuration detected or configured on this machine. More...
 

Public Types

enum class  ModifyResult { FAILURE , NOT_MODIFIED , MODIFIED }
 Result type for operations that may modify files. More...
 
- Public Types inherited from ezPreferences
enum class  Domain { Application , Project , Document }
 

Public Member Functions

 EZ_ADD_DYNAMIC_REFLECTION (ezCppProject, ezPreferences)
 
- Public Member Functions inherited from ezPreferences
Domain GetDomain () const
 Whether the preferences are app, project or document specific.
 
ezString GetName () const
 Within the same domain and visibility the name must be unique, but across those it can be reused.
 
const ezDocumentGetDocumentAssociation () const
 If these preferences are per document, the pointer is valid, otherwise nullptr.
 
void TriggerPreferencesChangedEvent ()
 Call this to broadcast that this preference object was modified.
 
- Public Member Functions inherited from ezReflectedClass
virtual const ezRTTIGetDynamicRTTI () const
 
bool IsInstanceOf (const ezRTTI *pType) const
 Returns whether the type of this instance is of the given type or derived from it.
 
template<typename T >
EZ_ALWAYS_INLINE bool IsInstanceOf () const
 Returns whether the type of this instance is of the given type or derived from it.
 

Static Public Member Functions

static ezString GetTargetSourceDir (ezStringView sProjectDirectory={})
 
static ezString GetGeneratorFolderName (const ezCppSettings &cfg)
 Returns the CMake generator-specific folder name (e.g., "vs2022x64").
 
static ezString GetCMakeGeneratorName (const ezCppSettings &cfg)
 Returns the CMake generator name string for the -G parameter.
 
static ezString GetPluginSourceDir (const ezCppSettings &cfg, ezStringView sProjectDirectory={})
 
static ezString GetBuildDir (const ezCppSettings &cfg)
 Returns the CMake build directory path.
 
static ezString GetSolutionPath (const ezCppSettings &cfg)
 Returns the full path to the generated solution file.
 
static ezStatus OpenSolution (const ezCppSettings &cfg)
 Opens the solution file in the configured IDE.
 
static ezStatus OpenInCodeEditor (const ezStringView &sFileName, ezInt32 iLineNumber)
 Attempts to launch the configured code editor with the specified file and line number.
 
static ezStringView CompilerToString (ezCompiler::Enum compiler)
 
static ezCompiler::Enum GetSdkCompiler ()
 
static ezString GetSdkCompilerMajorVersion ()
 Returns the major version number of the compiler used to build the SDK.
 
static ezStatus TestCompiler ()
 Tests if the currently configured compiler can be invoked successfully.
 
static const char * GetCMakePath ()
 Returns the path to the CMake executable bundled with the engine.
 
static ezResult CheckCMakeCache (const ezCppSettings &cfg)
 
static ModifyResult CheckCMakeUserPresets (const ezCppSettings &cfg, bool bWriteResult)
 
static bool ExistsSolution (const ezCppSettings &cfg)
 
static bool ExistsProjectCMakeListsTxt ()
 
static bool ShouldOverwriteExisting (ezStringView sSrc, ezStringView sDst)
 Returns true if sDst doesn't exist yet, or for some file types (e.g. CMakeLists.txt), when they got an update.
 
static ezResult PopulateWithDefaultSources (const ezCppSettings &cfg, ezUInt32 *pNumFilesCopied=nullptr)
 Copies default C++ plugin template files to the project's source directory.
 
static ezResult CleanBuildDir (const ezCppSettings &cfg)
 
static ezResult RunCMake (const ezCppSettings &cfg)
 Runs CMake to generate the build system files.
 
static ezResult RunCMakeIfNecessary (const ezCppSettings &cfg)
 
static ezResult CompileSolution (const ezCppSettings &cfg)
 Compiles the C++ plugin solution using the configured compiler.
 
static ezResult BuildCodeIfNecessary (const ezCppSettings &cfg)
 
static ezVariantDictionary CreateEmptyCMakeUserPresetsJson (const ezCppSettings &cfg)
 Creates a minimal CMakeUserPresets.json structure for the given configuration.
 
static ModifyResult ModifyCMakeUserPresetsJson (const ezCppSettings &cfg, ezVariantDictionary &inout_json)
 
static void UpdatePluginConfig (const ezCppSettings &cfg)
 Writes the plugin configuration header files based on current settings.
 
static ezResult UpdateEnginePluginDependencies ()
 Writes CMakeEngineExtensions.txt with the selected engine plugins for linking.
 
static ezResult EnsureCppPluginReady ()
 
static bool IsBuildRequired ()
 
static void LoadPreferences ()
 
static ezArrayPtr< const MachineSpecificCompilerPathsGetMachineSpecificCompilers ()
 
static ezResult ForceSdkCompatibleCompiler ()
 
- Static Public Member Functions inherited from ezPreferences
template<typename TYPE >
static TYPE * QueryPreferences (const ezDocument *pDocument=nullptr)
 Static function to query a preferences object of the given type. If the instance does not exist yet, it is created and the data is restored from file.
 
static ezPreferencesQueryPreferences (const ezRTTI *pRtti, const ezDocument *pDocument=nullptr)
 Static function to query a preferences object of the given type. If the instance does not exist yet, it is created and the data is restored from file.
 
static void SaveDocumentPreferences (const ezDocument *pDocument)
 Saves all preferences that are tied to the given document.
 
static void ClearDocumentPreferences (const ezDocument *pDocument)
 Removes all preferences for the given document. Does not save them. Afterwards the preferences will not appear in the UI any further.
 
static void SaveProjectPreferences ()
 Saves all project specific preferences.
 
static void ClearProjectPreferences ()
 Removes all project specific preferences. Does not save them. Afterwards the preferences will not appear in the UI any further.
 
static void SaveApplicationPreferences ()
 Saves all application specific preferences.
 
static void ClearApplicationPreferences ()
 Removes all application specific preferences. Does not save them. Afterwards the preferences will not appear in the UI any further.
 
static void GatherAllPreferences (ezDynamicArray< ezPreferences * > &out_allPreferences)
 
- Static Public Member Functions inherited from ezNoBase
static const ezRTTIGetStaticRTTI ()
 

Static Public Attributes

static ezEvent< const ezCppSettings & > s_ChangeEvents
 Fired when a notable change has been made.
 

Additional Inherited Members

- Public Attributes inherited from ezPreferences
ezEvent< ezPreferences * > m_ChangedEvent
 A simple event that can be fired when any preference property changes. No specific change details are given.
 
- Protected Member Functions inherited from ezPreferences
 ezPreferences (Domain domain, const char *szUniqueName)
 
ezString GetFilePath () const
 

Detailed Description

Manages C++ plugin project generation, compilation, and IDE integration.

Provides functionality to generate CMake projects for C++ game plugins, configure compilers, build solutions, and open code in external editors.

Member Enumeration Documentation

◆ ModifyResult

enum class ezCppProject::ModifyResult
strong

Result type for operations that may modify files.

Enumerator
FAILURE 

Operation failed.

NOT_MODIFIED 

Files already up-to-date, no changes made.

MODIFIED 

Files were successfully modified.

Member Function Documentation

◆ BuildCodeIfNecessary()

ezResult ezCppProject::BuildCodeIfNecessary ( const ezCppSettings cfg)
static

Checks if compilation is needed and builds the code if required. Skips the build if the plugin binary is already up-to-date.

◆ CheckCMakeCache()

ezResult ezCppProject::CheckCMakeCache ( const ezCppSettings cfg)
static

Verifies that the CMake cache matches the current configuration. Returns failure if the cache is outdated or incompatible.

◆ CheckCMakeUserPresets()

ezCppProject::ModifyResult ezCppProject::CheckCMakeUserPresets ( const ezCppSettings cfg,
bool  bWriteResult 
)
static

Checks if CMakeUserPresets.json needs updating for the given configuration. If bWriteResult is true, writes the updated file when changes are needed.

◆ EnsureCppPluginReady()

ezResult ezCppProject::EnsureCppPluginReady ( )
static

Ensures the C++ plugin project is generated and compiled. Runs all necessary steps to make the plugin ready for use.

◆ ForceSdkCompatibleCompiler()

ezResult ezCppProject::ForceSdkCompatibleCompiler ( )
static

Changes the current preferences to use an SDK-compatible compiler. This is necessary to avoid ABI compatibility issues between the plugin and engine.

◆ GetPluginSourceDir()

ezString ezCppProject::GetPluginSourceDir ( const ezCppSettings cfg,
ezStringView  sProjectDirectory = {} 
)
static

Returns the source directory for the C++ plugin project. If sProjectDirectory is empty, uses the current project directory.

◆ GetSdkCompiler()

ezCompiler::Enum ezCppProject::GetSdkCompiler ( )
static

Returns the compiler used to build the editor SDK itself. Plugins should typically use a compatible compiler to avoid ABI issues.

◆ GetTargetSourceDir()

ezString ezCppProject::GetTargetSourceDir ( ezStringView  sProjectDirectory = {})
static

Returns the directory where C++ plugin template files are copied to. If sProjectDirectory is empty, uses the current project directory.

◆ IsBuildRequired()

bool ezCppProject::IsBuildRequired ( )
static

Checks whether the C++ plugin needs to be rebuilt. Returns true if source files have changed since the last build.

◆ ModifyCMakeUserPresetsJson()

ezCppProject::ModifyResult ezCppProject::ModifyCMakeUserPresetsJson ( const ezCppSettings cfg,
ezVariantDictionary inout_json 
)
static

Updates an existing CMakeUserPresets.json with current configuration settings. The inout_json parameter is both read and modified.

◆ RunCMakeIfNecessary()

ezResult ezCppProject::RunCMakeIfNecessary ( const ezCppSettings cfg)
static

Checks if CMake needs to run and executes it if required. Skips CMake if the build files are already up-to-date.


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