x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Get UE version in ModuleRules (.Build.cs file)

We're working with 2 versions of UE4 here due to a bug in the later versions, and I need to be able to check what version to do some conditional stuff in my Build file. Is there a way to do this, ideally with preprocessor checks?

Product Version: UE 4.12
Tags:
more ▼

asked Aug 23 '16 at 12:43 AM in C++ Programming

avatar image

duke22
180 11 15 29

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Before UE4.14:

 var VersionFilePath = Path.Combine(UnrealBuildTool.UnrealBuildTool.EngineDirectory.FullName, "Build" + Path.DirectorySeparatorChar + "Build.version");
 
 BuildVersion Version;
 if (BuildVersion.TryRead(VersionFilePath, out Version))
 {
     if (Version.MajorVersion == X && Version.MinorVersion == Y)
     {
         // do version specific stuff
     }
 }

After and including UE4.14:

 BuildVersion Version;
 if (BuildVersion.TryRead(out Version))
 {
     if (Version.MajorVersion == X && Version.MinorVersion == Y)
     {
         // do version specific stuff
     }
 }
more ▼

answered Feb 24 '17 at 05:00 PM

avatar image

LazerFalcon
11

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

In 4.17 Epic introduced C# preprocessor macros for this (see release notes), and you can now conditionally compile blocks with something like:

 #if UE_4_17_OR_LATER
 // Do something
 #else
 // Do something else
 #endif

Additionally, from 4.16 the macro WITH_FORWARDED_MODULE_RULES_CTOR is also defined. This was intended to decide whether the constructor of your ModuleRules subclass should receive a TargetInfo (up to 4.15) or a ReadOnlyTargetRules (from 4.16). However, you could use it to check for version 4.16 or later too (assuming that macro will not go away in the future...); that is, you could do:

 #if WITH_FORWARDED_MODULE_RULES_CTOR
 #define UE_4_16_OR_LATER
 #endf

more ▼

answered Jul 20 '18 at 11:24 AM

avatar image

javidcf
16 2 4

avatar image FilAl Jul 24 '18 at 02:34 PM

Dude where did you find this ?!? Please elaborate.

avatar image javidcf Jul 24 '18 at 02:42 PM

What exactly? As mentioned, the UE_4_X_OR_LATER macros were introduced in the 4.17 release notes. The macro WITH_FORWARDED_MODULE_RULES_CTOR was introduced in the 4.16 release notes, as part of the change from TargetInfo to ReadOnlyTargetRules. I didn't learn about these from the release notes themselves (I don't remember where I saw them first, but I think probably in some question on this site), but that is the best reference I could find for them (besides the source code).

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question