'File too big with MinGW-w64 and CMake

I'm trying to compile a project with MinGW-w64 and I get a file too big error while creating the object code.

I already tried, in vain, to add some compile options to my CMakeLists.txt file as follows:

if(WIN32)
    target_compile_options(${target_name} PUBLIC -Wa,-mbig-obj)
endif()

I also tried to append -O2 to such options, but I should really avoid it for my debug and release configurations.

I installed MinGW-w64 and CMake from the MSYS2 package. They're both up to date. MinGW-w64 should have Large File Support, so I'm not sure about the source of the problem. Is MinGW-w64 actually a 32 bit compiler targeting 64 and 32 bit systems? If it was the case, shouldn't LFS prevent file too big errors?

Thanks in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source