cmake: Centralize MinGW/Cygwin -Wa,-mbig-obj test workaround

This commit is contained in:
Kartik Kenchi 2026-08-16 22:28:42 +05:30
parent a2118f6587
commit 7e3704f106
2 changed files with 7 additions and 4 deletions

View File

@ -131,10 +131,6 @@ if (gmock_build_tests)
# 'make test' or ctest.
enable_testing()
if (MINGW OR CYGWIN)
add_compile_options("-Wa,-mbig-obj")
endif()
############################################################
# C++ tests built with standard compiler flags.

View File

@ -237,6 +237,13 @@ function(cxx_executable_with_flags name cxx_flags libs)
if (MSVC)
# BigObj required for tests.
set(cxx_flags "${cxx_flags} -bigobj")
elseif (MINGW OR CYGWIN)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR
CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# MinGW and Cygwin use the GNU assembler, which has a 2^16 section limit.
# Large generated test executables exceed this limit, so raise it.
set(cxx_flags "${cxx_flags} -Wa,-mbig-obj")
endif()
endif()
if (cxx_flags)
set_target_properties(${name}