Excluding folder from build

I want to exclude a folder from build in certain configuration. Basically, I need some way to say this in Build.cs file:


This way when sln is generated from uproject, files in that folder doesn’t show up in solution and no attempts are made to build files in that folder. This is equivalent to Include/Exclude functionality in normal Visual Studio projects. Right now Unreal build system attempts to build any header/cpp files that are found in source folder.

Any idea how this can be achieved?


1 Like

Did you considered making separate module for that code?

The usual way of doing that in C++ would be using preprocessor macros. Lets say have 2 different cases that you want to build. in the first case you would define a preprocessore variable anywhere in the file, like this:


you would then ifdef the code that is conditionally not built:

  your code here

if you don’t want this code to build you simply delete the


The preprocessor will then eliminate all the code between ifdef end endif. It doesn’t exactly stop the file from beeing built, but it excludes the code in the file from beeing built.

This doesn’t work for my scenario. I’ve 400+ files that I need to exclude in certain build configuration. These files are from 3rd part so I rather not modify them. I’m hopping there is better way to tell Unreal Build system to not to compile every single file that it can possibly find.

For those searching how to do that not using C++, in UE4 go to Project Settings > Packaging > Directories to never cook


The Unreal header tool doesn’t respect pre-processor statements like that, it still looks inside #ifdef’d code for things like UCLASS