Cog's presence detection
Last updated
Last updated
We will use my plugin as an example.
Inside of the build.cs
file, you'll find this code:
This code will enable or disable the COG_INSTALLED
preprocessor macro depending of the Cog
plugin can be found inside the Plugins
folder and add it as a dependency if it's found.
This setup enables us to write Cog dependend code, which is disabled and ignored by the IDE and compiler if the Cog plugin is disabled.
In the code example above, if Cog is missing, the code will automatically be disabled and not recognized by the IDE. Thus, not causing any errors and allowing you to continue using the plugin.
It's important you do COG_INSTALLED
first.
The compiler is smart enough that if it sees COG_INSTALLED
as false, it won't bother to check ENABLE_COG
, which in the case of Cog not being installed, would result in an error. But since COG_INSTALLED
returns false before ENABLE_COG
, the compiler immediately strips it out and doesn't bother checking it.
If the checks are reversed, you'll get an error saying ENABLE_COG
is undefined if Cog is ever uninstalled.
In some cases, you might have to wrap #include
's with the #if COG_INSTALLED
preprocessor macro, then use #if ENABLE_COG
.