[CMake] /STACK:10000000 being added to linker in Visual Studio?

David Cole david.cole at kitware.com
Wed Jun 27 15:43:33 EDT 2012


You're welcome! Glad it worked well.


On Wed, Jun 27, 2012 at 3:42 PM, Robert Dailey <rcdailey.lists at gmail.com> wrote:
> Here is my final code, this seems to work for both DLL and EXE targets:
>
> string( REGEX REPLACE "/STACK:[0-9]+" "" CMAKE_EXE_LINKER_FLAGS
> "${CMAKE_EXE_LINKER_FLAGS}" )
> string( REGEX REPLACE "/STACK:[0-9]+" "" CMAKE_SHARED_LINKER_FLAGS
> "${CMAKE_SHARED_LINKER_FLAGS}" )
> string( REGEX REPLACE "/STACK:[0-9]+" "" CMAKE_MODULE_LINKER_FLAGS
> "${CMAKE_MODULE_LINKER_FLAGS}" )
>
> Thanks for the super quick help David!
>
> On Wed, Jun 27, 2012 at 2:38 PM, Robert Dailey <rcdailey.lists at gmail.com>
> wrote:
>>
>> Yeah certainly, especially since multicore is pretty much everywhere now
>> and most applications are designed with parallelization in mind.
>>
>> Like every other compiler and linker flag out there, have the user
>> manually set that up if they want it. CMake doesn't automatically add any
>> other compiler flags for me, so /STACK shouldn't be any different IMHO.
>>
>> Thanks for your help, I will try using those new global variables.
>>
>>
>> On Wed, Jun 27, 2012 at 2:35 PM, David Cole <david.cole at kitware.com>
>> wrote:
>>>
>>> Ah. I just read through Windows-cl.cmake again to refresh my memory....
>>>
>>> Also do the same thing with these two variables:
>>> CMAKE_SHARED_LINKER_FLAGS for SHARED dll targets, and
>>> CMAKE_MODULE_LINKER_FLAGS for MODULE dll targets. That should take
>>> care of it.
>>>
>>> Whew. Maybe we should just remove it from CMake one of these days.
>>> Seems like a bit of an excessive stack size to have by default,
>>> doesn't it? :-)
>>>
>>>
>>> David
>>>
>>>
>>> On Wed, Jun 27, 2012 at 3:27 PM, Robert Dailey <rcdailey.lists at gmail.com>
>>> wrote:
>>> > I just tried your code and unfortunately /STACK still shows up for DLL
>>> > targets, although for EXE targets it seems to be gone.
>>> >
>>> >
>>> > On Wed, Jun 27, 2012 at 2:24 PM, David Cole <david.cole at kitware.com>
>>> > wrote:
>>> >>
>>> >> Try my code, and tell us if it removes the generated /STACK from all
>>> >> your linker calls or not...
>>> >>
>>> >> Thx,
>>> >> David
>>> >>
>>> >> On Wed, Jun 27, 2012 at 3:22 PM, Robert Dailey
>>> >> <rcdailey.lists at gmail.com>
>>> >> wrote:
>>> >> > Apparently this won't work... /STACK doesn't show up in any of the
>>> >> > compile
>>> >> > flags retrieved this way. However, CMAKE_EXE_COMPILER_FLAGS doesn't
>>> >> > apply to
>>> >> > library targets, right?
>>> >> >
>>> >> >
>>> >> > On Wed, Jun 27, 2012 at 2:19 PM, Robert Dailey
>>> >> > <rcdailey.lists at gmail.com>
>>> >> > wrote:
>>> >> >>
>>> >> >> This flag is appended to DLL targets too, so I created this (i
>>> >> >> haven't
>>> >> >> tested it yet though):
>>> >> >>
>>> >> >> function( _remove_stack_flag target_name )
>>> >> >> get_property( flags TARGET ${target_name} PROPERTY COMPILE_FLAGS )
>>> >> >> string( REGEX REPLACE "/STACK:[0-9]+" "" flags ${flags} )
>>> >> >> set_property( TARGET ${target_name} PROPERTY COMPILE_FLAGS ${flags}
>>> >> >> )
>>> >> >> endfunction()
>>> >> >>
>>> >> >> I call this once for each target I define.
>>> >> >>
>>> >> >>
>>> >> >> On Wed, Jun 27, 2012 at 2:17 PM, David Cole
>>> >> >> <david.cole at kitware.com>
>>> >> >> wrote:
>>> >> >>>
>>> >> >>> You could do:
>>> >> >>>
>>> >> >>>  string(REPLACE "/STACK:10000000 " "" CMAKE_EXE_LINKER_FLAGS
>>> >> >>> "${CMAKE_EXE_LINKER_FLAGS}")
>>> >> >>>
>>> >> >>> after the first project command in the top level CMakeLists file.
>>> >> >>> (Or
>>> >> >>> "/STACK:some other number" to change it, instead of the empty
>>> >> >>> string
>>> >> >>> to just remove it...)
>>> >> >>>
>>> >> >>> The /STACK string only appears in the two files:
>>> >> >>>
>>> >> >>>  Modules/Platform/Windows-Intel.cmake
>>> >> >>>  Modules/Platform/Windows-cl.cmake
>>> >> >>>
>>> >> >>>
>>> >> >>> HTH,
>>> >> >>> David
>>> >> >>>
>>> >> >>>
>>> >> >>> On Wed, Jun 27, 2012 at 3:11 PM, Robert Dailey
>>> >> >>> <rcdailey.lists at gmail.com>
>>> >> >>> wrote:
>>> >> >>> > This is added to every generated visual studio project from
>>> >> >>> > version
>>> >> >>> > 7.1
>>> >> >>> > to
>>> >> >>> > 9. How can I tell CMake not to modify the stack size?
>>> >> >>> > --
>>> >> >>> >
>>> >> >>> > Powered by www.kitware.com
>>> >> >>> >
>>> >> >>> > Visit other Kitware open-source projects at
>>> >> >>> > http://www.kitware.com/opensource/opensource.html
>>> >> >>> >
>>> >> >>> > Please keep messages on-topic and check the CMake FAQ at:
>>> >> >>> > http://www.cmake.org/Wiki/CMake_FAQ
>>> >> >>> >
>>> >> >>> > Follow this link to subscribe/unsubscribe:
>>> >> >>> > http://www.cmake.org/mailman/listinfo/cmake
>>> >> >>
>>> >> >>
>>> >> >
>>> >
>>> >
>>
>>
>


More information about the CMake mailing list