From 792cc37dc2808e6884c3504ab3cbe8cab6f0c1d5 Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Fri, 15 Sep 2023 22:30:16 +0100 Subject: [PATCH] add /bigobj flag to SWIG wrappers for MSVC we get an error `C1128: number of sections exceeded object file format limit: compile with /bigobj` so add that flag --- src/swig/CMakeLists.txt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/swig/CMakeLists.txt b/src/swig/CMakeLists.txt index c7825bdd73..51b3a5abac 100644 --- a/src/swig/CMakeLists.txt +++ b/src/swig/CMakeLists.txt @@ -1,5 +1,5 @@ # Copyright 2012 Kris Thielemans -# Copyright 2014, 2018, 2020, 2022 University College London +# Copyright 2014, 2018, 2020, 2022, 2023 University College London # This file is part of STIR. # # SPDX-License-Identifier: Apache-2.0 @@ -151,6 +151,9 @@ if(BUILD_SWIG_PYTHON) SWIG_ADD_MODULE(stir python stir.i $) else() SWIG_ADD_LIBRARY(stir LANGUAGE python TYPE MODULE SOURCES stir.i $) + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC") + set_property(TARGET ${SWIG_MODULE_stir_REAL_NAME} PROPERTY SWIG_GENERATED_COMPILE_OPTIONS /bigobj) + endif() endif() SWIG_WORKAROUND(${SWIG_MODULE_stir_REAL_NAME}) SWIG_LINK_LIBRARIES(stir ${STIR_LIBRARIES} ${STIR_Python_dependency}) @@ -198,6 +201,9 @@ if (BUILD_SWIG_OCTAVE) SWIG_ADD_MODULE(stiroct octave stir.i $) else() SWIG_ADD_LIBRARY(stiroct LANGUAGE octave TYPE MODULE SOURCES stir.i $) + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC") + set_property(TARGET ${SWIG_MODULE_stiroct_REAL_NAME} PROPERTY SWIG_GENERATED_COMPILE_OPTIONS /bigobj) + endif() endif() SET_TARGET_PROPERTIES(${SWIG_MODULE_stiroct_REAL_NAME} PROPERTIES SUFFIX ${OCTAVE_SUFFIX} PREFIX "${OCTAVE_PREFIX}") SWIG_WORKAROUND(${SWIG_MODULE_stiroct_REAL_NAME}) @@ -224,6 +230,9 @@ if (BUILD_SWIG_MATLAB) SWIG_ADD_MODULE(stirMATLAB matlab stir.i $) else() SWIG_ADD_LIBRARY(stirMATLAB LANGUAGE matlab TYPE MODULE SOURCES stir.i $) + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC") + set_property(TARGET ${SWIG_MODULE_stirMATLAB_REAL_NAME} PROPERTY SWIG_GENERATED_COMPILE_OPTIONS /bigobj) + endif() endif() if (WIN32) set (Matlab_CXXLINKER_FLAGS "/EXPORT:mexFunction")