From 1058e40cb0f42820ba1364477537bc9c668fb85f Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Tue, 28 Apr 2020 18:18:28 -0500 Subject: [PATCH] Enable /bigobj globally on MSVC. This changes the intermediate format used for compiled files from one that can hold up to 65279 (slightly less than 2^16) addressable sections to one that can hold 4294967296 (2^32). Code that uses templates, such as... C++ code... can easily run up against the smaller limit. This does not affect the finished executable, only the intermediate object files. --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a5e8312b..de0c858af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,6 +89,10 @@ if(MSVC) # a smaller type, and most of the time this is just conversion from 64 to 32 bits # for things like vector sizes, which are never that big anyway. add_definitions("/wd4267") + + # MSVC panics if an object file contains more than 65,279 sections. this + # happens quite frequently with code that uses templates, such as vectors. + add_definitions("/bigobj") endif() # Automatically detect architecture based on Visual Studio generator